/** * Function that sets page's title. Hooks to wp_title filter * @param $title string current page title * @param $sep string title separator * @return string changed title text if SEO plugins aren't installed * * @since 5.0 * @version 0.3 */ function qode_wp_title($title, $sep) { global $qode_options_proya; //is SEO plugin installed? if (qode_seo_plugin_installed()) { //don't do anything, seo plugin will take care of it } else { //get current post id $id = get_queried_object_id(); $sep = ' | '; $title_prefix = get_bloginfo('name'); $title_suffix = ''; //is WooCommerce installed and is current page shop page? if (qode_is_woocommerce_installed() && qode_is_woocommerce_shop()) { //get shop page id $id = qode_get_woo_shop_page_id(); } //set unchanged title variable so we can use it later $unchanged_title = $title; //is qode seo enabled? if (isset($qode_options_proya['disable_qode_seo']) && $qode_options_proya['disable_qode_seo'] !== 'yes') { //get current post seo title $seo_title = get_post_meta($id, "qode_seo_title", true); //is current post seo title set? if ($seo_title !== '') { $title_suffix = $seo_title; } } //title suffix is empty, which means that it wasn't set by qode seo if (empty($title_suffix)) { //if current page is front page append site description, else take original title string $title_suffix = is_front_page() ? get_bloginfo('description') : $unchanged_title; } //concatenate title string $title = $title_prefix . $sep . $title_suffix; //return generated title string return $title; } }
/** * Function that returns current page / post id. * Checks if current page is woocommerce page and returns that id if it is. * Checks if current page is any archive page (category, tag, date, author etc.) and returns -1 because that isn't * page that is created in WP admin. * * @return int * * @version 0.1 * * @see qode_is_woocommerce_installed() * @see qode_is_woocommerce_shop() */ function qode_get_page_id() { if (qode_is_woocommerce_installed() && (qode_is_woocommerce_shop() || is_singular('product'))) { return qode_get_woo_shop_page_id(); } if (is_archive() || is_404() || is_search()) { return -1; } return get_queried_object_id(); }
/** * Function that returns current page / post id. * Checks if current page is woocommerce page and returns that id if it is. * Checks if current page is any archive page (category, tag, date, author etc.) and returns -1 because that isn't * page that is created in WP admin. * * @return int * * @version 0.1 * * @see qode_is_woocommerce_installed() * @see qode_is_woocommerce_shop() */ function qode_get_page_id() { if (qode_is_woocommerce_installed() && qode_is_woocommerce_shop()) { return qode_get_woo_shop_page_id(); } if (is_archive()) { return -1; } return get_queried_object_id(); }