/** * get_crumb * * * @return string The html code * @version 2.0.7 * */ public static function get_crumb(array $args = []) { $args = array_merge(['header' => null, 'footer' => null], $args); $links = []; if (theme_cache::is_home()) { return null; } $links['home'] = '<a href="' . theme_cache::home_url() . '" class="home" title="' . ___('Back to Homepage') . '"> <i class="fa fa-home fa-fw"></i> <span class="tx">' . ___('Back to Homepage') . '</span> </a>'; $split = '<span class="split"><i class="fa fa-angle-right"></i></span>'; /* category */ if (theme_cache::is_category()) { $cat_curr = theme_features::get_current_cat_id(); if ($cat_curr > 1) { $links_cat = get_category_parents($cat_curr, true, '%split%'); $links_cats = explode('%split%', $links_cat); array_pop($links_cats); $links['category'] = implode($split, $links_cats); $links['curr_text'] = ___('Category Browser'); } /* tag */ } else { if (theme_cache::is_tag()) { $tag_id = theme_features::get_current_tag_id(); $tag_obj = get_tag($tag_id); $links['tag'] = '<a href="' . esc_url(get_tag_link($tag_id)) . '">' . esc_html(theme_features::get_current_tag_name()) . '</a>'; $links['curr_text'] = ___('Tags Browser'); /* date */ } else { if (theme_cache::is_date()) { global $wp_query; $day = $wp_query->query_vars['day']; $month = $wp_query->query_vars['monthnum']; $year = $wp_query->query_vars['year']; /* day */ if (theme_cache::is_day()) { $date_link = get_day_link(null, null, $day); /* month */ } else { if (theme_cache::is_month()) { $date_link = get_month_link($year, $month); /* year */ } else { if (theme_cache::is_year()) { $date_link = get_year_link($year); } } } $links['date'] = '<a href="' . $date_link . '">' . theme_cache::wp_title('', false) . '</a>'; $links['curr_text'] = ___('Date Browser'); /* search*/ } else { if (theme_cache::is_search()) { // $nav_link = null; $links['curr_text'] = sprintf(___('Search Result: %s'), esc_html(get_search_query())); /* author */ } else { if (theme_cache::is_author()) { global $author; $user = get_user_by('id', $author); $links['author'] = '<a href="' . theme_cache::get_author_posts_url($author) . '">' . theme_cache::get_the_author_meta('display_name', $user->ID) . '</a>'; $links['curr_text'] = ___('Author posts'); /* archive */ } else { if (theme_cache::is_archive()) { $links['archive'] = '<a href="' . get_current_url() . '">' . theme_cache::wp_title('', false) . '</a>'; $links['curr_text'] = ___('Archive Browser'); /* Singular */ } else { if (theme_cache::is_singular()) { global $post; /* The page parent */ if ($post->post_parent) { $links['singular'] = '<a href="' . theme_cache::get_permalink($post->post_parent) . '">' . theme_cache::get_the_title($post->post_parent) . '</a>'; } /** * post / page */ if (theme_features::get_current_cat_id() > 1) { $categories = get_the_category($post->ID); foreach ($categories as $key => $row) { $parent_id[$key] = $row->category_parent; } array_multisort($parent_id, SORT_ASC, $categories); foreach ($categories as $cat) { $cat_name = esc_html($cat->name); $links['singular'] = '<a href="' . esc_url(get_category_link($cat->cat_ID)) . '" title="' . sprintf(___('View all posts in %s'), $cat_name) . '">' . $cat_name . '</a>'; } } //$links['curr_text'] = esc_html(theme_cache::get_the_title($post->ID)); /* 404 */ } else { if (theme_cache::is_404()) { // $nav_link = null; $links['curr_text'] = ___('Not found'); } } } } } } } } return '<div class="crumb-container"> ' . $args['header'] . ' <nav class="crumb"> ' . implode($split, apply_filters('crumb_links', $links)) . ' </nav> ' . $args['footer'] . ' </div>'; }
public static function frontend_css() { if (!theme_cache::is_singular('post') || !self::is_enabled()) { return false; } wp_enqueue_style(__CLASS__, theme_features::get_theme_addons_css(__DIR__), 'frontend', theme_file_timestamp::get_timestamp()); }
private static function is_enabled() { global $post, $numpages; return theme_cache::is_singular() && $numpages > 1; }
public static function template_include($template) { if (!self::is_enabled() || self::get_cat_id() <= 0) { return $template; } if (theme_cache::is_category() && theme_features::get_cat_root_id() == self::get_cat_id()) { return self::get_tpl_include('category'); } else { if (theme_cache::is_singular('post') && theme_features::get_cat_root_id() == self::get_cat_id()) { return self::get_tpl_include('post'); } } return $template; }
public static function theme_body_classes(array $classes = []) { if (theme_cache::is_singular()) { $classes[] = 'singular'; } return $classes; }
private static function can_comment() { static $cache = null; if ($cache === null) { $cache = self::is_enabled() && theme_cache::is_singular() && !post_password_required() && comments_open(); } return $cache; }
/** * get_site_keywords * * @return string * @example * @version 1.0.1 * @copyright Copyright (c) 2011-2013 INN STUDIO. (http://www.inn-studio.com) **/ public static function get_site_keywords() { $all_tags = []; /** * post page */ if (theme_cache::is_singular('post')) { $posttags = get_the_tags(); if (!empty($posttags)) { foreach ($posttags as $v) { $all_tags[] = $v->name; } } /** * other page */ } else { if (!theme_cache::is_home()) { $single_term_title = single_term_title('', false); $all_tags[] = apply_filters('meta_keywords_not_home', $single_term_title); /** * load keywords */ } else { if (self::get_options('keywords')) { $theme_kws = explode(self::$keywords_split, self::get_options('keywords')); if (!empty($theme_kws)) { foreach ($theme_kws as $v) { if (!empty($v)) { $all_tags[] = trim($v); } } } } } } /** * add a hook */ $all_tags = array_filter(apply_filters('meta_keywords', $all_tags)); if (!empty($all_tags)) { echo '<meta name="keywords" content="' . esc_attr(strip_tags(implode(',', $all_tags))) . '">'; } }
public static function frontend_seajs_use() { if (!self::is_enabled() || !theme_cache::is_singular()) { return false; } ?> seajs.use('<?php echo self::$iden; ?> ',function(m){ m.config.process_url = '<?php echo esc_url(theme_features::get_process_url(['action' => self::$iden])); ?> '; m.config.lang.M01 = '<?php echo ___('Loading, please wait...'); ?> '; m.config.lang.E01 = '<?php echo ___('Sorry, server error please try again later.'); ?> '; m.init(); }); <?php }
public static function frontend_js_config(array $config) { if (!theme_cache::is_singular('post')) { return $config; } $config[__CLASS__] = 1; return $config; }
public static function frontend_seajs_use() { if (!theme_cache::is_singular()) { return false; } ?> seajs.use('<?php echo self::$iden; ?> ',function(m){ m.init(); }); <?php }
public static function frontend_seajs_use() { if (!self::is_enabled() || !theme_cache::is_singular()) { return false; } ?> seajs.use('<?php echo self::$iden; ?> ',function(m){ m.config.lang.M01 = '<?php echo ___('Table of content'); ?> '; m.config.lang.M02 = '<?php echo ___('[TOC]'); ?> '; m.init(); }); <?php }
public static function frontend_js_config(array $config) { if (!theme_cache::is_singular('post')) { return $config; } $config[__CLASS__] = ['process_url' => theme_features::get_process_url(['action' => __CLASS__, 'type' => 'incr'])]; return $config; }
public static function frontend_seajs_use() { if (!theme_cache::is_singular('post')) { return false; } ?> seajs.use('<?php echo __CLASS__; ?> ',function(m){ m.init(); }); <?php }
public static function can_show() { static $cache = null; if ($cache === null) { global $post; $cache = theme_cache::is_singular() && !post_password_required() && comments_open(); } return $cache; }