/** * Add language tabs to wpseo metabox ( .wpseo-metabox-tabs-div ) */ public static function action__wpseo_tab_content() { /** @global WP_Post $post */ global $post; $type = empty($post) ? '' : $post->post_type; if (WPGlobus::O()->disabled_entity($type)) { return; } $permalink = array(); if ('publish' == $post->post_status) { $permalink['url'] = get_permalink($post->ID); $permalink['action'] = 'complete'; } else { $permalink['url'] = trailingslashit(home_url()); $permalink['action'] = ''; } ?> <div id="wpglobus-wpseo-tabs"> <?php /** * Use span with attributes 'data' for send to js script ids, names elements for which needs to be set new ids, names with language code. */ ?> <span id="wpglobus-wpseo-attr" data-ids="wpseosnippet,wpseosnippet_title,yoast_wpseo_focuskw,focuskwresults,yoast_wpseo_title,yoast_wpseo_title-length-warning,yoast_wpseo_metadesc,yoast_wpseo_metadesc-length,yoast_wpseo_metadesc_notice" data-names="yoast_wpseo_focuskw,yoast_wpseo_title,yoast_wpseo_metadesc" data-qtip="snippetpreviewhelp,focuskwhelp,titlehelp,metadeschelp"> </span> <ul class="wpglobus-wpseo-tabs-list"> <?php $order = 0; foreach (WPGlobus::Config()->open_languages as $language) { ?> <li id="wpseo-link-tab-<?php echo $language; ?> " data-language="<?php echo $language; ?> " data-order="<?php echo $order; ?> " class="wpglobus-wpseo-tab"><a href="#wpseo-tab-<?php echo $language; ?> "><?php echo WPGlobus::Config()->en_language_name[$language]; ?> </a> </li> <?php $order++; } ?> </ul> <?php $metadesc = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true); $wpseotitle = get_post_meta($post->ID, '_yoast_wpseo_title', true); $focuskw = get_post_meta($post->ID, '_yoast_wpseo_focuskw', true); foreach (WPGlobus::Config()->open_languages as $language) { $permalink['url'] = WPGlobus_Utils::localize_url($permalink['url'], $language); $url = apply_filters('wpglobus_wpseo_permalink', $permalink['url'], $language); if ($url != $permalink['url']) { /* We accept that user's filter make complete permalink for draft */ /* @todo maybe need more investigation */ $permalink['action'] = 'complete'; } else { if ('publish' != $post->post_status) { /** * We cannot get post-name-full to make correct url here ( for draft & auto-draft ). We do it in JS * @see var wpseosnippet_url in wpglobus-wpseo-**.js */ $permalink['action'] = ''; } } ?> <div id="wpseo-tab-<?php echo $language; ?> " class="wpglobus-wpseo-general" data-language="<?php echo $language; ?> " data-url-<?php echo $language; ?> ="<?php echo $url; ?> " data-permalink="<?php echo $permalink['action']; ?> " data-metadesc="<?php echo esc_html(WPGlobus_Core::text_filter($metadesc, $language, WPGlobus::RETURN_EMPTY)); ?> " data-wpseotitle="<?php echo esc_html(WPGlobus_Core::text_filter($wpseotitle, $language, WPGlobus::RETURN_EMPTY)); ?> " data-focuskw="<?php echo WPGlobus_Core::text_filter($focuskw, $language, WPGlobus::RETURN_EMPTY); ?> "> </div> <?php } ?> </div> <?php }
/** * @covers WPGlobus_Utils::localize_url */ public function test_localize_url() { /** * Mock object sent as a parameter, because we do now have access to the actual config. * * @var WPGlobus_Config $config */ $config = $this->getMock('WPGlobus_Config'); /** * These languages are enabled */ $config->enabled_languages = array('en', 'ru', 'pt'); /** * This is the current language */ $config->language = 'pt'; /** * This is the default language */ $config->default_language = 'en'; /** * This says "Do not use language code in the default URL" * So, no /en/page/, just /page/ */ $config->hide_default_language = true; /** * Good test cases * * @var string[][] * list($url, $localized_url, $language) */ $good = array(array('/something/', '/something/', 'en'), array('?', '?', 'en'), array('', '/pt', ''), array('/cat/page/', '/pt/cat/page/'), array('', '/ru', 'ru'), array('/', '/ru/', 'ru'), array('/pt/', '/ru/', 'ru'), array('/ru/', '/ru/', 'ru'), array('/de/', '/ru/de/', 'ru'), array('/page/', '/ru/page/', 'ru'), array('/cat/page/', '/ru/cat/page/', 'ru'), array('/cat/page/pt/aaa/', '/ru/cat/page/pt/aaa/', 'ru'), array('?', '/ru?', 'ru'), array('/?', '/ru/?', 'ru'), array('/pt?', '/ru?', 'ru'), array('/ru/?', '/pt/?', 'pt'), array('?a=b', '/ru?a=b', 'ru'), array('/?a=b', '/ru/?a=b', 'ru'), array('/ru/?a=b', '/ru/?a=b', 'ru'), array('/ru/?a=b', '/pt/?a=b', 'pt'), array('/de/?a=b', '/pt/de/?a=b', 'pt'), array('/#hash', '/ru/#hash', 'ru'), array('/ru/#hash', '/pt/#hash', 'pt'), array('#hash', '/ru#hash', 'ru'), array('/#', '/ru/#', 'ru'), array('#', '/ru#', 'ru'), array('/pt#', '/ru#', 'ru'), array('/de#', '/ru/de#', 'ru'), array('/cat/page/pt/aaa/?a=b&c=d#hash', '/ru/cat/page/pt/aaa/?a=b&c=d#hash', 'ru'), array('/rush/', '/pt/rush/', 'pt'), array('/rush', '/pt/rush', 'pt')); /** * Bad test cases * * @var string[][] */ $bad = array(array('/de/', '/ru/', 'ru'), array('/cat/page/pt/aaa/', '/cat/page/ru/aaa/', 'ru')); /** * Various examples of home_url * * @var string[]; */ $homes = array('http://www.example.com/blog', 'http://localhost', 'http://localhost/my-site', 'http://just-name', 'http://just-name/my-site', 'http://127.0.0.1', 'http://127.0.0.1/my-site', 'http://www.example.com', 'http://develop.example.com', 'http://many.dots.in.domain.example.com', 'http://example.com', 'https://www.example.com', 'http://www.example.com/my-site/blog', 'http://dots.here.ac.uk/and.here/wordpress', 'http://www.example.de', 'http://www.example.pt'); foreach ($homes as $home) { self::$option_home = $home; $home_url = get_option('home'); foreach ($good as $_) { list($url, $localized_url, $language) = $_; self::assertEquals($home_url . $localized_url, WPGlobus_Utils::localize_url($home_url . $url, $language, $config), "In language={$language}, {$url} becomes {$localized_url}"); } foreach ($bad as $_) { list($url, $localized_url, $language) = $_; self::assertNotEquals($home_url . $localized_url, WPGlobus_Utils::localize_url($home_url . $url, $language, $config), "In language={$language}, {$url} MUST NOT become {$localized_url}"); } } /** * Checking combinations of `www` - no `www` and http(s) */ self::$option_home = 'http://www.example.com'; self::assertEquals('http://www.example.com/ru/page/', WPGlobus_Utils::localize_url('http://www.example.com/page/', 'ru', $config)); self::assertEquals('http://example.com/ru/page/', WPGlobus_Utils::localize_url('http://example.com/page/', 'ru', $config)); self::$option_home = 'http://example.com'; self::assertEquals('http://www.example.com/ru/page/', WPGlobus_Utils::localize_url('http://www.example.com/page/', 'ru', $config)); self::assertEquals('http://example.com/ru/page/', WPGlobus_Utils::localize_url('http://example.com/page/', 'ru', $config)); self::$option_home = 'https://example.com'; self::assertEquals('http://www.example.com/ru/page/', WPGlobus_Utils::localize_url('http://www.example.com/page/', 'ru', $config)); self::assertEquals('http://example.com/ru/page/', WPGlobus_Utils::localize_url('http://example.com/page/', 'ru', $config)); // A specific case from support forum /** @noinspection SpellCheckingInspection */ self::$option_home = 'http://www.fiskfelagid.is'; $config->default_language = 'en'; $config->enabled_languages = array('en', 'is'); /** @noinspection SpellCheckingInspection */ self::assertEquals('http://www.fiskfelagid.is/is', WPGlobus_Utils::localize_url('http://www.fiskfelagid.is/is', 'is', $config)); }
/** * @since 1.2.3 * @param string $language * @param WPGlobus_Config $config Alternative configuration (i.e. Unit Test mock object) * @return string */ public static function localize_current_url($language = '', WPGlobus_Config $config = null) { $url = apply_filters('wpglobus_pre_localize_current_url', '', $language); if (!$url) { /** * Use the global configuration is alternative not passed */ if (null === $config) { // @codeCoverageIgnoreStart $config = WPGlobus::Config(); } // @codeCoverageIgnoreEnd $url = WPGlobus_Utils::localize_url(WPGlobus_Utils::current_url(), $language, $config); } return $url; }
/** * Add language tabs to wpseo metabox ( .wpseo-metabox-tabs-div ) */ public static function action__wpseo_tab_content() { /** @global WP_Post $post */ global $post; $type = empty($post) ? '' : $post->post_type; if (WPGlobus::O()->disabled_entity($type)) { return; } $permalink = array(); if ('publish' === $post->post_status) { $permalink['url'] = get_permalink($post->ID); $permalink['action'] = 'complete'; } else { $permalink['url'] = trailingslashit(home_url()); $permalink['action'] = ''; } // #wpseo-metabox-tabs /** * Array of id to make multilingual */ $ids = array('wpseo-add-keyword-popup', 'wpseosnippet', 'snippet_preview', 'title_container', 'snippet_title', 'snippet_sitename', 'url_container', 'snippet_citeBase', 'snippet_cite', 'meta_container', 'snippet_meta', 'yoast_wpseo_focuskw_text_input', 'yoast_wpseo_focuskw', 'focuskwresults', 'yoast_wpseo_title', 'yoast_wpseo_metadesc', 'yoast_wpseo_linkdex', 'wpseo-pageanalysis', 'yoast-seo-content-analysis', 'YoastSEO-plugin-loading', 'snippet-editor-title', 'snippet-editor-slug', 'snippet-editor-meta-description'); $names = array('yoast_wpseo_focuskw_text_input', 'yoast_wpseo_focuskw', 'yoast_wpseo_title', 'yoast_wpseo_metadesc', 'yoast_wpseo_linkdex'); $qtip = array('snippetpreviewhelp', 'focuskw_text_inputhelp', 'pageanalysishelp', 'snippetpreview-help', 'focuskw_text_input-help', 'pageanalysis-help', 'snippetpreview-help-toggle', 'focuskw_text_input-help-toggle', 'pageanalysis-help-toggle'); ?> <div id="wpglobus-wpseo-tabs" style="width:90%; float:right;"> <?php /** * Use span with attributes 'data' for send to js script ids, names elements for which needs to be set new ids, names with language code. */ ?> <span id="wpglobus-wpseo-attr" data-ids="<?php echo esc_attr(implode(',', $ids)); ?> " data-names="<?php echo esc_attr(implode(',', $names)); ?> " data-qtip="<?php echo esc_attr(implode(',', $qtip)); ?> "> </span> <ul class="wpglobus-wpseo-tabs-list"> <?php $order = 0; foreach (WPGlobus::Config()->open_languages as $language) { ?> <li id="wpseo-link-tab-<?php echo esc_attr($language); ?> " data-language="<?php echo esc_attr($language); ?> " data-order="<?php echo esc_attr($order); ?> " class="wpglobus-wpseo-tab"><a href="#wpseo-tab-<?php echo $language; ?> "><?php echo esc_attr(WPGlobus::Config()->en_language_name[$language]); ?> </a> </li> <?php $order++; } ?> </ul> <?php /** * Get meta description */ $metadesc = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true); /** * Get title */ $wpseotitle = get_post_meta($post->ID, '_yoast_wpseo_title', true); /** * From Yoast3 focus keyword key is '_yoast_wpseo_focuskw_text_input' */ $focuskw = get_post_meta($post->ID, '_yoast_wpseo_focuskw_text_input', true); /** * make yoast cite base */ list($yoast_permalink) = get_sample_permalink($post->ID); $yoast_permalink = str_replace(array('%pagename%', '%postname%'), '', urldecode($yoast_permalink)); /** * Set cite does not editable by default */ $cite_contenteditable = 'false'; foreach (WPGlobus::Config()->open_languages as $language) { $yoast_cite_base = WPGlobus_Utils::localize_url($yoast_permalink, $language); $yoast_cite_base = str_replace(array('http://', 'https://'), '', $yoast_cite_base); $yoast_cite_base = str_replace('//', '/', $yoast_cite_base); $permalink['url'] = WPGlobus_Utils::localize_url($permalink['url'], $language); $url = apply_filters('wpglobus_wpseo_permalink', $permalink['url'], $language); if ($url !== $permalink['url']) { /* We accept that user's filter make complete permalink for draft */ /* @todo maybe need more investigation */ $permalink['action'] = 'complete'; } else { if ('publish' !== $post->post_status) { /** * We cannot get post-name-full to make correct url here ( for draft & auto-draft ). We do it in JS * @see var wpseosnippet_url in wpglobus-wpseo-**.js */ $permalink['action'] = ''; } } ?> <div id="wpseo-tab-<?php echo $language; ?> " class="wpglobus-wpseo-general" data-language="<?php echo $language; ?> " data-url-<?php echo $language; ?> ="<?php echo esc_attr($url); ?> " data-yoast-cite-base="<?php echo esc_attr($yoast_cite_base); ?> " data-cite-contenteditable="<?php echo esc_attr($cite_contenteditable); ?> " data-permalink="<?php echo esc_attr($permalink['action']); ?> " data-metadesc="<?php echo esc_attr(WPGlobus_Core::text_filter($metadesc, $language, WPGlobus::RETURN_EMPTY)); ?> " data-wpseotitle="<?php echo esc_attr(WPGlobus_Core::text_filter($wpseotitle, $language, WPGlobus::RETURN_EMPTY)); ?> " data-focuskw="<?php echo esc_attr(WPGlobus_Core::text_filter($focuskw, $language, WPGlobus::RETURN_EMPTY)); ?> "> </div> <?php } ?> </div> <?php }
/** * Localize feed url * @since 1.5.3 * * @scope front */ public static function fetch_feed_options($obj) { /** * Filter to disable localize feed url. * @since 1.5.3 * * @param boolean True is value by default. * @param SimplePie object $obj. * @return boolean */ if (apply_filters('wpglobus_localize_feed_url', true, $obj)) { if (!empty($obj->feed_url)) { $obj->feed_url = WPGlobus_Utils::localize_url($obj->feed_url); } } }
/** * Append language switcher dropdown to a navigation menu, which was created with * @see wp_list_pages * * @deprecated from 1.5.8 * * @param string $output The menu HTML string * @return string HTML with appended switcher */ public function on_wp_list_pages($output) { if (apply_filters('wpglobus_filter_wp_list_pages', true)) { return $this->filter__wp_list_pages($output); } /** * WPGlobus Configuration setting in admin. Must be "ON" to process. */ if (!WPGlobus::Config()->selector_wp_list_pages) { return $output; } $current_url = WPGlobus_Utils::current_url(); $current_language = WPGlobus::Config()->language; /** * List of the languages to show in the drop-down. * These are all enabled languages, except for the current one. * The current one will be shown at the top. */ $extra_languages = array_diff(WPGlobus::Config()->enabled_languages, (array) $current_language); /** * Filter extra languages. * Returning array. * @since 1.0.13 * * @param array $extra_languages An array with languages to show in the dropdown. * @param string $current_language The current language. */ $extra_languages = apply_filters('wpglobus_extra_languages', $extra_languages, $current_language); /** * Filter to show dropdown menu or not. * Returning boolean. * @since 1.2.2 * * @param bool * @param WPGlobus_Config */ $dropdown_menu = apply_filters('wpglobus_dropdown_menu', true, WPGlobus::Config()); /** * Build the top-level menu link */ $language = $current_language; $url = WPGlobus_Utils::localize_url($current_url, $language); $flag_name = $this->_get_flag_name($language); $span_classes_lang = $this->_get_language_classes($language); $link_text = '<span class="' . implode(' ', $span_classes_lang) . '">' . esc_html($flag_name) . '</span>'; $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url($url) . '">' . $link_text . '</a>'; if ($dropdown_menu) { $output .= '<li class="page_item page_item_wpglobus_menu_switch page_item_has_children wpglobus-current-language page_item_wpglobus_menu_switch_' . $language . '">' . $a_tag . '<ul class="children">'; foreach ($extra_languages as $language) { /** * Build the drop-down menu links for extra language */ $url = WPGlobus_Utils::localize_current_url($language); $flag_name = $this->_get_flag_name($language); $span_classes_lang = $this->_get_language_classes($language); $link_text = '<span class="' . implode(' ', $span_classes_lang) . '">' . esc_html($flag_name) . '</span>'; $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url($url) . '">' . $link_text . '</a>'; $output .= '<li class="page_item page_item_wpglobus_menu_switch_' . $language . '">' . $a_tag . '</li>'; } $output .= '</ul>' . '</li>'; } else { $output .= '<li class="page_item page_item_wpglobus_menu_switch wpglobus-current-language page_item_wpglobus_menu_switch_' . $language . '">' . $a_tag . '</li>'; foreach ($extra_languages as $language) { /** * Build the top-level menu link for extra language */ // $url = WPGlobus_Utils::localize_url( $current_url, $language ); $url = WPGlobus_Utils::localize_current_url($language); $flag_name = $this->_get_flag_name($language); $span_classes_lang = $this->_get_language_classes($language); $link_text = '<span class="' . implode(' ', $span_classes_lang) . '">' . esc_html($flag_name) . '</span>'; $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url($url) . '">' . $link_text . '</a>'; $output .= '<li class="page_item page_item_wpglobus_menu_switch page_item_wpglobus_menu_switch_' . $language . '">' . $a_tag . '</li>'; } } // $dropdown_menu return $output; }
function on_admin_footer() { global $post; $permalink = array(); $permalink['url'] = get_permalink($post->ID); $permalink['action'] = 'complete'; $fields = array(); /** * Keywords */ $fields['aiosp_keywords']['opts'] = array('name' => __('Keywords (comma separated)', 'all_in_one_seo_pack'), 'type' => 'text', 'label' => '', 'help_text' => __('A comma separated list of your most important keywords for this page that will be written as META keywords.', 'all_in_one_seo_pack')); $fields['aiosp_keywords']['opts']['help_text'] .= '<br /><a target="_blank" href="http://semperplugins.com/sections/postpage-settings/">Click here for documentation on this setting</a>'; $fields['aiosp_keywords']['args'] = array('name' => 'aiosp_keywords', 'attr' => 'placeholder="{{placeholder}}"', 'data' => '', 'classes' => 'class="wpglobus-aioseop_keywords"', 'value' => '', 'prefix' => '', 'options' => $fields['aiosp_keywords']['opts']); /** * Description */ $fields['aiosp_description']['opts'] = array('name' => __('Description', 'all_in_one_seo_pack'), 'type' => 'textarea', 'count' => true, 'cols' => 80, 'rows' => 2, 'label' => '', 'help_text' => __('The META description for this page. This will override any autogenerated descriptions.', 'all_in_one_seo_pack'), 'placeholder' => ''); $fields['aiosp_description']['opts']['help_text'] .= '<br /><a target="_blank" href="http://semperplugins.com/sections/postpage-settings/">Click here for documentation on this setting</a>'; $fields['aiosp_description']['args'] = array('name' => 'aiosp_description', 'attr' => 'placeholder="{{placeholder}}"', 'data' => ' data-max-size="160" ', 'classes' => 'class="wpglobus_countable wpglobus-aioseop_description"', 'value' => '', 'prefix' => 'wpglobus_', 'suffix' => '', 'options' => $fields['aiosp_description']['opts']); /** * Title */ $fields['aiosp_title']['opts'] = array('name' => __('Title', 'all_in_one_seo_pack'), 'type' => 'text', 'count' => true, 'size' => 60, 'help_text' => __('A custom title that shows up in the title tag for this page.', 'all_in_one_seo_pack'), 'default' => '', 'initial_options' => '', 'nowrap' => '', 'label' => '', 'save' => true, 'placeholder' => ''); $fields['aiosp_title']['opts']['help_text'] .= '<br /><a target="_blank" href="http://semperplugins.com/sections/postpage-settings/">Click here for documentation on this setting</a>'; $fields['aiosp_title']['args'] = array('name' => 'aiosp_title_{{language}}', 'attr' => 'size="60" placeholder="{{placeholder}}"', 'data' => ' data-max-size="60" ', 'classes' => 'class="wpglobus_countable wpglobus-aioseop_title"', 'value' => '', 'prefix' => 'wpglobus_', 'suffix' => '', 'options' => $fields['aiosp_title']['opts']); /** * Snippet must be last in array */ $fields['aiosp_snippet']['opts'] = array('name' => __('Preview Snippet', 'all_in_one_seo_pack'), 'type' => 'html', 'label' => 'top', 'help_text' => __('A preview of what this page might look like in search engine results.', 'all_in_one_seo_pack'), 'nowrap' => 1, 'save' => true, 'prefix' => ''); $fields['aiosp_snippet']['opts']['help_text'] .= '<br /><a target="_blank" href="http://semperplugins.com/sections/postpage-settings/">Click here for documentation on this setting</a>'; $fields['aiosp_snippet']['args'] = array('name' => 'aiosp_snippet', 'attr' => '', 'classes' => 'wpglobus-aioseop_snippet', 'data' => '', 'value' => '<div class="preview_snippet"> <div id="aioseop_snippet_{{language}}" data-extra-length="{{extra_length}}"> <h3{{header_style}}><a{{link_style}}><span id="aioseop_snippet_title_{{language}}">%s</span>%s</a></h3> <div> <div> <cite{{cite_style}} id="aioseop_snippet_link_{{language}}">%s</cite> </div> <span id="aioseop_snippet_description_{{language}}">%s</span> </div> </div> </div> ', 'prefix' => '', 'options' => $fields['aiosp_snippet']['opts']); $aio = new WPGlobus_All_in_One_SEO(); /** * @todo check url */ $permalink = array(); if ('publish' == $post->post_status) { $permalink['url'] = get_permalink($post->ID); $permalink['action'] = 'complete'; } else { $permalink['url'] = trailingslashit(home_url()); $permalink['action'] = ''; } /** * get keywords for current post * use original function for compatibility * * "All In One SEO Pack" may to add keywords in addition to any keywords you specify on the Edit Post screen. * @see options in Keyword Settings metabox on General Settings page. */ $keywords = $aio->get_all_keywords(); $keywords = explode(',', $keywords); global $wpdb; //$keywords_source = array(); foreach ($keywords as $keyword) { $keyword = trim($keyword); if (empty($keyword)) { $keywords_source[$keyword] = ''; } else { $name = $wpdb->get_var("SELECT name FROM {$wpdb->terms} WHERE name LIKE '%{$keyword}%'"); if (empty($name)) { $keywords_source[$keyword] = ''; } else { $keywords_source[$keyword] = $name; } } } $aioseop_options = aioseop_get_options(); switch ($post->post_type) { case 'post': $title_format = $aioseop_options['aiosp_post_title_format']; $title_format = explode(' ', preg_replace('/\\s+/', ' ', $title_format)); break; default: $title_format = ''; } /** * Get meta title in current language ( WPGlobus::Config()->language ) * in $aioseop_options['aiosp_post_title_format'] format, usual as %post_title% | %blog_title% * Title will be like to "New Post for All in one Seo Pack | WPGlobus" without language marks */ $aiosp_meta_title = $aio->get_aioseop_title($post); if (isset($title_format[1])) { $aiosp_meta_title = explode($title_format[1], $aiosp_meta_title); $aiosp_meta_title = $aiosp_meta_title[0]; } $aiosp_meta_title_source = get_post_meta($post->ID, "_aioseop_title", true); $aiosp_meta_title_source = trim($aiosp_meta_title_source); if (!WPGlobus_Core::text_filter($aiosp_meta_title_source, WPGlobus::Config()->default_language)) { /** * Reset meta title for default language */ $aiosp_meta_title = ''; } /** * Get meta description in current language ( WPGlobus::Config()->language ) with $aio->get_post_description($post) * @see 'localization' filter in wpglobus-controller.php */ // $aiosp_post_description = $aio->get_post_description($post); /** * but we need description with language marks */ $aiosp_meta_description_source = $aiosp_post_description = get_post_meta($post->ID, "_aioseop_description", true); $aiosp_meta_description_source = trim($aiosp_meta_description_source); /** * Get keywords /// title in current language ( WPGlobus::Config()->language ) */ $aiosp_keywords_source = get_post_meta($post->ID, "_aioseop_keywords", true); $header_style = ' style="padding:8px 0;"'; $link_style = ' style="color:#12c;cursor: pointer;text-decoration: -moz-use-text-color none solid;font-size:16px;"'; $cite_style = ' style="color:#093;font-style:normal;"'; ?> <div id="wpglobus-aioseop-tabs" class="hidden wpglobus-hidden"> <ul class="wpglobus-aioseop-tabs-list"> <?php $order = 0; foreach (WPGlobus::Config()->enabled_languages as $language) { ?> <li id="aioseop-link-tab-<?php echo $language; ?> " data-language="<?php echo $language; ?> " data-order="<?php echo $order; ?> " class="wpglobus-aioseop-tab"><a href="#aioseop-tab-<?php echo $language; ?> "><?php echo WPGlobus::Config()->en_language_name[$language]; ?> </a> </li> <?php $order++; } ?> </ul> <div style="clear:both;margin-bottom:20px;"></div><?php foreach (WPGlobus::Config()->enabled_languages as $language) { if ($language == WPGlobus::Config()->default_language) { $return = WPGlobus::RETURN_IN_DEFAULT_LANGUAGE; if ($language == WPGlobus::Config()->language) { $aiosp_title = trim(WPGlobus_Core::text_filter($aiosp_meta_title, $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE)); } else { /** * Get title from source ( post meta key '_aioseop_title' ) */ $aiosp_title = trim(WPGlobus_Core::text_filter($aiosp_meta_title_source, $language, WPGlobus::RETURN_EMPTY)); } } else { $return = WPGlobus::RETURN_EMPTY; $aiosp_title = trim(WPGlobus_Core::text_filter($aiosp_meta_title, $language, WPGlobus::RETURN_EMPTY)); if (empty($aiosp_title)) { /** * Get title from source ( post meta key '_aioseop_title' ) */ $aiosp_title = trim(WPGlobus_Core::text_filter($aiosp_meta_title_source, $language, WPGlobus::RETURN_EMPTY)); } } $url = WPGlobus_Utils::localize_url($permalink['url'], $language); /** * Set snippet title */ $aiosp_placeholder_title = WPGlobus_Core::text_filter($post->post_title, $language, $return); $aiosp_snippet_title = empty($aiosp_title) ? $aiosp_placeholder_title : $aiosp_title; /** * Set meta description */ $aiosp_meta_description = WPGlobus_Core::text_filter($aiosp_meta_description_source, $language, $return); if (empty($aiosp_meta_description)) { $description = ''; if (empty($aioseop_options["aiosp_skip_excerpt"])) { $description = $aio->trim_excerpt_without_filters_full_length(WPGlobus_Core::text_filter($post->post_excerpt, $language, WPGlobus::RETURN_EMPTY)); } if (!$description && $aioseop_options["aiosp_generate_descriptions"]) { $content = WPGlobus_Core::text_filter($post->post_content, $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE); if (!empty($aioseop_options["aiosp_run_shortcodes"])) { $content = do_shortcode($content); } $content = wp_strip_all_tags($content); $description = $aio->trim_excerpt_without_filters($content); } $aiosp_description = ''; $aiosp_placeholder_description = $description; $aiosp_snippet_description = $aiosp_placeholder_description; } else { $aiosp_description = WPGlobus_Core::text_filter($aiosp_post_description, $language, $return); $aiosp_placeholder_description = $aiosp_description; $aiosp_snippet_description = $aiosp_description; } /** * Make All in one Seo Pack tabs */ ?> <div id="aioseop-tab-<?php echo $language; ?> " class="wpglobus-aioseop-general" data-language="<?php echo $language; ?> " data-url-<?php echo $language; ?> ="<?php echo $url; ?> "> <?php $r = ''; foreach ($fields as $name => $data) { if ('aiosp_snippet' == $name) { $snippet_title_2 = ''; if (isset($title_format[2]) && false !== strpos($title_format[2], '%blog_title%')) { $snippet_title_2 = ' ' . $title_format[1] . ' ' . WPGlobus_Core::text_filter(get_option('blogname'), $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE); } $data['args']['value'] = str_replace('{{language}}', $language, $data['args']['value']); $data['args']['value'] = str_replace('{{header_style}}', $header_style, $data['args']['value']); $data['args']['value'] = str_replace('{{link_style}}', $link_style, $data['args']['value']); $data['args']['value'] = str_replace('{{cite_style}}', $cite_style, $data['args']['value']); $data['args']['value'] = sprintf($data['args']['value'], $aiosp_snippet_title, $snippet_title_2, WPGlobus_Utils::localize_url($permalink['url'], $language), $aiosp_snippet_description); $data['args']['value'] = str_replace('{{extra_length}}', mb_strlen($snippet_title_2), $data['args']['value']); } else { if ('aiosp_title' == $name) { $data['args']['name'] = str_replace('{{language}}', $language, $data['args']['name']); $data['args']['attr'] = str_replace('{{placeholder}}', $aiosp_placeholder_title, $data['args']['attr']); $data['args']['prefix'] = 'wpglobus_title_'; $data['args']['suffix'] = '_' . $language; $data['args']['data'] = $data['args']['data'] . ' data-field-count="wpglobus_title_length_' . $language . '" data-extra-element="aioseop_snippet_' . $language . '" data-language="' . $language . '"'; $data['args']['value'] = $aiosp_title; } else { if ('aiosp_description' == $name) { $data['args']['attr'] = str_replace('{{placeholder}}', $aiosp_placeholder_description, $data['args']['attr']); $data['args']['prefix'] = 'wpglobus_description_'; $data['args']['suffix'] = '_' . $language; $data['args']['name'] = $data['args']['name'] . '_' . $language; $data['args']['data'] = $data['args']['data'] . ' data-field-count="wpglobus_description_length_' . $language . '" data-language="' . $language . '"'; $data['args']['value'] = $aiosp_description; } else { if ('aiosp_keywords' == $name) { $placeholders = array(); foreach ($keywords as $keyword) { if (empty($keywords_source[$keyword])) { continue; } /** * @todo maybe better use WPGlobus::RETURN_EMPTY, in this case we will be have tags in native language only */ $placeholders[] = WPGlobus_Core::text_filter($keywords_source[$keyword], $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE); } $placeholder = implode(',', $placeholders); $data['args']['attr'] = str_replace('{{placeholder}}', $placeholder, $data['args']['attr']); $data['args']['data'] = ' data-language="' . $language . '" '; $data['args']['name'] = $data['args']['name'] . '_' . $language; $data['args']['data'] = ' data-language="' . $language . '" '; $data['args']['value'] = WPGlobus_Core::text_filter($aiosp_keywords_source, $language, WPGlobus::RETURN_EMPTY); } } } } $r = $aio->wpg_get_option_row($name, $data['opts'], $data['args'], $language) . $r; } echo $r; ?> </div> <!-- .wpglobus-aioseop-general --> <?php } // end foreach ?> <!-- <hr /> --> </div> <!-- #wpglobus-aioseop-tabs --> <?php }
/** * Localize home_url * Should be processed on: * - front * - AJAX, except for several specific actions * * @param string $url * * @return string */ public static function filter__home_url($url) { /** * @internal note * Example of URL in admin: * When admin interface is not in default language, we still should not see * any permalinks with language prefixes. * For that, we could check if we are at the 'post.php' screen: * if ( 'post.php' == $pagenow ) .... * However, we do not need it, because we disallowed almost any processing in admin. */ /** * 1. Do not work in admin */ $need_to_process = !is_admin(); if (WPGlobus_WP::is_pagenow('admin-ajax.php')) { /** * 2. But work in AJAX, which is also admin */ $need_to_process = true; /** * 3. However, don't convert url for these AJAX actions: */ if (WPGlobus_WP::is_http_post_action(array('heartbeat', 'sample-permalink', 'add-menu-item'))) { $need_to_process = false; } } if ($need_to_process) { $url = WPGlobus_Utils::localize_url($url); } return $url; }