当前位置: 首页>>代码示例>>PHP>>正文


PHP hybrid_get_context函数代码示例

本文整理汇总了PHP中hybrid_get_context函数的典型用法代码示例。如果您正苦于以下问题:PHP hybrid_get_context函数的具体用法?PHP hybrid_get_context怎么用?PHP hybrid_get_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了hybrid_get_context函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: template_redirect

 /**
  * Ready for conditionals, before template choice.
  */
 function template_redirect()
 {
     global $hybrid;
     if (is_page()) {
         hybrid_get_context();
         $hybrid->context[] = 'singular-page-' . get_query_var('pagename');
     }
 }
开发者ID:kreapress,项目名称:hybrid-wing,代码行数:11,代码来源:class-core.php

示例2: get_atomic_template

/**
 * Looks for a template based on the hybrid_get_context() function.  If the $template parameter
 * is a directory, it will look for files within that directory.  Otherwise, $template becomes the 
 * template name prefix.  The function looks for templates based on the context of the current page
 * being viewed by the user.
 *
 * @since 0.8.0
 * @param string $template The slug of the template whose context we're searching for.
 * @return string $template The full path of the located template.
 */
function get_atomic_template($template)
{
    $templates = array();
    $theme_dir = trailingslashit(THEME_DIR) . $template;
    $child_dir = trailingslashit(CHILD_THEME_DIR) . $template;
    if (is_dir($child_dir) || is_dir($theme_dir)) {
        $dir = true;
        $templates[] = "{$template}/index.php";
    } else {
        $dir = false;
        $templates[] = "{$template}.php";
    }
    foreach (hybrid_get_context() as $context) {
        $templates[] = $dir ? "{$template}/{$context}.php" : "{$template}-{$context}.php";
    }
    return locate_template(array_reverse($templates), true);
}
开发者ID:rdbartlett,项目名称:kellyspencer.co.nz,代码行数:27,代码来源:utility.php

示例3: hybrid_body_class

/**
 * Provides classes for the <body> element depending on page context.
 *
 * @since 0.1.0
 * @uses $wp_query
 * @param string|array $class Additional classes for more control.
 * @return string
 */
function hybrid_body_class( $class = '' ) {
	global $wp_query;

	/* Text direction (which direction does the text flow). */
	$classes = array( 'wordpress', get_bloginfo( 'text_direction' ), get_locale() );

	/* Multisite check adds the 'multisite' class and the blog ID. */
	if ( is_multisite() ) {
		$classes[] = 'multisite';
		$classes[] = 'blog-' . get_current_blog_id();
	}

	/* Date classes. */
	$time = time() + ( get_option( 'gmt_offset' ) * 3600 );
	$classes[] = strtolower( gmdate( '\yY \mm \dd \hH l', $time ) );

	/* Is the current user logged in. */
	$classes[] = ( is_user_logged_in() ) ? 'logged-in' : 'logged-out';

	/* WP admin bar. */
	if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() )
		$classes[] = 'admin-bar';

	/* Merge base contextual classes with $classes. */
	$classes = array_merge( $classes, hybrid_get_context() );

	/* Singular post (post_type) classes. */
	if ( is_singular() ) {

		/* Checks for custom template. */
		$template = str_replace( array ( "{$wp_query->post->post_type}-template-", "{$wp_query->post->post_type}-", '.php' ), '', get_post_meta( $wp_query->post->ID, "_wp_{$wp_query->post->post_type}_template", true ) );
		if ( !empty( $template ) )
			$classes[] = "{$wp_query->post->post_type}-template-{$template}";

		/* Post format. */
		if ( current_theme_supports( 'post-formats' ) ) {
			$post_format = get_post_format( $wp_query->post->ID );
			$classes[] = ( ( empty( $post_format ) || is_wp_error( $post_format ) ) ? "{$wp_query->post->post_type}-format-standard" : "{$wp_query->post->post_type}-format-{$post_format}" );
		}

		/* Attachment mime types. */
		if ( is_attachment() ) {
			foreach ( explode( '/', get_post_mime_type() ) as $type )
				$classes[] = "attachment-{$type}";
		}
	}

	/* Paged views. */
	if ( ( ( $page = $wp_query->get( 'paged' ) ) || ( $page = $wp_query->get( 'page' ) ) ) && $page > 1 ) {
		$page = intval( $page );
		$classes[] = 'paged paged-' . $page;
	}

	/* Input class. */
	if ( !empty( $class ) ) {
		if ( !is_array( $class ) )
			$class = preg_split( '#\s+#', $class );
		$classes = array_merge( $classes, $class );
	}

	/* Apply the filters for WP's 'body_class'. */
	$classes = apply_filters( 'body_class', $classes, $class );

	/* Join all the classes into one string. */
	$class = join( ' ', $classes );

	/* Print the body class. */
	echo apply_atomic( 'body_class', $class );
}
开发者ID:nerdfiles,项目名称:mabrylaw.com,代码行数:77,代码来源:context.php

示例4: apply_atomic

/**
 * Adds contextual filter hooks to the theme.  This allows users to easily filter context-based content 
 * without having to know how to use WordPress conditional tags.  The theme handles the logic.
 *
 * An example of a basic hook would be 'hybrid_entry_meta'.  The apply_atomic() function extends 
 * that to give extra hooks such as 'hybrid_singular_entry_meta', 'hybrid_singular-post_entry_meta', 
 * and 'hybrid_singular-post-ID_entry_meta'.
 *
 * @since 0.7.0
 * @access public
 * @uses hybrid_get_prefix() Gets the theme prefix.
 * @uses hybrid_get_context() Gets the context of the current page.
 * @param string $tag Usually the location of the hook but defines what the base hook is.
 * @param mixed $value The value on which the filters hooked to $tag are applied on.
 * @param mixed $var,... Additional variables passed to the functions hooked to $tag.
 * @return mixed $value The value after it has been filtered.
 */
function apply_atomic($tag = '', $value = '')
{
    if (empty($tag)) {
        return false;
    }
    /* Get theme prefix. */
    $pre = hybrid_get_prefix();
    /* Get the args passed into the function and remove $tag. */
    $args = func_get_args();
    array_splice($args, 0, 1);
    /* Apply filters on the basic hook. */
    $value = $args[0] = apply_filters_ref_array("{$pre}_{$tag}", $args);
    /* Loop through context array and apply filters on a contextual scale. */
    foreach ((array) hybrid_get_context() as $context) {
        $value = $args[0] = apply_filters_ref_array("{$pre}_{$context}_{$tag}", $args);
    }
    /* Return the final value once all filters have been applied. */
    return $value;
}
开发者ID:JerryXie96,项目名称:PBSMUNC2013WebSite,代码行数:36,代码来源:core.php

示例5: hybrid_body_class_filter

/**
 * Filters the WordPress body class with a better set of classes that are more consistently handled and 
 * are backwards compatible with the original body class functionality that existed prior to WordPress 
 * core adopting this feature.
 *
 * @since  2.0.0
 * @access public
 * @param  array        $classes
 * @param  string|array $class
 * @return array
 */
function hybrid_body_class_filter($classes, $class)
{
    /* WordPress class for uses when WordPress isn't always the only system on the site. */
    $classes = array('wordpress');
    /* Text direction. */
    $classes[] = is_rtl() ? 'rtl' : 'ltr';
    /* Locale and language. */
    $locale = get_locale();
    $lang = hybrid_get_language($locale);
    if ($locale !== $lang) {
        $classes[] = $lang;
    }
    $classes[] = strtolower(str_replace('_', '-', $locale));
    /* Check if the current theme is a parent or child theme. */
    $classes[] = is_child_theme() ? 'child-theme' : 'parent-theme';
    /* Multisite check adds the 'multisite' class and the blog ID. */
    if (is_multisite()) {
        $classes[] = 'multisite';
        $classes[] = 'blog-' . get_current_blog_id();
    }
    /* Date classes. */
    $time = time() + get_option('gmt_offset') * 3600;
    $classes[] = strtolower(gmdate('\\yY \\mm \\dd \\hH l', $time));
    /* Is the current user logged in. */
    $classes[] = is_user_logged_in() ? 'logged-in' : 'logged-out';
    /* WP admin bar. */
    if (is_admin_bar_showing()) {
        $classes[] = 'admin-bar';
    }
    /* Use the '.custom-background' class to integrate with the WP background feature. */
    if (get_background_image() || get_background_color()) {
        $classes[] = 'custom-background';
    }
    /* Add the '.custom-header' class if the user is using a custom header. */
    if (get_header_image() || display_header_text() && get_header_textcolor()) {
        $classes[] = 'custom-header';
    }
    /* Add the '.display-header-text' class if the user chose to display it. */
    if (display_header_text()) {
        $classes[] = 'display-header-text';
    }
    /* Plural/multiple-post view (opposite of singular). */
    if (is_home() || is_archive() || is_search()) {
        $classes[] = 'plural';
    }
    /* Merge base contextual classes with $classes. */
    $classes = array_merge($classes, hybrid_get_context());
    /* Singular post (post_type) classes. */
    if (is_singular()) {
        /* Get the queried post object. */
        $post = get_queried_object();
        /* Checks for custom template. */
        $template = str_replace(array("{$post->post_type}-template-", "{$post->post_type}-"), '', basename(get_post_meta(get_queried_object_id(), "_wp_{$post->post_type}_template", true), '.php'));
        if (!empty($template)) {
            $classes[] = "{$post->post_type}-template-{$template}";
        }
        /* Post format. */
        if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) {
            $post_format = get_post_format(get_queried_object_id());
            $classes[] = empty($post_format) || is_wp_error($post_format) ? "{$post->post_type}-format-standard" : "{$post->post_type}-format-{$post_format}";
        }
        /* Attachment mime types. */
        if (is_attachment()) {
            foreach (explode('/', get_post_mime_type()) as $type) {
                $classes[] = "attachment-{$type}";
            }
        }
    }
    /* Paged views. */
    if (is_paged()) {
        $classes[] = 'paged';
        $classes[] = 'paged-' . intval(get_query_var('paged'));
    } elseif (is_singular() && 1 < get_query_var('page')) {
        $classes[] = 'paged';
        $classes[] = 'paged-' . intval(get_query_var('page'));
    }
    /* Input class. */
    if (!empty($class)) {
        $class = is_array($class) ? $class : preg_split('#\\s+#', $class);
        $classes = array_merge($classes, $class);
    }
    return array_map('esc_attr', $classes);
}
开发者ID:Jessphung,项目名称:Phungtastic,代码行数:94,代码来源:context.php

示例6: apply_atomic

/**
 * Adds contextual filter hooks to the theme.  This allows users to easily filter context-based content 
 * without having to know how to use WordPress conditional tags.  The theme handles the logic.
 *
 * An example of a basic hook would be 'hybrid_entry_meta'.  The apply_atomic() function extends 
 * that to give extra hooks such as 'hybrid_singular_entry_meta', 'hybrid_singular-post_entry_meta', 
 * and 'hybrid_singular-post-ID_entry_meta'.
 *
 * @since 0.7
 * @uses hybrid_get_prefix() Gets the theme prefix.
 * @uses hybrid_get_context() Gets the context of the current page.
 * @param string $tag Usually the location of the hook but defines what the base hook is.
 * @param mixed $value The value to be filtered.
 * @return mixed $value The value after it has been filtered.
 */
function apply_atomic( $tag = '', $value = '' ) {
	if ( !$tag )
		return false;

	/* Get theme prefix. */
	$pre = hybrid_get_prefix();

	/* Apply filters on the basic hook. */
	$value = apply_filters( "{$pre}_{$tag}", $value );

	/* Loop through context array and apply filters on a contextual scale. */
	foreach ( (array)hybrid_get_context() as $context )
		$value = apply_filters( "{$pre}_{$context}_{$tag}", $value );

	/* Return the final value once all filters have been applied. */
	return $value;
}
开发者ID:nerdfiles,项目名称:tbotw.org,代码行数:32,代码来源:core.php

示例7: hybrid_body_class

/**
 * Provides classes for the <body> element depending on page context.
 *
 * @since 0.1.0
 * @access public
 * @uses $wp_query
 * @param string|array $class Additional classes for more control.
 * @return void
 */
function hybrid_body_class($class = '')
{
    global $wp_query;
    /* Text direction (which direction does the text flow). */
    $classes = array('wordpress', get_bloginfo('text_direction'), get_locale());
    /* Check if the current theme is a parent or child theme. */
    $classes[] = is_child_theme() ? 'child-theme' : 'parent-theme';
    /* Multisite check adds the 'multisite' class and the blog ID. */
    if (is_multisite()) {
        $classes[] = 'multisite';
        $classes[] = 'blog-' . get_current_blog_id();
    }
    /* Date classes. */
    $time = time() + get_option('gmt_offset') * 3600;
    $classes[] = strtolower(gmdate('\\yY \\mm \\dd \\hH l', $time));
    /* Is the current user logged in. */
    $classes[] = is_user_logged_in() ? 'logged-in' : 'logged-out';
    /* WP admin bar. */
    if (is_admin_bar_showing()) {
        $classes[] = 'admin-bar';
    }
    /* Use the '.custom-background' class to integrate with the WP background feature. */
    if (get_background_image() || get_background_color()) {
        $classes[] = 'custom-background';
    }
    /* Add the '.custom-header' class if the user is using a custom header. */
    if (get_header_image()) {
        $classes[] = 'custom-header';
    }
    /* Merge base contextual classes with $classes. */
    $classes = array_merge($classes, hybrid_get_context());
    /* Singular post (post_type) classes. */
    if (is_singular()) {
        /* Get the queried post object. */
        $post = get_queried_object();
        /* Checks for custom template. */
        $template = str_replace(array("{$post->post_type}-template-", "{$post->post_type}-"), '', basename(get_post_meta(get_queried_object_id(), "_wp_{$post->post_type}_template", true), '.php'));
        if (!empty($template)) {
            $classes[] = "{$post->post_type}-template-{$template}";
        }
        /* Post format. */
        if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) {
            $post_format = get_post_format(get_queried_object_id());
            $classes[] = empty($post_format) || is_wp_error($post_format) ? "{$post->post_type}-format-standard" : "{$post->post_type}-format-{$post_format}";
        }
        /* Attachment mime types. */
        if (is_attachment()) {
            foreach (explode('/', get_post_mime_type()) as $type) {
                $classes[] = "attachment-{$type}";
            }
        }
    }
    /* Paged views. */
    if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) {
        $classes[] = 'paged paged-' . intval($page);
    }
    /* Input class. */
    if (!empty($class)) {
        if (!is_array($class)) {
            $class = preg_split('#\\s+#', $class);
        }
        $classes = array_merge($classes, $class);
    }
    /* Apply the filters for WP's 'body_class'. */
    $classes = apply_filters('body_class', $classes, $class);
    /* Join all the classes into one string. */
    $class = join(' ', $classes);
    /* Print the body class. */
    echo apply_atomic('body_class', $class);
}
开发者ID:ryanmr,项目名称:mirai-theme,代码行数:79,代码来源:context.php

示例8: hybrid_body_class

/**
 * Provides classes for the <body> element depending on page context.
 *
 * @since 0.1
 * @uses $wp_query
 * @param string|array $class Additional classes for more control.
 * @return string
 */
function hybrid_body_class( $class = '' ) {
	global $wp_query, $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome;

	/* Text direction (which direction does the text flow). */
	$classes = array( 'wordpress', get_bloginfo( 'text_direction' ), get_locale() );

	/* Layout class. */
	if ( ( current_theme_supports( 'post-layouts' ) || 'hybrid' == get_stylesheet() ) && is_singular() ) {
		$layout = get_post_meta( $wp_query->post->ID, 'Layout', true );
		if ( !empty( $layout ) )
			$classes[] = 'layout-' . strip_tags( esc_attr( $layout ) );
	}

	/* Date classes. */
	$time = time() + ( get_option( 'gmt_offset' ) * 3600 );
	$classes[] = strtolower( gmdate( '\yY \mm \dd \hH l', $time ) );

	/* Is the current user logged in. */
	$classes[] = ( is_user_logged_in() ) ? 'logged-in' : 'not-logged-in';

	/* Merge base contextual classes with $classes. */
	$classes = array_merge( $classes, hybrid_get_context() );

	/* Singular post (post_type) classes. */
	if ( is_singular() ) {

		/* Checks for custom template. */
		$template = str_replace( array ( "{$wp_query->post->post_type}-", "{$wp_query->post->post_type}-template-", '.php' ), '', get_post_meta( $wp_query->post->ID, "_wp_{$wp_query->post->post_type}_template", true ) );
		if ( $template ) {
			//$template = str_replace(  ), '', $template );
			$classes[] = "{$wp_query->post->post_type}-template-{$template}";
		}

		/* Attachment mime types. */
		if ( is_attachment() ) {
			foreach ( explode( '/', get_post_mime_type() ) as $type )
				$classes[] = "attachment-{$type}";
		}

		/* Deprecated classes. */
		elseif ( is_page() )
			$classes[] = "page-{$wp_query->post->ID}"; // Use singular-page-ID
		elseif ( is_singular( 'post' ) )
			$classes[] = "single-{$wp_query->post->ID}"; // Use singular-post-ID
	}

	/* Paged views. */
	if ( ( ( $page = $wp_query->get( 'paged' ) ) || ( $page = $wp_query->get( 'page' ) ) ) && $page > 1 ) {
		$page = intval( $page );
		$classes[] = 'paged paged-' . $page;
	}

	/* Browser detection. */
	$browsers = array( 	'gecko' => $is_gecko, 'opera' => $is_opera, 'lynx' => $is_lynx, 'ns4' => $is_NS4, 'safari' => $is_safari, 'chrome' => $is_chrome, 'msie' => $is_IE );
	foreach ( $browsers as $key => $value ) {
		if ( $value ) {
			$classes[] = $key;
			break;
		}
	}

	/* Hybrid theme widgets detection. */
	foreach ( array( 'primary', 'secondary', 'subsidiary' ) as $sidebar )
		$classes[] = ( is_active_sidebar( $sidebar ) ) ? "{$sidebar}-active" : "{$sidebar}-inactive";

	if ( in_array( 'primary-inactive', $classes ) && in_array( 'secondary-inactive', $classes ) && in_array( 'subsidiary-inactive', $classes ) )
		$classes[] = 'no-widgets';

	/* Input class. */
	if ( !empty( $class ) ) {
		if ( !is_array( $class ) )
			$class = preg_split( '#\s+#', $class );
		$classes = array_merge( $classes, $class );
	}

	/* Join all the classes into one string. */
	$class = join( ' ', $classes );

	/* Print the body class. */
	echo apply_atomic( 'body_class', $class );
}
开发者ID:nerdfiles,项目名称:sideshowtramps.com,代码行数:89,代码来源:context.php


注:本文中的hybrid_get_context函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。