本文整理汇总了PHP中get_queried_object函数的典型用法代码示例。如果您正苦于以下问题:PHP get_queried_object函数的具体用法?PHP get_queried_object怎么用?PHP get_queried_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_queried_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ups_display_sidebar
function ups_display_sidebar($default_sidebar)
{
$q_object = get_queried_object();
$sidebars = get_option('ups_sidebars');
foreach ($sidebars as $id => $sidebar) {
if (is_singular()) {
if (array_key_exists('pages', $sidebar)) {
if (array_key_exists('children', $sidebar) && $sidebar['children'] == 'on') {
$child = array_key_exists($q_object->post_parent, $sidebar['pages']);
} else {
$child = false;
}
if (array_key_exists($q_object->ID, $sidebar['pages']) || $child) {
return $id;
}
}
} elseif (is_home()) {
if (array_key_exists('index-blog', $sidebar) && $sidebar['index-blog'] == 'on') {
return $id;
}
} elseif (is_tax() || is_category() || is_tag()) {
if (array_key_exists('taxonomies', $sidebar)) {
if (array_key_exists($q_object->term_id, $sidebar['taxonomies'])) {
return $id;
}
}
} elseif (x_is_shop()) {
if (array_key_exists('index-shop', $sidebar) && $sidebar['index-shop'] == 'on') {
return $id;
}
}
}
return $default_sidebar;
}
示例2: set_clink_single_template
/**
* set clink single page template
*/
function set_clink_single_template($single_template)
{
$object = get_queried_object();
if ($object->post_type == 'clink') {
function clink_style()
{
global $wp_styles;
$wp_styles = '';
wp_enqueue_style('clink', CLINK_URL . 'assets/css/style.css');
if (get_bloginfo('language') == "fa-IR") {
wp_enqueue_style('clink-fa_IR', CLINK_URL . 'assets/css/fa_IR.css');
}
}
add_action('wp_print_styles', 'clink_style');
function clink_scripts()
{
global $wp_scripts;
$wp_scripts = '';
wp_deregister_script('jquery');
//wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', false, null);
//wp_enqueue_script('jquery');
wp_enqueue_script('jquery', CLINK_URL . 'assets/js/jquery.min.js');
wp_enqueue_script('countdown360', CLINK_URL . 'assets/js/jquery.countdown360.min.js');
wp_enqueue_script('clink', CLINK_URL . 'assets/js/main.js');
}
add_action('wp_enqueue_scripts', 'clink_scripts');
$single_template = CLINK_DIR . '/clink-template.php';
//dirname( clink__FILE__ ) . '/clink-template.php';
}
return $single_template;
}
示例3: amt_content_keywords
function amt_content_keywords()
{
$post = get_queried_object();
if (!is_null($post)) {
echo amt_get_content_keywords($post);
}
}
示例4: pinnacle_title
/**
* Page titles
*/
function pinnacle_title()
{
if (is_home()) {
if (get_option('page_for_posts', true)) {
return get_the_title(get_option('page_for_posts', true));
} else {
return __('Latest Posts', 'pinnacle');
}
} elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term) {
return $term->name;
} elseif (is_post_type_archive()) {
return get_queried_object()->labels->name;
} elseif (is_day()) {
return sprintf(__('Daily Archives: %s', 'pinnacle'), get_the_date());
} elseif (is_month()) {
return sprintf(__('Monthly Archives: %s', 'pinnacle'), get_the_date('F Y'));
} elseif (is_year()) {
return sprintf(__('Yearly Archives: %s', 'pinnacle'), get_the_date('Y'));
} elseif (is_author()) {
return sprintf(__('Author Archives: %s', 'pinnacle'), get_the_author());
} else {
return single_cat_title("", false);
}
} elseif (is_search()) {
return sprintf(__('Search Results for %s', 'pinnacle'), get_search_query());
} elseif (is_404()) {
return __('Not Found', 'pinnacle');
} else {
return get_the_title();
}
}
示例5: job_manager_output_jobs_defaults
public function job_manager_output_jobs_defaults($default)
{
$type = get_queried_object();
if (is_tax('job_listing_type')) {
$default['job_types'] = $type->slug;
$default['selected_job_types'] = $type->slug;
$default['show_categories'] = true;
} elseif (is_tax('job_listing_category')) {
$default['show_categories'] = true;
$default['categories'] = $type->slug;
$default['selected_category'] = $type->slug;
} elseif (is_search()) {
$default['keywords'] = get_search_query();
$default['show_filters'] = false;
}
if (is_home() || listify_is_widgetized_page()) {
$default['show_category_multiselect'] = false;
}
if (isset($_GET['search_categories'])) {
$categories = array_filter(array_map('esc_attr', $_GET['search_categories']), 'listify_array_filter_deep');
if (!empty($categories)) {
$default['selected_category'] = $categories[0];
}
$default['show_categories'] = true;
$default['categories'] = false;
}
return $default;
}
示例6: _prepare_filter
/**
* Prepares the object when the filter is applied.
*
* @uses \get_queried_object()
*
* @codeCoverageIgnore
*/
protected function _prepare_filter()
{
$post_type = \get_queried_object();
if (!empty($post_type->name) && !empty($post_type->has_archive)) {
$this->post_type = $post_type->name;
}
}
示例7: portfolioTypes
function portfolioTypes()
{
$portfolioTypes = get_terms('portfolio-type', 'orderby=id&order=ASC');
if (count($portfolioTypes) > 0) {
//current term
$currentTermId = is_tax('portfolio-type') ? get_queried_object()->term_id : "";
?>
<ol class="breadcrumb">
<?php
foreach ($portfolioTypes as $types) {
$activeClass = $currentTermId == $types->term_id ? " active " : "";
?>
<li class="gallery-type term-<?php
echo esc_attr($types->slug);
echo esc_attr($activeClass);
?>
term-id-<?php
echo esc_attr($types->term_id);
?>
">
<a href="<?php
echo esc_url(get_term_link($types));
?>
"><?php
echo esc_html($types->name);
?>
</a>
</li>
<?php
}
?>
</ol><?php
}
}
示例8: boilerplate_title
/**
* Handle output of page title
*/
function boilerplate_title($post = null)
{
$queried_object = get_queried_object();
if (is_home()) {
if (get_option('page_for_posts', true)) {
return get_the_title(get_option('page_for_posts', true));
} else {
return __('Latest Posts', 'boilerplate');
}
} elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term && get_query_var('taxonomy') !== 'language') {
return apply_filters('single_term_title', $term->name);
} elseif (is_post_type_archive()) {
return apply_filters('the_title', @$queried_object->labels->name ?: $queried_object->post_title);
} elseif (is_day()) {
return sprintf(__('Daily Archives: %s', 'boilerplate'), get_the_date());
} elseif (is_month()) {
return sprintf(__('Monthly Archives: %s', 'boilerplate'), get_the_date('F Y'));
} elseif (is_year()) {
return sprintf(__('Yearly Archives: %s', 'boilerplate'), get_the_date('Y'));
} elseif (is_author()) {
$author = $queried_object;
return sprintf(__('Author Archives: %s', 'boilerplate'), apply_filters('the_author', is_object($author) ? $author->display_name : null));
} else {
return single_cat_title('', false);
}
} elseif (is_search()) {
return sprintf(__('Search Results for “%s”', 'boilerplate'), get_search_query());
} elseif (is_404()) {
return __('Not Found', 'boilerplate');
} else {
return get_the_title();
}
}
示例9: documentate_template_chooser
function documentate_template_chooser($template)
{
global $wp_query;
$template_path = documentate_get_template_path();
$archive_page_id = documentate_get_option('archive_page_id');
$find = array();
$file = '';
if (is_single() && get_post_type() == 'document') {
$file = 'single-document.php';
$find[] = $file;
$find[] = $template_path . $file;
} elseif (is_tax(array('docu_cat', 'docu_tag'))) {
$term = get_queried_object();
$file = 'taxonomy-' . $term->taxonomy . '.php';
$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = $template_path . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = 'taxonomy-' . $term->taxonomy . '.php';
$find[] = $template_path . 'taxonomy-' . $term->taxonomy . '.php';
$find[] = $file;
$find[] = $template_path . $file;
} elseif (is_post_type_archive('document') || $archive_page_id && is_page($archive_page_id)) {
$file = 'archive-document.php';
$find[] = $file;
$find[] = $template_path . $file;
}
if ($file) {
$template = locate_template(array_unique($find));
if (!$template) {
$template = trailingslashit(Docu()->plugin_path()) . 'templates/' . $file;
}
}
return $template;
}
示例10: forge
public static function forge($term = null, $taxonomy = null)
{
if (is_tax($taxonomy) or is_category() or is_tag()) {
empty($term) and $term = get_queried_object();
}
return new static($term, $taxonomy);
}
示例11: generate_calendarize_shortcode
/**
*
*
* @version $Id$
* @copyright 2003
**/
function generate_calendarize_shortcode($params = array())
{
//
$args = array();
if (is_tax() || is_category()) {
$term = get_queried_object();
$args['taxonomy'] = sprintf('taxonomy="%s"', $term->taxonomy);
$args['terms'] = sprintf('terms="%s"', $term->slug);
} elseif (is_archive()) {
$args['post_type'] = sprintf('post_type="%s"', get_query_var('post_type'));
}
//--load default values
global $rhc_plugin;
$field_option_map = array("theme", "defaultview", "aspectratio", "header_left", "header_center", "header_right", "weekends", "firstday", "titleformat_month", "titleformat_week", "titleformat_day", "columnformat_month", "columnformat_week", "columnformat_day", "button_text_today", "button_text_month", "button_text_day", "button_text_week", "button_text_calendar", "button_text_event", "button_text_prev", "button_text_next", "buttonicons_prev", "buttonicons_next", "eventlistdateformat", "eventliststartdateformat", "eventlistshowheader", "eventlistnoeventstext", "eventlistmonthsahead", "eventlistupcoming", "timeformat_month", "timeformat_week", "timeformat_day", "timeformat_default", "axisformat", "tooltip_startdate", "tooltip_startdate_allday", "tooltip_enddate", "tooltip_enddate_allday", "tooltip_disable_title_link", "alldayslot", "alldaytext", "firsthour", "slotminutes", "mintime", "maxtime", "tooltip_target", "icalendar", "icalendar_width", "icalendar_button", "icalendar_title", "icalendar_description", "icalendar_align", "monthnames", "monthnamesshort", "daynames", "daynamesshort");
foreach ($field_option_map as $field) {
$option = 'cal_' . $field;
if (isset($params[$field])) {
continue;
}
$value = $rhc_plugin->get_option($option);
if (trim($value) != '') {
$params[$field] = $value;
}
}
//--
if (is_array($params) && count($params) > 0) {
foreach ($params as $field => $value) {
foreach (array('[' => '[', ']' => ']') as $replace => $with) {
$value = str_replace($replace, $with, $value);
}
$args[$field] = sprintf('%s="%s"', $field, $value);
}
}
return sprintf('[%s %s]', SHORTCODE_CALENDARIZE, implode(' ', $args));
}
开发者ID:TheMysticalSock,项目名称:westmichigansymphony,代码行数:41,代码来源:function.generate_calendarize_shortcode.php
示例12: password
/**
* main front end function wchich decides if the category is password
* protected or not
*
* @author Lukas Juhas
* @date 2016-02-05
* @return [type] [description]
*/
public function password($query)
{
// don't run if it's admin
if (is_admin()) {
return;
}
// make sure current category is "product_cat"
if (!isset(get_queried_object()->taxonomy) || !isset(get_queried_object()->taxonomy) && get_queried_object()->taxonomy !== 'product_cat') {
return;
}
// make sure temr id is set / that the page is actually a category
if (isset(get_queried_object()->term_id)) {
$is_password_protected = get_woocommerce_term_meta(get_queried_object()->term_id, 'wcl_cat_password_protected');
if ($is_password_protected) {
$cookie = 'wcl_' . md5(get_queried_object()->term_id);
$hash = isset($_COOKIE[wp_unslash($cookie)]) ? $_COOKIE[wp_unslash($cookie)] : false;
if (!$hash) {
add_filter('template_include', array($this, 'replace_template'));
} else {
// get current category id password
$cat_pass = get_woocommerce_term_meta(get_queried_object()->term_id, 'wcl_cat_password', true);
// decrypt cookie
require_once ABSPATH . WPINC . '/class-phpass.php';
$hasher = new PasswordHash(8, true);
$check = $hasher->CheckPassword($cat_pass, $hash);
if ($check) {
return;
} else {
add_filter('template_include', array($this, 'replace_template'));
}
}
}
}
}
示例13: registerPostType
/**
* Registering a post type
*
* @param string $type slug of the type
* @param string $singular singular name
* @param string $plural plural name
* @param array $config can override the defaults of this function (array_merge)
*/
public static function registerPostType($type, $singular, $plural, $config = array())
{
$labels = array('name' => $plural, 'singular_name' => $singular, 'add_new' => 'Erstellen', 'add_new_item' => $singular . ' erfassen', 'edit_item' => 'Bearbeite ' . $singular, 'new_item' => 'Neues ' . $singular, 'view_item' => $singular . ' ansehen', 'search_items' => $singular . ' suchen', 'not_found' => 'Keine ' . $plural . ' gefunden', 'not_found_in_trash' => 'Keine ' . $plural . ' im Papierkorb gefunden', 'parent_item_colon' => '');
$defaults = array('labels' => $labels, 'public' => true, 'has_archive' => true, 'plural_view_adminbar' => false);
$arguments = array_merge_recursive_distinct($defaults, $config);
if (isset($arguments['plural_view_adminbar']) && $arguments['plural_view_adminbar']) {
add_action('admin_bar_menu', function ($wp_admin_bar) use($type, $arguments) {
$object = get_queried_object();
if ($object->name == $type) {
$title = $object->labels->menu_name;
if (is_admin()) {
$url = get_post_type_archive_link($type);
} else {
$url = get_admin_url(null, 'edit.php?post_type=' . $type);
}
}
if ($object->post_type == $type) {
if (!is_admin()) {
$url = get_edit_post_link($object->ID);
$title = $arguments['labels']['edit_item'];
}
}
// Add admin bar entry
if ($url) {
$wp_admin_bar->add_node(array('id' => 'custom-button', 'title' => $title, 'href' => $url));
}
}, 95);
}
register_post_type($type, $arguments);
}
示例14: wpex_post_subheading
function wpex_post_subheading()
{
// Vars
global $post;
$output = '';
// Posts & Pages
if (is_singular()) {
$post_id = $post->ID;
$subheading = get_post_meta($post_id, 'wpex_post_subheading', true);
$output = '';
if ($subheading) {
$output .= '<div class="clr page-subheading">';
$output .= do_shortcode($subheading);
$output .= '</div>';
}
}
// Archives
if (is_tax()) {
$obj = get_queried_object();
$taxonomy = $obj->taxonomy;
$term_id = $obj->term_id;
$description = term_description($term_id, $taxonomy);
if (!empty($description)) {
$output .= '<div class="clr page-subheading term-description">';
$output .= $description;
$output .= '</div>';
}
}
// Return content
return $output;
}
示例15: dw_timeline_title
/**
* Page titles
*/
function dw_timeline_title()
{
if (is_home()) {
if (get_option('page_for_posts', true)) {
return get_the_title(get_option('page_for_posts', true));
} else {
return get_bloginfo('name');
}
} elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term) {
return apply_filters('single_term_title', $term->name);
} elseif (is_post_type_archive()) {
return apply_filters('the_title', get_queried_object()->labels->name);
} elseif (is_day()) {
return sprintf(__('Daily Archives: %s', 'dw-timeline'), get_the_date());
} elseif (is_month()) {
return sprintf(__('Monthly Archives: %s', 'dw-timeline'), get_the_date('F Y'));
} elseif (is_year()) {
return sprintf(__('Yearly Archives: %s', 'dw-timeline'), get_the_date('Y'));
} elseif (is_author()) {
$author = get_queried_object();
return sprintf(__('Author Archives: %s', 'dw-timeline'), $author->display_name);
} else {
return single_cat_title('', false);
}
} elseif (is_search()) {
return sprintf(__('Search Results for %s', 'dw-timeline'), get_search_query());
} elseif (is_404()) {
return __('Not Found', 'dw-timeline');
} else {
return get_the_title();
}
}