Example #1
2
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;
}
Example #2
0
/**
 * 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;
}
function amt_content_keywords()
{
    $post = get_queried_object();
    if (!is_null($post)) {
        echo amt_get_content_keywords($post);
    }
}
/**
 * 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();
    }
}
 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;
 }
 /**
  * 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;
     }
 }
Example #7
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 
        }
    }
/**
 * 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 &ldquo;%s&rdquo;', 'boilerplate'), get_search_query());
    } elseif (is_404()) {
        return __('Not Found', 'boilerplate');
    } else {
        return get_the_title();
    }
}
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;
}
Example #10
0
 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);
 }
/**
 * 
 *
 * @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('[' => '&#91;', ']' => '&#93;') as $replace => $with) {
                $value = str_replace($replace, $with, $value);
            }
            $args[$field] = sprintf('%s="%s"', $field, $value);
        }
    }
    return sprintf('[%s %s]', SHORTCODE_CALENDARIZE, implode(' ', $args));
}
 /**
  * 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'));
                 }
             }
         }
     }
 }
Example #13
0
 /**
  * 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);
 }
Example #14
0
 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;
 }
Example #15
0
/**
 * 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();
    }
}
Example #16
0
 /**
  * You can use this to output a proper title for your page. This handles special cases such as archive page titles,
  * taxonomy archives, etc.
  *
  * @return string A nice page title
  */
 public static function mainPageTitle()
 {
     if (is_home()) {
         if (get_option('page_for_posts', true)) {
             return get_the_title(get_option('page_for_posts', true));
         } else {
             return __('Latest Posts', 'baobab');
         }
     } 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', 'baobab'), get_the_date());
         } elseif (is_month()) {
             return sprintf(__('Monthly Archives: %s', 'baobab'), get_the_date('F Y'));
         } elseif (is_year()) {
             return sprintf(__('Yearly Archives: %s', 'baobab'), get_the_date('Y'));
         } elseif (is_author()) {
             $author = get_queried_object();
             return sprintf(__('Author Archives: %s', 'baobab'), 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', 'baobab'), get_search_query());
     } elseif (is_404()) {
         return __('Not Found', 'baobab');
     } else {
         return get_the_title();
     }
 }
 public function fully_background_setup()
 {
     if (!is_singular()) {
         return;
     }
     $post = get_queried_object();
     $post_id = get_queried_object_id();
     if (!post_type_supports($post->post_type, 'fully-background-manager')) {
         return;
     }
     $this->color = get_post_meta($post_id, '_fully_background_color', true);
     $is_layout = get_post_meta($post_id, '_fully_is_layout', true);
     $attachment_id = get_post_meta($post_id, '_fully_background_image_id', true);
     $pattern_image = get_post_meta($post_id, '_fully_background_pattern', true);
     if ($is_layout == "Yes" && $pattern_image != "") {
         $image = $this->plugin_path . "assets/images/big/" . $pattern_image . ".jpg";
         $this->image = !empty($image) ? esc_url($image) : '';
     }
     if ($is_layout == "No") {
         $image = wp_get_attachment_image_src($attachment_id, 'full');
         $this->image = !empty($image) && isset($image[0]) ? esc_url($image[0]) : '';
     }
     add_filter('theme_mod_background_color', array($this, 'fbm_background_color'), 25);
     add_filter('theme_mod_background_image', array($this, 'fbm_background_image'), 25);
     if (!empty($this->image)) {
         $this->attachment = get_post_meta($post_id, '_fully_background_attachment', true);
         $this->repeat = get_post_meta($post_id, '_fully_background_repeat', true);
         add_filter('theme_mod_background_attachment', array($this, 'fbm_background_attachment'), 25);
         add_filter('theme_mod_background_repeat', array($this, 'fbm_background_repeat'), 25);
     }
 }
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $show_hierarchy = $instance['show_hierarchy'];
     $show_counts = $instance['show_counts'];
     $hide_empty = $instance['hide_empty'];
     $show_child_only = $instance['show_child_only'];
     if (is_tax() && $show_child_only) {
         $term = get_queried_object();
         $term_id = $term->term_id;
         $taxonomy = $term->taxonomy;
         if ($taxonomy == "product_categories") {
             $show_child_only = $term_id;
         } else {
             $show_child_only = "";
         }
     } else {
         $show_child_only = "";
     }
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     echo '<ul class="menu">';
     $args = array('show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'style' => 'list', 'show_count' => $show_counts, 'hide_empty' => $hide_empty, 'use_desc_for_title' => 1, 'child_of' => $show_child_only, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'include' => '', 'hierarchical' => $show_hierarchy, 'title_li' => "", 'number' => null, 'echo' => 1, 'depth' => 10, 'current_category' => 0, 'pad_counts' => 0, 'taxonomy' => 'portfolio_categories', 'walker' => null);
     wp_list_categories($args);
     echo '</ul>';
     echo $after_widget;
 }
Example #19
0
 function helium_portfolio_body_class($classes)
 {
     if (function_exists('youxi_portfolio_cpt_name') && is_singular(youxi_portfolio_cpt_name())) {
         $post = get_queried_object();
         if (is_a($post, 'WP_Post')) {
             /* Layout metadata */
             $layout = wp_parse_args($post->layout, array('media_position' => 'top', 'details_position' => 'left'));
             /* Validate layout positions */
             if (!preg_match('/^top|(lef|righ)t$/', $layout['media_position'])) {
                 $layout['media_position'] = 'top';
             }
             if (!preg_match('/^hidden|(lef|righ)t$/', $layout['details_position'])) {
                 $layout['details_position'] = 'left';
             }
             /* Media metadata */
             $media = wp_parse_args($post->media, array('type' => 'featured-image'));
             /* Validate media type */
             if (!preg_match('/^(featur|stack|justifi)ed(-(image|grids))?|slider|(vide|audi)o$/', $media['type'])) {
                 $media['type'] = 'featured-image';
             }
             $classes = array_merge($classes, array("single-{$post->post_type}-media-" . $layout['media_position'], "single-{$post->post_type}-media-" . $media['type'], "single-{$post->post_type}-details-" . $layout['details_position']));
         }
     }
     return $classes;
 }
Example #20
0
/**
 * Page titles
 */
function ya_title()
{
    if (is_home()) {
        if (get_option('page_for_posts', true)) {
            echo get_the_title(get_option('page_for_posts', true));
        } else {
            esc_html_e('Latest Posts', 'yatheme');
        }
    } elseif (is_archive()) {
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        if ($term) {
            echo $term->name;
        } elseif (is_post_type_archive()) {
            echo get_queried_object()->labels->name;
        } elseif (is_day()) {
            printf(__('Daily Archives: %s', 'yatheme'), get_the_date());
        } elseif (is_month()) {
            printf(__('Monthly Archives: %s', 'yatheme'), get_the_date('F Y'));
        } elseif (is_year()) {
            printf(__('Yearly Archives: %s', 'yatheme'), get_the_date('Y'));
        } elseif (is_author()) {
            printf(__('Author Archives: %s', 'yatheme'), get_the_author());
        } else {
            single_cat_title();
        }
    } elseif (is_search()) {
        printf(__('Search Results for <small>%s</small>', 'yatheme'), get_search_query());
    } elseif (is_404()) {
        esc_html_e('Not Found', 'yatheme');
    } else {
        the_title();
    }
}
function _act_get_body_data()
{
    global $post;
    $body_data = array();
    //  echo 'pid';
    //
    $post_type = get_post_type(get_the_ID());
    if (is_archive()) {
        $post_type = "archive";
    }
    if (is_front_page()) {
        $post_type = 'home';
    }
    $body_data['post-type'] = $post_type;
    $post_slug = $post->post_name;
    if (is_archive() and isset(get_queried_object()->taxonomy)) {
        $tax = get_taxonomy(get_queried_object()->taxonomy);
        $post_slug = sanitize_title($tax->labels->singular_name);
    } elseif (is_archive() and !isset(get_queried_object()->taxonomy)) {
        $post_slug = get_queried_object()->name;
    }
    if (is_home()) {
        $post_slug = 'blog';
    }
    if (is_home() && is_paged()) {
        $post_slug = 'blog_paged';
    }
    $body_data['post-slug'] = $post_slug;
    return $body_data;
}
Example #22
0
function check_guide_page($type)
{
    if (is_tag()) {
        $tag = get_queried_object();
        $args = array('post_type' => 'guides', 'posts_per_page' => 1, 'name' => $tag->slug);
        $query = new WP_Query($args);
        $has_guide = $query->have_posts();
        if ($has_guide) {
            while ($query->have_posts()) {
                $query->the_post();
                if ($type === 'title') {
                    $title = get_field('guide_meta_title');
                    if ($title) {
                        return $title;
                    }
                }
                if ($type === 'description') {
                    $desc = get_field('guide_meta_description');
                    if ($desc) {
                        return $desc;
                    }
                }
                if ($type === 'image' && has_post_thumbnail()) {
                    $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                    return $image[0];
                }
            }
        } else {
            if ($type === 'title') {
                $new_title = ucwords($tag->name);
                return $new_title . ' Archives | What The Flicka??';
            }
        }
    }
}
Example #23
0
/**
 * Page titles
 */
function stachestack_title()
{
    if (is_home()) {
        if (get_option('page_for_posts', true)) {
            $title = get_the_title(get_option('page_for_posts', true));
        } else {
            $title = __('Latest Posts', 'stachestack');
        }
    } elseif (is_archive()) {
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        if ($term) {
            $title = apply_filters('single_term_title', $term->name);
        } elseif (is_post_type_archive()) {
            $title = apply_filters('the_title', get_queried_object()->labels->name);
        } elseif (is_day()) {
            $title = sprintf(__('Daily Archives: %s', 'stachestack'), get_the_date());
        } elseif (is_month()) {
            $title = sprintf(__('Monthly Archives: %s', 'stachestack'), get_the_date('F Y'));
        } elseif (is_year()) {
            $title = sprintf(__('Yearly Archives: %s', 'stachestack'), get_the_date('Y'));
        } elseif (is_author()) {
            $title = sprintf(__('Author Archives: %s', 'stachestack'), get_queried_object()->display_name);
        } else {
            $title = single_cat_title('', false);
        }
    } elseif (is_search()) {
        $title = sprintf(__('Search Results for %s', 'stachestack'), get_search_query());
    } elseif (is_404()) {
        $title = __('Not Found', 'stachestack');
    } else {
        $title = get_the_title();
    }
    return apply_filters('stachestack_title', $title);
}
Example #24
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;
}
Example #25
0
 function include_woocommerce_template($tmpl)
 {
     global $gantry;
     $find = array('woocommerce.php');
     $file = '';
     if (is_single() && get_post_type() == 'product') {
         $file = 'single-product.php';
         $find[] = $file;
     } elseif (is_tax('product_cat') || is_tax('product_tag')) {
         $term = get_queried_object();
         $file = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = $file;
     } elseif (is_post_type_archive('product') || is_page(woocommerce_get_page_id('shop'))) {
         $file = 'archive-product.php';
         $find[] = $file;
     }
     $find = array_reverse($find);
     $template = GantryBodyLayout::locate_type($find);
     if ($template && $template != '') {
         return $template;
     } else {
         woocommerce_content();
         return '';
     }
     return $tmpl;
 }
Example #26
0
/**
 * Page titles
 */
function roots_title()
{
    if (is_home()) {
        if (get_option('page_for_posts', true)) {
            return get_the_title(get_option('page_for_posts', true));
        } else {
            return __('Most Recent Posts', 'roots');
        }
    } 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(__('Old Posts, Organized by Day: %s', 'roots'), get_the_date());
        } elseif (is_month()) {
            return sprintf(__('Old Posts, Organized by Month: %s', 'roots'), get_the_date('F Y'));
        } elseif (is_year()) {
            return sprintf(__('Old Posts, Organized by Year: %s', 'roots'), get_the_date('Y'));
        } elseif (is_author()) {
            $author = get_queried_object();
            return sprintf(__('Old Posts, Organized by Author: %s', 'roots'), 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', 'roots'), get_search_query());
    } elseif (is_404()) {
        return __('Not Found', 'roots');
    } else {
        return get_the_title();
    }
}
Example #27
0
 function __construct($p = array())
 {
     $p += array('delimiter' => '');
     $this->delimiter = $p['delimiter'];
     // sets our current page so we know when to exit
     $this->i_current_page_id = get_queried_object()->ID;
 }
Example #28
0
/**
 * Get the current term meta value.
 *
 * @since 1.0.0
 *
 * @param string $field_id The term meta id searched.
 * @param mixed  $default  The default value to return if the term meta value doesn't exist.
 * @param int    $term_id  Overwrite the current term id.
 *
 * @return mixed Save data if the term meta value exists, otherwise set the default value.
 */
function beans_get_term_meta($field_id, $default = false, $term_id = false)
{
    if (!$term_id) {
        $term_id = ($_term_id = beans_get('term_id', get_queried_object())) ? $_term_id : beans_get('tag_ID');
    }
    return get_option("beans_term_{$term_id}_{$field_id}", $default);
}
 /**
  * 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;
 }
Example #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;
 }