/**
 * Overrides WP's default template for date-based archives. Better abstraction of templates than 
 * is_date() allows by checking for the year, month, week, day, hour, and minute.
 *
 * @since 0.6.0
 * @uses locate_template() Checks for template in child and parent theme.
 * @param string $template
 * @return string $template Full path to file.
 */
function hybrid_date_template($template)
{
    $templates = array();
    /* If viewing a time-based archive. */
    if (is_time()) {
        /* If viewing a minutely archive. */
        if (get_query_var('minute')) {
            $templates[] = 'minute.php';
        } elseif (get_query_var('hour')) {
            $templates[] = 'hour.php';
        }
        /* Catchall for any time-based archive. */
        $templates[] = 'time.php';
    } elseif (is_day()) {
        $templates[] = 'day.php';
    } elseif (get_query_var('w')) {
        $templates[] = 'week.php';
    } elseif (is_month()) {
        $templates[] = 'month.php';
    } elseif (is_year()) {
        $templates[] = 'year.php';
    }
    /* Catchall template for date-based archives. */
    $templates[] = 'date.php';
    /* Fall back to the basic archive template. */
    $templates[] = 'archive.php';
    /* Return the found template. */
    return locate_template($templates);
}
/**
 * Overrides WP's default template for date-based archives. Better abstraction of templates than
 * is_date() allows by checking for the year, month, week, day, hour, and minute.
 */
function spyropress_date_template($template)
{
    $templates = array();
    // If viewing a time-based archive
    if (is_time()) {
        // If viewing a minutely archive
        if (get_query_var('minute')) {
            $templates[] = 'minute.php';
        } elseif (get_query_var('hour')) {
            $templates[] = 'hour.php';
        }
        // Catchall for any time-based archive
        $templates[] = 'time.php';
    } elseif (is_day()) {
        $templates[] = 'day.php';
    } elseif (get_query_var('w')) {
        $templates[] = 'week.php';
    } elseif (is_month()) {
        $templates[] = 'month.php';
    } elseif (is_year()) {
        $templates[] = 'year.php';
    }
    // Catchall template for date-based archives
    $templates[] = 'date.php';
    // Fall back to the basic archive template
    $templates[] = 'archive.php';
    // Return the found template
    return locate_template($templates);
}
 public function parseQuery()
 {
     $query = $this->_getQueryToParse();
     if ($query->is_home()) {
         $this->_identifyHome();
     } else {
         if ($query->is_singular()) {
             $this->_identifySingular();
         } else {
             if ($query->is_category() || $query->is_tag() || $query->is_tax()) {
                 $this->_identifyTaxonomy();
             } else {
                 if ($query->is_search()) {
                     $this->_identifySearch();
                 } else {
                     if ($query->is_date() || is_time()) {
                         $this->_identifyDate();
                     } else {
                         if ($query->is_author()) {
                             $this->_identifyAuthor();
                         } else {
                             if ($query->is_404()) {
                                 $this->_identify404();
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #4
0
 public function get_date_data()
 {
     $data = $_POST;
     $resp = new ajax_response($data['action'], true);
     if ($data['variable_data'] != null) {
         $resp->set_status(true);
         $resp->set_data(array('loadable_content' => 'etrghvaoucyq3boigwsodrifuv suiboqiu5oqiuebroqviebrivueybrgirbf'));
         if (is_time($data['variable_data'])) {
         } else {
         }
     } else {
         $resp->set_message('Could not load data. Try Again.');
     }
     echo $resp->encode_response();
     die;
 }
Пример #5
0
function st_get_tpl_file_name()
{
    $default = 'list-post';
    $file = 'list-post';
    if (is_singular()) {
        global $post;
        if ($post->post_type != 'page' && $post->post_type != 'post') {
            $file = $post->post_type;
            if (!file_exists(ST_TEMPLATE_DIR . $file . '.php')) {
                $file = 'single';
            }
        } else {
            if (is_page()) {
                $file = 'page';
            } else {
                $file = 'single';
            }
        }
    } elseif (is_author()) {
        $file = 'author';
    } elseif (is_tag()) {
        $file = 'tag';
    } elseif (is_tax()) {
        $tax = get_queried_object();
        $file = 'taxonomy-' . $tax->taxonomy;
        if (file_exists(ST_TEMPLATE_DIR . $file . '.php')) {
            return $file;
        } else {
            return 'taxonomy';
        }
    } elseif ((is_archive() || is_day() || is_date() || is_month() || is_year() || is_time()) && !is_category()) {
        $file = 'archive';
    } elseif (is_search()) {
        $file = 'search';
    } elseif (is_404()) {
        $file = '404';
    }
    if (file_exists(ST_TEMPLATE_DIR . $file . '.php')) {
        return $file;
    } else {
        return $default;
    }
}
Пример #6
0
/**
* hybrid_page_class()
* Dynamic page class
*
* @since 0.1
* @deprecated 0.2
*/
function hybrid_page_class()
{
    if (is_front_page() || is_home()) {
        $class = 'home front-page';
    } elseif (is_attachment()) {
        $class = 'attachment';
    } elseif (is_single()) {
        $class = 'single';
    } elseif (is_page()) {
        $class = 'page';
    } elseif (is_category()) {
        $class = 'category';
    } elseif (is_tag()) {
        $class = 'tag';
    } elseif (is_search()) {
        $class = 'search';
    } elseif (is_404()) {
        $class = 'error-404';
    } elseif (is_year()) {
        $class = 'year';
    } elseif (is_month()) {
        $class = 'month';
    } elseif (is_day()) {
        $class = 'day';
    } elseif (is_time()) {
        $class = 'time';
    } elseif (is_author()) {
        $class = 'author';
    }
    if (is_date()) {
        $class .= ' date';
    }
    if (is_archive()) {
        $class .= ' archive';
    }
    if (is_paged()) {
        $class .= ' paged';
    }
    echo $class;
}
Пример #7
0
 /**
  * @return  string|false|null
  */
 public static function timeframe()
 {
     global $wp_query;
     static $unit;
     if (isset($unit) || empty($wp_query)) {
         # cached result *or* `null` before $wp_query is avail
         # codex.wordpress.org/Conditional_Tags
         return $unit;
     }
     if (!is_date()) {
         return $unit = false;
     }
     if (!is_time()) {
         $unit = is_day() ? 'day' : (get_query_var('w') ? 'week' : (is_month() ? 'month' : (is_year() ? 'year' : null)));
     } else {
         for ($units = array('second', 'minute', 'hour'); $unit = array_shift($units);) {
             if (($v = get_query_var($unit)) || is_numeric($v)) {
                 break;
             }
         }
     }
     return $unit = $unit ?: true;
 }
Пример #8
0
 function advertica_lite_simple_breadcrumb_case($der_post)
 {
     $markup = $this->opts['before'] . $this->opts['delimiter'] . $this->opts['after'];
     if (is_page()) {
         if ($der_post->post_parent) {
             $my_query = get_post($der_post->post_parent);
             $this->advertica_lite_simple_breadcrumb_case($my_query);
             $link = '<a href="';
             $link .= esc_url(get_permalink($my_query->ID));
             $link .= '">';
             $link .= '' . esc_attr(get_the_title($my_query->ID)) . '</a>' . $markup;
             echo $link;
         }
         return;
     }
     if (is_single() && !is_attachment()) {
         $category = get_the_category();
         if (is_attachment()) {
             $my_query = get_post($der_post->post_parent);
             $category = get_the_category($my_query->ID);
             $ID = $category[0]->cat_ID;
             echo get_category_parents($ID, true, $markup, false);
             previous_post_link("%link {$markup}");
         } else {
             if (isset($category[0]->cat_ID)) {
                 $ID = $category[0]->cat_ID;
                 echo get_category_parents($ID, true, $markup, false);
             }
         }
         return;
     }
     if (is_category()) {
         $category = get_the_category();
         $i = $category[0]->cat_ID;
         $parent = $category[0]->category_parent;
         if ($parent > 0 && $category[0]->cat_name == single_cat_title('', false)) {
             echo get_category_parents($parent, true, $markup, false);
         }
         return single_cat_title('', false);
     }
     if (is_author()) {
         #$curauth = get_userdatabylogin(get_query_var('author_name'));
         global $wp_query;
         $curauth = $wp_query->get_queried_object();
         return __('Author', 'advertica-lite') . ' : ' . $curauth->display_name;
     }
     if (is_tag()) {
         return __('Tag', 'advertica-lite') . ' : ' . single_tag_title('', false);
     }
     if (is_search()) {
         return __('Search', 'advertica-lite');
     }
     if (is_404()) {
         return __('Error 404', 'advertica-lite');
     }
     if (is_year()) {
         return get_the_time('Y');
     }
     if (is_month()) {
         $k_year = get_the_time('Y');
         echo "<a href='" . get_year_link($k_year) . "'>" . $k_year . "</a>" . $markup;
         return get_the_time('F');
     }
     if (is_day() || is_time()) {
         $k_year = get_the_time('Y');
         $k_month = get_the_time('m');
         $k_month_display = get_the_time('F');
         echo "<a href='" . get_year_link($k_year) . "'>" . $k_year . "</a>" . $markup;
         echo "<a href='" . get_month_link($k_year, $k_month) . "'>" . $k_month_display . "</a>" . $markup;
         return get_the_time('jS (l)');
     }
 }
Пример #9
0
/**
 * Gets the items for the breadcrumb trail.  This is the heart of the script.  It checks the current page 
 * being viewed and decided based on the information provided by WordPress what items should be
 * added to the breadcrumb trail.
 *
 * @since 0.4.0
 * @todo Build in caching based on the queried object ID.
 * @access public
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the trail.
 */
function tc_breadcrumb_trail_get_items($args = array())
{
    global $wp_rewrite;
    /* Set up an empty trail array and empty path. */
    $trail = array();
    $path = '';
    /* If $show_home is set and we're not on the front page of the site, link to the home page. */
    if (!is_front_page() && $args['show_home']) {
        if (is_multisite() && true === $args['network']) {
            $trail[] = '<a href="' . network_home_url() . '">' . $args['show_home'] . '</a>';
            $trail[] = '<a href="' . esc_url(home_url()) . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . get_bloginfo('name') . '</a>';
        } else {
            $trail[] = '<a href="' . esc_url(home_url()) . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . $args['show_home'] . '</a>';
        }
    }
    /* If bbPress is installed and we're on a bbPress page. */
    if (function_exists('is_bbpress') && is_bbpress()) {
        $trail = array_merge($trail, tc_breadcrumb_trail_get_bbpress_items());
    } elseif (is_front_page()) {
        if (!is_paged() && $args['show_home'] && $args['front_page']) {
            if (is_multisite() && true === $args['network']) {
                $trail[] = '<a href="' . network_home_url() . '">' . $args['show_home'] . '</a>';
                $trail[] = get_bloginfo('name');
            } else {
                $trail[] = $args['show_home'];
            }
        } elseif (is_paged() && $args['show_home'] && $args['front_page']) {
            if (is_multisite() && true === $args['network']) {
                $trail[] = '<a href="' . network_home_url() . '">' . $args['show_home'] . '</a>';
                $trail[] = '<a href="' . esc_url(home_url()) . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . get_bloginfo('name') . '</a>';
            } else {
                $trail[] = '<a href="' . esc_url(home_url()) . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . $args['show_home'] . '</a>';
            }
        }
    } elseif (is_home()) {
        $home_page = get_page(get_queried_object_id());
        $trail = array_merge($trail, tc_breadcrumb_trail_get_parents($home_page->post_parent, ''));
        if (is_paged()) {
            $trail[] = '<a href="' . get_permalink($home_page->ID) . '" title="' . esc_attr(get_the_title($home_page->ID)) . '">' . get_the_title($home_page->ID) . '</a>';
        } else {
            $trail[] = get_the_title($home_page->ID);
        }
    } elseif (is_singular()) {
        /* Get singular post variables needed. */
        $post = get_queried_object();
        $post_id = absint(get_queried_object_id());
        $post_type = $post->post_type;
        $parent = absint($post->post_parent);
        /* Get the post type object. */
        $post_type_object = get_post_type_object($post_type);
        /* If viewing a singular 'post'. */
        if ('post' == $post_type) {
            /* If $front has been set, add it to the $path. */
            $path .= trailingslashit($wp_rewrite->front);
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
            }
            /* Map the permalink structure tags to actual links. */
            $trail = array_merge($trail, tc_breadcrumb_trail_map_rewrite_tags($post_id, get_option('permalink_structure'), $args));
        } elseif ('attachment' == $post_type) {
            /* Get the parent post ID. */
            $parent_id = $post->post_parent;
            /* If the attachment has a parent (attached to a post). */
            if (0 < $parent_id) {
                /* Get the parent post type. */
                $parent_post_type = get_post_type($parent_id);
                /* If the post type is 'post'. */
                if ('post' == $parent_post_type) {
                    /* If $front has been set, add it to the $path. */
                    $path .= trailingslashit($wp_rewrite->front);
                    /* If there's a path, check for parents. */
                    if (!empty($path)) {
                        $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
                    }
                    /* Map the post (parent) permalink structure tags to actual links. */
                    $trail = array_merge($trail, tc_breadcrumb_trail_map_rewrite_tags($post->post_parent, get_option('permalink_structure'), $args));
                } elseif ('page' !== $parent_post_type) {
                    $parent_post_type_object = get_post_type_object($parent_post_type);
                    /* If $front has been set, add it to the $path. */
                    if ($parent_post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                        $path .= trailingslashit($wp_rewrite->front);
                    }
                    /* If there's a slug, add it to the $path. */
                    if (!empty($parent_post_type_object->rewrite['slug'])) {
                        $path .= $parent_post_type_object->rewrite['slug'];
                    }
                    /* If there's a path, check for parents. */
                    if (!empty($path)) {
                        $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
                    }
                    /* If there's an archive page, add it to the trail. */
                    if (!empty($parent_post_type_object->has_archive)) {
                        /* Add support for a non-standard label of 'archive_title' (special use case). */
                        $label = !empty($parent_post_type_object->labels->archive_title) ? $parent_post_type_object->labels->archive_title : $parent_post_type_object->labels->name;
                        $trail[] = '<a href="' . get_post_type_archive_link($parent_post_type) . '" title="' . esc_attr($label) . '">' . $label . '</a>';
                    }
                }
            }
        } elseif ('page' !== $post_type) {
            /* If $front has been set, add it to the $path. */
            if (isset($post_type_object) && $post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If there's a slug, add it to the $path. */
            if (!empty($post_type_object->rewrite['slug'])) {
                $path .= $post_type_object->rewrite['slug'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
            }
            /* If there's an archive page, add it to the trail. */
            if (!empty($post_type_object->has_archive)) {
                /* Add support for a non-standard label of 'archive_title' (special use case). */
                $label = !empty($post_type_object->labels->archive_title) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
                $trail[] = '<a href="' . get_post_type_archive_link($post_type) . '" title="' . esc_attr($label) . '">' . $label . '</a>';
            }
        }
        /* If the post type path returns nothing and there is a parent, get its parents. */
        if (empty($path) && 0 !== $parent || 'attachment' == $post_type) {
            $trail = array_merge($trail, tc_breadcrumb_trail_get_parents($parent, ''));
        } elseif (0 !== $parent && is_post_type_hierarchical($post_type)) {
            $trail = array_merge($trail, tc_breadcrumb_trail_get_parents($parent, ''));
        }
        /* Display terms for specific post type taxonomy if requested. */
        if (!empty($args["singular_{$post_type}_taxonomy"]) && ($terms = get_the_term_list($post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', ''))) {
            $trail[] = $terms;
        }
        /* End with the post title. */
        $post_title = single_post_title('', false);
        if (1 < get_query_var('page') && !empty($post_title)) {
            $trail[] = '<a href="' . get_permalink($post_id) . '" title="' . esc_attr($post_title) . '">' . $post_title . '</a>';
        } elseif (!empty($post_title)) {
            $trail[] = $post_title;
        }
    } elseif (is_archive()) {
        /* If viewing a taxonomy term archive. */
        if (is_tax() || is_category() || is_tag()) {
            /* Get some taxonomy and term variables. */
            $term = get_queried_object();
            $taxonomy = get_taxonomy($term->taxonomy);
            /* Get the path to the term archive. Use this to determine if a page is present with it. */
            if (is_category()) {
                $path = get_option('category_base');
            } elseif (is_tag()) {
                $path = get_option('tag_base');
            } else {
                if ($taxonomy->rewrite['with_front'] && $wp_rewrite->front) {
                    $path = trailingslashit($wp_rewrite->front);
                }
                $path .= $taxonomy->rewrite['slug'];
            }
            /* Get parent pages by path if they exist. */
            if ($path) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
            }
            /* Add post type archive if its 'has_archive' matches the taxonomy rewrite 'slug'. */
            if ($taxonomy->rewrite['slug']) {
                /* Get public post types that match the rewrite slug. */
                $post_types = get_post_types(array('public' => true, 'has_archive' => $taxonomy->rewrite['slug']), 'objects');
                /**
                 * If any post types are found, loop through them to find one that matches.
                 * The reason for this is because WP doesn't match the 'has_archive' string 
                 * exactly when calling get_post_types(). I'm assuming it just matches 'true'.
                 */
                if (!empty($post_types)) {
                    foreach ($post_types as $post_type_object) {
                        if ($taxonomy->rewrite['slug'] === $post_type_object->has_archive) {
                            /* Add support for a non-standard label of 'archive_title' (special use case). */
                            $label = !empty($post_type_object->labels->archive_title) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
                            /* Add the post type archive link to the trail. */
                            $trail[] = '<a href="' . get_post_type_archive_link($post_type_object->name) . '" title="' . esc_attr($label) . '">' . $label . '</a>';
                            /* Break out of the loop. */
                            break;
                        }
                    }
                }
            }
            /* If the taxonomy is hierarchical, list its parent terms. */
            if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_term_parents($term->parent, $term->taxonomy));
            }
            /* Add the term name to the trail end. */
            if (is_paged()) {
                $trail[] = '<a href="' . esc_url(get_term_link($term, $term->taxonomy)) . '" title="' . esc_attr(single_term_title('', false)) . '">' . single_term_title('', false) . '</a>';
            } else {
                $trail[] = single_term_title('', false);
            }
        } elseif (is_post_type_archive()) {
            /* Get the post type object. */
            $post_type_object = get_post_type_object(get_query_var('post_type'));
            /* If $front has been set, add it to the $path. */
            if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If there's a slug, add it to the $path. */
            if (!empty($post_type_object->rewrite['slug'])) {
                $path .= $post_type_object->rewrite['slug'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
            }
            /* Add the post type [plural] name to the trail end. */
            if (is_paged()) {
                $trail[] = '<a href="' . esc_url(get_post_type_archive_link($post_type_object->name)) . '" title="' . esc_attr(post_type_archive_title('', false)) . '">' . post_type_archive_title('', false) . '</a>';
            } else {
                $trail[] = post_type_archive_title('', false);
            }
        } elseif (is_author()) {
            /* Get the user ID. */
            $user_id = get_query_var('author');
            /* If $front has been set, add it to $path. */
            if (!empty($wp_rewrite->front)) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If an $author_base exists, add it to $path. */
            if (!empty($wp_rewrite->author_base)) {
                $path .= $wp_rewrite->author_base;
            }
            /* If $path exists, check for parent pages. */
            if (!empty($path)) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
            }
            /* Add the author's display name to the trail end. */
            if (is_paged()) {
                $trail[] = '<a href="' . esc_url(get_author_posts_url($user_id)) . '" title="' . esc_attr(get_the_author_meta('display_name', $user_id)) . '">' . get_the_author_meta('display_name', $user_id) . '</a>';
            } else {
                $trail[] = get_the_author_meta('display_name', $user_id);
            }
        } elseif (is_time()) {
            if (get_query_var('minute') && get_query_var('hour')) {
                $trail[] = get_the_time(__('g:i a', 'breadcrumb-trail'));
            } elseif (get_query_var('minute')) {
                $trail[] = sprintf(__('Minute %1$s', 'breadcrumb-trail'), get_the_time(__('i', 'breadcrumb-trail')));
            } elseif (get_query_var('hour')) {
                $trail[] = get_the_time(__('g a', 'breadcrumb-trail'));
            }
        } elseif (is_date()) {
            /* If $front has been set, check for parent pages. */
            if ($wp_rewrite->front) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $wp_rewrite->front));
            }
            if (is_day()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
                $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'breadcrumb-trail')) . '">' . get_the_time(__('F', 'breadcrumb-trail')) . '</a>';
                if (is_paged()) {
                    $trail[] = '<a href="' . get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" title="' . get_the_time(esc_attr__('d', 'breadcrumb-trail')) . '">' . get_the_time(__('d', 'breadcrumb-trail')) . '</a>';
                } else {
                    $trail[] = get_the_time(__('d', 'breadcrumb-trail'));
                }
            } elseif (get_query_var('w')) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
                if (is_paged()) {
                    $trail[] = get_archives_link(add_query_arg(array('m' => get_the_time('Y'), 'w' => get_the_time('W')), esc_url(home_url())), sprintf(__('Week %1$s', 'breadcrumb-trail'), get_the_time(esc_attr__('W', 'breadcrumb-trail'))), false);
                } else {
                    $trail[] = sprintf(__('Week %1$s', 'breadcrumb-trail'), get_the_time(esc_attr__('W', 'breadcrumb-trail')));
                }
            } elseif (is_month()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
                if (is_paged()) {
                    $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'breadcrumb-trail')) . '">' . get_the_time(__('F', 'breadcrumb-trail')) . '</a>';
                } else {
                    $trail[] = get_the_time(__('F', 'breadcrumb-trail'));
                }
            } elseif (is_year()) {
                if (is_paged()) {
                    $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . esc_attr(get_the_time(__('Y', 'breadcrumb-trail'))) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
                } else {
                    $trail[] = get_the_time(__('Y', 'breadcrumb-trail'));
                }
            }
        }
    } elseif (is_search()) {
        if (is_paged()) {
            $trail[] = '<a href="' . get_search_link() . '" title="' . sprintf(esc_attr__('Search results for &quot;%1$s&quot;', 'breadcrumb-trail'), esc_attr(get_search_query())) . '">' . sprintf(__('Search results for &quot;%1$s&quot;', 'breadcrumb-trail'), esc_attr(get_search_query())) . '</a>';
        } else {
            $trail[] = sprintf(__('Search results for &quot;%1$s&quot;', 'breadcrumb-trail'), esc_attr(get_search_query()));
        }
    } elseif (is_404()) {
        $trail[] = __('404 Not Found', 'breadcrumb-trail');
    }
    /* Check for pagination. */
    if (is_paged()) {
        $trail[] = sprintf(__('Page %d', 'breadcrumb-trail'), absint(get_query_var('paged')));
    } elseif (is_singular() && 1 < get_query_var('page')) {
        $trail[] = sprintf(__('Page %d', 'breadcrumb-trail'), absint(get_query_var('page')));
    }
    /* Allow devs to step in and filter the $trail array. */
    return apply_filters('breadcrumb_trail_items', $trail, $args);
}
Пример #10
0
?>
				<?php 
if (empty($_GET['page_id_all'])) {
    $_GET['page_id_all'] = 1;
}
if (!isset($_GET["s"])) {
    $_GET["s"] = '';
}
$taxonomy = 'category';
$taxonomy_tag = 'post_tag';
$args_cat = array();
if (is_author()) {
    $args_cat = array('author' => $wp_query->query_vars['author']);
    $post_type = array('post', 'events', 'cs_cause');
} elseif (is_date()) {
    if (is_month() || is_year() || is_day() || is_time()) {
        $args_cat = array('m' => $wp_query->query_vars['m'], 'year' => $wp_query->query_vars['year'], 'day' => $wp_query->query_vars['day'], 'hour' => $wp_query->query_vars['hour'], 'minute' => $wp_query->query_vars['minute'], 'second' => $wp_query->query_vars['second']);
    }
    $post_type = array('post');
} elseif (isset($wp_query->query_vars['taxonomy']) && !empty($wp_query->query_vars['taxonomy'])) {
    $taxonomy = $wp_query->query_vars['taxonomy'];
    $taxonomy_category = '';
    $taxonomy_category = $wp_query->query_vars[$taxonomy];
    if ($wp_query->query_vars['taxonomy'] == 'cs_cause-category' || $wp_query->query_vars['taxonomy'] == 'cs_cause-tag') {
        $args_cat = array($taxonomy => "{$taxonomy_category}");
        $post_type = 'cs_cause';
    } else {
        if ($wp_query->query_vars['taxonomy'] == 'event-category' || $wp_query->query_vars['taxonomy'] == 'event-tag') {
            $args_cat = array($taxonomy => "{$taxonomy_category}");
            $post_type = 'events';
        } else {
Пример #11
0
    function wpex_breadcrumbs($post_id = '')
    {
        // Globals
        global $wp_query, $wp_rewrite;
        // Get post id
        $post_id = $post_id ? $post_id : wpex_get_the_id();
        // Define main variables
        $breadcrumb = '';
        $trail = array();
        $path = '';
        $item_type_scope = 'itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"';
        // Default arguments
        $args = array('separator' => wpex_element('angle_right'), 'front_page' => false, 'echo' => false, 'show_posts_page' => true);
        // Extract args for easy variable naming.
        extract($args);
        /*-----------------------------------------------------------------------------------*/
        /*	- If not on the front page of the site, link to the home page
        		/*-----------------------------------------------------------------------------------*/
        if (!is_front_page()) {
            $home_title = get_theme_mod('breadcrumbs_home_title') ? get_theme_mod('breadcrumbs_home_title') : __('Home', 'wpex');
            $trail[] = '<span ' . $item_type_scope . '>
							<a href="' . home_url() . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">
								<span itemprop="title">' . $home_title . '</span>
							</a>
						</span>';
        }
        /*-----------------------------------------------------------------------------------*/
        /*	- Front Page
        		/*-----------------------------------------------------------------------------------*/
        if (is_front_page()) {
            if (!$front_page) {
                $trail = false;
            } elseif ($show_home) {
                $trail['trail_end'] = "{$show_home}";
            }
        } elseif (is_home()) {
            $home_page = get_page($wp_query->get_queried_object_id());
            $trail = array_merge($trail, wpex_breadcrumbs_get_parents($home_page->post_parent, ''));
            $trail['trail_end'] = get_the_title($home_page->ID);
        } elseif (is_singular()) {
            // Get singular vars
            $post = $wp_query->get_queried_object();
            $post_id = absint($wp_query->get_queried_object_id());
            $post_type = $post->post_type;
            $parent = $post->post_parent;
            // If a custom post type, check if there are any pages in its hierarchy based on the slug.
            if (!in_array($post_type, array('page', 'post', 'product', 'portfolio', 'staff', 'testimonials'))) {
                $post_type_object = get_post_type_object($post_type);
                // Add $front to the path
                if ('post' == $post_type || 'attachment' == $post_type || $post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                    $path .= trailingslashit($wp_rewrite->front);
                }
                // Add slug to $path
                if (!empty($post_type_object->rewrite['slug'])) {
                    $path .= $post_type_object->rewrite['slug'];
                }
                // If $path exists check for parents
                if (!empty($path)) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
                }
                // If archive page exists add to trail
                if (!empty($post_type_object->has_archive) && function_exists('get_post_type_archive_link')) {
                    if (!is_singular('product')) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
										<a href="' . get_post_type_archive_link($post_type) . '" title="' . esc_attr($post_type_object->labels->name) . '">
											<span itemprop="title">' . $post_type_object->labels->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            // Add shop page to cart
            if (is_singular('page') && class_exists('Woocommerce')) {
                if (is_cart() || is_checkout()) {
                    // Get shop page
                    if (class_exists('Woocommerce') && function_exists('wc_get_page_id')) {
                        $shop_id = wc_get_page_id('shop');
                        $shop_page_url = get_permalink($shop_id);
                        $shop_title = get_the_title($shop_id);
                        if (function_exists('icl_object_id')) {
                            $shop_title = get_the_title(icl_object_id($shop_id, 'page'));
                        }
                        $shop_title = apply_filters('wpex_bcrums_shop_title', $shop_title);
                    }
                    // Shop page
                    if ($shop_id && $shop_title) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
								<a href="' . get_permalink($shop_id) . '" title="' . esc_attr($shop_title) . '">
									<span itemprop="title">' . $shop_title . '</span>
								</a>
							</span>';
                    }
                }
            }
            // Standard Posts
            if ('post' == $post_type) {
                // Main Blog URL
                if ($blog_page = get_theme_mod('blog_page')) {
                    $blog_url = get_permalink($blog_page);
                    $blog_name = get_the_title($blog_page);
                    if (function_exists('icl_object_id')) {
                        $blog_name = get_the_title(icl_object_id($blog_page, 'page'));
                    }
                    $trail[] = '<span ' . $item_type_scope . ' class="trail-blog-url">
									<a href="' . $blog_url . '" title="' . $blog_name . '" itemprop="url">
										<span itemprop="title">' . $blog_name . '</span>
									</a>
								</span>';
                }
                // 1st Category
                if (get_theme_mod('breadcrumbs_blog_cat', '1')) {
                    $terms = get_the_terms($post_id, 'category');
                    if ($terms) {
                        $term = reset($terms);
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-blog-cat">
										<a href="' . get_term_link($term) . '" itemprop="url" title="' . $term->name . '">
											<span itemprop="title">' . $term->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            // Tribe Events
            if ('tribe_events' == $post_type && function_exists('tribe_get_events_link')) {
                $trail[] = '<span ' . $item_type_scope . ' class="trail-portfolio-url">
								<a href="' . tribe_get_events_link() . '" title="' . __('All Events', 'wpex') . '">
									<span itemprop="title">' . __('All Events', 'wpex') . '</span>
								</a>
							</span>';
            }
            //  Main Portfolio
            if ($post_type == 'portfolio') {
                if ($portfolio_page = get_theme_mod('portfolio_page')) {
                    $portfolio_url = get_permalink($portfolio_page);
                    $portfolio_name = get_the_title($portfolio_page);
                    if (function_exists('icl_object_id')) {
                        $portfolio_name = get_the_title(icl_object_id($portfolio_page, 'page'));
                    }
                    if ($portfolio_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-portfolio-url">
									<a href="' . $portfolio_url . '" title="' . $portfolio_name . '">
										<span itemprop="title">' . $portfolio_name . '</span>
									</a>
								</span>';
                    }
                }
                // Portfolio 1st Category
                if (get_theme_mod('breadcrumbs_portfolio_cat', '1') && taxonomy_exists('portfolio_category')) {
                    $terms = get_the_terms($post_id, 'portfolio_category');
                    if ($terms) {
                        $term = reset($terms);
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-portfolio-cat">
										<a href="' . get_term_link($term) . '" itemprop="url" title="' . $term->name . '">
											<span itemprop="title">' . $term->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            //  Main Staff
            if ($post_type == 'staff') {
                // Display staff page
                if ($staff_page = get_theme_mod('staff_page')) {
                    $staff_url = get_permalink($staff_page);
                    $staff_name = get_the_title($staff_page);
                    if (function_exists('icl_object_id')) {
                        $staff_name = get_the_title(icl_object_id($staff_page, 'page'));
                    }
                    if ($staff_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-staff-url">
									<a href="' . $staff_url . '" title="' . $staff_name . '">
										<span itemprop="title">' . $staff_name . '</span>
									</a>
								</span>';
                    }
                }
                // Staff 1st Category
                if (get_theme_mod('breadcrumbs_staff_cat', '1') && taxonomy_exists('staff_category')) {
                    $terms = get_the_terms($post_id, 'staff_category');
                    if ($terms) {
                        $term = reset($terms);
                        $trail[] = '<span ' . $item_type_scope . '>
										<a href="' . get_term_link($term) . '" itemprop="url" title="' . $term->name . '">
											<span itemprop="title">' . $term->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            //  Main Testimonials
            if ($post_type == 'testimonials') {
                // Display testimonials page
                if ($testimonials_page = get_theme_mod('testimonials_page')) {
                    $testimonials_url = get_permalink($testimonials_page);
                    $testimonials_name = get_the_title($testimonials_page);
                    if (function_exists('icl_object_id')) {
                        $testimonials_name = get_the_title(icl_object_id($testimonials_page, 'page'));
                    }
                    if ($testimonials_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-testimonials-url">
									<a href="' . $testimonials_url . '" title="' . $testimonials_name . '">
										<span itemprop="title">' . $testimonials_name . '</span>
									</a>
								</span>';
                    }
                }
                // Testimonials 1st Category
                if (get_theme_mod('breadcrumbs_testimonials_cat', '1') && taxonomy_exists('testimonials_category')) {
                    $terms = get_the_terms($post_id, 'testimonials_category');
                    if ($terms) {
                        $term = reset($terms);
                        $trail[] = '<span ' . $item_type_scope . '>
										<a href="' . get_term_link($term) . '" itemprop="url" title="' . $term->name . '">
											<span itemprop="title">' . $term->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            // Products
            if (is_singular('product') && class_exists('Woocommerce')) {
                // Globals
                global $woocommerce;
                // Get shop page
                if (class_exists('Woocommerce') && function_exists('wc_get_page_id')) {
                    $shop_id = wc_get_page_id('shop');
                    $shop_page_url = get_permalink($shop_id);
                    $shop_title = get_the_title($shop_id);
                    if (function_exists('icl_object_id')) {
                        $shop_title = get_the_title(icl_object_id($shop_id, 'page'));
                    }
                    $shop_title = apply_filters('wpex_bcrums_shop_title', $shop_title);
                }
                // Shop page
                if ($shop_id && $shop_title) {
                    $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
							<a href="' . get_permalink($shop_id) . '" title="' . esc_attr($shop_title) . '">
								<span itemprop="title">' . $shop_title . '</span>
							</a>
						</span>';
                }
                // Cart page
                if (sizeof($woocommerce->cart->cart_contents) > 0) {
                    $cart_id = wc_get_page_id('cart');
                    $cart_title = get_the_title($cart_id);
                    if ($cart_id) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
								<a href="' . get_permalink($cart_id) . '" title="' . esc_attr($cart_title) . '">
									<span itemprop="title">' . $cart_title . '</span>
								</a>
							</span>';
                    }
                }
            }
            // If the post type path returns nothing and there is a parent, get its parents.
            if (empty($path) && 0 !== $parent || 'attachment' == $post_type) {
                $trail = array_merge($trail, wpex_breadcrumbs_get_parents($parent, ''));
            }
            // End trail with post title
            $post_title = get_the_title($post_id);
            if (!empty($post_title)) {
                if ($trim_title = get_theme_mod('breadcrumbs_title_trim', '4')) {
                    $post_title = wp_trim_words($post_title, $trim_title);
                    $trail['trail_end'] = $post_title;
                } else {
                    $trail['trail_end'] = $post_title;
                }
            }
        } elseif (is_archive()) {
            // Add cart to shop
            if (function_exists('is_shop') && is_shop()) {
                global $woocommerce;
                if (sizeof($woocommerce->cart->cart_contents) > 0) {
                    $cart_id = wc_get_page_id('cart');
                    $cart_title = get_the_title($cart_id);
                    if ($cart_id) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
								<a href="' . get_permalink($cart_id) . '" title="' . esc_attr($cart_title) . '">
									<span itemprop="title">' . $cart_title . '</span>
								</a>
							</span>';
                    }
                }
            }
            // Topics
            if (is_post_type_archive('topic')) {
                $forums_link = get_post_type_archive_link('forum');
                $forum_obj = get_post_type_object('forum');
                $forum_name = $forum_obj->labels->name;
                if ($forums_link) {
                    $trail[] = '<span ' . $item_type_scope . '><a href="' . $forums_link . '" title="' . $forum_name . '">' . $forum_name . '</a></span>';
                }
            }
            /*-----------------------------------------------------------------------------------*/
            /*	- Taxonomies
            			/*-----------------------------------------------------------------------------------*/
            if (is_tax() || is_category() || is_tag()) {
                // Get some taxonomy variables
                $term = $wp_query->get_queried_object();
                $taxonomy = get_taxonomy($term->taxonomy);
                // Link to main portfolio page
                if (function_exists('wpex_is_portfolio_tax') && wpex_is_portfolio_tax() && ($portfolio_page = get_theme_mod('portfolio_page'))) {
                    $portfolio_url = get_permalink($portfolio_page);
                    $portfolio_name = get_the_title($portfolio_page);
                    if (function_exists('icl_object_id')) {
                        $portfolio_name = get_the_title(icl_object_id($portfolio_page, 'page'));
                    }
                    if ($portfolio_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-portfolio-url">
									<a href="' . $portfolio_url . '" title="' . $portfolio_name . '">
										<span itemprop="title">' . $portfolio_name . '</span>
									</a>
								</span>';
                    }
                }
                // Link to main staff page
                if (function_exists('wpex_is_staff_tax') && wpex_is_staff_tax() && ($staff_page = get_theme_mod('staff_page'))) {
                    $staff_url = get_permalink($staff_page);
                    $staff_name = get_the_title($staff_page);
                    if (function_exists('icl_object_id')) {
                        $staff_name = get_the_title(icl_object_id($staff_page, 'page'));
                    }
                    if ($staff_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-staff-url">
									<a href="' . $staff_url . '" title="' . $staff_name . '">
										<span itemprop="title">' . $staff_name . '</span>
									</a>
								</span>';
                    }
                }
                // Testimonials Tax
                if (function_exists('wpex_is_testimonials_tax') && wpex_is_testimonials_tax() && ($testimonials_page = get_theme_mod('testimonials_page'))) {
                    $testimonials_url = get_permalink($testimonials_page);
                    $testimonials_name = get_the_title($testimonials_page);
                    if (function_exists('icl_object_id')) {
                        $testimonials_name = get_the_title(icl_object_id($testimonials_page, 'page'));
                    }
                    if ($testimonials_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-testimonials-url">
									<a href="' . $testimonials_url . '" title="' . $testimonials_name . '">
										<span itemprop="title">' . $testimonials_name . '</span>
									</a>
								</span>';
                    }
                }
                // Woo Product Tax
                if (function_exists('wpex_is_woo_tax') && wpex_is_woo_tax()) {
                    // Get shop page
                    if (class_exists('Woocommerce') && function_exists('wc_get_page_id')) {
                        $shop_id = wc_get_page_id('shop');
                        $shop_page_url = get_permalink($shop_id);
                        $shop_title = get_the_title($shop_id);
                        if (function_exists('icl_object_id')) {
                            $shop_title = get_the_title(icl_object_id($shop_id, 'page'));
                        }
                        $shop_title = apply_filters('wpex_bcrums_shop_title', $shop_title);
                    }
                    if ($shop_page_url && $shop_title) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-shop">
										<a href="' . $shop_page_url . '" title="' . $shop_title . '" itemprop="url">
											<span itemprop="title">' . $shop_title . '</span>
										</a>
									</span>';
                    }
                }
                // Display main blog page on Categories & archives
                if (is_category() || is_tag()) {
                    if ($blog_page = get_theme_mod('blog_page')) {
                        $blog_url = get_permalink($blog_page);
                        $blog_name = get_the_title($blog_page);
                        if (function_exists('icl_object_id')) {
                            $blog_name = get_the_title(icl_object_id($blog_page, 'page'));
                        }
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-blog-url">
										<a href="' . $blog_url . '" title="' . $blog_name . '" itemprop="url">
											<span itemprop="title">' . $blog_name . '</span>
										</a>
									</span>';
                    }
                }
                // Get the path to the term archive. Use this to determine if a page is present with it.
                if (is_category()) {
                    $path = get_option('category_base');
                } elseif (is_tag()) {
                    $path = get_option('tag_base');
                } else {
                    if ($taxonomy->rewrite['with_front'] && $wp_rewrite->front) {
                        $path = trailingslashit($wp_rewrite->front);
                    }
                    $path .= $taxonomy->rewrite['slug'];
                }
                // Get parent pages if they exist
                if ($path) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
                }
                // Add term parents
                if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_term_parents($term->parent, $term->taxonomy));
                }
                // Add term name to trail end
                $trail['trail_end'] = $term->name;
            } elseif (is_post_type_archive()) {
                // Get post type object
                $post_type_object = get_post_type_object(get_query_var('post_type'));
                // Add $front to $path
                if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                    $path .= trailingslashit($wp_rewrite->front);
                }
                // Add slug to 4path
                if (!empty($post_type_object->rewrite['archive'])) {
                    $path .= $post_type_object->rewrite['archive'];
                }
                // If patch exists check for parents
                if (!empty($path)) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
                }
                // Add post type name to trail end
                $trail['trail_end'] = $post_type_object->labels->name;
            } elseif (is_author()) {
                /* If $front has been set, add it to $path. */
                if (!empty($wp_rewrite->front)) {
                    $path .= trailingslashit($wp_rewrite->front);
                }
                /* If an $author_base exists, add it to $path. */
                if (!empty($wp_rewrite->author_base)) {
                    $path .= $wp_rewrite->author_base;
                }
                /* If $path exists, check for parent pages. */
                if (!empty($path)) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
                }
                /* Add the author's display name to the trail end. */
                $trail['trail_end'] = get_the_author_meta('display_name', get_query_var('author'));
            } elseif (is_time()) {
                if (get_query_var('minute') && get_query_var('hour')) {
                    $trail['trail_end'] = get_the_time(__('g:i a', 'wpex'));
                } elseif (get_query_var('minute')) {
                    $trail['trail_end'] = sprintf(__('Minute %1$s', 'wpex'), get_the_time(__('i', 'wpex')));
                } elseif (get_query_var('hour')) {
                    $trail['trail_end'] = get_the_time(__('g a', 'wpex'));
                }
            } elseif (is_date()) {
                // If $front is set check for parents
                if ($wp_rewrite->front) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $wp_rewrite->front));
                }
                if (is_day()) {
                    $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
                    $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'wpex')) . '">' . get_the_time(__('F', 'wpex')) . '</a>';
                    $trail['trail_end'] = get_the_time(__('j', 'wpex'));
                } elseif (get_query_var('w')) {
                    $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
                    $trail['trail_end'] = sprintf(__('Week %1$s', 'wpex'), get_the_time(esc_attr__('W', 'wpex')));
                } elseif (is_month()) {
                    $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
                    $trail['trail_end'] = get_the_time(__('F', 'wpex'));
                } elseif (is_year()) {
                    $trail['trail_end'] = get_the_time(__('Y', 'wpex'));
                }
            }
        } elseif (is_search()) {
            $trail['trail_end'] = sprintf(__('Search results for &quot;%1$s&quot;', 'wpex'), esc_attr(get_search_query()));
        } elseif (is_404()) {
            $trail['trail_end'] = get_theme_mod('error_page_title') ? get_theme_mod('error_page_title') : __('404 Not Found', 'wpex');
        } elseif (function_exists('tribe_is_month') && tribe_is_month()) {
            $trail['trail_end'] = __('Events Calendar', 'wpex');
        }
        /*-----------------------------------------------------------------------------------*/
        /*	- Create and return the breadcrumbs
        		/*-----------------------------------------------------------------------------------*/
        if ($trail && is_array($trail)) {
            $classes = 'site-breadcrumbs clr';
            if ($breadcrumbs_position = get_theme_mod('breadcrumbs_position')) {
                $classes .= ' position-' . $breadcrumbs_position;
            }
            // Open Breadcrumbs
            $breadcrumb = '<nav class="' . $classes . '"><div class="breadcrumb-trail">';
            // Seperator HTML
            $separator = '<span class="sep">' . $separator . '</span>';
            // Join all trail items into a string
            $breadcrumb .= implode($separator, $trail);
            // Close breadcrumbs
            $breadcrumb .= '</div></nav>';
        }
        // Return the breadcrumbs trail
        return $breadcrumb;
    }
Пример #12
0
/**
 * Omega's main contextual function.  This allows code to be used more than once without running 
 * hundreds of conditional checks within the theme.  It returns an array of contexts based on what 
 * page a visitor is currently viewing on the site.  This function is useful for making dynamic/contextual
 * classes, action and filter hooks, and handling the templating system.
 *
 * Note that time and date can be tricky because any of the conditionals may be true on time-/date-
 * based archives depending on several factors.  For example, one could load an archive for a specific
 * second during a specific minute within a specific hour on a specific day and so on.
 *
 * @since 0.7.0
 * @access public
 * @global $wp_query The current page's query object.
 * @global $omega The global Omega object.
 * @return array $omega->context Several contexts based on the current page.
 */
function omega_get_context()
{
    global $omega;
    /* If $omega->context has been set, don't run through the conditionals again. Just return the variable. */
    if (isset($omega->context)) {
        return apply_filters('omega_context', $omega->context);
    }
    /* Set some variables for use within the function. */
    $omega->context = array();
    $object = get_queried_object();
    $object_id = get_queried_object_id();
    /* Front page of the site. */
    if (is_front_page()) {
        $omega->context[] = 'home';
    }
    /* Blog page. */
    if (is_home()) {
        $omega->context[] = 'blog';
    } elseif (is_singular()) {
        $omega->context[] = 'singular';
        $omega->context[] = "singular-{$object->post_type}";
        $omega->context[] = "singular-{$object->post_type}-{$object_id}";
    } elseif (is_archive()) {
        $omega->context[] = 'archive';
        /* Post type archives. */
        if (is_post_type_archive()) {
            $post_type = get_post_type_object(get_query_var('post_type'));
            $omega->context[] = "archive-{$post_type->name}";
        }
        /* Taxonomy archives. */
        if (is_tax() || is_category() || is_tag()) {
            $omega->context[] = 'taxonomy';
            $omega->context[] = "taxonomy-{$object->taxonomy}";
            $slug = 'post_format' == $object->taxonomy ? str_replace('post-format-', '', $object->slug) : $object->slug;
            $omega->context[] = "taxonomy-{$object->taxonomy}-" . sanitize_html_class($slug, $object->term_id);
        }
        /* User/author archives. */
        if (is_author()) {
            $user_id = get_query_var('author');
            $omega->context[] = 'user';
            $omega->context[] = 'user-' . sanitize_html_class(get_the_author_meta('user_nicename', $user_id), $user_id);
        }
        /* Date archives. */
        if (is_date()) {
            $omega->context[] = 'date';
            if (is_year()) {
                $omega->context[] = 'year';
            }
            if (is_month()) {
                $omega->context[] = 'month';
            }
            if (get_query_var('w')) {
                $omega->context[] = 'week';
            }
            if (is_day()) {
                $omega->context[] = 'day';
            }
        }
        /* Time archives. */
        if (is_time()) {
            $omega->context[] = 'time';
            if (get_query_var('hour')) {
                $omega->context[] = 'hour';
            }
            if (get_query_var('minute')) {
                $omega->context[] = 'minute';
            }
        }
    } elseif (is_search()) {
        $omega->context[] = 'search';
    } elseif (is_404()) {
        $omega->context[] = 'error-404';
    }
    return array_map('esc_attr', apply_filters('omega_context', array_unique($omega->context)));
}
Пример #13
0
/**
 * Hybrid's main contextual function.  This allows code to be used more than once without running 
 * hundreds of conditional checks within the theme.  It returns an array of contexts based on what 
 * page a visitor is currently viewing on the site.  This function is useful for making dynamic/contextual
 * classes, action and filter hooks, and handling the templating system.
 *
 * Note that time and date can be tricky because any of the conditionals may be true on time-/date-
 * based archives depending on several factors.  For example, one could load an archive for a specific
 * second during a specific minute within a specific hour on a specific day and so on.
 *
 * @since 0.7.0
 * @global $wp_query The current page's query object.
 * @global $hybrid The global Hybrid object.
 * @return array $hybrid->context Several contexts based on the current page.
 */
function hybrid_get_context()
{
    global $hybrid;
    /* If $hybrid->context has been set, don't run through the conditionals again. Just return the variable. */
    if (isset($hybrid->context)) {
        return $hybrid->context;
    }
    /* Set some variables for use within the function. */
    $hybrid->context = array();
    $object = get_queried_object();
    $object_id = get_queried_object_id();
    /* Front page of the site. */
    if (is_front_page()) {
        $hybrid->context[] = 'home';
    }
    /* Blog page. */
    if (is_home()) {
        $hybrid->context[] = 'blog';
    } elseif (is_singular()) {
        $hybrid->context[] = 'singular';
        $hybrid->context[] = "singular-{$object->post_type}";
        $hybrid->context[] = "singular-{$object->post_type}-{$object_id}";
    } elseif (is_archive()) {
        $hybrid->context[] = 'archive';
        /* Taxonomy archives. */
        if (is_tax() || is_category() || is_tag()) {
            $hybrid->context[] = 'taxonomy';
            $hybrid->context[] = "taxonomy-{$object->taxonomy}";
            $hybrid->context[] = "taxonomy-{$object->taxonomy}-" . sanitize_html_class($object->slug, $object->term_id);
        } elseif (is_post_type_archive()) {
            $post_type = get_post_type_object(get_query_var('post_type'));
            $hybrid->context[] = "archive-{$post_type->name}";
        } elseif (is_author()) {
            $hybrid->context[] = 'user';
            $hybrid->context[] = 'user-' . sanitize_html_class(get_the_author_meta('user_nicename', $object_id), $object_id);
        } else {
            if (is_date()) {
                $hybrid->context[] = 'date';
                if (is_year()) {
                    $hybrid->context[] = 'year';
                }
                if (is_month()) {
                    $hybrid->context[] = 'month';
                }
                if (get_query_var('w')) {
                    $hybrid->context[] = 'week';
                }
                if (is_day()) {
                    $hybrid->context[] = 'day';
                }
            }
            if (is_time()) {
                $hybrid->context[] = 'time';
                if (get_query_var('hour')) {
                    $hybrid->context[] = 'hour';
                }
                if (get_query_var('minute')) {
                    $hybrid->context[] = 'minute';
                }
            }
        }
    } elseif (is_search()) {
        $hybrid->context[] = 'search';
    } elseif (is_404()) {
        $hybrid->context[] = 'error-404';
    }
    return array_map('esc_attr', $hybrid->context);
}
Пример #14
0
/**
 * Hybrid's main contextual function.  This allows code to be used more than once without running 
 * hundreds of conditional checks within the theme.  It returns an array of contexts based on what 
 * page a visitor is currently viewing on the site.  This function is useful for making dynamic/contextual
 * classes, action and filter hooks, and handling the templating system.
 *
 * Note that time and date can be tricky because any of the conditionals may be true on time-/date-
 * based archives depending on several factors.  For example, one could load an archive for a specific
 * second during a specific minute within a specific hour on a specific day and so on.
 *
 * @since 0.7.0
 * @global $wp_query The current page's query object.
 * @global $hybrid The global Hybrid object.
 * @return array $hybrid->context Several contexts based on the current page.
 */
function hybrid_get_context() {
	global $wp_query, $hybrid;

	/* If $hybrid->context has been set, don't run through the conditionals again. Just return the variable. */
	if ( isset( $hybrid->context ) )
		return $hybrid->context;

	$hybrid->context = array();

	/* Front page of the site. */
	if ( is_front_page() )
		$hybrid->context[] = 'home';

	/* Blog page. */
	if ( is_home() ) {
		$hybrid->context[] = 'blog';
	}

	/* Singular views. */
	elseif ( is_singular() ) {
		$hybrid->context[] = 'singular';
		$hybrid->context[] = "singular-{$wp_query->post->post_type}";
		$hybrid->context[] = "singular-{$wp_query->post->post_type}-{$wp_query->post->ID}";
	}

	/* Archive views. */
	elseif ( is_archive() ) {
		$hybrid->context[] = 'archive';

		/* Taxonomy archives. */
		if ( is_tax() || is_category() || is_tag() ) {
			$term = $wp_query->get_queried_object();
			$hybrid->context[] = 'taxonomy';
			$hybrid->context[] = "taxonomy-{$term->taxonomy}";
			$hybrid->context[] = "taxonomy-{$term->taxonomy}-" . sanitize_html_class( $term->slug, $term->term_id );
		}

		/* Post type archives. */
		elseif ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) {
			$post_type = get_post_type_object( get_query_var( 'post_type' ) );
			$hybrid->context[] = "archive-{$post_type->name}";
		}

		/* User/author archives. */
		elseif ( is_author() ) {
			$hybrid->context[] = 'user';
			$hybrid->context[] = 'user-' . sanitize_html_class( get_the_author_meta( 'user_nicename', get_query_var( 'author' ) ), $wp_query->get_queried_object_id() );
		}

		/* Time/Date archives. */
		else {
			if ( is_date() ) {
				$hybrid->context[] = 'date';
				if ( is_year() )
					$hybrid->context[] = 'year';
				if ( is_month() )
					$hybrid->context[] = 'month';
				if ( get_query_var( 'w' ) )
					$hybrid->context[] = 'week';
				if ( is_day() )
					$hybrid->context[] = 'day';
			}
			if ( is_time() ) {
				$hybrid->context[] = 'time';
				if ( get_query_var( 'hour' ) )
					$hybrid->context[] = 'hour';
				if ( get_query_var( 'minute' ) )
					$hybrid->context[] = 'minute';
			}
		}
	}

	/* Search results. */
	elseif ( is_search() ) {
		$hybrid->context[] = 'search';
	}

	/* Error 404 pages. */
	elseif ( is_404() ) {
		$hybrid->context[] = 'error-404';
	}

	return array_map( 'esc_attr', $hybrid->context );
}
 /**
  * Checks if the current page can be accessed by the specified rules
  *
  * @since  1.0.0
  *
  * @param  array $rules List of allowed pages.
  * @return bool
  */
 protected function check_current_page($rules)
 {
     $result = false;
     foreach ($rules as $key => $active) {
         if (!$active) {
             continue;
         }
         /*
          * The item order is critical, in case a page has multiple flags
          * like "Front" and "Home" and "Archive".
          * In this example "Archive" might be denied but "Front" allowed,
          * so we have to define a hierarchy which flag is actually used.
          */
         switch ($key) {
             case 'front':
                 $result = is_front_page();
                 break;
             case 'home':
                 $result = is_home();
                 break;
             case 'notfound':
                 $result = is_404();
                 break;
             case 'search':
                 $result = is_search();
                 break;
             case 'attachment':
                 $result = is_attachment();
                 break;
             case 'single':
                 $result = is_singular();
                 break;
             case 'archive':
                 $result = is_archive();
                 break;
             case 'author':
                 $result = is_author();
                 break;
             case 'date':
                 $result = is_date();
                 break;
             case 'year':
                 $result = is_year();
                 break;
             case 'month':
                 $result = is_month();
                 break;
             case 'day':
                 $result = is_day();
                 break;
             case 'time':
                 $result = is_time();
                 break;
         }
         if ($result) {
             $this->matched_type = $key;
             break;
         }
     }
     return apply_filters('ms_rule_special_model_check_current_page', $result, $rules);
 }
Пример #16
0
function is_datetime($test)
{
    $set = explode(' ', $test);
    return is_time(array_pop($set)) && is_date(join(' ', $set));
}
Пример #17
0
/**
 * Gets the loop description.  This function should only be used on archive-type pages, such as archive, blog, and 
 * search results pages.  It outputs the description of the page.
 *
 * @link   http://core.trac.wordpress.org/ticket/21995
 * @since  2.0.0
 * @access public
 * @return string
 */
function hybrid_get_loop_description()
{
    $loop_desc = '';
    if (is_home() && !is_front_page()) {
        $loop_desc = get_post_field('post_content', get_queried_object_id(), 'raw');
    } elseif (is_category()) {
        $loop_desc = get_term_field('description', get_queried_object_id(), 'category', 'raw');
    } elseif (is_tag()) {
        $loop_desc = get_term_field('description', get_queried_object_id(), 'post_tag', 'raw');
    } elseif (is_tax()) {
        $loop_desc = get_term_field('description', get_queried_object_id(), get_query_var('taxonomy'), 'raw');
    } elseif (is_author()) {
        $loop_desc = get_the_author_meta('description', get_query_var('author'));
    } elseif (is_search()) {
        $loop_desc = sprintf(__('You are browsing the search results for &#8220;%s&#8221;', 'hybrid-core'), get_search_query());
    } elseif (is_post_type_archive()) {
        $loop_desc = get_post_type_object(get_query_var('post_type'))->description;
    } elseif (is_time()) {
        $loop_desc = __('You are browsing the site archives by time.', 'hybrid-core');
    } elseif (is_day()) {
        $loop_desc = sprintf(__('You are browsing the site archives for %s.', 'hybrid-core'), hybrid_single_day_title('', false));
    } elseif (is_month()) {
        $loop_desc = sprintf(__('You are browsing the site archives for %s.', 'hybrid-core'), single_month_title(' ', false));
    } elseif (is_year()) {
        $loop_desc = sprintf(__('You are browsing the site archives for %s.', 'hybrid-core'), hybrid_single_year_title('', false));
    } elseif (is_archive()) {
        $loop_desc = __('You are browsing the site archives.', 'hybrid-core');
    }
    return apply_filters('hybrid_loop_description', $loop_desc);
}
Пример #18
0
 function anaglyph_breadcrumbs_generate($args = array())
 {
     global $wp_query, $wp_rewrite;
     $breadcrumb = '';
     $trail = array();
     $path = '';
     $defaults = array('separator' => '', 'before' => false, 'after' => false, 'front_page' => true, 'show_home' => __('Home', 'anaglyph-lite'), 'echo' => true, 'show_posts_page' => true);
     if (is_singular()) {
         $defaults["singular_{$wp_query->post->post_type}_taxonomy"] = false;
     }
     extract(wp_parse_args($args, $defaults));
     if (!is_front_page() && $show_home) {
         $trail[] = '<li><a href="' . esc_url(home_url()) . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . esc_html($show_home) . '</a></li>';
     }
     /* If viewing the front page of the site. */
     if (is_front_page()) {
         if (!$front_page) {
             $trail = false;
         } elseif ($show_home) {
             $trail['trail_end'] = "{$show_home}";
         }
     } elseif (is_home()) {
         $home_page = get_page($wp_query->get_queried_object_id());
         $trail = array_merge($trail, anaglyph_breadcrumbs_get_parents($home_page->post_parent, ''));
         $trail['trail_end'] = get_the_title($home_page->ID);
     } elseif (is_singular()) {
         $post = $wp_query->get_queried_object();
         $post_id = absint($wp_query->get_queried_object_id());
         $post_type = $post->post_type;
         $parent = $post->post_parent;
         if ('page' !== $post_type && 'post' !== $post_type) {
             $post_type_object = get_post_type_object($post_type);
             if ('post' == $post_type || 'attachment' == $post_type || $post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                 $path .= trailingslashit($wp_rewrite->front);
             }
             if (!empty($post_type_object->rewrite['slug'])) {
                 $path .= $post_type_object->rewrite['slug'];
             }
             if (!empty($path) && '/' != $path) {
                 $trail = array_merge($trail, anaglyph_breadcrumbs_get_parents('', $path));
             }
             if (!empty($post_type_object->has_archive) && function_exists('get_post_type_archive_link')) {
                 $trail[] = '<li><a href="' . get_post_type_archive_link($post_type) . '" title="' . esc_attr($post_type_object->labels->name) . '">' . $post_type_object->labels->name . '</a></li>';
             }
         }
         /* If the post type path returns nothing and there is a parent, get its parents. */
         if (empty($path) && 0 !== $parent || 'attachment' == $post_type) {
             $trail = array_merge($trail, anaglyph_breadcrumbs_get_parents($parent, ''));
         }
         /* Toggle the display of the posts page on single blog posts. */
         if ('post' == $post_type && $show_posts_page == true && 'page' == get_option('show_on_front')) {
             $posts_page = get_option('page_for_posts');
             if ($posts_page != '' && is_numeric($posts_page)) {
                 $trail = array_merge($trail, anaglyph_breadcrumbs_get_parents($posts_page, ''));
             }
         }
         /* Display terms for specific post type taxonomy if requested. */
         if (isset($args["singular_{$post_type}_taxonomy"]) && ($terms = get_the_term_list($post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', ''))) {
             $trail[] = $terms;
         }
         /* End with the post title. */
         $post_title = get_the_title($post_id);
         // Force the post_id to make sure we get the correct page title.
         if (!empty($post_title)) {
             $trail['trail_end'] = $post_title;
         }
     } elseif (is_archive()) {
         /* If viewing a taxonomy term archive. */
         if (is_tax() || is_category() || is_tag()) {
             /* Get some taxonomy and term variables. */
             $term = $wp_query->get_queried_object();
             $taxonomy = get_taxonomy($term->taxonomy);
             /* Get the path to the term archive. Use this to determine if a page is present with it. */
             if (is_category()) {
                 $path = get_option('category_base');
             } elseif (is_tag()) {
                 $path = get_option('tag_base');
             } else {
                 if ($taxonomy->rewrite['with_front'] && $wp_rewrite->front) {
                     $path = trailingslashit($wp_rewrite->front);
                 }
                 $path .= $taxonomy->rewrite['slug'];
             }
             /* Get parent pages by path if they exist. */
             if ($path) {
                 $trail = array_merge($trail, anaglyph_breadcrumbs_get_parents('', $path));
             }
             /* If the taxonomy is hierarchical, list its parent terms. */
             if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
                 $trail = array_merge($trail, anaglyph_breadcrumbs_get_term_parents($term->parent, $term->taxonomy));
             }
             /* Add the term name to the trail end. */
             $trail['trail_end'] = $term->name;
         } elseif (function_exists('is_post_type_archive') && is_post_type_archive()) {
             /* Get the post type object. */
             $post_type_object = get_post_type_object(get_query_var('post_type'));
             /* If $front has been set, add it to the $path. */
             if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                 $path .= trailingslashit($wp_rewrite->front);
             }
             /* If there's a slug, add it to the $path. */
             if (!empty($post_type_object->rewrite['archive'])) {
                 $path .= $post_type_object->rewrite['archive'];
             }
             /* If there's a path, check for parents. */
             if (!empty($path) && '/' != $path) {
                 $trail = array_merge($trail, anaglyph_breadcrumbs_get_parents('', $path));
             }
             /* Add the post type [plural] name to the trail end. */
             $trail['trail_end'] = $post_type_object->labels->name;
         } elseif (is_author()) {
             /* If $front has been set, add it to $path. */
             if (!empty($wp_rewrite->front)) {
                 $path .= trailingslashit($wp_rewrite->front);
             }
             /* If an $author_base exists, add it to $path. */
             if (!empty($wp_rewrite->author_base)) {
                 $path .= $wp_rewrite->author_base;
             }
             /* If $path exists, check for parent pages. */
             if (!empty($path)) {
                 $trail = array_merge($trail, anaglyph_breadcrumbs_get_parents('', $path));
             }
             /* Add the author's display name to the trail end. */
             $trail['trail_end'] = get_the_author_meta('display_name', get_query_var('author'));
         } elseif (is_time()) {
             if (get_query_var('minute') && get_query_var('hour')) {
                 $trail['trail_end'] = get_the_time(__('g:i a', 'anaglyph-lite'));
             } elseif (get_query_var('minute')) {
                 $trail['trail_end'] = sprintf(__('Minute %1$s', 'anaglyph-lite'), get_the_time(__('i', 'anaglyph-lite')));
             } elseif (get_query_var('hour')) {
                 $trail['trail_end'] = get_the_time(__('g a', 'anaglyph-lite'));
             }
         } elseif (is_date()) {
             /* If $front has been set, check for parent pages. */
             if ($wp_rewrite->front) {
                 $trail = array_merge($trail, anaglyph_breadcrumbs_get_parents('', $wp_rewrite->front));
             }
             if (is_day()) {
                 $trail[] = '<li><a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'anaglyph-lite')) . '">' . get_the_time(__('Y', 'anaglyph-lite')) . '</a></li>';
                 $trail[] = '<li><a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'anaglyph-lite')) . '">' . get_the_time(__('F', 'anaglyph-lite')) . '</a></li>';
                 $trail['trail_end'] = get_the_time(__('j', 'anaglyph-lite'));
             } elseif (get_query_var('w')) {
                 $trail[] = '<li><a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'anaglyph-lite')) . '">' . get_the_time(__('Y', 'anaglyph-lite')) . '</a></li>';
                 $trail['trail_end'] = sprintf(__('Week %1$s', 'anaglyph-lite'), get_the_time(esc_attr__('W', 'anaglyph-lite')));
             } elseif (is_month()) {
                 $trail[] = '<li><a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'anaglyph-lite')) . '">' . get_the_time(__('Y', 'anaglyph-lite')) . '</a></li>';
                 $trail['trail_end'] = get_the_time(__('F', 'anaglyph-lite'));
             } elseif (is_year()) {
                 $trail['trail_end'] = get_the_time(__('Y', 'anaglyph-lite'));
             }
         }
     } elseif (is_search()) {
         $trail['trail_end'] = '<li>' . sprintf(__('Search results for &quot;%1$s&quot;', 'anaglyph-lite'), esc_attr(get_search_query())) . '</li>';
     } elseif (is_404()) {
         $trail['trail_end'] = __('404 Not Found', 'anaglyph-lite');
     }
     /* Connect the breadcrumb trail if there are items in the trail. */
     if (is_array($trail)) {
         /* If $before was set, wrap it in a container. */
         if (!empty($before)) {
             $breadcrumb .= '<span class="trail-before">' . wp_kses_post($before) . '</span> ';
         }
         /* Wrap the $trail['trail_end'] value in a container. */
         if (!empty($trail['trail_end']) && !is_search()) {
             $trail['trail_end'] = '<li class="active"><span class="trail-end">' . wp_kses_post($trail['trail_end']) . '</span></li>';
         }
         /* Format the separator. */
         if (!empty($separator)) {
             $separator = '<li><span class="sep">' . wp_kses_post($separator) . '</span></li>';
         }
         /* Join the individual trail items into a single string. */
         $breadcrumb .= join(" {$separator} ", $trail);
         /* If $after was set, wrap it in a container. */
         if (!empty($after)) {
             $breadcrumb .= '<li><span class="trail-after">' . wp_kses_post($after) . '</span></li>';
         }
         /* Close the breadcrumb trail containers. */
     }
     $breadcrumb = '<!-- Breadcrumb --><section id="breadcrumb"><div class="container"><nav class="nav-breadcrumb" role="navigation" aria-label="' . __('Breadcrumb Navigation', 'anaglyph-lite') . '" ><ol class="breadcrumb">' . $breadcrumb . '</ol></nav></div></section>';
     /* Output the breadcrumb. */
     if ($echo) {
         echo $breadcrumb;
     } else {
         return $breadcrumb;
     }
 }
Пример #19
0
 /**
  * @return bool
  */
 protected function getIsTime()
 {
     return is_time();
 }
Пример #20
0
 /**
  * Actually inserts the code for the <meta name='parsely-page'> parameter within the <head></head> tag.
  */
 public function insert_parsely_page()
 {
     $parselyOptions = $this->get_options();
     // If we don't have an API key or if we aren't supposed to show to logged in users, there's no need to proceed.
     if (empty($parselyOptions['apikey']) || !$parselyOptions['track_authenticated_users'] && is_user_logged_in()) {
         return '';
     }
     global $wp_query;
     global $post;
     // Assign default values for LD+JSON
     // TODO: Maping of an install's post types to Parse.ly post types (namely page/post)
     $parselyPage = array("@context" => "http://schema.org", "@type" => "WebPage");
     $currentURL = $this->get_current_url();
     if (is_single() && $post->post_status == 'publish') {
         $authors = $this->get_author_names($post);
         $category = $this->get_category_name($post, $parselyOptions);
         $postId = $parselyOptions['content_id_prefix'] . (string) get_the_ID();
         $image_url = '';
         if (has_post_thumbnail()) {
             $image_id = get_post_thumbnail_id();
             $image_url = wp_get_attachment_image_src($image_id);
             $image_url = $image_url[0];
         }
         $parselyPage['@type'] = 'NewsArticle';
         $parselyPage['headline'] = $this->get_clean_parsely_page_value(get_the_title());
         $parselyPage['url'] = get_permalink();
         $parselyPage['thumbnailUrl'] = $image_url;
         $parselyPage['articleId'] = $postId;
         $parselyPage['dateCreated'] = gmdate('Y-m-d\\TH:i:s\\Z', get_post_time('U', true));
         $parselyPage['articleSection'] = $category;
         $parselyPage['creator'] = $authors;
         $parselyPage['keywords'] = array_merge($this->get_tags_as_string($post->ID, $parselyOptions), $this->get_categories_as_tags($post, $parselyOptions));
     } elseif (is_page() && $post->post_status == 'publish') {
         $parselyPage['headline'] = $this->get_clean_parsely_page_value(get_the_title());
         $parselyPage['url'] = get_permalink();
     } elseif (is_author()) {
         // TODO: why can't we have something like a WP_User object for all the other cases? Much nicer to deal with than functions
         $author = get_query_var('author_name') ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
         $parselyPage['headline'] = $this->get_clean_parsely_page_value('Author - ' . $author->data->display_name);
         $parselyPage['url'] = $currentURL;
     } elseif (is_category()) {
         $category = get_the_category();
         $category = $category[0];
         $parselyPage['headline'] = $this->get_clean_parsely_page_value($category->name);
         $parselyPage['url'] = $currentURL;
     } elseif (is_date()) {
         if (is_year()) {
             $parselyPage['headline'] = 'Yearly Archive - ' . get_the_time('Y');
         } elseif (is_month()) {
             $parselyPage['headline'] = 'Monthly Archive - ' . get_the_time('F, Y');
         } elseif (is_day()) {
             $parselyPage['headline'] = 'Daily Archive - ' . get_the_time('F jS, Y');
         } elseif (is_time()) {
             $parselyPage['headline'] = 'Hourly, Minutely, or Secondly Archive - ' . get_the_time('F jS g:i:s A');
         }
         $parselyPage['url'] = $currentURL;
     } elseif (is_tag()) {
         $tag = single_tag_title('', FALSE);
         if (empty($tag)) {
             $tag = single_term_title('', FALSE);
         }
         $parselyPage['headline'] = $this->get_clean_parsely_page_value('Tagged - ' . $tag);
         $parselyPage['url'] = $currentURL;
         // get_tag_link(get_query_var('tag_id'));
     } elseif (is_front_page()) {
         $parselyPage['headline'] = $this->get_clean_parsely_page_value(get_bloginfo('name', 'raw'));
         $parselyPage['url'] = home_url();
         // site_url();?
     }
     include 'parsely-parsely-page.php';
 }
Пример #21
0
 /**
  * Adds the items to the trail items array for archives that don't have a more specific method
  * defined in this class.
  *
  * @since  1.0.0
  * @access protected
  * @return void
  */
 protected function add_default_archive_items()
 {
     // If this is a date-/time-based archive, add $wp_rewrite->front to the trail.
     if (is_date() || is_time()) {
         $this->add_rewrite_front_items();
     }
     if (true === $this->args['show_title']) {
         $this->items[] = $this->labels['archives'];
     }
 }
Пример #22
0
 function simple_breadcrumb_case($der_post)
 {
     $markup = $this->options['before'] . $this->options['after'];
     if (is_page()) {
         if ($der_post->post_parent) {
             $my_query = get_post($der_post->post_parent);
             $this->simple_breadcrumb_case($my_query);
             $link = '<a href="' . get_permalink($my_query->ID) . '">';
             $link .= '' . get_the_title($my_query->ID) . '</a>' . $markup;
             echo $link;
         }
         return;
     }
     if (is_single()) {
         $category = get_the_category();
         if (is_attachment()) {
             $my_query = get_post($der_post->post_parent);
             $category = get_the_category($my_query->ID);
             $ID = $category[0]->cat_ID;
             echo get_category_parents($ID, TRUE, $markup, FALSE);
             previous_post_link("%link {$markup}");
         } else {
             $postType = get_post_type();
             if ($postType == 'post') {
                 $ID = $category[0]->cat_ID;
                 echo get_category_parents($ID, TRUE, $markup, FALSE);
             } else {
                 if ($postType == 'portfolio') {
                     global $post;
                     $terms = get_the_term_list($post->ID, 'portfolio_entries', '', '$$$', '');
                     $terms = array_filter(explode('$$$', $terms));
                     if (!empty($terms)) {
                         echo $terms[0] . $markup;
                     }
                 } else {
                     if ($postType == 'product') {
                         global $post;
                         $terms = get_the_term_list($post->ID, 'product_cat', '', '$$$', '');
                         $terms = array_filter(explode('$$$', $terms));
                         if (!empty($terms)) {
                             echo $terms[0] . $markup;
                         }
                     }
                 }
             }
         }
         return;
     }
     if (is_tax()) {
         $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
         return $term->name;
     }
     if (is_category()) {
         $category = get_the_category();
         $i = $category[0]->cat_ID;
         $parent = $category[0]->category_parent;
         if ($parent > 0 && $category[0]->cat_name == single_cat_title("", false)) {
             echo get_category_parents($parent, TRUE, $markup, FALSE);
         }
         return __("Archive for Category: ", 'dt_rise') . single_cat_title('', FALSE);
     }
     if (is_author()) {
         $curauth = get_userdatabylogin(get_query_var('author_name'));
         return __("Archive for Author: ", 'dt_rise') . $curauth->nickname;
     }
     if (is_tag()) {
         return __("Archive for Tag: ", 'dt_rise') . single_tag_title('', FALSE);
     }
     if (is_404()) {
         return __("LOST", 'dt_rise');
     }
     if (is_search()) {
         return __("Search", 'dt_rise');
     }
     if (is_year()) {
         return get_the_time('Y');
     }
     if (is_month()) {
         $k_year = get_the_time('Y');
         echo "<a href='" . get_year_link($k_year) . "'>" . $k_year . "</a>" . $markup;
         return get_the_time('F');
     }
     if (is_day() || is_time()) {
         $k_year = get_the_time('Y');
         $k_month = get_the_time('m');
         $k_month_display = get_the_time('F');
         echo "<a href='" . get_year_link($k_year) . "'>" . $k_year . "</a>" . $markup;
         echo "<a href='" . get_month_link($k_year, $k_month) . "'>" . $k_month_display . "</a>" . $markup;
         return get_the_time('jS (l)');
     }
     if (is_post_type_archive('product')) {
         return 'Products';
     }
 }
Пример #23
0
 /**
  * woo_get_query_context()
  *
  * Retrieve the context of the queried template.
  *
  * @since 3.9.0
  * @return array $query_context
  */
 function woo_get_query_context()
 {
     global $wp_query, $query_context;
     /* If $query_context->context has been set, don't run through the conditionals again. Just return the variable. */
     if (is_object($query_context) && isset($query_context->context) && is_array($query_context->context)) {
         return $query_context->context;
     }
     unset($query_context);
     $query_context = new stdClass();
     $query_context->context = array();
     /* Front page of the site. */
     if (is_front_page()) {
         $query_context->context[] = 'home';
     }
     /* Blog page. */
     if (is_home() && !is_front_page()) {
         $query_context->context[] = 'blog';
         /* Singular views. */
     } elseif (is_singular()) {
         $query_context->context[] = 'singular';
         $query_context->context[] = "singular-{$wp_query->post->post_type}";
         /* Page Templates. */
         if (is_page_template()) {
             $to_skip = array('page', 'post');
             $page_template = basename(get_page_template());
             $page_template = str_replace('.php', '', $page_template);
             $page_template = str_replace('.', '-', $page_template);
             if ($page_template && !in_array($page_template, $to_skip)) {
                 $query_context->context[] = $page_template;
             }
         }
         $query_context->context[] = "singular-{$wp_query->post->post_type}-{$wp_query->post->ID}";
     } elseif (is_archive()) {
         $query_context->context[] = 'archive';
         /* Taxonomy archives. */
         if (is_tax() || is_category() || is_tag()) {
             $term = $wp_query->get_queried_object();
             $query_context->context[] = 'taxonomy';
             $query_context->context[] = $term->taxonomy;
             $query_context->context[] = "{$term->taxonomy}-" . sanitize_html_class($term->slug, $term->term_id);
         } elseif (is_author()) {
             $query_context->context[] = 'user';
             $query_context->context[] = 'user-' . sanitize_html_class(get_the_author_meta('user_nicename', get_query_var('author')), $wp_query->get_queried_object_id());
         } else {
             if (is_date()) {
                 $query_context->context[] = 'date';
                 if (is_year()) {
                     $query_context->context[] = 'year';
                 }
                 if (is_month()) {
                     $query_context->context[] = 'month';
                 }
                 if (get_query_var('w')) {
                     $query_context->context[] = 'week';
                 }
                 if (is_day()) {
                     $query_context->context[] = 'day';
                 }
             }
             if (is_time()) {
                 $query_context->context[] = 'time';
                 if (get_query_var('hour')) {
                     $query_context->context[] = 'hour';
                 }
                 if (get_query_var('minute')) {
                     $query_context->context[] = 'minute';
                 }
             }
         }
     } elseif (is_search()) {
         $query_context->context[] = 'search';
         /* Error 404 pages. */
     } elseif (is_404()) {
         $query_context->context[] = 'error-404';
     }
     return $query_context->context;
 }
Пример #24
0
 function magee_simple_breadcrumb_case($der_post)
 {
     global $post;
     $markup = $this->options['before'] . $this->options['delimiter'] . $this->options['after'];
     if (is_page()) {
         if ($der_post->post_parent) {
             $my_query = get_post($der_post->post_parent);
             $this->magee_simple_breadcrumb_case($my_query);
             $link = '<a href="';
             $link .= get_permalink($my_query->ID);
             $link .= '">';
             $link .= '' . get_the_title($my_query->ID) . '</a>' . $markup;
             echo $link;
         }
         return;
     }
     if (is_single()) {
         $category = get_the_category();
         if (is_attachment()) {
             $my_query = get_post($der_post->post_parent);
             $category = get_the_category($my_query->ID);
             if (isset($category[0])) {
                 $ID = $category[0]->cat_ID;
                 $parents = get_category_parents($ID, TRUE, $markup, FALSE);
                 if (!is_object($parents)) {
                     echo $parents;
                 }
                 previous_post_link("%link {$markup}");
             }
         } else {
             $postType = get_post_type();
             if ($postType == 'post') {
                 $ID = $category[0]->cat_ID;
                 echo get_category_parents($ID, TRUE, $markup, FALSE);
             } else {
                 if ($postType == 'portfolio') {
                     $terms = get_the_term_list($post->ID, 'portfolio-category', '', '$$$', '');
                     $terms = explode('$$$', $terms);
                     echo $terms[0] . $markup;
                 }
             }
         }
         return;
     }
     if (is_tax()) {
         $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
         return $term->name;
     }
     if (is_category()) {
         $category = get_the_category();
         $i = isset($category[0]->cat_ID) ? $category[0]->cat_ID : 0;
         $parent = isset($category[0]->category_parent) ? $category[0]->category_parent : 0;
         if ($parent > 0 && $category[0]->cat_name == single_cat_title("", false)) {
             echo get_category_parents($parent, TRUE, $markup, FALSE);
         }
         return single_cat_title('', FALSE);
     }
     if (is_author()) {
         $curauth = get_userdatabylogin(get_query_var('author_name'));
         return "Author: " . $curauth->nickname;
     }
     if (is_tag()) {
         return "Tag: " . single_tag_title('', FALSE);
     }
     if (is_404()) {
         return _e("404 - Page not Found", 'magee_framework');
     }
     if (is_search()) {
         return _e("Search", 'magee_framework');
     }
     if (is_year()) {
         return get_the_time('Y');
     }
     if (is_month()) {
         $k_year = get_the_time('Y');
         echo "<a href='" . get_year_link($k_year) . "'>" . $k_year . "</a>" . $markup;
         return get_the_time('F');
     }
     if (is_day() || is_time()) {
         $k_year = get_the_time('Y');
         $k_month = get_the_time('m');
         $k_month_display = get_the_time('F');
         echo "<a href='" . get_year_link($k_year) . "'>" . $k_year . "</a>" . $markup;
         echo "<a href='" . get_month_link($k_year, $k_month) . "'>" . $k_month_display . "</a>" . $markup;
         return get_the_time('jS (l)');
     }
 }
function mb_get_page_type()
{
    global $post;
    $type = false;
    if (is_category()) {
        $type = 'category';
    }
    if (is_time()) {
        $type = 'time';
    }
    if (is_day()) {
        $type = 'day';
    }
    if (is_month()) {
        $type = 'month';
    }
    if (is_year()) {
        $type = 'year';
    }
    if (is_author()) {
        $type = 'author';
    }
    if (is_tag()) {
        $type = 'tag';
    }
    if (is_home()) {
        $type = 'home';
    }
    if (is_admin()) {
        $type = 'admin';
    }
    if (is_single()) {
        $type = 'single';
    }
    if (is_tax()) {
        $type = 'tax';
    }
    if (is_search()) {
        $type = 'search';
    }
    if (is_404()) {
        $type = '404';
    }
    return $type;
}
Пример #26
0
/**
 * The code below is inspired by Justin Tadlock's Hybrid Core.
 *
 * woo_breadcrumbs() shows a breadcrumb for all types of pages.  Themes and plugins can filter $args or input directly.
 * Allow filtering of only the $args using get_the_breadcrumb_args.
 *
 * @since 3.7.0
 * @param array $args Mixed arguments for the menu.
 * @return string Output of the breadcrumb menu.
 */
function woo_breadcrumbs($args = array())
{
    global $wp_query, $wp_rewrite;
    /* Create an empty variable for the breadcrumb. */
    $breadcrumb = '';
    /* Create an empty array for the trail. */
    $trail = array();
    $path = '';
    /* Set up the default arguments for the breadcrumb. */
    $defaults = array('separator' => '›', 'before' => '<span class="breadcrumb-title">' . __('You are here:', 'woothemes') . '</span>', 'after' => false, 'front_page' => true, 'show_home' => __('Home', 'woothemes'), 'echo' => true, 'show_posts_page' => true, 'show_only_first_taxonomy_tree' => false);
    /* Allow singular post views to have a taxonomy's terms prefixing the trail. */
    if (is_singular()) {
        $defaults["singular_{$wp_query->post->post_type}_taxonomy"] = false;
    }
    /* Apply filters to the arguments. */
    $args = apply_filters('woo_breadcrumbs_args', $args);
    /* Parse the arguments and extract them for easy variable naming. */
    extract(wp_parse_args($args, $defaults));
    /* If $show_home is set and we're not on the front page of the site, link to the home page. */
    if (!is_front_page() && $show_home) {
        $trail[] = '<a href="' . esc_url(home_url()) . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . esc_html($show_home) . '</a>';
    }
    /* If viewing the front page of the site. */
    if (is_front_page()) {
        if (!$front_page) {
            $trail = false;
        } elseif ($show_home) {
            $trail['trail_end'] = "{$show_home}";
        }
    } elseif (is_home()) {
        $home_page = get_page($wp_query->get_queried_object_id());
        $trail = array_merge($trail, woo_breadcrumbs_get_parents($home_page->post_parent, ''));
        $trail['trail_end'] = get_the_title($home_page->ID);
    } elseif (is_singular()) {
        /* Get singular post variables needed. */
        $post = $wp_query->get_queried_object();
        $post_id = absint($wp_query->get_queried_object_id());
        $post_type = $post->post_type;
        $parent = $post->post_parent;
        $post_type_object = get_post_type_object($post_type);
        /* If an attachment, check if there are any pages in its hierarchy based on the slug. */
        if ('attachment' == $post_type) {
            /* If $front has been set, add it to the $path. */
            if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If there's a slug, add it to the $path. */
            if (!empty($post_type_object->rewrite['slug'])) {
                $path .= $post_type_object->rewrite['slug'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path) && '/' != $path) {
                $trail = array_merge($trail, woo_breadcrumbs_get_parents('', $path));
            }
        }
        /* If there's an archive page, add it to the trail. */
        if (!empty($post_type_object->has_archive)) {
            $trail['post_type_archive_link'] = '<a href="' . get_post_type_archive_link($post_type) . '" title="' . esc_attr($post_type_object->labels->name) . '">' . esc_html($post_type_object->labels->name) . '</a>';
        }
        /* If the post type path returns nothing and there is a parent, get its parents. */
        if (empty($path) && 0 !== $parent || 'attachment' == $post_type) {
            $trail = array_merge($trail, woo_breadcrumbs_get_parents($parent, ''));
        }
        /* Toggle the display of the posts page on single blog posts. */
        if ('post' == $post_type && $show_posts_page == true && 'page' == get_option('show_on_front')) {
            $posts_page = get_option('page_for_posts');
            if ($posts_page != '' && is_numeric($posts_page)) {
                $trail = array_merge($trail, woo_breadcrumbs_get_parents($posts_page, ''));
            }
        }
        /* Display terms for specific post type taxonomy if requested. */
        if (isset($args["singular_{$post_type}_taxonomy"]) && $post_type != 'page') {
            $raw_terms = get_the_terms($post_id, $args["singular_{$post_type}_taxonomy"]);
            if (is_array($raw_terms) && 0 < count($raw_terms) && !is_wp_error($raw_terms)) {
                $links = array();
                $count = 0;
                $sorted = $raw_terms;
                $terms_by_ancestor = array();
                foreach ($raw_terms as $k => $v) {
                    $ancestors = array_reverse(get_ancestors($v->term_id, $args["singular_{$post_type}_taxonomy"]));
                    if (isset($ancestors[0])) {
                        $key = $ancestors[0];
                    } else {
                        $key = $v->term_id;
                    }
                    $terms_by_ancestor[$key][$v->term_id] = get_term_by('term_id', $v->term_id, $args["singular_{$post_type}_taxonomy"]);
                }
                if (0 < count($terms_by_ancestor)) {
                    $sorted = array();
                    foreach ($terms_by_ancestor as $k => $v) {
                        if (0 < count($v)) {
                            foreach ($v as $i => $j) {
                                $sorted[$i] = $j;
                            }
                        }
                    }
                    foreach ($sorted as $k => $v) {
                        if (isset($sorted[$v->parent])) {
                            unset($sorted[$v->parent]);
                        }
                    }
                }
                foreach ($sorted as $k => $v) {
                    $count++;
                    if (isset($args['show_only_first_taxonomy_tree']) && true == (bool) $args['show_only_first_taxonomy_tree'] && 1 < $count) {
                        continue;
                    }
                    // Display only the first match.
                    $parents = woo_get_term_parents($v->term_id, $args["singular_{$post_type}_taxonomy"], true, '|-|', $v->name, array());
                    if ($parents != '' && !is_wp_error($parents)) {
                        $parents_arr = explode('|-|', $parents);
                        foreach ($parents_arr as $p) {
                            if ($p != '' && !in_array($p, $links)) {
                                $links[] = $p;
                            }
                        }
                    }
                }
                if (0 < count($links)) {
                    foreach ($links as $k => $v) {
                        $trail[] = $v;
                    }
                }
            }
        }
        /* End with the post title. */
        $post_title = get_the_title($post_id);
        // Force the post_id to make sure we get the correct page title.
        if (!empty($post_title)) {
            $trail['trail_end'] = $post_title;
        }
    } elseif (is_archive()) {
        /* If viewing a taxonomy term archive. */
        if (is_tax() || is_category() || is_tag()) {
            /* Get some taxonomy and term variables. */
            $term = $wp_query->get_queried_object();
            $taxonomy = get_taxonomy($term->taxonomy);
            /* Get the path to the term archive. Use this to determine if a page is present with it. */
            if (is_category()) {
                $path = get_option('category_base');
            } elseif (is_tag()) {
                $path = get_option('tag_base');
            } else {
                if ($taxonomy->rewrite['with_front'] && $wp_rewrite->front) {
                    $path = trailingslashit($wp_rewrite->front);
                }
                $path .= $taxonomy->rewrite['slug'];
            }
            /* Get parent pages by path if they exist. */
            if ($path) {
                $trail = array_merge($trail, woo_breadcrumbs_get_parents('', $path));
            }
            /* If the taxonomy is hierarchical, list its parent terms. */
            if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
                $trail = array_merge($trail, woo_breadcrumbs_get_term_parents($term->parent, $term->taxonomy));
            }
            /* Add the term name to the trail end. */
            $trail['trail_end'] = $term->name;
        } elseif (is_post_type_archive()) {
            /* Get the post type object. */
            $post_type_object = get_post_type_object(get_query_var('post_type'));
            /* If $front has been set, add it to the $path. */
            if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If there's a slug, add it to the $path. */
            if (!empty($post_type_object->rewrite['archive'])) {
                $path .= $post_type_object->rewrite['archive'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path) && '/' != $path) {
                $trail = array_merge($trail, woo_breadcrumbs_get_parents('', $path));
            }
            /* Add the post type [plural] name to the trail end. */
            $trail['trail_end'] = $post_type_object->labels->name;
        } elseif (is_author()) {
            /* If $front has been set, add it to $path. */
            if (!empty($wp_rewrite->front)) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If an $author_base exists, add it to $path. */
            if (!empty($wp_rewrite->author_base)) {
                $path .= $wp_rewrite->author_base;
            }
            /* If $path exists, check for parent pages. */
            if (!empty($path)) {
                $trail = array_merge($trail, woo_breadcrumbs_get_parents('', $path));
            }
            /* Add the author's display name to the trail end. */
            $trail['trail_end'] = get_the_author_meta('display_name', get_query_var('author'));
        } elseif (is_time()) {
            if (get_query_var('minute') && get_query_var('hour')) {
                $trail['trail_end'] = get_the_time(__('g:i a', 'woothemes'));
            } elseif (get_query_var('minute')) {
                $trail['trail_end'] = sprintf(__('Minute %1$s', 'woothemes'), get_the_time(__('i', 'woothemes')));
            } elseif (get_query_var('hour')) {
                $trail['trail_end'] = get_the_time(__('g a', 'woothemes'));
            }
        } elseif (is_date()) {
            /* If $front has been set, check for parent pages. */
            if ($wp_rewrite->front) {
                $trail = array_merge($trail, woo_breadcrumbs_get_parents('', $wp_rewrite->front));
            }
            if (is_day()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'woothemes')) . '">' . get_the_time(__('Y', 'woothemes')) . '</a>';
                $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'woothemes')) . '">' . get_the_time(__('F', 'woothemes')) . '</a>';
                $trail['trail_end'] = get_the_time(__('j', 'woothemes'));
            } elseif (get_query_var('w')) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'woothemes')) . '">' . get_the_time(__('Y', 'woothemes')) . '</a>';
                $trail['trail_end'] = sprintf(__('Week %1$s', 'woothemes'), get_the_time(esc_attr__('W', 'woothemes')));
            } elseif (is_month()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'woothemes')) . '">' . get_the_time(__('Y', 'woothemes')) . '</a>';
                $trail['trail_end'] = get_the_time(__('F', 'woothemes'));
            } elseif (is_year()) {
                $trail['trail_end'] = get_the_time(__('Y', 'woothemes'));
            }
        }
    } elseif (is_search()) {
        $trail['trail_end'] = sprintf(__('Search results for &quot;%1$s&quot;', 'woothemes'), esc_attr(get_search_query()));
    } elseif (is_404()) {
        $trail['trail_end'] = __('404 Not Found', 'woothemes');
    }
    /* Allow child themes/plugins to filter the trail array. */
    $trail = apply_filters('woo_breadcrumbs_trail', $trail, $args);
    /* Connect the breadcrumb trail if there are items in the trail. */
    if (is_array($trail)) {
        /* Open the breadcrumb trail containers. */
        $breadcrumb = '<div class="breadcrumb breadcrumbs woo-breadcrumbs"><div class="breadcrumb-trail">';
        /* If $before was set, wrap it in a container. */
        if (!empty($before)) {
            $breadcrumb .= '<span class="trail-before">' . wp_kses_post($before) . '</span> ';
        }
        /* Wrap the $trail['trail_end'] value in a container. */
        if (!empty($trail['trail_end'])) {
            $trail['trail_end'] = '<span class="trail-end">' . wp_kses_post($trail['trail_end']) . '</span>';
        }
        /* Format the separator. */
        if (!empty($separator)) {
            $separator = '<span class="sep">' . wp_kses_post($separator) . '</span>';
        }
        /* Join the individual trail items into a single string. */
        $breadcrumb .= join(" {$separator} ", $trail);
        /* If $after was set, wrap it in a container. */
        if (!empty($after)) {
            $breadcrumb .= ' <span class="trail-after">' . wp_kses_post($after) . '</span>';
        }
        /* Close the breadcrumb trail containers. */
        $breadcrumb .= '</div></div>';
    }
    /* Allow developers to filter the breadcrumb trail HTML. */
    $breadcrumb = apply_filters('woo_breadcrumbs', $breadcrumb);
    /* Output the breadcrumb. */
    if ($echo) {
        echo $breadcrumb;
    } else {
        return $breadcrumb;
    }
}
Пример #27
0
 /**
  * Adds the items to the trail items array for archives that don't have a more specific method
  * defined in this class.
  *
  * @since  0.6.0
  * @access public
  * @return void
  */
 public function do_default_archive_items()
 {
     /* If this is a date-/time-based archive, add $wp_rewrite->front to the trail. */
     if (is_date() || is_time()) {
         $this->do_rewrite_front_items();
     }
     if (true === $this->args['show_title']) {
         $this->items[] = $this->args['labels']['archives'];
     }
 }
Пример #28
0
function render_content()
{
    ?>
	<?php 
    if (have_posts()) {
        ?>
		<div class="loop">
			<div class="loop-header">
				<h4 class="loop-title">
					<?php 
        the_post();
        if (is_category()) {
            // Category Archive
            $title = sprintf(__('Archive for %s', 'it-l10n-Builder-Paige'), single_cat_title('', false));
        } else {
            if (is_tag()) {
                // Tag Archive
                $title = sprintf(__('Archive for %s', 'it-l10n-Builder-Paige'), single_tag_title('', false));
            } else {
                if (is_tax()) {
                    // Tag Archive
                    $title = sprintf(__('Archive for %s', 'it-l10n-Builder-Paige'), builder_get_tax_term_title());
                } else {
                    if (function_exists('is_post_type_archive') && is_post_type_archive() && function_exists('post_type_archive_title')) {
                        // Post Type Archive
                        $title = post_type_archive_title('', false);
                    } else {
                        if (is_author()) {
                            // Author Archive
                            $title = sprintf(__('Author Archive for %s', 'it-l10n-Builder-Paige'), get_the_author());
                        } else {
                            if (is_year()) {
                                // Year-Specific Archive
                                $title = sprintf(__('Archive for %s', 'it-l10n-Builder-Paige'), get_the_time('Y'));
                            } else {
                                if (is_month()) {
                                    // Month-Specific Archive
                                    $title = sprintf(__('Archive for %s', 'it-l10n-Builder-Paige'), get_the_time('F Y'));
                                } else {
                                    if (is_day()) {
                                        // Day-Specific Archive
                                        $title = sprintf(__('Archive for %s', 'it-l10n-Builder-Paige'), get_the_date());
                                    } else {
                                        if (is_time()) {
                                            // Time-Specific Archive
                                            $title = __('Time Archive', 'it-l10n-Builder-Paige');
                                        } else {
                                            // Default catchall just in case
                                            $title = __('Archive', 'it-l10n-Builder-Paige');
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (is_paged()) {
            printf('%s &ndash; Page %d', $title, get_query_var('paged'));
        } else {
            echo $title;
        }
        rewind_posts();
        ?>
				</h4>
			</div>

			<div class="loop-content">
				<?php 
        while (have_posts()) {
            // The Loop
            ?>
					<?php 
            the_post();
            ?>
						<?php 
            get_template_part('post-formats/content', get_post_format());
            ?>
				<?php 
        }
        // end of one post
        ?>
			</div>

			<div class="loop-footer">
				<!-- Previous/Next page navigation -->
				<div class="loop-utility clearfix">
					<div class="alignleft"><?php 
        previous_posts_link(__('&larr; Previous Page', 'it-l10n-Builder-Paige'));
        ?>
</div>
					<div class="alignright"><?php 
        next_posts_link(__('Next Page &rarr;', 'it-l10n-Builder-Paige'));
        ?>
</div>
				</div>
			</div>
		</div>
	<?php 
    } else {
        // do not delete
        ?>
		<?php 
        do_action('builder_template_show_not_found');
        ?>
	<?php 
    }
    // do not delete
}
Пример #29
0
function adminhelper_true_conditions()
{
    global $post;
    $conditions = array();
    $output = '';
    $count = 0;
    if (is_admin()) {
        $conditions[] = "is_admin()";
    }
    if (is_front_page()) {
        $conditions[] = "is_front_page()";
    }
    if (is_home()) {
        $conditions[] = "is_home()";
    }
    if (is_attachment()) {
        $conditions[] = "is_attachment()";
    }
    if (is_single()) {
        $conditions[] = "is_single()";
    }
    if (is_page()) {
        $conditions[] = "is_page()";
    }
    if (is_singular()) {
        $conditions[] = "is_singular() ";
    }
    if (is_category()) {
        $conditions[] = "is_category()";
    }
    if (is_tag()) {
        $conditions[] = "is_tag()";
    }
    if (is_tax()) {
        $conditions[] = "is_tax()";
    }
    if (is_author()) {
        $conditions[] = "is_author()";
    }
    if (is_post_type_archive()) {
        $conditions[] = "is_post_type_archive()";
    }
    if (is_date()) {
        $conditions[] = "is_date()";
    }
    if (is_year()) {
        $conditions[] = "is_year()";
    }
    if (is_month()) {
        $conditions[] = " is_month()";
    }
    if (is_day()) {
        $conditions[] = " is_day()";
    }
    if (is_time()) {
        $conditions[] = " is_time()";
    }
    if (is_archive()) {
        $conditions[] = " is_archive() ";
    }
    if (is_search()) {
        $conditions[] = "is_search() ";
    }
    if (is_404()) {
        $conditions[] = "is_404() ";
    }
    if (is_paged()) {
        $conditions[] = "is_paged() ";
    }
    foreach ($conditions as $condition) {
        if ($count == 0) {
            $output .= '<span class="first condition">' . $condition . '</span>';
        } else {
            $output .= '<span class="condition">, ' . $condition . '</span>';
        }
        $count++;
    }
    return $output;
}
/**
 * Gets the items for the breadcrumb trail.  This is the heart of the script.  It checks the current page 
 * being viewed and decided based on the information provided by WordPress what items should be
 * added to the breadcrumb trail.
 *
 * @since 0.4.0
 * @todo Build in caching based on the queried object ID.
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the trail.
 */
function breadcrumb_trail_get_items($args = array())
{
    global $wp_rewrite;
    /* Get the textdomain. */
    $textdomain = breadcrumb_trail_textdomain();
    /* Set up an empty trail array and empty path. */
    $trail = array();
    $path = '';
    /* If $show_home is set and we're not on the front page of the site, link to the home page. */
    if (!is_front_page() && $args['show_home']) {
        $trail[] = '<a href="' . home_url() . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . $args['show_home'] . '</a>';
    }
    /* If viewing the front page of the site. */
    if (is_front_page()) {
        if ($args['show_home'] && $args['front_page']) {
            $trail['trail_end'] = "{$args['show_home']}";
        }
    } elseif (is_home()) {
        $home_page = get_page(get_queried_object_id());
        $trail = array_merge($trail, breadcrumb_trail_get_parents($home_page->post_parent, ''));
        $trail['trail_end'] = get_the_title($home_page->ID);
    } elseif (is_singular()) {
        /* Get singular post variables needed. */
        $post = get_queried_object();
        $post_id = absint(get_queried_object_id());
        $post_type = $post->post_type;
        $parent = absint($post->post_parent);
        /* Get the post type object. */
        $post_type_object = get_post_type_object($post_type);
        /* If viewing a singular 'post'. */
        if ('post' == $post_type) {
            /* If $front has been set, add it to the $path. */
            $path .= trailingslashit($wp_rewrite->front);
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* Map the permalink structure tags to actual links. */
            $trail = array_merge($trail, breadcrumb_trail_map_rewrite_tags($post_id, get_option('permalink_structure'), $args));
        } elseif ('attachment' == $post_type) {
            /* If $front has been set, add it to the $path. */
            $path .= trailingslashit($wp_rewrite->front);
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* Map the post (parent) permalink structure tags to actual links. */
            $trail = array_merge($trail, breadcrumb_trail_map_rewrite_tags($post->post_parent, get_option('permalink_structure'), $args));
        } elseif ('page' !== $post_type) {
            /* If $front has been set, add it to the $path. */
            if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If there's a slug, add it to the $path. */
            if (!empty($post_type_object->rewrite['slug'])) {
                $path .= $post_type_object->rewrite['slug'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* If there's an archive page, add it to the trail. */
            if (!empty($post_type_object->has_archive)) {
                $trail[] = '<a href="' . get_post_type_archive_link($post_type) . '" title="' . esc_attr($post_type_object->labels->name) . '">' . $post_type_object->labels->name . '</a>';
            }
        }
        /* If the post type path returns nothing and there is a parent, get its parents. */
        if (empty($path) && 0 !== $parent || 'attachment' == $post_type) {
            $trail = array_merge($trail, breadcrumb_trail_get_parents($parent, ''));
        } elseif (0 !== $parent && is_post_type_hierarchical($post_type)) {
            $trail = array_merge($trail, breadcrumb_trail_get_parents($parent, ''));
        }
        /* Display terms for specific post type taxonomy if requested. */
        if (!empty($args["singular_{$post_type}_taxonomy"]) && ($terms = get_the_term_list($post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', ''))) {
            $trail[] = $terms;
        }
        /* End with the post title. */
        $post_title = get_the_title();
        if (!empty($post_title)) {
            $trail['trail_end'] = $post_title;
        }
    } elseif (is_archive()) {
        /* If viewing a taxonomy term archive. */
        if (is_tax() || is_category() || is_tag()) {
            /* Get some taxonomy and term variables. */
            $term = get_queried_object();
            $taxonomy = get_taxonomy($term->taxonomy);
            /* Get the path to the term archive. Use this to determine if a page is present with it. */
            if (is_category()) {
                $path = get_option('category_base');
            } elseif (is_tag()) {
                $path = get_option('tag_base');
            } else {
                if ($taxonomy->rewrite['with_front'] && $wp_rewrite->front) {
                    $path = trailingslashit($wp_rewrite->front);
                }
                $path .= $taxonomy->rewrite['slug'];
            }
            /* Get parent pages by path if they exist. */
            if ($path) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* If the taxonomy is hierarchical, list its parent terms. */
            if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
                $trail = array_merge($trail, breadcrumb_trail_get_term_parents($term->parent, $term->taxonomy));
            }
            /* Add the term name to the trail end. */
            $trail['trail_end'] = single_term_title('', false);
        } elseif (is_post_type_archive()) {
            /* Get the post type object. */
            $post_type_object = get_post_type_object(get_query_var('post_type'));
            /* If $front has been set, add it to the $path. */
            if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If there's a slug, add it to the $path. */
            if (!empty($post_type_object->rewrite['slug'])) {
                $path .= $post_type_object->rewrite['slug'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* Add the post type [plural] name to the trail end. */
            $trail['trail_end'] = $post_type_object->labels->name;
        } elseif (is_author()) {
            /* If $front has been set, add it to $path. */
            if (!empty($wp_rewrite->front)) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If an $author_base exists, add it to $path. */
            if (!empty($wp_rewrite->author_base)) {
                $path .= $wp_rewrite->author_base;
            }
            /* If $path exists, check for parent pages. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* Add the author's display name to the trail end. */
            $trail['trail_end'] = get_the_author_meta('display_name', get_query_var('author'));
        } elseif (is_time()) {
            if (get_query_var('minute') && get_query_var('hour')) {
                $trail['trail_end'] = get_the_time(__('g:i a', $textdomain));
            } elseif (get_query_var('minute')) {
                $trail['trail_end'] = sprintf(__('Minute %1$s', $textdomain), get_the_time(__('i', $textdomain)));
            } elseif (get_query_var('hour')) {
                $trail['trail_end'] = get_the_time(__('g a', $textdomain));
            }
        } elseif (is_date()) {
            /* If $front has been set, check for parent pages. */
            if ($wp_rewrite->front) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $wp_rewrite->front));
            }
            if (is_day()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', $textdomain)) . '">' . get_the_time(__('Y', $textdomain)) . '</a>';
                $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', $textdomain)) . '">' . get_the_time(__('F', $textdomain)) . '</a>';
                $trail['trail_end'] = get_the_time(__('d', $textdomain));
            } elseif (get_query_var('w')) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', $textdomain)) . '">' . get_the_time(__('Y', $textdomain)) . '</a>';
                $trail['trail_end'] = sprintf(__('Week %1$s', $textdomain), get_the_time(esc_attr__('W', $textdomain)));
            } elseif (is_month()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', $textdomain)) . '">' . get_the_time(__('Y', $textdomain)) . '</a>';
                $trail['trail_end'] = get_the_time(__('F', $textdomain));
            } elseif (is_year()) {
                $trail['trail_end'] = get_the_time(__('Y', $textdomain));
            }
        }
    } elseif (is_search()) {
        $trail['trail_end'] = sprintf(__('Search results for &quot;%1$s&quot;', $textdomain), esc_attr(get_search_query()));
    } elseif (is_404()) {
        $trail['trail_end'] = __('404 Not Found', $textdomain);
    }
    /* Allow devs to step in and filter the $trail array. */
    return apply_filters('breadcrumb_trail_items', $trail, $args);
}