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


PHP get_queried_object_id函数代码示例

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


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

示例1: get_inti_option

 function get_inti_option($field_name, $option_array, $default = false, $meta_id = null)
 {
     // if meta_id isset then get the post meta
     if (isset($meta_id)) {
         $post_id = absint(get_queried_object_id());
         // if posts page is set in reading settings get the page id
         if ('page' == get_option('show_on_front') && get_option('page_for_posts') && is_home()) {
             the_post();
             $post_id = get_option('page_for_posts');
             wp_reset_postdata();
         }
         // get the meta from the database
         $meta = get_post_meta($post_id, $meta_id, true) ? get_post_meta($post_id, $meta_id, true) : null;
         // if meta is an array check for the name in the array
         if (is_array($meta)) {
             $meta = $meta[$field_name];
         }
         // if meta isset return the value
         if (isset($meta)) {
             $meta = do_shortcode($meta);
             return apply_filters("inti_meta_{$field_name}", $meta);
         }
         // if meta_id is null, then we're talking theme options, get the array of options
     } else {
         $options = get_option($option_array) ? get_option($option_array) : null;
     }
     // return the option if it exists
     if (isset($options[$field_name])) {
         return $options[$field_name];
     }
     // return default if nothing else
     return $default;
 }
开发者ID:waqastudios,项目名称:inti-foundation,代码行数:33,代码来源:get-options.php

示例2: document_title_parts_cb_s

function document_title_parts_cb_s($title)
{
    if (is_single() and $id = get_queried_object_id()) {
        $title[] = '#' . $id;
    }
    return $title;
}
开发者ID:systemo-biz,项目名称:add-id-in-title-wp,代码行数:7,代码来源:add-id-in-title.php

示例3: create

 /**
  * Factory method
  *
  * @param int $id
  *
  * @return MslsOptionsTax
  */
 public static function create($id = 0)
 {
     if (is_admin()) {
         $obj = MslsContentTypes::create();
         $id = (int) $id;
         $req = $obj->acl_request();
     } else {
         $id = get_queried_object_id();
         $req = is_category() ? 'category' : (is_tag() ? 'post_tag' : '');
     }
     switch ($req) {
         case 'category':
             $options = new MslsOptionsTaxTermCategory($id);
             break;
         case 'post_tag':
             $options = new MslsOptionsTaxTerm($id);
             break;
         default:
             $options = new MslsOptionsTax($id);
     }
     if ($req) {
         add_filter('check_url', array($options, 'check_base'), 9, 2);
     } else {
         global $wp_rewrite;
         $options->with_front = !empty($wp_rewrite->extra_permastructs[$options->get_tax_query()]['with_front']);
     }
     return $options;
 }
开发者ID:laishidua,项目名称:laishidua.com,代码行数:35,代码来源:MslsOptionsTax.php

示例4: shortcode

 /**
  * Shortcode Output
  */
 public function shortcode()
 {
     /*
      * Because it's possible to trigger inception, we need to keep track which
      * level we are in, and reset the shortcode object accordingly.
      *
      * Clever alert. The ++ happens AFTER the value is read, So $my_level starts at 0.
      */
     $my_level = self::$inception_levels++;
     $args = $this->map_related_term_args($this->get_initial_query_args());
     if (!$args) {
         // We failed the related term check.
         return '';
     }
     if (!isset($args['post__not_in']) && is_singular($this->sermons->post_type())) {
         $args['post__not_in'] = array(get_queried_object_id());
     }
     $sermons = $this->sermons->get_many($args);
     if (!$sermons->have_posts()) {
         return '';
     }
     $max = $sermons->max_num_pages;
     $sermons = $this->map_sermon_args($sermons, $my_level);
     $content = '';
     if (0 === $my_level) {
         $content .= GCS_Style_Loader::get_template('list-item-style');
     }
     $args = $this->get_pagination($max);
     $args['wrap_classes'] = $this->get_wrap_classes();
     $args['sermons'] = $sermons;
     $content .= GCS_Template_Loader::get_template('sermons-list', $args);
     return $content;
 }
开发者ID:jtsternberg,项目名称:gc-sermons,代码行数:36,代码来源:class-run.php

示例5: get_primary_category_id

 static function get_primary_category_id()
 {
     if (empty(self::$post->ID)) {
         return get_queried_object_id();
     }
     return self::$primary_category;
 }
开发者ID:Vatia13,项目名称:tofido,代码行数:7,代码来源:td_global.php

示例6: display

    public function display($post)
    {
        if (!empty($this->settings['page_template'])) {
            //echo $this->settings['page_template'];
            $page_template = get_page_template_slug(get_queried_object_id());
            if ($page_template != $this->settings['page_template']) {
                return false;
            }
        }
        $this->postID = $post->ID;
        wp_nonce_field($this->settings['id'], TF . '_' . $this->settings['id'] . '_nonce');
        if (!empty($this->settings['desc'])) {
            ?>
<p class='description'><?php 
            echo $this->settings['desc'];
            ?>
</p><?php 
        }
        ?>
		<table class="form-table tf-form-table">
		<tbody>
		<?php 
        foreach ($this->options as $option) {
            $option->display();
        }
        ?>
		</tbody>
		</table>
		<?php 
    }
开发者ID:gambitph,项目名称:titan-framework,代码行数:30,代码来源:class-meta-box.php

示例7: outputFaqs

 /**
  * Outputs the entire chunk of FAQs
  * @author Mike Biel <mike@orbitmedia.com>
  */
 function outputFaqs()
 {
     //Gets the current page id
     $post_id = get_queried_object_id();
     $return = '';
     $faqHTML = '';
     $faqs = get_field('related_faqs', $post_id);
     $show_adv_options = get_field('show_adv_options', $post_id);
     if ($faqs) {
         foreach ($faqs as $k => $f) {
             // variable must be called $post (IMPORTANT)
             // Question
             $question = $this->faqQuestion(get_field('question', $f->ID), $f->ID, 0 == $k);
             // Answer
             $answer = $this->faqAnswer(get_field('answer', $f->ID), $f->ID, 0 == $k);
             // Output Formatting
             $faqHTML .= $this->formatFAQ($question, $answer);
         }
         $advOptions = $show_adv_options ? $this->outPutAdvancedExpHTML() : '';
         $return = '
             <!-- START THE FAQS!!1!1!111 -->
             <div class="container-fluid">
                 <div class="row">
                     <div id="faqBlock" class="block">
                             ' . $advOptions . '
                         <div class="group-holder">
                             ' . $faqHTML . '
                         </div>
                             ' . $advOptions . '
                     </div>
                 </div>
             </div>';
     }
     return $return;
 }
开发者ID:pjsinco,项目名称:doctorsthatdo,代码行数:39,代码来源:FAQs.php

示例8: force_members_login_init

 /**
  * function which forces all users to log in
  */
 public static function force_members_login_init()
 {
     /* If the user is logged in, then abort */
     if (current_user_can('read')) {
         return;
     }
     /* get options to determine login page ID */
     $options = ltp_options::get_options();
     /* This is an array of pages that will be EXCLUDED from being blocked */
     $exclusions = array('wp-cron.php', 'wp-trackback.php', 'xmlrpc.php');
     /* If the current script name is in the exclusion list, abort */
     if (in_array(basename($_SERVER['PHP_SELF']), $exclusions)) {
         return;
     }
     /* if this is the login page, abort */
     if (isset($options["login_page_id"])) {
         if (get_queried_object_id() == $options["login_page_id"]) {
             return;
         }
         /* Still here? Okay, then redirect to the login form */
         self::redirect();
     } else {
         return;
     }
 }
开发者ID:Steadroy,项目名称:leeds-talent-pool,代码行数:28,代码来源:login.php

示例9: theme_layouts_get_layout

/**
 * Gets the layout for the current post based off the 'Layout' custom field key if viewing a singular post 
 * entry.  All other pages are given a default layout of 'layout-default'.
 *
 * @since 0.2.0
 * @return string The layout for the given page.
 */
function theme_layouts_get_layout()
{
    /* Get the available post layouts. */
    $post_layouts = get_theme_support('theme-layouts');
    /* Set the layout to an empty string. */
    $layout = '';
    /* If viewing a singular post, check if a layout has been specified. */
    if (is_singular()) {
        /* Get the current post ID. */
        $post_id = get_queried_object_id();
        /* Get the post layout. */
        $layout = get_post_layout($post_id);
    } elseif (is_author()) {
        /* Get the current user ID. */
        $user_id = get_queried_object_id();
        /* Get the user layout. */
        $layout = get_user_layout($user_id);
    }
    /* Make sure the given layout is in the array of available post layouts for the theme. */
    if (empty($layout) || !in_array($layout, $post_layouts[0])) {
        $layout = 'default';
    }
    /* @deprecated 0.2.0. Use the 'get_theme_layout' hook. */
    $layout = apply_filters('get_post_layout', "layout-{$layout}");
    /* Return the layout and allow plugin/theme developers to override it. */
    return esc_attr(apply_filters('get_theme_layout', $layout));
}
开发者ID:nixter,项目名称:d.school,代码行数:34,代码来源:theme-layouts.php

示例10: custom_list_categories

function custom_list_categories($args = '')
{
    $defaults = array('taxonomy' => 'category', 'show_option_none' => '', 'echo' => 1, 'depth' => 2, 'wrap_class' => '', 'level_class' => '', 'parent_title_format' => '%s', 'current_class' => 'current');
    $r = wp_parse_args($args, $defaults);
    if (!isset($r['wrap_class'])) {
        $r['wrap_class'] = 'category' == $r['taxonomy'] ? 'categories' : $r['taxonomy'];
    }
    extract($r);
    if (!taxonomy_exists($taxonomy)) {
        return false;
    }
    $categories = get_categories($r);
    $output = "<ul class='" . esc_attr($wrap_class) . "'>" . PHP_EOL;
    if (empty($categories)) {
        if (!empty($show_option_none)) {
            $output .= "<li>" . $show_option_none . "</li>" . PHP_EOL;
        }
    } else {
        if (is_category() || is_tax() || is_tag()) {
            $current_term_object = get_queried_object();
            if ($r['taxonomy'] == $current_term_object->taxonomy) {
                $r['current_category'] = get_queried_object_id();
            }
        }
        $depth = $r['depth'];
        $walker = new My_Category_Walker();
        $output .= $walker->walk($categories, $depth, $r);
    }
    $output .= "</ul>" . PHP_EOL;
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:binhdarkcu,项目名称:shoping_quan,代码行数:35,代码来源:functions.php

示例11: add_script_vars

    public function add_script_vars()
    {
        $post_id = get_queried_object_id();
        ?>
			<script type="text/javascript">
				var optinoid = {
					id: '<?php 
        echo get_queried_object_id();
        ?>
',
					api_url: '<?php 
        echo admin_url('admin-ajax.php');
        ?>
',
					nonce: '<?php 
        echo wp_create_nonce('optinoid');
        ?>
',
					is_home: <?php 
        echo is_front_page() ? 1 : 0;
        ?>
				};
			</script>
			<?php 
    }
开发者ID:stefanolaru,项目名称:optinoid,代码行数:25,代码来源:Output.php

示例12: widget

 /**
  * Outputs the widget based on the arguments input through the widget controls.
  *
  * @since  0.1.0
  * @access public
  * @return void
  */
 public function widget($sidebar, $instance)
 {
     extract($sidebar);
     /* If not viewing a single post, bail. */
     if (!is_singular()) {
         return;
     }
     /* Get the current post ID. */
     $post_id = get_queried_object_id();
     /* Get the snippet content and title. */
     $snippet_content = get_post_meta($post_id, 'Snippet', true);
     $snippet_title = get_post_meta($post_id, 'Snippet Title', true);
     /* If there's no snippet content, bail. */
     if (empty($snippet_content)) {
         return false;
     }
     /* If there's a custom snippet title, use it. Otherwise, default to the widget title. */
     $instance['title'] = !empty($snippet_title) ? $snippet_title : $instance['title'];
     /* Output the theme's widget wrapper. */
     echo $before_widget;
     /* If a title was input by the user, display it. */
     if (!empty($instance['title'])) {
         echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
     }
     /* Output the snippet. */
     printf('<div class="snippet-content">%s</div>', apply_filters('my_snippets_content', $snippet_content));
     /* Close the theme's widget wrapper. */
     echo $after_widget;
 }
开发者ID:ThemeSurgeon,项目名称:my-snippets,代码行数:36,代码来源:class-widget-snippet.php

示例13: handle_form_submission

 public function handle_form_submission()
 {
     if (get_queried_object_id() != $this->get_page_id()) {
         return false;
     }
     $action = $this->get_action();
     if (get_query_var('cuar_action', null) != null) {
         $action = get_query_var('cuar_action', null);
     }
     if (!$this->is_action_authorized($action)) {
         return false;
     }
     do_action('cuar/private-content/edit/before_' . $action, $this, $this->form_errors);
     do_action('cuar/private-content/edit/before_' . $action . '/page-slug=' . $this->get_slug(), $this, $this->form_errors);
     $result = $this->do_edit_content($action, $_POST);
     do_action('cuar/private-content/edit/after_' . $action, $this, $this->form_errors);
     do_action('cuar/private-content/edit/after_' . $action . '/page-slug=' . $this->get_slug(), $this, $this->form_errors);
     if (true === $result && empty($this->form_errors)) {
         $redirect_url = apply_filters('cuar/private-content/edit/after_' . $action . '/redirect_url', $this->get_redirect_url_after_action(), $this->get_slug());
         if ($redirect_url != null) {
             wp_redirect($redirect_url);
             exit;
         }
     }
     return true;
 }
开发者ID:joasssko,项目名称:schk,代码行数:26,代码来源:addon-edit-content-page.class.php

示例14: widget

 function widget($args, $instance)
 {
     extract($args);
     $user_id = $instance['user_id'];
     if (empty($user_id)) {
         if (is_author()) {
             $user_id = get_queried_object_id();
         } else {
             return;
         }
     }
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $title = sprintf($instance['title'], '<span class="display-name">' . get_the_author_meta('display_name', $user_id) . '</span>');
     $bio = get_the_author_meta('description', $user_id);
     if ($instance['strip_tags']) {
         $bio = strip_tags($bio);
     }
     if (function_exists('mb_strimwidth') && ($bio_length = $instance['bio_length'])) {
         $bio = mb_strimwidth($bio, 0, $bio_length);
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     echo '<div class="bio">' . wpautop($bio) . '</div>';
     echo $after_widget;
 }
开发者ID:alphadc,项目名称:xiuxing,代码行数:27,代码来源:widget-user-bio.php

示例15: cherry_post_inline_styles

/**
 * Get post specific CSS styles and paste it to head.
 *
 * @since 4.0.0
 */
function cherry_post_inline_styles()
{
    $post_id = get_queried_object_id();
    $post_type = get_post_type($post_id);
    if (!$post_type || !post_type_supports($post_type, 'cherry-post-style')) {
        return;
    }
    if (wp_style_is(CHERRY_DYNAMIC_CSS_HANDLE, 'enqueued')) {
        $handle = CHERRY_DYNAMIC_CSS_HANDLE;
    } else {
        $cherry_styles = cherry_get_styles();
        $handle = isset($cherry_styles['style']) ? $cherry_styles['style']['handle'] : false;
    }
    if (!$handle) {
        return;
    }
    $header_bg = cherry_current_page()->get_property('background', 'header');
    if (!$header_bg) {
        return;
    }
    $custom_bg = cherry_get_background_css('.site-header', $header_bg);
    /**
     * Filter a custom background style.
     *
     * @since 4.0.0
     * @param string $custom_bg Background style.
     * @param int    $post_id   The post ID.
     */
    $custom_bg = apply_filters('cherry_post_inline_styles', $custom_bg, $post_id);
    if (!$custom_bg) {
        return;
    }
    wp_add_inline_style($handle, sanitize_text_field($custom_bg));
}
开发者ID:xav335,项目名称:sfnettoyage,代码行数:39,代码来源:styles.php


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