function base_getBreadcrumbs() { if (is_404()) { return false; } // Hack to fix breadcrumbs when you're viewing the news home if (is_home()) { $post = new \Timber\Post(get_option('page_for_posts')); } else { global $post; } $breadcrumbs = []; if ($post->post_parent) { $parent_id = $post->post_parent; while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = new \Timber\Post($page->ID); $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); } // Add 'Blog Home' to breadcrumbs if you're on a news post or archive if ((is_single() || is_archive()) && !is_search()) { $breadcrumbs[] = new \Timber\Post(get_option('page_for_posts')); } return $breadcrumbs; }
function title() { if (is_category()) { echo 'Category Archive for "'; single_cat_title(); echo '" | '; bloginfo('name'); } elseif (is_tag()) { echo 'Tag Archive for "'; single_tag_title(); echo '" | '; bloginfo('name'); } elseif (is_archive()) { wp_title(''); echo ' Archive | '; bloginfo('name'); } elseif (is_search()) { echo 'Search for "' . wp_specialchars($s) . '" | '; bloginfo('name'); } elseif (is_home() || is_front_page()) { bloginfo('name'); echo ' | '; bloginfo('description'); } elseif (is_404()) { echo 'Error 404 Not Found | '; bloginfo('name'); } elseif (is_single()) { wp_title(''); } else { echo wp_title(' | ', false, right); bloginfo('name'); } }
/** * Prints better page title */ function perfect_title() { echo '<title>'; if (function_exists('is_tag') && is_tag()) { single_tag_title(__('Tag Archive for') . '"'); $output .= '" - '; } elseif (is_archive()) { wp_title(''); echo __('Archive') . ' - '; } elseif (is_search()) { echo __('Search for') . '"' . esc_html($s) . '" - '; } elseif (!is_404() && is_single() || is_page()) { wp_title(''); echo ' - '; } elseif (is_404()) { echo __('Not Found') . '-'; } if (is_home()) { bloginfo('name'); echo ' - '; bloginfo('description'); } else { bloginfo('name'); } if ($paged > 1) { echo ' - ' . __('page') . ' ' . $paged; } echo '</title>'; }
function qtranxf_wp_head() { global $q_config; if ($q_config['header_css_on']) { echo '<style type="text/css">' . PHP_EOL . $q_config['header_css'] . '</style>' . PHP_EOL; } do_action('qtranslate_head_add_css'); //not really needed? // skip the rest if 404 if (is_404()) { return; } // set links to translations of current page foreach ($q_config['enabled_languages'] as $lang) { if (!empty($q_config['locale_html'][$lang])) { $hreflang = $q_config['locale_html'][$lang]; } else { $hreflang = $lang; } //if($language != qtranxf_getLanguage())//standard requires them all echo '<link hreflang="' . $hreflang . '" href="' . qtranxf_convertURL('', $lang, false, true) . '" rel="alternate" />' . PHP_EOL; } //https://support.google.com/webmasters/answer/189077 echo '<link hreflang="x-default" href="' . qtranxf_convertURL('', $q_config['default_language']) . '" rel="alternate" />' . PHP_EOL; //qtranxf_add_css();// since 3.2.5 no longer needed }
/** * returns the language based on the queried content * * @since 1.2 * * @return object|bool detected language, false if none was found */ protected function get_language_from_content() { // no language set for 404 if (is_404() || is_attachment() && !$this->options['media_support']) { return $this->get_preferred_language(); } if ($var = get_query_var('lang')) { $lang = explode(',', $var); $lang = $this->model->get_language(reset($lang)); // choose the first queried language } elseif ((is_single() || is_page() || is_attachment() && $this->options['media_support']) && (($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) || ($var = get_query_var('attachment_id')))) { $lang = $this->model->post->get_language($var); } else { foreach ($this->model->get_translated_taxonomies() as $taxonomy) { if ($var = get_query_var(get_taxonomy($taxonomy)->query_var)) { $lang = $this->model->term->get_language($var, $taxonomy); } } } /** * Filter the language before it is set from the content * * @since 0.9 * * @param bool|object $lang language object or false if none was found */ return apply_filters('pll_get_current_language', isset($lang) ? $lang : false); }
function featureText() { if (is_front_page()) { the_field('feature_text'); } elseif (is_home() || is_single()) { _e('Rock Theme Official Blog'); } elseif (is_archive()) { _e('Rock Theme Official Blog'); _e('<br>'); single_term_title('Browsing: '); if (is_month()) { $monthNum = get_query_var('monthnum'); $month = date('F', mktime(0, 0, 0, $monthNum)); $year = get_query_var('year'); echo 'Posts from ' . $month . ' ' . $year; } } elseif (is_page_template('page-news.php') || is_page_template('page-about.php') || is_page_template('page-contact.php')) { bloginfo('name'); _e('<br>'); the_title(); } elseif (is_404()) { _e('Whoops, were a little lost.'); } elseif (is_search()) { _e('Rock Theme Official Blog'); _e('<br>'); printf('Search results for: %s', get_search_query()); } }
function bavota_breadcrumbs() { if (!is_front_page()) { echo '<a href="' . home_url('/') . 'blog">Blog</a><span class="divider"> <i class="icon-angle-right"></i> </span>'; } if (is_category() || is_single()) { $category = get_the_category(); $ID = $category[0]->cat_ID; // echo get_category_parents($ID, TRUE, ' ', FALSE ); // was causing errors in the error_log echo is_wp_error($cat_parents = get_category_parents($ID, TRUE, ' ', FALSE)) ? '' : $cat_parents; } $mytitle = get_the_title(); if (strlen($mytitle) > 22) { $mytitle = substr($mytitle, 0, 38) . "..."; } if (is_single() || is_page()) { echo ' <span class="divider"> <i class="icon-angle-right"></i> </span> '; echo $mytitle; } if (is_tag()) { echo "Tag: " . single_tag_title('', FALSE); } if (is_404()) { echo "404 - Page not Found"; } if (is_search()) { echo "Search"; } if (is_year()) { echo get_the_time('Y'); } }
/** * Custom class for the WP 'body_class()' function * updated: 4/15/10 */ function dbdb_body_classes($classes) { // source http://darrinb.com/notes/2010/customizing-the-wordpress-body_class-function/ global $post; global $wp_query; // if there is no parent ID and it's not a single post page, category page, or 404 page, give it // a class of "parent-page" if ($post->post_parent < 1 && !is_single() && !is_archive() && !is_404()) { $classes[] = 'parent-page'; } // if the page/post has a parent, it's a child, give it a class of its parent name if ($post->post_parent > 0) { /* $parent_title = get_the_title($wp_query->post->post_parent); $parent_title = preg_replace('#\s#','-', $parent_title); $parent_title = strtolower($parent_title); $classes[] = 'parent-pagename-'.$parent_title; */ $parent_id = wp_get_post_parent_id($wp_query->post); // $parent_id = get_the_ID($wp_query->post->post_parent); echo "PARENT ID : " . $parent_id; // $parent_id = preg_replace('#\s#','-', $parent_id); $parent_id = strtolower($parent_id); $classes[] = 'parent-id-' . $parent_id; } // add a class = to the name of post or page $classes[] = $wp_query->queried_object->post_name; return array_unique($classes); }
/** * Filters wp_title to print a neat <title> tag based on what is being viewed. * * @param string $title Default title text for current view. * @param string $sep Optional separator. * @return string The filtered title. */ function cinnamon_wp_title($title, $sep) { /** * If this is version 4.1, directly stop the manual title modification. Let WordPress does that through add_theme_support( 'title-tag' ); */ if (function_exists('_wp_render_title_tag')) { return $title; } if (is_feed()) { return $title; } global $page, $paged; // Add the blog name $title .= get_bloginfo('name', 'display'); // Add the blog description for the home/front page. $site_description = get_bloginfo('description', 'display'); if ($site_description && (is_home() || is_front_page())) { $title .= " {$sep} {$site_description}"; } // Add a page number if necessary: if (($paged >= 2 || $page >= 2) && !is_404()) { $title .= " {$sep} " . sprintf(__('Page %s', 'cinnamon'), max($paged, $page)); } return $title; }
/** * Get the ID for the current post */ private function get_the_ID() { if (is_404()) { return ''; } return get_the_ID(); }
function display($args = array()) { /* Use the generic_content action if it's set. See http://core.trac.wordpress.org/ticket/20509 */ if ($this->get_setting('mode', 'default') == 'default' && has_action('generic_content') && !did_action('generic_content')) { return do_action('generic_content'); } /* Since it's impossible to get the $wp_query in its correct form when loading the content from admin-ajax.php, we will display this notice. */ if (headway_get('ve-live-content-query', $this->block, false) && $this->get_setting('mode', 'default') == 'default') { echo '<div class="alert alert-yellow" style="margin: 5px;"><p><strong>Please note:</strong> What\'s being displayed here in the Content Block may not be correct. When viewing the site outside of the Visual Editor, you will see the correct content.</p></div>'; } /* If LoopBuddy is activated, we'll strictly rely on it for the query setup and how the content is displayed. */ if (class_exists('pluginbuddy_loopbuddy')) { global $pluginbuddy_loopbuddy; $loopbuddy_query = $this->get_setting('loopbuddy-query', -1); $loopbuddy_layout = $this->get_setting('loopbuddy-layout', -1); if (isset($pluginbuddy_loopbuddy) && $loopbuddy_query !== -1) { echo $pluginbuddy_loopbuddy->render_loop($loopbuddy_query, $loopbuddy_layout); $this->remove_hooks(); return; } } /* Display the 404 text if it's a 404 (has to be default behavior) */ if (is_404() && $this->get_setting('mode', 'default') == 'default' && !headway_get('ve-live-content-query', $this->block, false)) { $this->remove_hooks(); return $this->display_404(); } /* Display loop like normal if nothing else fires first */ $this->loop($args); $this->remove_hooks(); wp_reset_query(); }
function mh_page_title() { if (is_home()) { echo get_the_title(get_option('page_for_posts', true)); } elseif (is_author()) { global $author; $user_info = get_userdata($author); echo __('Articles by ', 'mh') . esc_attr($user_info->display_name); } elseif (is_category() || is_tax()) { echo single_cat_title("", false); } elseif (is_tag()) { echo single_tag_title("", false); } elseif (is_search()) { echo __('Search Results for ', 'mh') . get_search_query(); } elseif (is_day()) { echo get_the_date(); } elseif (is_month()) { echo get_the_date('F Y'); } elseif (is_year()) { echo get_the_date('Y'); } elseif (is_404()) { echo __('Page not found (404)', 'mh'); } else { echo get_the_title(); } }
function ubik_seo_meta_description($desc = '') { // Generate a meta description if (empty($desc)) { // Single posts, pages, and attachments if (is_singular()) { $post = get_post(); if (empty($post)) { $desc = ''; } $desc = wptexturize($post->post_content); // Get the entire contents, not the excerpt, so as to not duplicate Ubik Excerpt } // Check to see if we have a description for this category, tag, or taxonomy if (is_category() || is_tag() || is_tax()) { $desc = term_description(); } // Now match other possibilities... if (is_author()) { $desc = get_the_author_meta('description'); } // Front or home page if (is_front_page() || is_home()) { $desc = get_bloginfo('description'); } // No excerpt to return if (is_404() || is_search()) { $desc = ''; } $desc = ubik_seo_meta_description_sanitize($desc); } return apply_filters('ubik_seo_meta_description', $desc); }
/** * Add our own classes to the body_class function * adapted from: http://www.mimoymima.com/2013/01/lab/better-body-class-function-wordpress/ * * @20131220: This in an update to the earlier code, where it was needed to change the call to the body_class. * with the snippet below however that is no longer necessary and as an additional advantage it also keeps the * original WordPress body class which may (or may not) come in handy one day. * * @20140423 adjusted the code to make it more useful */ function so_body_classes($classes) { global $post; // return some of these things if (is_category()) { $classes[] = 'cat-archive'; } elseif (is_search()) { $classes[] = 'search-page'; } elseif (is_tag()) { $classes[] = 'tag-archive'; } elseif (is_home()) { $classes[] = 'home-page'; } elseif (is_404()) { $classes[] = 'error-page'; } // return page-(page name) if (is_page()) { $pn = $post->post_name; $classes[] = 'page-' . $pn; } if (is_page() && $post->post_parent) { $classes[] = 'child-of-' . $parentSlug; } // if WPML has been installed return the language code if (in_array('sitepress-multilingual-cms/sitepress.php', apply_filters('active_plugins', get_option('active_plugins')))) { if (defined('ICL_LANGUAGE_CODE')) { $lang = 'lang-' . ICL_LANGUAGE_CODE; $classes[] = $lang; } } return $classes; }
/** * * Returns the list of classes * * @param $post * @return array * @author Tim Perry */ protected function getBodyClasses($post) { $classes = array(); if (is_single()) { $classes[] = "single"; } else { $classes[] = "page"; } if (is_page()) { $classes[] = 'page--' . $post->post_name; } if (is_404()) { $classes[] = 'page--404'; } elseif (is_front_page()) { $classes[] = 'page--front'; } elseif (is_home()) { $classes[] = 'page--news'; } elseif (is_search()) { $classes[] = 'page--search'; } elseif (is_single() && ($postType = strtolower(str_replace("_", "-", $post->post_type)))) { $classes[] = "single--" . $postType; } if (is_user_logged_in()) { $classes[] = 'has-admin-bar'; } return $classes; }
function fortyfourwp_setTemplate($page_template) { if (is_404()) { $page_template = dirname(__DIR__) . '/views/page-404.php'; } return $page_template; }
function getWpTemplate() { if (defined('WP_USE_THEMES') && WP_USE_THEMES) { $template = false; if (is_404() && ($template = get_404_template())) { } elseif (is_search() && ($template = get_search_template())) { } elseif (is_tax() && ($template = get_taxonomy_template())) { } elseif (is_front_page() && ($template = get_front_page_template())) { } elseif (is_home() && ($template = get_home_template())) { } elseif (is_attachment() && ($template = get_attachment_template())) { } elseif (is_single() && ($template = get_single_template())) { } elseif (is_page() && ($template = get_page_template())) { } elseif (is_category() && ($template = get_category_template())) { } elseif (is_tag() && ($template = get_tag_template())) { } elseif (is_author() && ($template = get_author_template())) { } elseif (is_date() && ($template = get_date_template())) { } elseif (is_archive() && ($template = get_archive_template())) { } elseif (is_comments_popup() && ($template = get_comments_popup_template())) { } elseif (is_paged() && ($template = get_paged_template())) { } else { $template = get_index_template(); } return str_replace(ABSPATH, '', $template); } else { return null; } }
function getPost() { $data = new stdClass(); $categoryId = (int) get_query_var('cat'); if (is_tag()) { $data->post = get_post(ThemeOption::getOption('blog_search_post_id')); $tagQuery = get_query_var('tag'); $tagData = get_tags(array('slug' => $tagQuery)); $data->post->post_title = esc_html($tagData[0]->name); } elseif (is_category($categoryId)) { $category = get_category($categoryId); $data->post = get_post(ThemeOption::getOption('blog_category_post_id')); $data->post->post_title = ThemeHelper::esc_html($category->name); } elseif (is_day()) { $data->post = get_post(ThemeOption::getOption('blog_archive_post_id')); $data->post->post_title = get_the_date(); } elseif (is_archive()) { $data->post = get_post(ThemeOption::getOption('blog_archive_post_id')); $data->post->post_title = single_month_title(' ', false); } elseif (is_search()) { $data->post = get_post(ThemeOption::getOption('blog_search_post_id')); $data->post->post_title = sprintf(__('Search result for phrase <i>%s</i>', THEME_DOMAIN), esc_html(get_query_var('s'))); } elseif (is_404()) { $data->post = get_post(ThemeOption::getOption('page_404_page_id')); $data->post->post_title = $data->post->post_title; } else { return false; } return $data; }
/** * Page titles */ function pinnacle_title() { if (is_home()) { if (get_option('page_for_posts', true)) { return get_the_title(get_option('page_for_posts', true)); } else { return __('Latest Posts', 'pinnacle'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { return $term->name; } elseif (is_post_type_archive()) { return get_queried_object()->labels->name; } elseif (is_day()) { return sprintf(__('Daily Archives: %s', 'pinnacle'), get_the_date()); } elseif (is_month()) { return sprintf(__('Monthly Archives: %s', 'pinnacle'), get_the_date('F Y')); } elseif (is_year()) { return sprintf(__('Yearly Archives: %s', 'pinnacle'), get_the_date('Y')); } elseif (is_author()) { return sprintf(__('Author Archives: %s', 'pinnacle'), get_the_author()); } else { return single_cat_title("", false); } } elseif (is_search()) { return sprintf(__('Search Results for %s', 'pinnacle'), get_search_query()); } elseif (is_404()) { return __('Not Found', 'pinnacle'); } else { return get_the_title(); } }
/** * Display breadcrumbs */ public function display() { if (Habakiri::get('is_displaying_bread_crumb') === 'false') { return; } global $wp_query; // Set to home $home_label = $this->get_home_label(); $this->set($home_label, home_url('/')); // Set to blog $post_type = $this->get_post_type(); if (is_category() || is_tag() || is_date() || is_author() || is_single() && $post_type === 'post') { $show_on_front = get_option('show_on_front'); $page_for_posts = get_option('page_for_posts'); if ($show_on_front === 'page' && $page_for_posts) { $this->set(get_the_title($page_for_posts), get_permalink($page_for_posts)); } } // Set current and ancestors if (is_404()) { $this->set_for_404(); } elseif (is_search()) { $this->set_for_search(); } elseif (is_tax()) { $this->set_for_tax(); } elseif (is_attachment()) { $this->set_for_attachment(); } elseif (is_page() && !is_front_page()) { $this->set_for_page(); } elseif (is_post_type_archive()) { $this->set_for_post_type_archive(); } elseif (is_single()) { $this->set_for_single(); } elseif (is_category()) { $this->set_for_category(); } elseif (is_tag()) { $this->set_for_tag(); } elseif (is_author()) { $this->set_for_author(); } elseif (is_day()) { $this->set_for_day(); } elseif (is_month()) { $this->set_for_month(); } elseif (is_year()) { $this->set_for_year(); } elseif (is_home() && !is_front_page()) { $this->set_for_blog(); } $bread_crumb = array(); $last_item = array_pop($this->bread_crumb); foreach ($this->bread_crumb as $_bread_crumb) { if (!empty($_bread_crumb['link'])) { $bread_crumb[] = sprintf('<a href="%s">%s</a>', esc_url($_bread_crumb['link']), esc_html($_bread_crumb['title'])); } else { $bread_crumb[] = esc_html($_bread_crumb['title']); } } $bread_crumb[] = sprintf('<strong>%s</strong>', $last_item['title']); printf('<div class="breadcrumbs">%s</div>', implode(' > ', apply_filters('habakiri_bread_crumb', $bread_crumb))); }
/** * Page titles */ function roots_title() { if (is_home()) { if (get_option('page_for_posts', true)) { return get_the_title(get_option('page_for_posts', true)); } else { return __('Most Recent Posts', 'roots'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { return apply_filters('single_term_title', $term->name); } elseif (is_post_type_archive()) { return apply_filters('the_title', get_queried_object()->labels->name); } elseif (is_day()) { return sprintf(__('Old Posts, Organized by Day: %s', 'roots'), get_the_date()); } elseif (is_month()) { return sprintf(__('Old Posts, Organized by Month: %s', 'roots'), get_the_date('F Y')); } elseif (is_year()) { return sprintf(__('Old Posts, Organized by Year: %s', 'roots'), get_the_date('Y')); } elseif (is_author()) { $author = get_queried_object(); return sprintf(__('Old Posts, Organized by Author: %s', 'roots'), apply_filters('the_author', is_object($author) ? $author->display_name : null)); } else { return single_cat_title('', false); } } elseif (is_search()) { return sprintf(__('Search Results for %s', 'roots'), get_search_query()); } elseif (is_404()) { return __('Not Found', 'roots'); } else { return get_the_title(); } }
function get_breadcrumbs($post) { echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=" . get_bloginfo('url') . " itemprop=\"url\"><span itemprop=\"title\">Home</span></a><span class=arrow> > </span></li>"; if (is_home()) { $breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_post_title($page->ID) . '</span></a><span class=arrow> > </span></li>'; } elseif (is_single() || is_page()) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . get_the_title($page->ID) . '</span></a><span class=arrow> > </span></li>'; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb) { echo $crumb; } echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><span itemprop=\"title\">" . $post->post_title . "</span></li>"; } elseif (is_category()) { echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_cat_title($page->ID) . '</span></a></li>'; } elseif (is_archive()) { echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">Archives</span></li>'; } elseif (is_404()) { echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">404 Page Not Found</span></li>'; } }
/** * Gets the page type from WordPress. * * @return string A string representation of the current page type, * corresponding to the values used by publisherplugin.google.com. */ public static function getWordPressPageType() { // is_front_page() returns true if (1) a static front page is set and this // is that page, or (2) the front page is the blog home page and this // is the blog home page. if (is_front_page()) { return 'front'; } if (is_home()) { return 'home'; } if (is_single()) { return 'singlePost'; } if (is_page()) { return 'page'; } if (is_category()) { return 'category'; } if (is_archive()) { return 'archive'; } if (is_search()) { return 'search'; } if (is_404()) { return 'errorPage'; } return ''; }
/** * Page titles */ function dw_timeline_title() { if (is_home()) { if (get_option('page_for_posts', true)) { return get_the_title(get_option('page_for_posts', true)); } else { return get_bloginfo('name'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { return apply_filters('single_term_title', $term->name); } elseif (is_post_type_archive()) { return apply_filters('the_title', get_queried_object()->labels->name); } elseif (is_day()) { return sprintf(__('Daily Archives: %s', 'dw-timeline'), get_the_date()); } elseif (is_month()) { return sprintf(__('Monthly Archives: %s', 'dw-timeline'), get_the_date('F Y')); } elseif (is_year()) { return sprintf(__('Yearly Archives: %s', 'dw-timeline'), get_the_date('Y')); } elseif (is_author()) { $author = get_queried_object(); return sprintf(__('Author Archives: %s', 'dw-timeline'), $author->display_name); } else { return single_cat_title('', false); } } elseif (is_search()) { return sprintf(__('Search Results for %s', 'dw-timeline'), get_search_query()); } elseif (is_404()) { return __('Not Found', 'dw-timeline'); } else { return get_the_title(); } }
function qtrans_header() { global $q_config; echo "\n<meta http-equiv=\"Content-Language\" content=\"" . str_replace('_', '-', $q_config['locale'][$q_config['language']]) . "\" />\n"; $css = "<style type=\"text/css\" media=\"screen\">\n"; $css .= ".qtrans_flag span { display:none }\n"; $css .= ".qtrans_flag { height:12px; width:18px; display:block }\n"; $css .= ".qtrans_flag_and_text { padding-left:20px }\n"; $baseurl = WP_CONTENT_URL; if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == '1' || $_SERVER['HTTPS'] == 'on')) { $baseurl = preg_replace('#^http://#', 'https://', $baseurl); } foreach ($q_config['enabled_languages'] as $language) { $css .= ".qtrans_flag_" . $language . " { background:url(" . $baseurl . '/' . $q_config['flag_location'] . $q_config['flag'][$language] . ") no-repeat }\n"; } $css .= "</style>\n"; echo apply_filters('mqtranslate_header_css', $css); // skip the rest if 404 if (is_404()) { return; } // set links to translations of current page foreach ($q_config['enabled_languages'] as $language) { if ($language != qtrans_getLanguage()) { echo '<link hreflang="' . $language . '" href="' . qtrans_convertURL('', $language) . '" rel="alternate" />' . "\n"; } } }
/** * Returns the document title. * * The order (site name first or last) can be set on the Tarski Options page. * While the function ultimately returns a string, please note that filters * are applied to an array! This allows plugins to easily alter any aspect * of the title. For example, one might write a plugin to change the separator. * * @since 1.5 * @deprecated 3.2.0 * * @param string $sep * @return string * * @hook filter tarski_doctitle * Filter document titles. */ function tarski_doctitle($sep = '·') { _deprecated_function('wp_title', '3.2.0'); $site_name = get_bloginfo('name'); $content = trim(wp_title('', false)); if (is_404()) { $content = sprintf(__('Error %s', 'tarski'), '404'); } elseif (get_option('show_on_front') == 'posts' && is_home()) { $content = get_bloginfo('description', 'display'); } elseif (is_search()) { $content = sprintf(__('Search results for %s', 'tarski'), esc_html(get_search_query())); } elseif (is_month()) { $content = single_month_title(' ', false); } elseif (is_tag()) { $content = multiple_tag_titles(); } $elements = strlen($content) > 0 ? array('site_name' => $site_name, 'separator' => $sep, 'content' => $content) : array('site_name' => $site_name); if (get_tarski_option('swap_title_order')) { $elements = array_reverse($elements, true); } // Filters should return an array $elements = apply_filters('tarski_doctitle', $elements); // But if they don't, it won't try to implode if (is_array($elements)) { $doctitle = implode(' ', $elements); } echo $doctitle; }
function porto_page_title() { global $porto_settings; $output = ''; if (!is_front_page()) { } elseif (is_home()) { $output .= $porto_settings['blog-title']; } if (is_singular()) { $output .= porto_page_title_leaf(); } else { if (is_post_type_archive()) { if (is_search()) { $output .= porto_page_title_leaf('search'); } else { $output .= porto_page_title_archive(); } } elseif (is_tax() || is_tag() || is_category()) { $html = porto_page_title_leaf('term'); if (is_tag()) { $output .= sprintf(__('Tag - %s', 'porto'), $html); } elseif (is_tax('product_tag')) { $output .= sprintf(__('Product Tag - %s', 'porto'), $html); } else { $output .= $html; } } elseif (is_date()) { if (is_year()) { $output .= porto_page_title_leaf('year'); } elseif (is_month()) { $output .= porto_page_title_leaf('month'); } elseif (is_day()) { $output .= porto_page_title_leaf('day'); } } elseif (is_author()) { $output .= porto_page_title_leaf('author'); } elseif (is_search()) { $output .= porto_page_title_leaf('search'); } elseif (is_404()) { $output .= porto_page_title_leaf('404'); } elseif (class_exists('bbPress') && is_bbpress()) { if (bbp_is_search()) { $output .= porto_page_title_leaf('bbpress_search'); } elseif (bbp_is_single_user()) { $output .= porto_page_title_leaf('bbpress_user'); } else { $output .= porto_page_title_leaf(); } } else { if (is_home() && !is_front_page()) { if (get_option('show_on_front') == 'page') { $output .= get_the_title(get_option('page_for_posts', true)); } else { $output .= $porto_settings['blog-title']; } } } } return apply_filters('porto_page_title', $output); }
/** * Page titles */ function stachestack_title() { if (is_home()) { if (get_option('page_for_posts', true)) { $title = get_the_title(get_option('page_for_posts', true)); } else { $title = __('Latest Posts', 'stachestack'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { $title = apply_filters('single_term_title', $term->name); } elseif (is_post_type_archive()) { $title = apply_filters('the_title', get_queried_object()->labels->name); } elseif (is_day()) { $title = sprintf(__('Daily Archives: %s', 'stachestack'), get_the_date()); } elseif (is_month()) { $title = sprintf(__('Monthly Archives: %s', 'stachestack'), get_the_date('F Y')); } elseif (is_year()) { $title = sprintf(__('Yearly Archives: %s', 'stachestack'), get_the_date('Y')); } elseif (is_author()) { $title = sprintf(__('Author Archives: %s', 'stachestack'), get_queried_object()->display_name); } else { $title = single_cat_title('', false); } } elseif (is_search()) { $title = sprintf(__('Search Results for %s', 'stachestack'), get_search_query()); } elseif (is_404()) { $title = __('Not Found', 'stachestack'); } else { $title = get_the_title(); } return apply_filters('stachestack_title', $title); }
function bdn_browse_docs() { global $wp_query; if (is_singular() || is_404() || is_admin()) { return false; } if (empty($wp_query->query_vars['post_type'])) { $wp_query->query_vars['post_type'] = array('doc'); $wp_query->query_vars['orderby'] = 'modified'; } if (is_home() && !isset($_GET['all']) && ($default_view = get_user_meta(get_current_user_id(), 'default_view', true))) { if ($default_view == 'default_desk') { $default_desk = (int) get_user_meta(get_current_user_id(), 'default_desk', true); $term = get_term($default_desk, 'desk'); if (!empty($term) && !is_wp_error($term)) { $wp_query->query_vars['desk'] = $term->slug; } } elseif ($default_view == 'user_docs') { $user = wp_get_current_user(); $wp_query->query_vars['author_name'] = $user->user_login; } } if (!empty($_GET['hide-final-published'])) { $wp_query->query_vars['tax_query'][] = array('taxonomy' => 'status', 'field' => 'slug', 'terms' => array('final-published'), 'operator' => 'NOT IN'); } }
function meanthemes_load_js() { wp_register_style('meanmenu', get_template_directory_uri() . '/assets/js/plugins/meanmenu.min.css', array(), '1.0.7', 'screen', 'meanmenu'); wp_register_script('meanmenu', get_template_directory_uri() . '/assets/js/plugins/jquery.meanmenu.min.js', array('jquery'), '2.0.8', true); wp_register_script('jplayer', get_template_directory_uri() . '/assets/js/plugins/jquery.jplayer.min.js', array('jquery'), '1.0.0', true); wp_register_script('flexslider', get_template_directory_uri() . '/assets/js/plugins/jquery.flexslider-min.js', array('jquery'), '1.0.0', true); wp_register_script('slabtext', get_template_directory_uri() . '/assets/js/plugins/jquery.slabtext.min.js', array('jquery'), '2.3', true); wp_register_script('global', get_template_directory_uri() . '/assets/js/plugins/global-plugins.min.js', array('jquery'), MEANTHEMES_THEME_VER, false); wp_register_script('mt-scripts', get_template_directory_uri() . '/assets/js/scripts.min.js', array('jquery', 'global'), MEANTHEMES_THEME_VER, true); if (is_single() || is_archive() || is_search() || is_author() || is_front_page() || is_page_template('t-index.php')) { wp_enqueue_script('jplayer'); wp_enqueue_script('flexslider'); } if (is_home() || is_404()) { wp_enqueue_script('slabtext'); } if (!is_home() || !is_404()) { wp_enqueue_style('webfonts'); } // Check theme options for using a standard menu if (get_theme_mod('use_standard_menu', '0') == '1') { wp_enqueue_style('meanmenu'); wp_enqueue_script('meanmenu'); } // load on all pages wp_enqueue_script('global'); wp_enqueue_script('mt-scripts'); }