本文整理汇总了PHP中is_time函数的典型用法代码示例。如果您正苦于以下问题:PHP is_time函数的具体用法?PHP is_time怎么用?PHP is_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hybrid_date_template
/**
* Overrides WP's default template for date-based archives. Better abstraction of templates than
* is_date() allows by checking for the year, month, week, day, hour, and minute.
*
* @since 0.6.0
* @uses locate_template() Checks for template in child and parent theme.
* @param string $template
* @return string $template Full path to file.
*/
function hybrid_date_template($template)
{
$templates = array();
/* If viewing a time-based archive. */
if (is_time()) {
/* If viewing a minutely archive. */
if (get_query_var('minute')) {
$templates[] = 'minute.php';
} elseif (get_query_var('hour')) {
$templates[] = 'hour.php';
}
/* Catchall for any time-based archive. */
$templates[] = 'time.php';
} elseif (is_day()) {
$templates[] = 'day.php';
} elseif (get_query_var('w')) {
$templates[] = 'week.php';
} elseif (is_month()) {
$templates[] = 'month.php';
} elseif (is_year()) {
$templates[] = 'year.php';
}
/* Catchall template for date-based archives. */
$templates[] = 'date.php';
/* Fall back to the basic archive template. */
$templates[] = 'archive.php';
/* Return the found template. */
return locate_template($templates);
}
示例2: spyropress_date_template
/**
* Overrides WP's default template for date-based archives. Better abstraction of templates than
* is_date() allows by checking for the year, month, week, day, hour, and minute.
*/
function spyropress_date_template($template)
{
$templates = array();
// If viewing a time-based archive
if (is_time()) {
// If viewing a minutely archive
if (get_query_var('minute')) {
$templates[] = 'minute.php';
} elseif (get_query_var('hour')) {
$templates[] = 'hour.php';
}
// Catchall for any time-based archive
$templates[] = 'time.php';
} elseif (is_day()) {
$templates[] = 'day.php';
} elseif (get_query_var('w')) {
$templates[] = 'week.php';
} elseif (is_month()) {
$templates[] = 'month.php';
} elseif (is_year()) {
$templates[] = 'year.php';
}
// Catchall template for date-based archives
$templates[] = 'date.php';
// Fall back to the basic archive template
$templates[] = 'archive.php';
// Return the found template
return locate_template($templates);
}
示例3: parseQuery
public function parseQuery()
{
$query = $this->_getQueryToParse();
if ($query->is_home()) {
$this->_identifyHome();
} else {
if ($query->is_singular()) {
$this->_identifySingular();
} else {
if ($query->is_category() || $query->is_tag() || $query->is_tax()) {
$this->_identifyTaxonomy();
} else {
if ($query->is_search()) {
$this->_identifySearch();
} else {
if ($query->is_date() || is_time()) {
$this->_identifyDate();
} else {
if ($query->is_author()) {
$this->_identifyAuthor();
} else {
if ($query->is_404()) {
$this->_identify404();
}
}
}
}
}
}
}
}
示例4: get_date_data
public function get_date_data()
{
$data = $_POST;
$resp = new ajax_response($data['action'], true);
if ($data['variable_data'] != null) {
$resp->set_status(true);
$resp->set_data(array('loadable_content' => 'etrghvaoucyq3boigwsodrifuv suiboqiu5oqiuebroqviebrivueybrgirbf'));
if (is_time($data['variable_data'])) {
} else {
}
} else {
$resp->set_message('Could not load data. Try Again.');
}
echo $resp->encode_response();
die;
}
示例5: st_get_tpl_file_name
function st_get_tpl_file_name()
{
$default = 'list-post';
$file = 'list-post';
if (is_singular()) {
global $post;
if ($post->post_type != 'page' && $post->post_type != 'post') {
$file = $post->post_type;
if (!file_exists(ST_TEMPLATE_DIR . $file . '.php')) {
$file = 'single';
}
} else {
if (is_page()) {
$file = 'page';
} else {
$file = 'single';
}
}
} elseif (is_author()) {
$file = 'author';
} elseif (is_tag()) {
$file = 'tag';
} elseif (is_tax()) {
$tax = get_queried_object();
$file = 'taxonomy-' . $tax->taxonomy;
if (file_exists(ST_TEMPLATE_DIR . $file . '.php')) {
return $file;
} else {
return 'taxonomy';
}
} elseif ((is_archive() || is_day() || is_date() || is_month() || is_year() || is_time()) && !is_category()) {
$file = 'archive';
} elseif (is_search()) {
$file = 'search';
} elseif (is_404()) {
$file = '404';
}
if (file_exists(ST_TEMPLATE_DIR . $file . '.php')) {
return $file;
} else {
return $default;
}
}
示例6: hybrid_page_class
/**
* hybrid_page_class()
* Dynamic page class
*
* @since 0.1
* @deprecated 0.2
*/
function hybrid_page_class()
{
if (is_front_page() || is_home()) {
$class = 'home front-page';
} elseif (is_attachment()) {
$class = 'attachment';
} elseif (is_single()) {
$class = 'single';
} elseif (is_page()) {
$class = 'page';
} elseif (is_category()) {
$class = 'category';
} elseif (is_tag()) {
$class = 'tag';
} elseif (is_search()) {
$class = 'search';
} elseif (is_404()) {
$class = 'error-404';
} elseif (is_year()) {
$class = 'year';
} elseif (is_month()) {
$class = 'month';
} elseif (is_day()) {
$class = 'day';
} elseif (is_time()) {
$class = 'time';
} elseif (is_author()) {
$class = 'author';
}
if (is_date()) {
$class .= ' date';
}
if (is_archive()) {
$class .= ' archive';
}
if (is_paged()) {
$class .= ' paged';
}
echo $class;
}
示例7: timeframe
/**
* @return string|false|null
*/
public static function timeframe()
{
global $wp_query;
static $unit;
if (isset($unit) || empty($wp_query)) {
# cached result *or* `null` before $wp_query is avail
# codex.wordpress.org/Conditional_Tags
return $unit;
}
if (!is_date()) {
return $unit = false;
}
if (!is_time()) {
$unit = is_day() ? 'day' : (get_query_var('w') ? 'week' : (is_month() ? 'month' : (is_year() ? 'year' : null)));
} else {
for ($units = array('second', 'minute', 'hour'); $unit = array_shift($units);) {
if (($v = get_query_var($unit)) || is_numeric($v)) {
break;
}
}
}
return $unit = $unit ?: true;
}
示例8: advertica_lite_simple_breadcrumb_case
function advertica_lite_simple_breadcrumb_case($der_post)
{
$markup = $this->opts['before'] . $this->opts['delimiter'] . $this->opts['after'];
if (is_page()) {
if ($der_post->post_parent) {
$my_query = get_post($der_post->post_parent);
$this->advertica_lite_simple_breadcrumb_case($my_query);
$link = '<a href="';
$link .= esc_url(get_permalink($my_query->ID));
$link .= '">';
$link .= '' . esc_attr(get_the_title($my_query->ID)) . '</a>' . $markup;
echo $link;
}
return;
}
if (is_single() && !is_attachment()) {
$category = get_the_category();
if (is_attachment()) {
$my_query = get_post($der_post->post_parent);
$category = get_the_category($my_query->ID);
$ID = $category[0]->cat_ID;
echo get_category_parents($ID, true, $markup, false);
previous_post_link("%link {$markup}");
} else {
if (isset($category[0]->cat_ID)) {
$ID = $category[0]->cat_ID;
echo get_category_parents($ID, true, $markup, false);
}
}
return;
}
if (is_category()) {
$category = get_the_category();
$i = $category[0]->cat_ID;
$parent = $category[0]->category_parent;
if ($parent > 0 && $category[0]->cat_name == single_cat_title('', false)) {
echo get_category_parents($parent, true, $markup, false);
}
return single_cat_title('', false);
}
if (is_author()) {
#$curauth = get_userdatabylogin(get_query_var('author_name'));
global $wp_query;
$curauth = $wp_query->get_queried_object();
return __('Author', 'advertica-lite') . ' : ' . $curauth->display_name;
}
if (is_tag()) {
return __('Tag', 'advertica-lite') . ' : ' . single_tag_title('', false);
}
if (is_search()) {
return __('Search', 'advertica-lite');
}
if (is_404()) {
return __('Error 404', 'advertica-lite');
}
if (is_year()) {
return get_the_time('Y');
}
if (is_month()) {
$k_year = get_the_time('Y');
echo "<a href='" . get_year_link($k_year) . "'>" . $k_year . "</a>" . $markup;
return get_the_time('F');
}
if (is_day() || is_time()) {
$k_year = get_the_time('Y');
$k_month = get_the_time('m');
$k_month_display = get_the_time('F');
echo "<a href='" . get_year_link($k_year) . "'>" . $k_year . "</a>" . $markup;
echo "<a href='" . get_month_link($k_year, $k_month) . "'>" . $k_month_display . "</a>" . $markup;
return get_the_time('jS (l)');
}
}
示例9: tc_breadcrumb_trail_get_items
//.........这里部分代码省略.........
/* If $front has been set, add it to the $path. */
if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
$path .= trailingslashit($wp_rewrite->front);
}
/* If there's a slug, add it to the $path. */
if (!empty($post_type_object->rewrite['slug'])) {
$path .= $post_type_object->rewrite['slug'];
}
/* If there's a path, check for parents. */
if (!empty($path)) {
$trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
}
/* Add the post type [plural] name to the trail end. */
if (is_paged()) {
$trail[] = '<a href="' . esc_url(get_post_type_archive_link($post_type_object->name)) . '" title="' . esc_attr(post_type_archive_title('', false)) . '">' . post_type_archive_title('', false) . '</a>';
} else {
$trail[] = post_type_archive_title('', false);
}
} elseif (is_author()) {
/* Get the user ID. */
$user_id = get_query_var('author');
/* If $front has been set, add it to $path. */
if (!empty($wp_rewrite->front)) {
$path .= trailingslashit($wp_rewrite->front);
}
/* If an $author_base exists, add it to $path. */
if (!empty($wp_rewrite->author_base)) {
$path .= $wp_rewrite->author_base;
}
/* If $path exists, check for parent pages. */
if (!empty($path)) {
$trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
}
/* Add the author's display name to the trail end. */
if (is_paged()) {
$trail[] = '<a href="' . esc_url(get_author_posts_url($user_id)) . '" title="' . esc_attr(get_the_author_meta('display_name', $user_id)) . '">' . get_the_author_meta('display_name', $user_id) . '</a>';
} else {
$trail[] = get_the_author_meta('display_name', $user_id);
}
} elseif (is_time()) {
if (get_query_var('minute') && get_query_var('hour')) {
$trail[] = get_the_time(__('g:i a', 'breadcrumb-trail'));
} elseif (get_query_var('minute')) {
$trail[] = sprintf(__('Minute %1$s', 'breadcrumb-trail'), get_the_time(__('i', 'breadcrumb-trail')));
} elseif (get_query_var('hour')) {
$trail[] = get_the_time(__('g a', 'breadcrumb-trail'));
}
} elseif (is_date()) {
/* If $front has been set, check for parent pages. */
if ($wp_rewrite->front) {
$trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $wp_rewrite->front));
}
if (is_day()) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
$trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'breadcrumb-trail')) . '">' . get_the_time(__('F', 'breadcrumb-trail')) . '</a>';
if (is_paged()) {
$trail[] = '<a href="' . get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" title="' . get_the_time(esc_attr__('d', 'breadcrumb-trail')) . '">' . get_the_time(__('d', 'breadcrumb-trail')) . '</a>';
} else {
$trail[] = get_the_time(__('d', 'breadcrumb-trail'));
}
} elseif (get_query_var('w')) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
if (is_paged()) {
$trail[] = get_archives_link(add_query_arg(array('m' => get_the_time('Y'), 'w' => get_the_time('W')), esc_url(home_url())), sprintf(__('Week %1$s', 'breadcrumb-trail'), get_the_time(esc_attr__('W', 'breadcrumb-trail'))), false);
} else {
$trail[] = sprintf(__('Week %1$s', 'breadcrumb-trail'), get_the_time(esc_attr__('W', 'breadcrumb-trail')));
}
} elseif (is_month()) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
if (is_paged()) {
$trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'breadcrumb-trail')) . '">' . get_the_time(__('F', 'breadcrumb-trail')) . '</a>';
} else {
$trail[] = get_the_time(__('F', 'breadcrumb-trail'));
}
} elseif (is_year()) {
if (is_paged()) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . esc_attr(get_the_time(__('Y', 'breadcrumb-trail'))) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
} else {
$trail[] = get_the_time(__('Y', 'breadcrumb-trail'));
}
}
}
} elseif (is_search()) {
if (is_paged()) {
$trail[] = '<a href="' . get_search_link() . '" title="' . sprintf(esc_attr__('Search results for "%1$s"', 'breadcrumb-trail'), esc_attr(get_search_query())) . '">' . sprintf(__('Search results for "%1$s"', 'breadcrumb-trail'), esc_attr(get_search_query())) . '</a>';
} else {
$trail[] = sprintf(__('Search results for "%1$s"', 'breadcrumb-trail'), esc_attr(get_search_query()));
}
} elseif (is_404()) {
$trail[] = __('404 Not Found', 'breadcrumb-trail');
}
/* Check for pagination. */
if (is_paged()) {
$trail[] = sprintf(__('Page %d', 'breadcrumb-trail'), absint(get_query_var('paged')));
} elseif (is_singular() && 1 < get_query_var('page')) {
$trail[] = sprintf(__('Page %d', 'breadcrumb-trail'), absint(get_query_var('page')));
}
/* Allow devs to step in and filter the $trail array. */
return apply_filters('breadcrumb_trail_items', $trail, $args);
}
示例10: array
?>
<?php
if (empty($_GET['page_id_all'])) {
$_GET['page_id_all'] = 1;
}
if (!isset($_GET["s"])) {
$_GET["s"] = '';
}
$taxonomy = 'category';
$taxonomy_tag = 'post_tag';
$args_cat = array();
if (is_author()) {
$args_cat = array('author' => $wp_query->query_vars['author']);
$post_type = array('post', 'events', 'cs_cause');
} elseif (is_date()) {
if (is_month() || is_year() || is_day() || is_time()) {
$args_cat = array('m' => $wp_query->query_vars['m'], 'year' => $wp_query->query_vars['year'], 'day' => $wp_query->query_vars['day'], 'hour' => $wp_query->query_vars['hour'], 'minute' => $wp_query->query_vars['minute'], 'second' => $wp_query->query_vars['second']);
}
$post_type = array('post');
} elseif (isset($wp_query->query_vars['taxonomy']) && !empty($wp_query->query_vars['taxonomy'])) {
$taxonomy = $wp_query->query_vars['taxonomy'];
$taxonomy_category = '';
$taxonomy_category = $wp_query->query_vars[$taxonomy];
if ($wp_query->query_vars['taxonomy'] == 'cs_cause-category' || $wp_query->query_vars['taxonomy'] == 'cs_cause-tag') {
$args_cat = array($taxonomy => "{$taxonomy_category}");
$post_type = 'cs_cause';
} else {
if ($wp_query->query_vars['taxonomy'] == 'event-category' || $wp_query->query_vars['taxonomy'] == 'event-tag') {
$args_cat = array($taxonomy => "{$taxonomy_category}");
$post_type = 'events';
} else {
示例11: wpex_breadcrumbs
//.........这里部分代码省略.........
$path = trailingslashit($wp_rewrite->front);
}
$path .= $taxonomy->rewrite['slug'];
}
// Get parent pages if they exist
if ($path) {
$trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
}
// Add term parents
if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
$trail = array_merge($trail, wpex_breadcrumbs_get_term_parents($term->parent, $term->taxonomy));
}
// Add term name to trail end
$trail['trail_end'] = $term->name;
} elseif (is_post_type_archive()) {
// Get post type object
$post_type_object = get_post_type_object(get_query_var('post_type'));
// Add $front to $path
if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
$path .= trailingslashit($wp_rewrite->front);
}
// Add slug to 4path
if (!empty($post_type_object->rewrite['archive'])) {
$path .= $post_type_object->rewrite['archive'];
}
// If patch exists check for parents
if (!empty($path)) {
$trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
}
// Add post type name to trail end
$trail['trail_end'] = $post_type_object->labels->name;
} elseif (is_author()) {
/* If $front has been set, add it to $path. */
if (!empty($wp_rewrite->front)) {
$path .= trailingslashit($wp_rewrite->front);
}
/* If an $author_base exists, add it to $path. */
if (!empty($wp_rewrite->author_base)) {
$path .= $wp_rewrite->author_base;
}
/* If $path exists, check for parent pages. */
if (!empty($path)) {
$trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
}
/* Add the author's display name to the trail end. */
$trail['trail_end'] = get_the_author_meta('display_name', get_query_var('author'));
} elseif (is_time()) {
if (get_query_var('minute') && get_query_var('hour')) {
$trail['trail_end'] = get_the_time(__('g:i a', 'wpex'));
} elseif (get_query_var('minute')) {
$trail['trail_end'] = sprintf(__('Minute %1$s', 'wpex'), get_the_time(__('i', 'wpex')));
} elseif (get_query_var('hour')) {
$trail['trail_end'] = get_the_time(__('g a', 'wpex'));
}
} elseif (is_date()) {
// If $front is set check for parents
if ($wp_rewrite->front) {
$trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $wp_rewrite->front));
}
if (is_day()) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
$trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'wpex')) . '">' . get_the_time(__('F', 'wpex')) . '</a>';
$trail['trail_end'] = get_the_time(__('j', 'wpex'));
} elseif (get_query_var('w')) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
$trail['trail_end'] = sprintf(__('Week %1$s', 'wpex'), get_the_time(esc_attr__('W', 'wpex')));
} elseif (is_month()) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
$trail['trail_end'] = get_the_time(__('F', 'wpex'));
} elseif (is_year()) {
$trail['trail_end'] = get_the_time(__('Y', 'wpex'));
}
}
} elseif (is_search()) {
$trail['trail_end'] = sprintf(__('Search results for "%1$s"', 'wpex'), esc_attr(get_search_query()));
} elseif (is_404()) {
$trail['trail_end'] = get_theme_mod('error_page_title') ? get_theme_mod('error_page_title') : __('404 Not Found', 'wpex');
} elseif (function_exists('tribe_is_month') && tribe_is_month()) {
$trail['trail_end'] = __('Events Calendar', 'wpex');
}
/*-----------------------------------------------------------------------------------*/
/* - Create and return the breadcrumbs
/*-----------------------------------------------------------------------------------*/
if ($trail && is_array($trail)) {
$classes = 'site-breadcrumbs clr';
if ($breadcrumbs_position = get_theme_mod('breadcrumbs_position')) {
$classes .= ' position-' . $breadcrumbs_position;
}
// Open Breadcrumbs
$breadcrumb = '<nav class="' . $classes . '"><div class="breadcrumb-trail">';
// Seperator HTML
$separator = '<span class="sep">' . $separator . '</span>';
// Join all trail items into a string
$breadcrumb .= implode($separator, $trail);
// Close breadcrumbs
$breadcrumb .= '</div></nav>';
}
// Return the breadcrumbs trail
return $breadcrumb;
}
示例12: omega_get_context
/**
* Omega's main contextual function. This allows code to be used more than once without running
* hundreds of conditional checks within the theme. It returns an array of contexts based on what
* page a visitor is currently viewing on the site. This function is useful for making dynamic/contextual
* classes, action and filter hooks, and handling the templating system.
*
* Note that time and date can be tricky because any of the conditionals may be true on time-/date-
* based archives depending on several factors. For example, one could load an archive for a specific
* second during a specific minute within a specific hour on a specific day and so on.
*
* @since 0.7.0
* @access public
* @global $wp_query The current page's query object.
* @global $omega The global Omega object.
* @return array $omega->context Several contexts based on the current page.
*/
function omega_get_context()
{
global $omega;
/* If $omega->context has been set, don't run through the conditionals again. Just return the variable. */
if (isset($omega->context)) {
return apply_filters('omega_context', $omega->context);
}
/* Set some variables for use within the function. */
$omega->context = array();
$object = get_queried_object();
$object_id = get_queried_object_id();
/* Front page of the site. */
if (is_front_page()) {
$omega->context[] = 'home';
}
/* Blog page. */
if (is_home()) {
$omega->context[] = 'blog';
} elseif (is_singular()) {
$omega->context[] = 'singular';
$omega->context[] = "singular-{$object->post_type}";
$omega->context[] = "singular-{$object->post_type}-{$object_id}";
} elseif (is_archive()) {
$omega->context[] = 'archive';
/* Post type archives. */
if (is_post_type_archive()) {
$post_type = get_post_type_object(get_query_var('post_type'));
$omega->context[] = "archive-{$post_type->name}";
}
/* Taxonomy archives. */
if (is_tax() || is_category() || is_tag()) {
$omega->context[] = 'taxonomy';
$omega->context[] = "taxonomy-{$object->taxonomy}";
$slug = 'post_format' == $object->taxonomy ? str_replace('post-format-', '', $object->slug) : $object->slug;
$omega->context[] = "taxonomy-{$object->taxonomy}-" . sanitize_html_class($slug, $object->term_id);
}
/* User/author archives. */
if (is_author()) {
$user_id = get_query_var('author');
$omega->context[] = 'user';
$omega->context[] = 'user-' . sanitize_html_class(get_the_author_meta('user_nicename', $user_id), $user_id);
}
/* Date archives. */
if (is_date()) {
$omega->context[] = 'date';
if (is_year()) {
$omega->context[] = 'year';
}
if (is_month()) {
$omega->context[] = 'month';
}
if (get_query_var('w')) {
$omega->context[] = 'week';
}
if (is_day()) {
$omega->context[] = 'day';
}
}
/* Time archives. */
if (is_time()) {
$omega->context[] = 'time';
if (get_query_var('hour')) {
$omega->context[] = 'hour';
}
if (get_query_var('minute')) {
$omega->context[] = 'minute';
}
}
} elseif (is_search()) {
$omega->context[] = 'search';
} elseif (is_404()) {
$omega->context[] = 'error-404';
}
return array_map('esc_attr', apply_filters('omega_context', array_unique($omega->context)));
}
示例13: hybrid_get_context
/**
* Hybrid's main contextual function. This allows code to be used more than once without running
* hundreds of conditional checks within the theme. It returns an array of contexts based on what
* page a visitor is currently viewing on the site. This function is useful for making dynamic/contextual
* classes, action and filter hooks, and handling the templating system.
*
* Note that time and date can be tricky because any of the conditionals may be true on time-/date-
* based archives depending on several factors. For example, one could load an archive for a specific
* second during a specific minute within a specific hour on a specific day and so on.
*
* @since 0.7.0
* @global $wp_query The current page's query object.
* @global $hybrid The global Hybrid object.
* @return array $hybrid->context Several contexts based on the current page.
*/
function hybrid_get_context()
{
global $hybrid;
/* If $hybrid->context has been set, don't run through the conditionals again. Just return the variable. */
if (isset($hybrid->context)) {
return $hybrid->context;
}
/* Set some variables for use within the function. */
$hybrid->context = array();
$object = get_queried_object();
$object_id = get_queried_object_id();
/* Front page of the site. */
if (is_front_page()) {
$hybrid->context[] = 'home';
}
/* Blog page. */
if (is_home()) {
$hybrid->context[] = 'blog';
} elseif (is_singular()) {
$hybrid->context[] = 'singular';
$hybrid->context[] = "singular-{$object->post_type}";
$hybrid->context[] = "singular-{$object->post_type}-{$object_id}";
} elseif (is_archive()) {
$hybrid->context[] = 'archive';
/* Taxonomy archives. */
if (is_tax() || is_category() || is_tag()) {
$hybrid->context[] = 'taxonomy';
$hybrid->context[] = "taxonomy-{$object->taxonomy}";
$hybrid->context[] = "taxonomy-{$object->taxonomy}-" . sanitize_html_class($object->slug, $object->term_id);
} elseif (is_post_type_archive()) {
$post_type = get_post_type_object(get_query_var('post_type'));
$hybrid->context[] = "archive-{$post_type->name}";
} elseif (is_author()) {
$hybrid->context[] = 'user';
$hybrid->context[] = 'user-' . sanitize_html_class(get_the_author_meta('user_nicename', $object_id), $object_id);
} else {
if (is_date()) {
$hybrid->context[] = 'date';
if (is_year()) {
$hybrid->context[] = 'year';
}
if (is_month()) {
$hybrid->context[] = 'month';
}
if (get_query_var('w')) {
$hybrid->context[] = 'week';
}
if (is_day()) {
$hybrid->context[] = 'day';
}
}
if (is_time()) {
$hybrid->context[] = 'time';
if (get_query_var('hour')) {
$hybrid->context[] = 'hour';
}
if (get_query_var('minute')) {
$hybrid->context[] = 'minute';
}
}
}
} elseif (is_search()) {
$hybrid->context[] = 'search';
} elseif (is_404()) {
$hybrid->context[] = 'error-404';
}
return array_map('esc_attr', $hybrid->context);
}
示例14: hybrid_get_context
/**
* Hybrid's main contextual function. This allows code to be used more than once without running
* hundreds of conditional checks within the theme. It returns an array of contexts based on what
* page a visitor is currently viewing on the site. This function is useful for making dynamic/contextual
* classes, action and filter hooks, and handling the templating system.
*
* Note that time and date can be tricky because any of the conditionals may be true on time-/date-
* based archives depending on several factors. For example, one could load an archive for a specific
* second during a specific minute within a specific hour on a specific day and so on.
*
* @since 0.7.0
* @global $wp_query The current page's query object.
* @global $hybrid The global Hybrid object.
* @return array $hybrid->context Several contexts based on the current page.
*/
function hybrid_get_context() {
global $wp_query, $hybrid;
/* If $hybrid->context has been set, don't run through the conditionals again. Just return the variable. */
if ( isset( $hybrid->context ) )
return $hybrid->context;
$hybrid->context = array();
/* Front page of the site. */
if ( is_front_page() )
$hybrid->context[] = 'home';
/* Blog page. */
if ( is_home() ) {
$hybrid->context[] = 'blog';
}
/* Singular views. */
elseif ( is_singular() ) {
$hybrid->context[] = 'singular';
$hybrid->context[] = "singular-{$wp_query->post->post_type}";
$hybrid->context[] = "singular-{$wp_query->post->post_type}-{$wp_query->post->ID}";
}
/* Archive views. */
elseif ( is_archive() ) {
$hybrid->context[] = 'archive';
/* Taxonomy archives. */
if ( is_tax() || is_category() || is_tag() ) {
$term = $wp_query->get_queried_object();
$hybrid->context[] = 'taxonomy';
$hybrid->context[] = "taxonomy-{$term->taxonomy}";
$hybrid->context[] = "taxonomy-{$term->taxonomy}-" . sanitize_html_class( $term->slug, $term->term_id );
}
/* Post type archives. */
elseif ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) {
$post_type = get_post_type_object( get_query_var( 'post_type' ) );
$hybrid->context[] = "archive-{$post_type->name}";
}
/* User/author archives. */
elseif ( is_author() ) {
$hybrid->context[] = 'user';
$hybrid->context[] = 'user-' . sanitize_html_class( get_the_author_meta( 'user_nicename', get_query_var( 'author' ) ), $wp_query->get_queried_object_id() );
}
/* Time/Date archives. */
else {
if ( is_date() ) {
$hybrid->context[] = 'date';
if ( is_year() )
$hybrid->context[] = 'year';
if ( is_month() )
$hybrid->context[] = 'month';
if ( get_query_var( 'w' ) )
$hybrid->context[] = 'week';
if ( is_day() )
$hybrid->context[] = 'day';
}
if ( is_time() ) {
$hybrid->context[] = 'time';
if ( get_query_var( 'hour' ) )
$hybrid->context[] = 'hour';
if ( get_query_var( 'minute' ) )
$hybrid->context[] = 'minute';
}
}
}
/* Search results. */
elseif ( is_search() ) {
$hybrid->context[] = 'search';
}
/* Error 404 pages. */
elseif ( is_404() ) {
$hybrid->context[] = 'error-404';
}
return array_map( 'esc_attr', $hybrid->context );
}
示例15: check_current_page
/**
* Checks if the current page can be accessed by the specified rules
*
* @since 1.0.0
*
* @param array $rules List of allowed pages.
* @return bool
*/
protected function check_current_page($rules)
{
$result = false;
foreach ($rules as $key => $active) {
if (!$active) {
continue;
}
/*
* The item order is critical, in case a page has multiple flags
* like "Front" and "Home" and "Archive".
* In this example "Archive" might be denied but "Front" allowed,
* so we have to define a hierarchy which flag is actually used.
*/
switch ($key) {
case 'front':
$result = is_front_page();
break;
case 'home':
$result = is_home();
break;
case 'notfound':
$result = is_404();
break;
case 'search':
$result = is_search();
break;
case 'attachment':
$result = is_attachment();
break;
case 'single':
$result = is_singular();
break;
case 'archive':
$result = is_archive();
break;
case 'author':
$result = is_author();
break;
case 'date':
$result = is_date();
break;
case 'year':
$result = is_year();
break;
case 'month':
$result = is_month();
break;
case 'day':
$result = is_day();
break;
case 'time':
$result = is_time();
break;
}
if ($result) {
$this->matched_type = $key;
break;
}
}
return apply_filters('ms_rule_special_model_check_current_page', $result, $rules);
}