コード例 #1
2
 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;
 }
コード例 #2
0
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 
}
コード例 #3
0
ファイル: page-title.php プロジェクト: booklein/wpbookle
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);
}
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
ファイル: utils.php プロジェクト: skylarkcob/hocwp-projects
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;
}
コード例 #6
0
ファイル: theme-js.php プロジェクト: plusplusminus/athol
 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');
 }
コード例 #7
0
ファイル: module.php プロジェクト: koopmant/Mens-site
 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;
 }
コード例 #8
0
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;
        }
    }
}
コード例 #9
0
ファイル: extras.php プロジェクト: swaroop42/RockRose
/**
 * 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;
}
コード例 #10
0
 /**
  * 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'];
 }
コード例 #11
0
ファイル: series.php プロジェクト: synapticism/ubik
function get_posts($query)
{
    if (is_tax('series') && $query->is_main_query()) {
        $query->set('order', option('order'));
    }
    return $query;
}
コード例 #12
0
 /**
  * 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)));
 }
コード例 #13
0
/**
* 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');
    }
}
コード例 #14
0
/**
 * 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}"));
}
コード例 #15
0
 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;
 }
コード例 #16
0
 /**
  * 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;
 }
コード例 #17
0
 /**
  * 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(
         //
         //     )
         // );
     }
 }
コード例 #18
0
ファイル: taxonomy.php プロジェクト: wells5609/wp-app
/**
 * 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;
}
コード例 #19
0
 /**
  * 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'];
 }
コード例 #20
0
ファイル: functions.php プロジェクト: k111/wp_theme_skeleton
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;
}
コード例 #21
0
ファイル: widget.php プロジェクト: pivotlearning/wpsite
 function widget($args, $instance)
 {
     global $wp_query;
     $facets = elasticsearch\Faceting::all();
     $url = null;
     if (is_category() || is_tax()) {
         $url = get_term_link($wp_query->queried_object);
     } elseif (is_tag()) {
         $url = get_tag_link($wp_query->queried_object->term_id);
     } elseif (is_archive()) {
         $url = get_post_type_archive_link($wp_query->queried_object->query_var);
     } elseif (is_search()) {
         $url = home_url('/');
     }
     foreach ($facets as $type => $facet) {
         if (count($facet['selected']) > 0) {
             $name = $type;
             if (taxonomy_exists($type)) {
                 $name = get_taxonomy($type)->label;
             }
             echo '<aside id="facet-' . $type . '-selected" class="widget facets facets-selected">';
             echo '<h3 class="widget-title">' . $name . '</h3>';
             echo '<ul>';
             foreach ($facet['selected'] as $option) {
                 $url = elasticsearch\Faceting::urlRemove($url, $type, $option['slug']);
                 echo '<li id="facet-' . $type . '-' . $option['slug'] . '" class="facet-item">';
                 echo '<a href="' . $url . '">' . $option['name'] . '</a>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</aside>';
         }
     }
 }
コード例 #22
0
ファイル: open-graph.php プロジェクト: kalushta/darom
 public function tags()
 {
     if (!did_action('pre_get_posts')) {
         return array();
     }
     $queried_object = get_queried_object();
     $tags = array();
     $default_tags = array('og:type' => 'website', 'og:locale' => get_locale(), 'og:site_name' => get_bloginfo('name'), 'og:image' => $this->get_image_url());
     if (is_front_page()) {
         $tags = array('og:url' => home_url('/'), 'og:title' => get_bloginfo('name'), 'og:description' => get_bloginfo('description'));
     } else {
         if (is_singular()) {
             $tags = array('og:type' => 'article', 'og:url' => get_permalink($queried_object), 'og:title' => get_the_title($queried_object), 'og:description' => $this->generate_preview($queried_object->post_content), 'article:published_time' => date('c', strtotime($queried_object->post_date_gmt)), 'article:modified_time' => date('c', strtotime($queried_object->post_modified_gmt)), 'article:author' => get_author_posts_url($queried_object->post_author));
         } else {
             if (is_tax() || is_category() || is_tag()) {
                 $tags = array('og:url' => get_term_link($queried_object), 'og:title' => $queried_object->name, 'og:description' => $this->generate_preview($queried_object->description));
             } else {
                 if (is_author()) {
                     $tags = array('og:type' => 'profile', 'og:url' => get_author_posts_url($queried_object->ID), 'og:title' => $queried_object->display_name, 'og:description' => $this->generate_preview($queried_object->user_description), 'profile:first_name' => get_the_author_meta('first_name', $queried_object->ID), 'profile:last_name' => get_the_author_meta('last_name', $queried_object->ID));
                 }
             }
         }
     }
     $tags = array_merge($default_tags, $tags);
     return apply_filters('appthemes_open_graph_meta_tags', $tags);
 }
コード例 #23
0
 /**
  * Pick the correct template to include
  * @param string $template Path to template
  *
  * @return string Path to template
  */
 public static function templateChooser($template)
 {
     $events = TribeEvents::instance();
     do_action('tribe_tec_template_chooser', $template);
     // hijack this method right up front if it's a 404
     if (is_404() && $events->displaying == 'single-event' && apply_filters('tribe_events_templates_is_404', '__return_true')) {
         return get_404_template();
     }
     // no non-events need apply
     if (!in_array(get_query_var('post_type'), array(TribeEvents::POSTTYPE, TribeEvents::VENUE_POST_TYPE, TribeEvents::ORGANIZER_POST_TYPE)) && !is_tax(TribeEvents::TAXONOMY)) {
         return $template;
     }
     if (tribe_get_option('tribeEventsTemplate', 'default') == '') {
         return self::getTemplateHierarchy('default-template');
     } else {
         // add_filter( 'wp_title', array(__CLASS__, 'remove_default_title'), 1);
         if (!is_single() || !post_password_required()) {
             add_action('loop_start', array(__CLASS__, 'setup_ecp_template'));
         }
         $template = locate_template(tribe_get_option('tribeEventsTemplate', 'default') == 'default' ? 'page.php' : tribe_get_option('tribeEventsTemplate', 'default'));
         if ($template == '') {
             $template = get_index_template();
         }
         // remove singular body class if sidebar-page.php
         if ($template == get_stylesheet_directory() . '/sidebar-page.php') {
             add_filter('body_class', array(__CLASS__, 'remove_singular_body_class'));
         } else {
             add_filter('body_class', array(__CLASS__, 'add_singular_body_class'));
         }
         return $template;
     }
 }
コード例 #24
0
ファイル: choose-lang-url.php プロジェクト: MaryMaffka/dpm
 public function check_language_code_in_url()
 {
     global $wp_query, $post;
     if (is_single() || is_page()) {
         if (isset($post->ID) && $this->model->is_translated_post_type($post->post_type)) {
             $language = $this->model->get_post_language((int) $post->ID);
         }
     } elseif (is_category() || is_tag() || is_tax()) {
         $obj = $wp_query->get_queried_object();
         if ($this->model->is_translated_taxonomy($obj->taxonomy)) {
             $language = $this->model->get_term_language((int) $obj->term_id);
         }
     } elseif ($wp_query->is_posts_page) {
         $obj = $wp_query->get_queried_object();
         $language = $this->model->get_post_language((int) $obj->ID);
     }
     // the language is not correctly set so let's redirect to the correct url for this object
     if (!empty($language)) {
         $requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         $redirect_url = $this->links_model->switch_language_in_link($requested_url, $language);
         if ($requested_url != $redirect_url) {
             wp_redirect($redirect_url, 301);
             exit;
         }
     }
 }
コード例 #25
0
 function add_builtin_template($template)
 {
     $theme_files = array();
     $template_path = '';
     if (is_post_type_archive('route')) {
         $theme_files = array('archive-route.php', 'djb-rrr/archive-route.php');
         $template_path = plugin_dir_path(__FILE__) . '../../public/archive-route.php';
     } elseif (is_tax('route-category')) {
         $theme_files = array('taxonomy-route.php', 'djb-rrr/taxonomy-route.php');
         $template_path = plugin_dir_path(__FILE__) . '../../public/taxonomy-route.php';
     } elseif (is_singular('route')) {
         $theme_files = array('single-route.php', 'djb-rrr/single-route.php');
         $template_path = plugin_dir_path(__FILE__) . '../../public/single-route.php';
     }
     if (count($theme_files) > 0) {
         //We use the presence of theme files to check as an indicator that we might want to inject a template. If we wanted to always inject, we'd need to do something different.
         $exists_in_theme = locate_template($theme_files, false);
         if ($exists_in_theme != '') {
             return $exists_in_theme;
         } else {
             return $template_path;
         }
     }
     return $template;
 }
コード例 #26
0
    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 
        }
    }
コード例 #27
0
/**
 * Display a list categories
 * @param array $args
 * @return bool
 */
function zfwca_list_categories($args = array())
{
    $defaults = array('show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'exclude' => '', 'include' => '', 'exclude_tree' => '', 'current_category' => 0, 'taxonomy' => 'category');
    $r = wp_parse_args($args, $defaults);
    $r['walker'] = new ZFWCA_Post_Category_Walker();
    if (!isset($r['class'])) {
        $r['class'] = 'category' == $r['taxonomy'] ? 'categories' : $r['taxonomy'];
    }
    extract($r);
    if (!taxonomy_exists($taxonomy)) {
        return false;
    }
    $categories = get_categories($r);
    $output = '';
    if (empty($categories)) {
        $output .= 'No categories';
    } else {
        if (empty($r['current_category']) && (is_category() || is_tax() || is_tag())) {
            $current_term_object = get_queried_object();
            if ($current_term_object && $r['taxonomy'] === $current_term_object->taxonomy) {
                $r['current_category'] = get_queried_object_id();
            }
        }
        $output .= walk_category_tree($categories, 0, $r);
    }
    $output = apply_filters('zfwca_wp_list_categories', $output, $args);
    return $output;
}
コード例 #28
0
 /**
  * Check for an taxonomy-{taxonomy} situation.
  *
  * @param string $postType The post type to check for
  * @param array $details Settings for the route
  */
 private static function tax($postType, array $details)
 {
     if (is_tax($postType . '_type')) {
         self::loadController($details);
         exit;
     }
 }
コード例 #29
0
 /**
  * Modify the query (using the 'pre_get_posts' filter)
  */
 public function set_post_filters($query)
 {
     if (!is_admin() && $query->is_main_query() && (is_tax('portfolio_category') || is_tax('portfolio_skills') || is_tax('portfolio_tags'))) {
         $query->set('posts_per_page', Avada()->settings->get('portfolio_items'));
     }
     return $query;
 }
コード例 #30
-1
 /**
  * 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 static 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_product_taxonomy()) {
         $term = get_queried_object();
         if (is_tax('product_cat') || is_tax('product_tag')) {
             $file = 'taxonomy-' . $term->taxonomy . '.php';
         } else {
             $file = 'archive-product.php';
         }
         $find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '.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(array_unique($find));
         if (!$template || WC_TEMPLATE_DEBUG_MODE) {
             $template = WC()->plugin_path() . '/templates/' . $file;
         }
     }
     return $template;
 }