• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_tax函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: presscore_search_title_shortcode

 function presscore_search_title_shortcode()
 {
     $title = '';
     $wrap_class = '';
     if (is_search()) {
         $title = get_search_query();
     } else {
         if (is_archive()) {
             if (is_category()) {
                 $title = single_cat_title('', false);
             } elseif (is_tag()) {
                 $title = single_tag_title('', false);
             } elseif (is_author()) {
                 the_post();
                 $title = '<a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta("ID"))) . '" title="' . esc_attr(get_the_author()) . '" rel="me">' . get_the_author() . '</a>';
                 $wrap_class .= ' vcard';
                 rewind_posts();
             } elseif (is_day()) {
                 $title = '<span>' . get_the_date() . '</span>';
             } elseif (is_month()) {
                 $title = '<span>' . get_the_date('F Y');
             } elseif (is_year()) {
                 $title = '<span>' . get_the_date('Y');
             } elseif (is_tax('dt_portfolio_category')) {
                 $title = single_term_title('', false);
             } elseif (is_tax('dt_gallery_category')) {
                 $title = single_term_title('', false);
             }
         }
     }
     if ($title) {
         $title = '<span' . ($wrap_class ? ' class="' . esc_attr($wrap_class) . '"' : '') . '>' . $title . '</span>';
     }
     return $title;
 }
开发者ID:RDePoppe,项目名称:luminaterealestate,代码行数:35,代码来源:shortcode-search-title.php


示例2: add_open_field_to_context_search

function add_open_field_to_context_search()
{
    if (!(is_post_type_archive('cases') or is_tax('functions'))) {
        return;
    }
    $open = '';
    if (isset($_REQUEST['open'])) {
        $open = $_REQUEST['open'];
    }
    ?>


	<div id="case_open_field_wrapper_cp" class="form-group">
		<label for="case_open_field">Открытые</label>
		<select type="text" id="case_open_field" class="form-control" name="open">
			<option <?php 
    selected($open, "", true);
    ?>
 value="">Все дела</option>
			<option <?php 
    selected($open, "yes", true);
    ?>
 value="yes">Только открытые дела</option>
			<option <?php 
    selected($open, "no", true);
    ?>
 value="no">Только закрытые дела</option>
		</select>
	</div>

<?php 
}
开发者ID:Laxiston,项目名称:casepress,代码行数:32,代码来源:filter_open_closed.php


示例3: porto_page_title

function porto_page_title()
{
    global $porto_settings;
    $output = '';
    if (!is_front_page()) {
    } elseif (is_home()) {
        $output .= $porto_settings['blog-title'];
    }
    if (is_singular()) {
        $output .= porto_page_title_leaf();
    } else {
        if (is_post_type_archive()) {
            if (is_search()) {
                $output .= porto_page_title_leaf('search');
            } else {
                $output .= porto_page_title_archive();
            }
        } elseif (is_tax() || is_tag() || is_category()) {
            $html = porto_page_title_leaf('term');
            if (is_tag()) {
                $output .= sprintf(__('Tag - %s', 'porto'), $html);
            } elseif (is_tax('product_tag')) {
                $output .= sprintf(__('Product Tag - %s', 'porto'), $html);
            } else {
                $output .= $html;
            }
        } elseif (is_date()) {
            if (is_year()) {
                $output .= porto_page_title_leaf('year');
            } elseif (is_month()) {
                $output .= porto_page_title_leaf('month');
            } elseif (is_day()) {
                $output .= porto_page_title_leaf('day');
            }
        } elseif (is_author()) {
            $output .= porto_page_title_leaf('author');
        } elseif (is_search()) {
            $output .= porto_page_title_leaf('search');
        } elseif (is_404()) {
            $output .= porto_page_title_leaf('404');
        } elseif (class_exists('bbPress') && is_bbpress()) {
            if (bbp_is_search()) {
                $output .= porto_page_title_leaf('bbpress_search');
            } elseif (bbp_is_single_user()) {
                $output .= porto_page_title_leaf('bbpress_user');
            } else {
                $output .= porto_page_title_leaf();
            }
        } else {
            if (is_home() && !is_front_page()) {
                if (get_option('show_on_front') == 'page') {
                    $output .= get_the_title(get_option('page_for_posts', true));
                } else {
                    $output .= $porto_settings['blog-title'];
                }
            }
        }
    }
    return apply_filters('porto_page_title', $output);
}
开发者ID:booklein,项目名称:wpbookle,代码行数:60,代码来源:page-title.php


示例4: tb_archive_title

 /**
  * Gets The Archive Title Set In The Options, With Normal Defaults.
  *
  * Pass true to echo instead or returning the value
  *
  * @param bool $echo
  * @return mixed|null|string|void
  * @since 0.1
  */
 function tb_archive_title($echo = true)
 {
     $out = __('Archive');
     if (is_tax('tb_genre')) {
         $opt = get_option('genre_archive_title');
         $out = $opt ? $opt : single_term_title('', false);
     }
     if (is_tax('tb_author')) {
         $opt = get_option('author_archive_title');
         $out = $opt ? $opt : single_term_title('', false);
     }
     if (is_tax('tb_series')) {
         $opt = get_option('series_archive_title');
         $out = $opt ? $opt : single_term_title('', false);
     }
     if (is_post_type_archive('tb_book')) {
         $opt = get_option('book_archive_title');
         $out = $opt ? $opt : __('Books Archives', 'totally-booked');
     }
     if (!$echo) {
         return $out;
     }
     echo $out;
     return;
 }
开发者ID:tigerstrikemedia,项目名称:totally-booked,代码行数:34,代码来源:template_tags.php


示例5: hocwp_is_post_type_archive

function hocwp_is_post_type_archive($post_type)
{
    if (is_tax(get_object_taxonomies($post_type)) || is_post_type_archive($post_type)) {
        return true;
    }
    return false;
}
开发者ID:skylarkcob,项目名称:hocwp-projects,代码行数:7,代码来源:utils.php


示例6: woothemes_add_css

 function woothemes_add_css()
 {
     global $woo_options;
     wp_register_style('prettyPhoto', get_template_directory_uri() . '/includes/css/prettyPhoto.css');
     wp_register_style('non-responsive', get_template_directory_uri() . '/css/non-responsive.css');
     // Disable prettyPhoto css if WooCommerce is activated and user is on the product page
     $woocommerce_activated = is_woocommerce_activated();
     $woocommerce_lightbox = get_option('woocommerce_enable_lightbox') == 'yes' ? true : false;
     $woocommerce_product = false;
     if ($woocommerce_activated) {
         $woocommerce_product = is_product();
     }
     if ($woocommerce_activated && $woocommerce_product && $woocommerce_lightbox) {
         wp_deregister_style('prettyPhoto');
     }
     // Conditionally load the Portfolio CSS, where needed.
     $load_portfolio_css = false;
     if (is_page_template('template-portfolio.php') || is_singular() && get_post_type() == 'portfolio' || is_post_type_archive('portfolio') || is_tax('portfolio-gallery')) {
         $load_portfolio_css = true;
     }
     // Allow child themes/plugins to load the portfolio CSS when they need it.
     $load_portfolio_css = apply_filters('woo_load_portfolio_css', $load_portfolio_css);
     if ($load_portfolio_css) {
         wp_enqueue_style('prettyPhoto');
     }
     do_action('woothemes_add_css');
 }
开发者ID:plusplusminus,项目名称:athol,代码行数:27,代码来源:theme-js.php


示例7: context_check

 function context_check($check, $settings)
 {
     if (empty($settings)) {
         return $check;
     }
     $status = array();
     if (!is_array($this->post_types)) {
         $this->set_objects();
     }
     foreach ($this->post_types as $post_type => $post_type_settings) {
         if (isset($settings['is_singular-' . $post_type]) && $settings['is_singular-' . $post_type]) {
             $status['is_singular-' . $post_type] = is_singular($post_type);
         }
         if (isset($settings['is_archive-' . $post_type]) && $settings['is_archive-' . $post_type]) {
             $status['is_archive-' . $post_type] = is_post_type_archive($post_type);
         }
     }
     foreach ($this->taxonomies as $taxonomy => $tax_settings) {
         if (isset($settings['is_tax-' . $taxonomy]) && $settings['is_tax-' . $taxonomy]) {
             $status['is_tax-' . $taxonomy] = is_tax($taxonomy);
         }
     }
     $matched = array_intersect_assoc($settings, $status);
     if (!empty($matched)) {
         return true;
     }
     return $check;
 }
开发者ID:koopmant,项目名称:Mens-site,代码行数:28,代码来源:module.php


示例8: woocommerce_category_archive_description

function woocommerce_category_archive_description()
{
    if (is_tax(array('product_cat', 'product_tag')) && get_query_var('paged') == 0) {
        $description = wc_format_content(term_description());
        $image = false;
        if (is_tax() || is_tag() || is_category()) {
            $term = get_queried_object();
            $thumbnail_id = absint(get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true));
            if ($thumbnail_id) {
                $image = wp_get_attachment_image($thumbnail_id, 250);
            } else {
                $image = wc_placeholder_img_src();
            }
        }
        if ($description) {
            $string = '<div class="row margin-bottom">';
            if ($image) {
                $string .= '<div class="col-sm-4 col-sm-push-8">' . $image . '</div>';
            }
            $string .= '<div class="term-description col-sm-8';
            if ($image) {
                $string .= ' col-sm-pull-4';
            }
            $string .= '">' . $description . '</div></div>';
            echo $string;
        }
    }
}
开发者ID:n3ssi3,项目名称:tauch-terminal,代码行数:28,代码来源:functions_woocommerce.php


示例9: listable_body_classes

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 *
 * @return array
 */
function listable_body_classes($classes)
{
    // Adds a class of group-blog to blogs with more than 1 published author.
    if (is_multi_author()) {
        $classes[] = 'group-blog';
    }
    global $post;
    if (has_nav_menu('secondary')) {
        $classes[] = 'has--secondary-menu';
    }
    if (isset($post->post_content) && has_shortcode($post->post_content, 'jobs') || is_search() || is_tax(array('job_listing_category', 'job_listing_tag', 'job_listing_region'))) {
        $classes[] = 'page-listings';
    }
    if (isset($post->post_content) && has_shortcode($post->post_content, 'job_dashboard')) {
        $classes[] = 'page-job-dashboard';
    }
    if (isset($post->post_content) && has_shortcode($post->post_content, 'my_bookmarks')) {
        $classes[] = 'page-my-bookmarks';
    }
    if (isset($post->post_content) && has_shortcode($post->post_content, 'woocommerce_my_account')) {
        $classes[] = 'page-login';
    }
    if (isset($post->post_content) && has_shortcode($post->post_content, 'submit_job_form')) {
        $classes[] = 'page-add-listing';
    }
    if (listable_using_facetwp()) {
        $classes[] = 'is--using-facetwp';
    }
    if (isset($post->post_content) && has_shortcode($post->post_content, 'jobs_by_tag')) {
        $classes[] = 'jobs-by-tags-page';
    }
    return $classes;
}
开发者ID:swaroop42,项目名称:RockRose,代码行数:40,代码来源:extras.php


示例10: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
         return;
     }
     // enqueue necessary scripts
     wp_enqueue_style('wcapf-style');
     wp_enqueue_style('font-awesome');
     wp_enqueue_script('wcapf-script');
     global $wcapf;
     $active_filters = $wcapf->getChosenFilters()['active_filters'];
     $found = false;
     $html = '';
     if (sizeof($active_filters) > 0) {
         $found = true;
         $html .= '<div class="wcapf-active-filters">';
         foreach ($active_filters as $key => $active_filter) {
             if ($key === 'term') {
                 foreach ($active_filter as $data_key => $terms) {
                     foreach ($terms as $term_id => $term_name) {
                         $html .= '<a href="javascript:void(0)" data-key="' . $data_key . '" data-value="' . $term_id . '">' . $term_name . '</a>';
                     }
                 }
             }
             if ($key === 'keyword') {
                 $html .= '<a href="javascript:void(0)" data-key="keyword">' . __('Search For: ', 'wcapf') . $active_filter . '</a>';
             }
             if ($key === 'orderby') {
                 $html .= '<a href="javascript:void(0)" data-key="orderby">' . __('Orderby: ', 'wcapf') . $active_filter . '</a>';
             }
             if ($key === 'min_price') {
                 $html .= '<a href="javascript:void(0)" data-key="min-price">' . __('Min Price: ', 'wcapf') . $active_filter . '</a>';
             }
             if ($key === 'max_price') {
                 $html .= '<a href="javascript:void(0)" data-key="max-price">' . __('Max Price: ', 'wcapf') . $active_filter . '</a>';
             }
         }
         $html .= '</div>';
     }
     extract($args);
     // Add class to before_widget from within a custom widget
     // http://wordpress.stackexchange.com/questions/18942/add-class-to-before-widget-from-within-a-custom-widget
     if ($found === false) {
         $widget_class = 'wcapf-widget-hidden woocommerce wcapf-ajax-term-filter';
     } else {
         $widget_class = 'woocommerce wcapf-ajax-term-filter';
     }
     // no class found, so add it
     if (strpos($before_widget, 'class') === false) {
         $before_widget = str_replace('>', 'class="' . $widget_class . '"', $before_widget);
     } else {
         $before_widget = str_replace('class="', 'class="' . $widget_class . ' ', $before_widget);
     }
     echo $before_widget;
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     echo $html;
     echo $args['after_widget'];
 }
开发者ID:wptailor,项目名称:wc-ajax-product-filter,代码行数:68,代码来源:widget-active-filter.php


示例11: get_posts

function get_posts($query)
{
    if (is_tax('series') && $query->is_main_query()) {
        $query->set('order', option('order'));
    }
    return $query;
}
开发者ID:synapticism,项目名称:ubik,代码行数:7,代码来源:series.php


示例12: display

 /**
  * Display breadcrumbs
  */
 public function display()
 {
     if (Habakiri::get('is_displaying_bread_crumb') === 'false') {
         return;
     }
     global $wp_query;
     // Set to home
     $home_label = $this->get_home_label();
     $this->set($home_label, home_url('/'));
     // Set to blog
     $post_type = $this->get_post_type();
     if (is_category() || is_tag() || is_date() || is_author() || is_single() && $post_type === 'post') {
         $show_on_front = get_option('show_on_front');
         $page_for_posts = get_option('page_for_posts');
         if ($show_on_front === 'page' && $page_for_posts) {
             $this->set(get_the_title($page_for_posts), get_permalink($page_for_posts));
         }
     }
     // Set current and ancestors
     if (is_404()) {
         $this->set_for_404();
     } elseif (is_search()) {
         $this->set_for_search();
     } elseif (is_tax()) {
         $this->set_for_tax();
     } elseif (is_attachment()) {
         $this->set_for_attachment();
     } elseif (is_page() && !is_front_page()) {
         $this->set_for_page();
     } elseif (is_post_type_archive()) {
         $this->set_for_post_type_archive();
     } elseif (is_single()) {
         $this->set_for_single();
     } elseif (is_category()) {
         $this->set_for_category();
     } elseif (is_tag()) {
         $this->set_for_tag();
     } elseif (is_author()) {
         $this->set_for_author();
     } elseif (is_day()) {
         $this->set_for_day();
     } elseif (is_month()) {
         $this->set_for_month();
     } elseif (is_year()) {
         $this->set_for_year();
     } elseif (is_home() && !is_front_page()) {
         $this->set_for_blog();
     }
     $bread_crumb = array();
     $last_item = array_pop($this->bread_crumb);
     foreach ($this->bread_crumb as $_bread_crumb) {
         if (!empty($_bread_crumb['link'])) {
             $bread_crumb[] = sprintf('<a href="%s">%s</a>', esc_url($_bread_crumb['link']), esc_html($_bread_crumb['title']));
         } else {
             $bread_crumb[] = esc_html($_bread_crumb['title']);
         }
     }
     $bread_crumb[] = sprintf('<strong>%s</strong>', $last_item['title']);
     printf('<div class="breadcrumbs">%s</div>', implode(' &gt; ', apply_filters('habakiri_bread_crumb', $bread_crumb)));
 }
开发者ID:ConductiveIO,项目名称:mbrady,代码行数:63,代码来源:class.breadcrumbs.php


示例13: dportfolio_post_archive

/**
* set query post type dportfolio for taxonomy dportfolio_categories 
*/
function dportfolio_post_archive($query)
{
    if (!is_admin() && is_tax('dportfolio_categories') && $query->is_tax) {
        $query->set('post_type', array('dportfolio'));
        remove_action('pre_get_posts', 'dportfolio_post_archive');
    }
}
开发者ID:Dinamiko,项目名称:DPortfolio,代码行数:10,代码来源:dportfolio-setup-post-types-taxonomies.php


示例14: sb_get_layout

/**
 * Gets the layout for the current post, page or taxonomy. If none is specified, use 'layout-default'.
 *
 * @since StartBox 2.5
 * @return string The layout for the given page.
 */
function sb_get_layout()
{
    global $wp_query;
    /* Get the available post layouts and store them in an array */
    foreach (get_theme_support('sb-layouts') as $layout => $key) {
        $layouts[] = $layout;
    }
    /* Set the layout to an empty string. */
    $layout = '';
    /* If viewing a singular post/page, check if a layout has been specified. */
    if (is_singular()) {
        /* Get the current post ID. */
        $post_id = $wp_query->get_queried_object_id();
        /* Get the post layout. */
        $layout = sb_get_post_layout($post_id);
    }
    /* If viewing a taxonomy, check if a layout has been specified */
    if (is_category() || is_tag() || is_tax() || is_archive()) {
        global $wp_query;
        $term = $wp_query->get_queried_object();
        $layout = $term->meta['layout'];
    }
    /* Make sure the given layout is in the array of available post layouts for the theme. */
    if (empty($layout) || !in_array($layout, $layouts) || $layout == 'default') {
        $layout = apply_filters('sb_get_post_layout_default', 'default');
    }
    /* Return the layout and allow plugin/theme developers to override it. */
    return esc_attr(apply_filters('get_theme_layout', "layout-{$layout}"));
}
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:35,代码来源:layouts.php


示例15: sbg_post_meta

 function sbg_post_meta($post_meta)
 {
     if (is_post_type_archive('staff-member') || is_singular('staff-member') || is_tax('staff-position') || is_page()) {
         $post_meta = '[post_terms taxonomy="staff-position" before=""]';
     }
     return $post_meta;
 }
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:7,代码来源:staff-bio-grid.php


示例16: template_loader

 /**
  * Load a template.
  *
  * Handles template usage so that we can use our own templates instead of the themes.
  *
  * Templates are in the 'templates' folder. woocommerce looks for theme
  * overrides in /theme/woocommerce/ by default
  *
  * For beginners, it also looks for a woocommerce.php template first. If the user adds
  * this to the theme (containing a woocommerce() inside) this will be used for all
  * woocommerce templates.
  *
  * @param mixed $template
  * @return string
  */
 public function template_loader($template)
 {
     $find = array('woocommerce.php');
     $file = '';
     if (is_single() && get_post_type() == 'product') {
         $file = 'single-product.php';
         $find[] = $file;
         $find[] = WC_TEMPLATE_PATH . $file;
     } elseif (is_tax('product_cat') || is_tax('product_tag')) {
         $term = get_queried_object();
         $file = 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = WC_TEMPLATE_PATH . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = $file;
         $find[] = WC_TEMPLATE_PATH . $file;
     } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
         $file = 'archive-product.php';
         $find[] = $file;
         $find[] = WC_TEMPLATE_PATH . $file;
     }
     if ($file) {
         $template = locate_template($find);
         $status_options = get_option('woocommerce_status_options', array());
         if (!$template || !empty($status_options['template_debug_mode']) && current_user_can('manage_options')) {
             $template = WC()->plugin_path() . '/templates/' . $file;
         }
     }
     return $template;
 }
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:44,代码来源:class-wc-template-loader.php


示例17: scripts

 /**
  * Add our custom stylesheets and scripts
  */
 function scripts()
 {
     $options = get_option('maera_admin_options', array());
     $active_shell = isset($options['shell']) ? $options['shell'] : 'core';
     // Remove the default EDD styles
     wp_dequeue_style('edd-styles');
     // If EDD-Software-Specs is installed, remove its styles
     if (class_exists('EDD_Software_Specs')) {
         wp_dequeue_style('edd-software-specs');
         wp_deregister_style('edd-software-specs');
     }
     // Add our custom styles
     wp_register_style('maera-edd', trailingslashit(get_template_directory_uri()) . 'assets/css/edd/style.css');
     wp_enqueue_style('maera-edd');
     if ('isotope' == get_theme_mod('filter_mode', 'isotope') && (is_archive('download') || is_tax('download_tag') || is_tax('download_category'))) {
         // Register && Enqueue Isotope
         wp_register_script('maera_isotope', trailingslashit(get_template_directory_uri()) . 'assets/vendor/jquery.isotope.min.js', false, null, true);
         wp_enqueue_script('maera_isotope');
         // Register && Enqueue Isotope-Sloppy-Masonry
         wp_register_script('maera_isotope_sloppy_masonry', trailingslashit(get_template_directory_uri()) . 'assets/vendor/jquery.isotope.sloppy-masonry.min.js', false, null, true);
         wp_enqueue_script('maera_isotope_sloppy_masonry');
         wp_enqueue_script('edd_script', trailingslashit(get_template_directory_uri()) . 'assets/js/edd-scripts.js', false, null, true);
         // wp_localize_script( 'maera_foundation_script', 'maera_foundation_script_vars', array(
         //
         //     )
         // );
     }
 }
开发者ID:wpmu,项目名称:maera,代码行数:31,代码来源:class-maera-edd-scripts.php


示例18: is_term_top_level

/**
 * Returns true if term is a top-level term.
 * Behavior is the same for non-hierarchical taxonomies (i.e. always returns true).
 * 
 * @param object|int|string $term Term object, ID, or slug. Can leave null if on a term page.
 * @param string $taxonomy Taxonomy name.
 * @return boolean True if term is a top-level term, otherwise false.
 */
function is_term_top_level($term = null, $taxonomy = null)
{
    if (empty($term) || !is_object($term)) {
        // Are we in taxonomy context?
        if (is_tax()) {
            $term = get_query_var('term');
            $taxonomy = get_query_var('taxonomy');
        }
        // Require taxonomy if $term is not object
        if (empty($taxonomy) || !taxonomy_exists($taxonomy)) {
            return null;
        }
        if (is_int($term)) {
            $term = get_term($term, $taxonomy);
        } else {
            if (is_string($term)) {
                $orig = $term;
                $term = get_term_by('slug', $term, $taxonomy);
                if (null === $term) {
                    // slug didn't work, try name
                    $term = get_term_by('name', $orig, $taxonomy);
                }
            }
        }
    }
    return $term ? $term->parent === 0 : null;
}
开发者ID:wells5609,项目名称:wp-app,代码行数:35,代码来源:taxonomy.php


示例19: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
         return;
     }
     global $wcapf;
     // price range for filtered products
     $filtered_price_range = $wcapf->getPriceRange(true);
     // price range for all published products
     $unfiltered_price_range = $wcapf->getPriceRange(false);
     $html = '';
     // to be sure that these values are number
     $min_val = $max_val = 0;
     if (sizeof($unfiltered_price_range) === 2) {
         $min_val = $unfiltered_price_range[0];
         $max_val = $unfiltered_price_range[1];
     }
     // required scripts
     // enqueue necessary scripts
     wp_enqueue_style('wcapf-style');
     wp_enqueue_style('font-awesome');
     wp_enqueue_script('wcapf-script');
     wp_enqueue_script('wcapf-nouislider-script');
     wp_enqueue_script('wcapf-price-filter-script');
     wp_enqueue_style('wcapf-nouislider-style');
     // get values from url
     $set_min_val = null;
     if (isset($_GET['min-price']) && !empty($_GET['min-price'])) {
         $set_min_val = (int) $_GET['min-price'];
     }
     $set_max_val = null;
     if (isset($_GET['max-price']) && !empty($_GET['max-price'])) {
         $set_max_val = (int) $_GET['max-price'];
     }
     // HTML markup for price slider
     $html .= '<div class="wcapf-price-filter-wrapper">';
     $html .= '<div id="wcapf-noui-slider" class="noUi-extended" data-min="' . $min_val . '" data-max="' . $max_val . '" data-set-min="' . $set_min_val . '" data-set-max="' . $set_max_val . '"></div>';
     $html .= '<br />';
     $html .= '<div class="slider-values">';
     $html .= '<p>Min Price: <span class="wcapf-slider-value" id="wcapf-noui-slider-value-min"></span></p>';
     $html .= '<p>Max Price: <span class="wcapf-slider-value" id="wcapf-noui-slider-value-max"></span></p>';
     $html .= '</div>';
     $html .= '</div>';
     extract($args);
     // Add class to before_widget from within a custom widget
     // http://wordpress.stackexchange.com/questions/18942/add-class-to-before-widget-from-within-a-custom-widget
     $widget_class = 'woocommerce wcapf-price-filter-widget';
     // no class found, so add it
     if (strpos($before_widget, 'class') === false) {
         $before_widget = str_replace('>', 'class="' . $widget_class . '"', $before_widget);
     } else {
         $before_widget = str_replace('class="', 'class="' . $widget_class . ' ', $before_widget);
     }
     echo $before_widget;
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     echo $html;
     echo $args['after_widget'];
 }
开发者ID:wptailor,项目名称:wc-ajax-product-filter,代码行数:68,代码来源:widget-price-filter.php


示例20: mypace_custom_navi_menu

function mypace_custom_navi_menu($classes, $item)
{
    global $wp_query;
    $singular_slug = 'service';
    $page_for_custom_type_title = 'サービス';
    $page_for_posts = get_option('page_for_posts');
    $post_type_query = $wp_query->query_vars['post_type'];
    $del_flag = true;
    $add_flag = false;
    if (is_singular('post') || is_category() || is_tag()) {
        $del_flag = false;
    } elseif (is_author() || is_date() || is_author()) {
        if (in_array($post_type_query, array('', 'post'))) {
            $del_flag = false;
        } elseif ($post_type_query == $custom_post_type) {
            $add_flag = true;
        }
    } elseif (is_tax()) {
        $taxonomy = get_taxonomy($wp_query->query_vars['taxonomy']);
        if (count($taxonomy->object_type) == 1 && $taxonomy->object_type[0] == 'post') {
            $del_flag = false;
        } elseif (count($taxonomy->object_type) == 1 && $taxonomy->object_type[0] == $singular_slug) {
            $add_flag = true;
        }
    } elseif (is_singular($singular_slug)) {
        $add_flag = true;
    }
    if ($del_flag && is_numeric($page_for_posts) && $item->object_id == $page_for_posts && $item->object == 'page' && ($key = array_search('current_page_parent', $classes))) {
        unset($classes[$key]);
    } elseif ($add_flag && $item->title == $page_for_custom_type_title && $item->object == 'page') {
        $classes[] = 'current_page_parent';
    }
    return $classes;
}
开发者ID:k111,项目名称:wp_theme_skeleton,代码行数:34,代码来源:functions.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_taxonomy函数代码示例发布时间:2022-05-15
下一篇:
PHP is_tag函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap