/**
  * Filter a string to check translations for URL.
  * // We build multilingual URLs in customizer using the ':::' delimiter.
  * We build multilingual URLs in customizer using the '|||' delimiter.
  * See wpglobus-customize-control.js
  *
  * @note  To work correctly, value of $url should begin with URL for default language.
  * @see   esc_url() - the 'clean_url' filter
  * @since 1.3.0
  *
  * @param string $url          The cleaned URL.
  * @param string $original_url The URL prior to cleaning.
  *
  * @return string
  */
 public static function filter__clean_url($url, $original_url)
 {
     if (false !== strpos($original_url, '|||')) {
         $arr1 = array();
         $arr = explode('|||', $original_url);
         foreach ($arr as $k => $val) {
             // Note: 'null' is a string, not real `null`.
             if ('null' !== $val) {
                 $arr1[WPGlobus::Config()->enabled_languages[$k]] = $val;
             }
         }
         return WPGlobus_Utils::build_multilingual_string($arr1);
     }
     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'] = '';
        }
        ?>

		<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 
    }
 /**
  * @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;
 }
Exemplo n.º 4
0
 public function setSections()
 {
     $config = WPGlobus::Config();
     /** @var array $wpglobus_option */
     $wpglobus_option = get_option($config->option);
     $fields_home = array();
     /**
      * Display warning if an old Redux is loaded
      *
      * @see  ReduxFrameworkInstances::get_all_instances()
      */
     /** @noinspection PhpUndefinedClassInspection */
     if (version_compare(ReduxFramework::$_version, WPGlobus::$minimalReduxFramework_version) < 0) {
         /** @noinspection PhpUndefinedClassInspection */
         $fields_home[] = array('id' => 'version_warning', 'type' => 'wpglobus_info', 'title' => esc_html__('WARNING: old version of the ReduxFramework is active!', 'wpglobus'), 'desc' => '</br>' . sprintf(esc_html__('WPGlobus settings panel requires ReduxFramework %1$s or later.'), WPGlobus::$minimalReduxFramework_version) . '</br>' . '</br>' . sprintf(esc_html__('The currently active ReduxFramework (version %1$s) was loaded from the %2$s folder.', 'wpglobus'), ReduxFramework::$_version, '<code>' . ReduxFramework::$_dir . '</code>') . '</br>' . '</br>' . '<strong>' . sprintf(esc_html__('We recommend you to install the most recent version of the ReduxFramework plugin: %1$s.', 'wpglobus'), '<a href="https://wordpress.org/plugins/redux-framework/">https://wordpress.org/plugins/redux-framework/</a>') . '</strong>', 'style' => 'critical', 'notice' => false);
     }
     /**
      * The Welcome message
      */
     $fields_home[] = array('id' => 'welcome_intro', 'type' => 'wpglobus_info', 'title' => __('Thank you for installing WPGlobus!', 'wpglobus'), 'desc' => '' . '<br/>' . '&bull; ' . '<a href="' . admin_url() . 'admin.php?page=' . WPGlobus::PAGE_WPGLOBUS_ABOUT . '">' . __('Read About WPGlobus', 'wpglobus') . '</a>' . '<br/>' . '&bull; ' . __('Click the <strong>[Languages]</strong> tab at the left to setup the options.', 'wpglobus') . '<br/>' . '&bull; ' . __('Use the <strong>[Languages Table]</strong> section to add a new language or to edit the language attributes: name, code, flag icon, etc.', 'wpglobus') . '<br/>' . '<br/>' . __('Should you have any questions or comments, please do not hesitate to contact us.', 'wpglobus') . '<br/>' . '<br/>' . '<em>' . __('Sincerely Yours,', 'wpglobus') . '<br/>' . __('The WPGlobus Team', 'wpglobus') . '</em>' . '', 'style' => 'info', 'notice' => false);
     /**
      * For Google Analytics
      */
     $ga_campaign = '?utm_source=wpglobus-admin-clean&utm_medium=link&utm_campaign=talk-to-us';
     $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
     $url_wpglobus_site_submit_ticket = $url_wpglobus_site . 'support/submit-ticket/' . $ga_campaign;
     $fields_home[] = array('id' => 'wpglobus_clean', 'type' => 'wpglobus_info', 'title' => __('Deactivating / Uninstalling', 'wpglobus'), 'desc' => '' . '<p><em>' . sprintf(esc_html(__('We would hate to see you go. If something goes wrong, do not uninstall WPGlobus yet. Please %1$stalk to us%2$s and let us help!', 'wpglobus')), '<a href="' . $url_wpglobus_site_submit_ticket . '" target="_blank">', '</a>') . '</em></p>' . '<hr/>' . '<p><i class="el el-exclamation-sign" style="color:red"></i> <strong>' . esc_html(__('Please note that if you deactivate WPGlobus, your site will show all the languages together, mixed up. You will need to remove all translations, keeping only one language.', 'wpglobus')) . '</strong></p>' . '<p>' . sprintf(__('If there are just a few places, you should edit them manually. To automatically remove all translations at once, you can use the %s. WARNING: The clean-up operation is irreversible, so use it only if you need to completely uninstall WPGlobus.', 'wpglobus'), sprintf(__('%1$sClean-up Tool%2$s', 'wpglobus'), '<a href="' . admin_url() . 'admin.php?page=' . WPGlobus::PAGE_WPGLOBUS_CLEAN . '">', '</a>')) . '</p>' . '', 'style' => 'normal', 'notice' => false);
     $this->sections[] = array('wpglobus_id' => 'welcome', 'title' => __('Welcome!', 'wpglobus'), 'icon' => 'el-icon-globe', 'fields' => $fields_home);
     /*
      * SECTION: languages
      */
     /** @var array $enabled_languages contains all enabled languages */
     $enabled_languages = array();
     /** @var array $defaults_for_enabled_languages Need for the sortable field setup */
     $defaults_for_enabled_languages = array();
     /** @var array $more_languages */
     $more_languages = array();
     foreach ($config->enabled_languages as $code) {
         $lang_in_en = '';
         if (isset($config->en_language_name[$code]) && !empty($config->en_language_name[$code])) {
             $lang_in_en = ' (' . $config->en_language_name[$code] . ')';
         }
         $enabled_languages[$code] = $config->language_name[$code] . $lang_in_en;
         $defaults_for_enabled_languages[$code] = true;
     }
     /** Add language from 'more_language' option to array $enabled_languages */
     if (isset($wpglobus_option['more_languages']) && !empty($wpglobus_option['more_languages'])) {
         $lang = $wpglobus_option['more_languages'];
         $lang_in_en = '';
         if (isset($config->en_language_name[$lang]) && !empty($config->en_language_name[$lang])) {
             $lang_in_en = ' (' . $config->en_language_name[$lang] . ')';
         }
         $enabled_languages[$lang] = $config->language_name[$lang] . $lang_in_en;
         $wpglobus_option['enabled_languages'][$wpglobus_option['more_languages']] = $config->language_name[$wpglobus_option['more_languages']];
         update_option($config->option, $wpglobus_option);
     }
     /** Generate array $more_languages */
     foreach ($config->flag as $code => $file) {
         if (!array_key_exists($code, $enabled_languages)) {
             $lang_in_en = '';
             if (isset($config->en_language_name[$code]) && !empty($config->en_language_name[$code])) {
                 $lang_in_en = ' (' . $config->en_language_name[$code] . ')';
             }
             $more_languages[$code] = $config->language_name[$code] . $lang_in_en;
         }
     }
     /*
      * for miniGLOBUS
      */
     if (empty($this->menus)) {
         $navigation_menu_placeholder = __('No navigation menu', 'wpglobus');
     } else {
         $navigation_menu_placeholder = __('Select navigation menu', 'wpglobus');
     }
     $desc_languages_intro = implode('', array('<ul style="list-style: disc; list-style-position: inside;">', '<li>' . sprintf(__('Place the <strong>main language</strong> of your site at the top of the list by dragging the %s icons.', 'wpglobus'), '<i class="el el-move icon-large"></i>') . '</li>', '<li>' . __('<strong>Uncheck</strong> the languages you do not plan to use.', 'wpglobus') . '</li>', '<li>' . __('<strong>Add</strong> more languages using the section below.', 'wpglobus') . '</li>', '<li>' . __('When done, click the [Save Changes] button.', 'wpglobus') . '</li>', '</ul>'));
     $desc_more_languages = __('Choose a language you would like to enable. <br>Press the [Save Changes] button to confirm.', 'wpglobus') . '<br /><br />';
     // translators: %1$s and %2$s - placeholders to insert HTML link around 'here'
     $desc_more_languages .= sprintf(__('or Add new Language %1$s here %2$s', 'wpglobus'), '<a href="?page=wpglobus_language_edit&action=add">', '</a>');
     $this->sections[] = array('wpglobus_id' => 'languages', 'title' => esc_html__('Languages', 'wpglobus'), 'icon' => 'el-icon-wrench-alt', 'fields' => array(array('id' => 'languages_intro', 'type' => 'wpglobus_info', 'title' => esc_html__('Instructions:', 'wpglobus'), 'subtitle' => esc_html__('NOTE: you cannot remove the main language.', 'wpglobus'), 'desc' => $desc_languages_intro, 'style' => 'info', 'notice' => false), array('id' => 'enabled_languages', 'type' => 'wpglobus_sortable', 'title' => __('Enabled Languages', 'wpglobus'), 'compiler' => 'false', 'subtitle' => __('These languages are currently enabled on your site.', 'wpglobus'), 'options' => $enabled_languages, 'default' => $defaults_for_enabled_languages, 'mode' => 'checkbox'), array('id' => 'more_languages', 'type' => 'wpglobus_select', 'title' => __('Add Languages', 'wpglobus'), 'compiler' => 'false', 'mode' => false, 'desc' => $desc_more_languages, 'placeholder' => __('Select a language', 'wpglobus'), 'options' => $more_languages), array('id' => 'show_flag_name', 'type' => 'wpglobus_select', 'title' => __('Language Selector Mode', 'wpglobus'), 'compiler' => 'false', 'mode' => false, 'desc' => __('Choose the way language name and country flag are shown in the drop-down menu', 'wpglobus'), 'select2' => array('allowClear' => false, 'minimumResultsForSearch' => -1), 'options' => array('code' => __('Two-letter Code with flag (en, ru, it, etc.)', 'wpglobus'), 'full_name' => __('Full Name (English, Russian, Italian, etc.)', 'wpglobus'), 'name' => __('Full Name with flag (English, Russian, Italian, etc.)', 'wpglobus'), 'empty' => __('Flags only', 'wpglobus')), 'default' => 'code'), array('id' => 'use_nav_menu', 'type' => 'wpglobus_select', 'title' => __('Language Selector Menu', 'wpglobus'), 'compiler' => 'false', 'mode' => false, 'desc' => __('Choose the navigation menu where the language selector will be shown', 'wpglobus'), 'select2' => array('allowClear' => true, 'minimumResultsForSearch' => -1), 'options' => $this->menus, 'placeholder' => $navigation_menu_placeholder), array('id' => 'selector_wp_list_pages', 'type' => 'wpglobus_checkbox', 'title' => __('"All Pages" menus Language selector', 'wpglobus'), 'subtitle' => __('(Found in some themes)', 'wpglobus'), 'desc' => __('Adds language selector to the menus that automatically list all existing pages (using `wp_list_pages`)', 'wpglobus'), 'compiler' => 'false', 'default' => 1, 'options' => array('show_selector' => __('Enable', 'wpglobus'))), array('id' => 'css_editor', 'type' => 'wpglobus_ace_editor', 'title' => __('Custom CSS', 'wpglobus'), 'mode' => 'css', 'theme' => 'chrome', 'compiler' => 'false', 'desc' => __('Here you can enter the CSS rules to adjust the language selector menu for your theme. Look at the examples in the `style-samples.css` file.', 'wpglobus'), 'subtitle' => __('(Optional)', 'wpglobus'), 'default' => '', 'rows' => 15)));
     /*
      *	SECTION: Language table
      */
     $this->sections[] = array('wpglobus_id' => 'language_table', 'title' => __('Languages table', 'wpglobus'), 'icon' => 'el-icon-th-list', 'fields' => array(array('id' => 'description', 'type' => 'wpglobus_info', 'title' => __('Use this table to add, edit or delete languages.', 'wpglobus'), 'subtitle' => __('NOTE: you cannot remove the main language.', 'wpglobus'), 'style' => 'info', 'notice' => false), array('id' => 'lang_new', 'type' => 'table')));
     /**
      *    SECTION: Post types
      */
     $post_types = get_post_types(array('_builtin' => true));
     $fields = array(array('id' => 'description', 'type' => 'wpglobus_info', 'title' => __('Uncheck to disable WPGlobus', 'wpglobus'), 'style' => 'info', 'notice' => false));
     $default = array();
     $open_post_types = array();
     foreach ($post_types as $post_type) {
         if (!in_array($post_type, array('attachment', 'revision', 'nav_menu_item'), true)) {
             $open_post_types[$post_type] = $post_type;
             $default[$post_type] = true;
         }
     }
     $fields[] = array('id' => 'post_type', 'type' => 'wpglobus_checkbox', 'compiler' => false, 'default' => $default, 'options' => $open_post_types);
     $fields[] = array('id' => 'custom_post_types', 'type' => 'post_types');
     $this->sections[] = array('wpglobus_id' => 'post_types', 'title' => __('Post types', 'wpglobus'), 'icon' => 'el-icon-th-list', 'fields' => $fields);
     /**
      * SECTION: Add-ons
      * We need add it for menu item only
      */
     $this->sections[] = array('wpglobus_id' => 'add_ons', 'title' => __('Add-ons', 'wpglobus'), 'icon' => 'el-icon-th-list', 'class' => 'wpglobus-addons-group hidden');
     /**
      * Filter the array of sections.
      *
      * @since 1.0.11
      *
      * @param array $sections Array of Redux sections.
      */
     $this->sections = apply_filters('wpglobus_option_sections', $this->sections);
 }
Exemplo n.º 5
0
        /**
         * Output the clean screen.
         *
         * @return void
         */
        public static function screen()
        {
            /**
             * For Google Analytics
             */
            $ga_campaign = '?utm_source=wpglobus-admin-clean&utm_medium=link&utm_campaign=clean-up-tool';
            $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
            //			$url_wpglobus_site_home        = $url_wpglobus_site . $ga_campaign;
            $url_wpglobus_site_contact = $url_wpglobus_site . 'pg/contact-us/' . $ga_campaign;
            $url_wpglobus_site_quick_start = $url_wpglobus_site . 'quick-start/' . $ga_campaign;
            //			$url_wpglobus_site_faq         = $url_wpglobus_site . 'faq/' . $ga_campaign;
            //			$url_wpglobus_site_pro_support = $url_wpglobus_site . 'professional-support/' . $ga_campaign;
            $url_wpglobus_logo = WPGlobus::$PLUGIN_DIR_URL . 'includes/css/images/wpglobus-logo-180x180.png';
            ?>
			<style>
				.wp-badge.wpglobus-badge {
					background:      #ffffff url(<?php 
            echo $url_wpglobus_logo;
            ?>
) no-repeat;
					background-size: contain;
				}
			</style>
			<div class="wrap about-wrap wpglobus-about-wrap clean-wrap wpglobus-clean">
				<h1 class="wpglobus"><span class="wpglobus-wp">WP</span>Globus
					<span class="wpglobus-version"><?php 
            echo WPGLOBUS_VERSION;
            ?>
</span>
				</h1>

				<div class="wpglobus-motto"><?php 
            esc_html_e('Multilingual Everything!', 'wpglobus');
            ?>
</div>

				<div class="about-text">
					<?php 
            esc_html_e('WPGlobus is a family of WordPress plugins assisting you in making multilingual WordPress blogs and sites.', 'wpglobus');
            ?>
				</div>

				<div class="wp-badge wpglobus-badge"></div>

				<h2 class="nav-tab-wrapper">
					<a href="#" class="nav-tab nav-tab-active">
						<?php 
            _e('Clean-up Tool', 'wpglobus');
            ?>
					</a>
					<a href="<?php 
            echo esc_url($url_wpglobus_site_quick_start);
            ?>
"
					   target="_blank"
					   class="nav-tab">
						<?php 
            _e('Guide', 'wpglobus');
            ?>
					</a>
					<a href="admin.php?page=wpglobus_options" class="nav-tab">
						<?php 
            _e('Settings');
            ?>
					</a>
					<a href="admin.php?page=wpglobus_options&amp;tab=4" class="nav-tab">
						<?php 
            _e('Add-ons', 'wpglobus');
            ?>
					</a>
					<a href="<?php 
            echo esc_url($url_wpglobus_site_contact);
            ?>
"
					   class="nav-tab">
						<?php 
            _e('Support', 'wpglobus');
            ?>
					</a>
				</h2>

				<div style="color: white; background-color: red; padding: .5em; margin-top: 1em;">
					<?php 
            esc_html_e('WARNING: this operation is non-reversible. It is strongly recommended that you backup your database before proceeding.', 'wpglobus');
            ?>
				</div>

				<div style="padding: .5em"><strong>
						<?php 
            esc_html_e('This tool should be used only if you plan to completely uninstall WPGlobus. By running it, you will remove ALL translations you have entered to your post, pages, etc., keeping only the MAIN language texts. Please make sure that all entries have some content in the main language. Otherwise, you might end up with empty titles, no content, no excerpts, blank comments and so on.', 'wpglobus');
            ?>
					</strong></div>

				<div style="color:red; background-color: white; padding: .5em">
					<?php 
            echo esc_html(sprintf(__('The main language is currently set to %1$s (%2$s). ALL TEXTS THAT ARE NOT IN %1$s WILL BE DELETED! To change the main language, please go to Settings.', 'wpglobus'), WPGlobus::Config()->en_language_name[WPGlobus::Config()->default_language], WPGlobus::Config()->default_language));
            ?>
				</div>

				<hr />
				<h3 id="about-to-clean">
					<?php 
            esc_html_e('You are about to clean the content of the following database tables:', 'wpglobus');
            ?>
				</h3>

				<?php 
            echo self::get_table_list();
            ?>

				<hr />

				<h3>
					<?php 
            esc_html_e('The operations log', 'wpglobus');
            ?>
				</h3>
				<div>
					<?php 
            esc_html_e('We are going to write a detailed log of all the database changes performed. It should help in the case you need to restore something important. The log will be written to the file:', 'wpglobus');
            ?>
				</div>
				<br />
				<code>
					<?php 
            echo self::$log_file;
            ?>
				</code>
				<br />
				<br />
				<label>
					<input type="checkbox" name="wpglobus-clean-log" id="wpglobus-clean-log" checked="checked" />
					<?php 
            esc_html_e('Uncheck if you do not want to write the operations log (we recommend to keep it checked)', 'wpglobus');
            ?>

				</label>
				<hr />
				<h3>
					<?php 
            esc_html_e('You have been warned...', 'wpglobus');
            ?>
				</h3>
					<?php 
            esc_html_e('Please confirm by checking the box below:', 'wpglobus');
            ?>
				<div style="color:red; background-color: white; padding: .5em; margin: 1em 0;">
					<?php 
            esc_html_e('I have read and understood everything written on this page. I am aware that by using this tool I may loose some content of my website. I have made a database backup and know how to restore it if necessary. I am fully responsible for the results.', 'wpglobus');
            ?>
				</div>

				<label><input type="checkbox" name="wpglobus-clean-activate" id="wpglobus-clean-activate" /><?php 
            esc_html_e('YES, I CONFIRM', 'wpglobus');
            ?>
				</label>
				<div class="return-to-dashboard">
					<a id="wpglobus-clean-button" class="button button-primary hidden" href="#about-to-clean">
						<?php 
            _e('Process with the Clean-up', 'wpglobus');
            ?>
					</a>
				</div>

			</div>

			<?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;
 }
 /**
  * Template for plugin info.
  *
  * @return stdClass
  */
 protected static function _plugin_info_template()
 {
     $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
     $template = new stdClass();
     $template->name = '';
     $template->short_description = '';
     $template->author = '<a href="' . $url_wpglobus_site . '">WPGlobus</a>';
     $template->author_profile = $url_wpglobus_site;
     $template->homepage = $url_wpglobus_site;
     $template->slug = '';
     $template->rating = 100;
     $template->num_ratings = 0;
     $template->active_installs = self::FAKE_ACTIVE_INSTALLS;
     $template->version = self::FAKE_VERSION;
     $template->tested = self::$fake_compatible_with;
     $template->icons['default'] = '';
     $template->icons['2x'] = '';
     $template->icons['1x'] = '';
     $template->last_updated = date('c');
     return $template;
 }
    /**
     * Output the about screen.
     */
    public static function about_screen()
    {
        /**
         * For Google Analytics
         */
        $ga_campaign = '?utm_source=wpglobus-admin-about&utm_medium=link&utm_campaign=activate-plugin';
        $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
        $url_wpglobus_site_home = $url_wpglobus_site . $ga_campaign;
        $url_wpglobus_site_contact = $url_wpglobus_site . 'pg/contact-us/' . $ga_campaign;
        $url_wpglobus_site_quick_start = $url_wpglobus_site . 'quick-start/' . $ga_campaign;
        $url_wpglobus_site_faq = $url_wpglobus_site . 'faq/' . $ga_campaign;
        $url_wpglobus_site_pro_support = $url_wpglobus_site . 'professional-support/' . $ga_campaign;
        $url_wpglobus_logo = WPGlobus::$PLUGIN_DIR_URL . 'includes/css/images/wpglobus-logo-180x180.png';
        ?>
		<style>
			.wp-badge.wpglobus-badge {
				background: #ffffff url(<?php 
        echo $url_wpglobus_logo;
        ?>
) no-repeat;
				background-size: contain;
			}
		</style>
		<div class="wrap about-wrap">
			<h1 class="wpglobus"><span class="wpglobus-wp">WP</span>Globus
				<span class="wpglobus-version"><?php 
        echo WPGLOBUS_VERSION;
        ?>
</span>
			</h1>

			<h2 class="wpglobus-motto"><?php 
        esc_html_e('Multilingual Everything!', 'wpglobus');
        ?>
</h2>

			<div class="about-text">
				<?php 
        esc_html_e('WPGlobus is a family of WordPress plugins assisting you in making multilingual WordPress blogs and sites.', 'wpglobus');
        ?>
			</div>

			<div class="wp-badge wpglobus-badge"></div>

			<h2 class="nav-tab-wrapper">
				<a href="#" class="nav-tab nav-tab-active">
					<?php 
        _e('Quick Start', 'wpglobus');
        ?>
				</a>
				<a href="<?php 
        echo esc_url($url_wpglobus_site_quick_start);
        ?>
"
				   target="_blank"
				   class="nav-tab">
					<?php 
        _e('Guide', 'wpglobus');
        ?>
				</a>
				<a href="admin.php?page=wpglobus_options" class="nav-tab">
					<?php 
        _e('Settings');
        ?>
				</a>
				<a href="admin.php?page=wpglobus-addons" class="nav-tab">
					<?php 
        _e('Add-ons', 'wpglobus');
        ?>
				</a>
				<a href="<?php 
        echo esc_url($url_wpglobus_site_contact);
        ?>
"
				   class="nav-tab">
					<?php 
        _e('Support', 'wpglobus');
        ?>
				</a>
			</h2>

			<div class="feature-main feature-section col two-col">
				<div>
					<h4><?php 
        _e('Easy as 1-2-3:', 'wpglobus');
        ?>
</h4>
					<ul class="wpglobus-checkmarks">
						<li><?php 
        _e('Go to WPGlobus admin menu and choose the countries / languages;', 'wpglobus');
        ?>
</li>
						<li><?php 
        _e('Enter the translations to the posts, pages, categories, tags and menus using a clean and simple interface.', 'wpglobus');
        ?>
</li>
						<li><?php 
        _e('Switch languages at the front-end using a drop-down menu with language names and country flags.', 'wpglobus');
        ?>
</li>
					</ul>
				</div>
				<div class="last-feature">
					<h4><?php 
        _e('Links:', 'wpglobus');
        ?>
</h4>
					<ul>
						<li>&bull; <a href="<?php 
        echo esc_url($url_wpglobus_site_home);
        ?>
"
						              target="_blank">WPGlobus.com</a></li>
						<li>&bull; <a href="<?php 
        echo esc_url($url_wpglobus_site_quick_start);
        ?>
"
						              target="_blank"><?php 
        _e('Guide', 'wpglobus');
        ?>
</a></li>
						<li>&bull; <a href="<?php 
        echo esc_url($url_wpglobus_site_faq);
        ?>
"
						              target="_blank"><?php 
        _e('FAQs', 'wpglobus');
        ?>
</a></li>
						<li>&bull; <a href="<?php 
        echo esc_url($url_wpglobus_site_contact);
        ?>
"
						              target="_blank"><?php 
        _e('Contact Us', 'wpglobus');
        ?>
</a></li>
						<li>&bull; <a href="https://wordpress.org/support/view/plugin-reviews/wpglobus?filter=5"
						              target="_blank"><?php 
        _e('Please give us 5 stars!', 'wpglobus');
        ?>
</a>
							<span class="wpglobus-stars">&#x2606;&#x2606;&#x2606;&#x2606;&#x2606;</span></li>

					</ul>
				</div>
			</div>

			<hr/>

			<ul class="wpglobus-important">

				<li>
					<?php 
        _e("WPGlobus only supports the localization URLs in the form of <code>example.com/xx/page/</code>. We do not plan to support subdomains <code>xx.example.com</code> and language queries <code>example.com?lang=xx</code>.", 'wpglobus');
        ?>
				</li>
				<li>
					<?php 
        _e('Some themes and plugins are <strong>not multilingual-ready</strong>.', 'wpglobus');
        ?>
					<?php 
        _e('They might display some texts with no translation, or with all languages mixed together.', 'wpglobus');
        ?>
					<?php 
        /* translators: %s are used to insert HTML link. Keep them in place. */
        printf(__('Please contact the theme / plugin author. If they are unable to assist, consider %s hiring the WPGlobus Team %s to write a custom code for you.', 'wpglobus'), '<a href="' . $url_wpglobus_site_pro_support . '">', '</a>');
        ?>
				</li>

			</ul>

			<hr/>

			<div class="return-to-dashboard">
				<a class="button button-primary" href="admin.php?page=wpglobus_options">
					<?php 
        _e('Go to WPGlobus Settings', 'wpglobus');
        ?>
				</a>
			</div>
		</div>

		<?php 
    }
Exemplo n.º 9
0
 /**
  * Add language switcher to navigation menu
  *
  * @param array  $sorted_menu_items
  * @param object $args An object containing wp_nav_menu() arguments.
  *
  * @return array
  * @see wp_nav_menu()
  */
 function on_add_item($sorted_menu_items, $args)
 {
     if (empty(WPGlobus::Config()->nav_menu)) {
         /**
          * User can use WPGlobus widget
          * @since 1.0.7
          */
         return $sorted_menu_items;
     } elseif ('all' == WPGlobus::Config()->nav_menu) {
         /**
          * Attach to every nav menu
          * @since 1.0.7
          */
     } else {
         $items = array();
         foreach ($sorted_menu_items as $item) {
             $items[] = $item->ID;
         }
         $return = true;
         foreach ($this->menus as $key => $menu) {
             $diff = array_diff($items, $menu->menu_items);
             if (empty($diff) && WPGlobus::Config()->nav_menu === $menu->slug) {
                 $return = false;
                 break;
             }
         }
         if ($return) {
             return $sorted_menu_items;
         }
     }
     $extra_languages = array();
     foreach (WPGlobus::Config()->enabled_languages as $languages) {
         if ($languages != WPGlobus::Config()->language) {
             $extra_languages[] = $languages;
         }
     }
     /**
      * Filter extra languages.
      * Returning array.
      * @since 1.0.13
      *
      * @param array $extra_languages An array with languages to show off in menu.
      * @param       string           WPGlobus::Config()->language The current language.
      */
     $extra_languages = apply_filters('wpglobus_extra_languages', $extra_languages, WPGlobus::Config()->language);
     /** main menu item classes */
     $menu_item_classes = array('', 'menu-item', 'menu_item_wpglobus_menu_switch', 'wpglobus-selector-link');
     /** submenu item classes */
     $submenu_item_classes = array('', 'sub_menu_item_wpglobus_menu_switch', 'wpglobus-selector-link');
     if (apply_filters('wpglobus_dropdown_menu', true, WPGlobus::Config())) {
         $parent_item_ID = 9999999999;
         # 9 999 999 999
     } else {
         $parent_item_ID = 0;
     }
     $span_classes_lang = $this->_get_language_classes(WPGlobus::Config()->language);
     $current_url = WPGlobus_Utils::current_url();
     $item = new stdClass();
     $item->ID = $parent_item_ID == 0 ? 'wpglobus_menu_switch_' . WPGlobus::Config()->language : $parent_item_ID;
     $item->db_id = $parent_item_ID == 0 ? 'wpglobus_menu_switch_' . WPGlobus::Config()->language : $parent_item_ID;
     $item->menu_item_parent = 0;
     $item->title = '<span class="' . implode(' ', $span_classes_lang) . '">' . $this->_get_flag_name(WPGlobus::Config()->language) . '</span>';
     // The top menu level points to the current URL. Useless? Maybe good for refresh.
     $item->url = $current_url;
     $item->classes = $menu_item_classes;
     $item->classes[] = 'wpglobus-current-language';
     $item->description = '';
     $item->language = WPGlobus::Config()->language;
     $wpglobus_menu_items[] = $item;
     foreach ($extra_languages as $language) {
         $span_classes_lang = $this->_get_language_classes($language);
         $item = new stdClass();
         $item->ID = 'wpglobus_menu_switch_' . $language;
         $item->db_id = 'wpglobus_menu_switch_' . $language;
         $item->menu_item_parent = $parent_item_ID;
         $item->title = '<span class="' . implode(' ', $span_classes_lang) . '">' . $this->_get_flag_name($language) . '</span>';
         // This points to the URL localized for the selected language
         //			$item->url         = WPGlobus_Utils::localize_url( $current_url, $language );
         $item->url = WPGlobus_Utils::localize_current_url($language);
         $item->classes = $parent_item_ID == 0 ? $menu_item_classes : $submenu_item_classes;
         $item->description = '';
         $item->language = $language;
         $wpglobus_menu_items[] = $item;
     }
     $languages = $extra_languages;
     array_unshift($languages, WPGlobus::Config()->language);
     return array_merge($sorted_menu_items, apply_filters('wpglobus_menu_items', $wpglobus_menu_items, $languages));
 }
Exemplo n.º 10
0
 /**
  * Add language switcher to navigation menu
  *
  * @param array  $sorted_menu_items
  * @param stdClass $args An object containing wp_nav_menu() arguments.
  *
  * @return array
  * @see wp_nav_menu()
  */
 public function on_add_item($sorted_menu_items, $args)
 {
     if (empty(WPGlobus::Config()->nav_menu)) {
         /**
          * User can use WPGlobus widget
          * @since 1.0.7
          */
         $disable_add_selector = true;
     } elseif ('all' === WPGlobus::Config()->nav_menu) {
         /**
          * Attach to every nav menu
          * @since 1.0.7
          */
         $disable_add_selector = false;
     } else {
         $items = array();
         foreach ($sorted_menu_items as $item) {
             $items[] = $item->ID;
         }
         $disable_add_selector = true;
         foreach ($this->menus as $key => $menu) {
             $diff = array_diff($items, $menu->menu_items);
             if (empty($diff) && WPGlobus::Config()->nav_menu === $menu->slug) {
                 $disable_add_selector = false;
                 break;
             }
         }
     }
     /**
      * Filter to add or not language selector to the menu.
      * Returning boolean.
      * @since 1.5.8
      *
      * @param bool 	$disable_add_selector 	Disable or not to add language selector to the menu.
      * @param stdClass 	$args 					An object containing wp_nav_menu() arguments.
      */
     $disable_add_selector = apply_filters('wpglobus_menu_add_selector', $disable_add_selector, $args);
     if ($disable_add_selector) {
         return $sorted_menu_items;
     }
     /**
      * List of all languages, except the main one.
      *
      * @var string[] $extra_languages
      */
     $extra_languages = array();
     foreach (WPGlobus::Config()->enabled_languages as $languages) {
         if ($languages !== WPGlobus::Config()->language) {
             $extra_languages[] = $languages;
         }
     }
     /**
      * Filter extra languages.
      * Returning array.
      * @since 1.0.13
      *
      * @param array $extra_languages An array of languages to show in the menu.
      * @param       string           WPGlobus::Config()->language The current language.
      */
     $extra_languages = apply_filters('wpglobus_extra_languages', $extra_languages, WPGlobus::Config()->language);
     // Main menu item classes.
     $menu_item_classes = array('', 'menu-item', 'menu-item-type-custom', 'menu-item-object-custom', 'menu_item_wpglobus_menu_switch', 'wpglobus-selector-link');
     // Submenu item classes.
     $submenu_item_classes = array('', 'menu-item', 'menu-item-type-custom', 'menu-item-object-custom', 'sub_menu_item_wpglobus_menu_switch', 'wpglobus-selector-link');
     if (apply_filters('wpglobus_dropdown_menu', true, WPGlobus::Config())) {
         $parent_item_ID = 9999999999;
         # 9 999 999 999
     } else {
         $parent_item_ID = 0;
     }
     $span_classes_lang = $this->_get_language_classes(WPGlobus::Config()->language);
     $current_url = WPGlobus_Utils::current_url();
     $item = new stdClass();
     $item->ID = 0 === $parent_item_ID ? 'wpglobus_menu_switch_' . WPGlobus::Config()->language : $parent_item_ID;
     $item->db_id = $item->ID;
     $item->object_id = $item->ID;
     $item->object = 'custom';
     $item->menu_item_parent = 0;
     $item->title = '<span class="' . implode(' ', $span_classes_lang) . '">' . $this->_get_flag_name(WPGlobus::Config()->language) . '</span>';
     // The top menu level points to the current URL. Useless? Maybe good for refresh.
     $item->url = $current_url;
     $item->classes = $menu_item_classes;
     $item->classes[] = 'wpglobus-current-language';
     $item->description = '';
     $item->language = WPGlobus::Config()->language;
     $wpglobus_menu_items[] = new WP_Post($item);
     foreach ($extra_languages as $language) {
         $span_classes_lang = $this->_get_language_classes($language);
         $item = new stdClass();
         $item->ID = 'wpglobus_menu_switch_' . $language;
         $item->db_id = $item->ID;
         $item->object_id = $item->ID;
         $item->object = 'custom';
         $item->menu_item_parent = $parent_item_ID;
         $item->title = '<span class="' . implode(' ', $span_classes_lang) . '">' . $this->_get_flag_name($language) . '</span>';
         // This points to the URL localized for the selected language.
         $item->url = WPGlobus_Utils::localize_current_url($language);
         $item->classes = 0 === $parent_item_ID ? $menu_item_classes : $submenu_item_classes;
         $item->description = '';
         $item->language = $language;
         $wpglobus_menu_items[] = new WP_Post($item);
     }
     $languages = $extra_languages;
     array_unshift($languages, WPGlobus::Config()->language);
     return array_merge($sorted_menu_items, apply_filters('wpglobus_menu_items', $wpglobus_menu_items, $languages));
 }
 /**
  * Get content for WPGlobusTextBox element
  *
  * @param string $control
  * @param mixed  $attrs
  *
  * @return string
  */
 public static function get_content($control = '', $attrs = null)
 {
     if ('' == $control) {
         return '';
     }
     $content = '';
     switch ($control) {
         case 'settings_section_help':
             $content = __('Here you can specify which fields should be considered multilingual by WPGlobus. To exclude a field, uncheck it and then press the button below.', 'wpglobus');
             break;
         case 'welcome_message':
             $content = '<div style="width:100%;">' . __('Thank you for installing WPGlobus!', 'wpglobus') . '<br/>' . '&bull; ' . '<a style="text-decoration:underline;" target="_blank" href="' . admin_url() . 'admin.php?page=' . WPGlobus::PAGE_WPGLOBUS_ABOUT . '">' . __('Read About WPGlobus', 'wpglobus') . '</a>' . '<br/>' . '&bull; ' . __('Click the <strong>[Languages]</strong> tab at the left to setup the options.', 'wpglobus') . '<br/>' . '<br/>' . __('Should you have any questions or comments, please do not hesitate to contact us.', 'wpglobus') . '<br/>' . '<br/>' . '<em>' . __('Sincerely Yours,', 'wpglobus') . '<br/>' . __('The WPGlobus Team', 'wpglobus') . '</em>' . '</div>';
             break;
         case 'deactivate_message':
             /**
              * For Google Analytics
              */
             $ga_campaign = '?utm_source=wpglobus-admin-clean&utm_medium=link&utm_campaign=talk-to-us';
             $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
             $url_wpglobus_site_submit_ticket = $url_wpglobus_site . 'support/submit-ticket/' . $ga_campaign;
             $content = '<p><em>' . sprintf(esc_html(__('We would hate to see you go. If something goes wrong, do not uninstall WPGlobus yet. Please %1$stalk to us%2$s and let us help!', 'wpglobus')), '<a href="' . $url_wpglobus_site_submit_ticket . '" target="_blank" style="text-decoration:underline;">', '</a>') . '</em></p>' . '<hr/>' . '<p><i class="el el-exclamation-sign" style="color:red"></i> <strong>' . esc_html(__('Please note that if you deactivate WPGlobus, your site will show all the languages together, mixed up. You will need to remove all translations, keeping only one language.', 'wpglobus')) . '</strong></p>' . '<p>' . sprintf(__('If there are just a few places, you should edit them manually. To automatically remove all translations at once, you can use the %s. WARNING: The clean-up operation is irreversible, so use it only if you need to completely uninstall WPGlobus.', 'wpglobus'), sprintf(__('%1$sClean-up Tool%2$s', 'wpglobus'), '<a style="text-decoration:underline;" target="_blank" href="' . admin_url() . 'admin.php?page=' . WPGlobus::PAGE_WPGLOBUS_CLEAN . '">', '</a>')) . '</p>';
             break;
         case 'sorry_message':
             $content = '<p><strong>' . sprintf(__('Sorry, WPGlobus customizer doesn\'t support current theme %s.', 'wpglobus'), '<em>' . $attrs->__get('name') . '</em>') . '<br />' . sprintf(__('Please use %1$sWPGlobus options page%2$s instead.', 'wpglobus'), '<a style="text-decoration:underline;" target="_blank" href="' . admin_url() . 'admin.php?page=' . WPGlobus::OPTIONS_PAGE_SLUG . '&tab=0">', '</a>') . '</strong></p>';
             break;
     }
     return $content;
 }
		</a>
		<a href="<?php 
echo esc_url(WPGlobus_Utils::url_wpglobus_site() . 'faq/');
?>
"
		   target="_blank"
		   class="nav-tab">
			<?php 
WPGlobus_Admin_Page::nav_tab_icon_e('FAQ');
?>
			<?php 
esc_html_e('FAQ', 'wpglobus');
?>
		</a>
		<a href="<?php 
echo esc_url(WPGlobus_Utils::url_wpglobus_site());
?>
"
		   target="_blank"
		   class="nav-tab">
			<?php 
WPGlobus_Admin_Page::nav_tab_icon_e('globe');
?>
			<?php 
echo esc_html('WPGlobus.com');
?>
		</a>
	</h2>
	<div class="feature-main feature-section col two-col">
		<div class="col">
			<p><em>
Exemplo n.º 13
0
    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 
    }
Exemplo n.º 14
0
 /**
  * Set the current language: if not found in the URL or REFERER, then keep the default
  * @since 1.1.1
  */
 public function init_current_language()
 {
     /**
      * Keep the default language if any of the code before does not detect another one.
      */
     $this->language = $this->default_language;
     /**
      * Theoretically, we might not have any URL to get the language info from.
      */
     $url_to_check = '';
     if (WPGlobus_WP::is_doing_ajax()) {
         /**
          * If DOING_AJAX, we cannot retrieve the language information from the URL,
          * because it's always `admin-ajax`.
          * Therefore, we'll rely on the HTTP_REFERER (if it exists).
          */
         if (!empty($_SERVER['HTTP_REFERER'])) {
             $url_to_check = $_SERVER['HTTP_REFERER'];
         }
     } else {
         /**
          * If not AJAX and not ADMIN then we are at the front. Will use the current URL.
          */
         if (!is_admin()) {
             $url_to_check = WPGlobus_Utils::current_url();
         }
     }
     /**
      * If we have an URL, extract language from it.
      * If extracted, set it as a current.
      */
     if ($url_to_check) {
         $language_from_url = WPGlobus_Utils::extract_language_from_url($url_to_check);
         if ($language_from_url) {
             $this->language = $language_from_url;
         }
     }
 }
Exemplo n.º 15
0
 /**
  * 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);
         }
     }
 }
Exemplo n.º 16
0
    /**
     * Echo the widget content
     *
     * @param array $args     Display arguments including before_title, after_title, before_widget, and after_widget.
     * @param array $instance The settings for the particular instance of the widget
     */
    public function widget($args, $instance)
    {
        if (!empty($instance['type'])) {
            $type = $instance['type'];
        } else {
            $type = 'flags';
        }
        $inside = '';
        $enabled_languages = WPGlobus::Config()->enabled_languages;
        switch ($type) {
            case 'list':
                $code = '<div class="list">{{inside}}</div>';
                break;
            case 'list_with_flags':
                $code = '<div class="list flags">{{inside}}</div>';
                break;
            case 'select':
            case 'select_with_code':
                $code = '<div class="select-styled"><select onchange="document.location.href = this.value;">{{inside}}</select></div>';
                break;
            case 'dropdown':
            case 'dropdown_with_flags':
                $sorted[] = WPGlobus::Config()->language;
                foreach ($enabled_languages as $language) {
                    if ($language != WPGlobus::Config()->language) {
                        $sorted[] = $language;
                    }
                }
                $enabled_languages = $sorted;
                $code = '<div class="dropdown-styled"> <ul>
					  <li>
						{{language}}
						<ul>
							{{inside}}
						</ul>
					  </li>
					</ul></div>';
                break;
            default:
                //	This is case 'flags'. Having is as default makes $code always set.
                $code = '<div class="flags-styled">{{inside}}</div>';
                break;
        }
        /**
         * Filter enabled languages.
         *
         * Returning array.
         *
         * @since 1.0.13
         *
         * @param array     $enabled_languages 			 An array with languages to show off in menu.
         * @param string    WPGlobus::Config()->language The current language.
         */
        $enabled_languages = apply_filters('wpglobus_extra_languages', $enabled_languages, WPGlobus::Config()->language);
        /**
         * Class for link in a and option tags. Used for adding hash.
         * @see class wpglobus-selector-link 
         * @since 1.2.0
         */
        $link_classes['selector_link'] = 'wpglobus-selector-link';
        /**
         * Class for flag box
         * @since 1.4.0
         */
        $flag_classes = array();
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . $instance['title'] . $args['after_title'];
        }
        foreach ($enabled_languages as $language) {
            $selected = '';
            /**
             * Init current language class
             */
            $link_classes['current_language'] = '';
            /**
             * Init current language class for flag box
             */
            $flag_classes['current_language'] = '';
            if ($language == WPGlobus::Config()->language) {
                $selected = ' selected';
                switch ($type) {
                    case 'flags':
                        $flag_classes['current_language'] = 'wpglobus-current-language';
                        break;
                    case 'list':
                    case 'list_with_flags':
                    case 'dropdown':
                    case 'dropdown_with_flags':
                        $link_classes['current_language'] = 'wpglobus-current-language';
                        break;
                }
            }
            $url = WPGlobus_Utils::localize_current_url($language);
            $flag = WPGlobus::Config()->flags_url . WPGlobus::Config()->flag[$language];
            switch ($type) {
                case 'flags':
                    $inside .= '<span class="flag ' . implode(' ', $flag_classes) . '">';
                    $inside .= '<a href="' . $url . '" class="' . implode(' ', $link_classes) . '"><img src="' . $flag . '"/></a>';
                    $inside .= '</span>';
                    break;
                case 'list':
                case 'list_with_flags':
                    $inside .= '<a href="' . $url . '" class="' . implode(' ', $link_classes) . '">' . '<img src="' . $flag . '" alt=""/>' . ' ' . '<span class="name">' . WPGlobus::Config()->language_name[$language] . '</span>' . ' ' . '<span class="code">' . strtoupper($language) . '</span>' . '</a>';
                    break;
                case 'select':
                    $inside .= '<option class="' . implode(' ', $link_classes) . '" ' . $selected . ' value="' . $url . '">' . WPGlobus::Config()->language_name[$language] . '</option>';
                    break;
                case 'select_with_code':
                    $inside .= '<option class="' . implode(' ', $link_classes) . '" ' . $selected . ' value="' . $url . '">' . WPGlobus::Config()->language_name[$language] . '&nbsp;(' . strtoupper($language) . ')</option>';
                    break;
                case 'dropdown':
                    if ('' != $selected) {
                        $code = str_replace('{{language}}', '<a class="' . implode(' ', $link_classes) . '" href="' . $url . '">' . WPGlobus::Config()->language_name[$language] . '&nbsp;(' . strtoupper($language) . ')</a>', $code);
                    } else {
                        $inside .= '<li><a class="' . implode(' ', $link_classes) . '" href="' . $url . '">' . WPGlobus::Config()->language_name[$language] . '&nbsp;(' . strtoupper($language) . ')</a></li>';
                    }
                    break;
                case 'dropdown_with_flags':
                    if ('' != $selected) {
                        $code = str_replace('{{language}}', '<a class="' . implode(' ', $link_classes) . '" href="' . $url . '"><img src="' . $flag . '"/>&nbsp;&nbsp;' . WPGlobus::Config()->language_name[$language] . '</a>', $code);
                    } else {
                        $inside .= '<li><a class="' . implode(' ', $link_classes) . '" href="' . $url . '"><img src="' . $flag . '"/>&nbsp;&nbsp;' . WPGlobus::Config()->language_name[$language] . '</a></li>';
                    }
                    break;
            }
        }
        echo str_replace('{{inside}}', $inside, $code);
        echo $args['after_widget'];
    }
Exemplo n.º 17
0
    /**
     * 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 
    }
Exemplo n.º 18
0
    protected static function important_notes()
    {
        ?>
		<h4 class="dashicons-before dashicons-info highlight">
			<?php 
        esc_html_e('Important notes:', 'wpglobus');
        ?>
		</h4>
		<ul class="wpglobus-important">

			<li>
				<?php 
        _e('WPGlobus only supports the localization URLs in the form of <code>example.com/xx/page/</code>. We do not plan to support subdomains <code>xx.example.com</code> and language queries <code>example.com?lang=xx</code>.', 'wpglobus');
        // WPCS: XSS ok.
        ?>
			</li>
			<li>
				<?php 
        _e('Some themes and plugins are <strong>not multilingual-ready</strong>.', 'wpglobus');
        // WPCS: XSS ok.
        ?>
				<?php 
        esc_html_e('They might display some texts with no translation, or with all languages mixed together.', 'wpglobus');
        ?>
				<?php 
        /* translators: %s are used to insert HTML link. Keep them in place. */
        printf(esc_html__('Please contact the theme / plugin author. If they are unable to assist, consider %s hiring the WPGlobus Team %s to write a custom code for you.', 'wpglobus'), '<a href="' . esc_url(WPGlobus_Utils::url_wpglobus_site() . 'professional-support/' . self::QA_CAMPAIGN) . '">', '</a>');
        ?>
			</li>

		</ul>
		<?php 
    }
 /**
  * @covers \WPGlobus_Utils::hreflangs
  */
 public function test_hreflangs()
 {
     /**
      * 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 = 'ru';
     /**
      * This says "Do not use language code in the default URL"
      * So, no /en/page/, just /page/
      */
     $config->hide_default_language = true;
     $config->locale['en'] = "en_US";
     $config->locale['ru'] = "ru_RU";
     $config->locale['pt'] = "pt_PT";
     /**
      * Mock web request
      */
     $_SERVER['HTTP_HOST'] = 'www.example.com';
     $_SERVER['REQUEST_URI'] = '/folder/file?var=value';
     $hreflangs = WPGlobus_Utils::hreflangs($config);
     self::assertEquals('<link rel="alternate" hreflang="ru-RU" href="http://www.example.com/folder/file?var=value"/>', $hreflangs['ru']);
     self::assertEquals('<link rel="alternate" hreflang="pt-PT" href="http://www.example.com/pt/folder/file?var=value"/>', $hreflangs['pt']);
 }
Exemplo n.º 20
0
				<?php 
esc_html_e('Thank you!', 'wpglobus');
?>
				<br/>
				<?php 
esc_html_e('The WPGlobus Team', 'wpglobus');
?>
			</div>
		</div>
	</div>

<?php 
if (!defined('WPGLOBUS_PLUS_VERSION')) {
    ?>
	<?php 
    $_url_wpglobus_plus_store = WPGlobus_Utils::url_wpglobus_site() . 'product/wpglobus-plus/';
    $_url_wpglobus_plus_logo = WPGlobus::$PLUGIN_DIR_URL . 'includes/css/images/wpglobus-plus-logo-150x150.png';
    ?>
	<div class="wpg-bnr wpg-bnr-right">
		<a class="wpg-a-img" href="<?php 
    echo esc_url($_url_wpglobus_plus_store);
    ?>
">
			<img src="<?php 
    echo esc_url($_url_wpglobus_plus_logo);
    ?>
"
			     alt="WPGlobus Plus"/>
		</a>

		<div class="wpg-text-block">
				<?php 
esc_html_e('Thank you!', 'wpglobus');
?>
				<br/>
				<?php 
esc_html_e('The WPGlobus Team', 'wpglobus');
?>
			</div>
		</div>
	</div>

<?php 
if (!defined('WPGLOBUS_PLUS_VERSION')) {
    ?>
	<?php 
    $_url_wpglobus_plus_store = WPGlobus_Utils::url_wpglobus_site() . 'shop/extensions/wpglobus-plus/';
    $_url_wpglobus_plus_logo = WPGlobus::URL_WPGLOBUS_SITE . 'app/uploads/2015/08/wpglobus-plus-logo-150x150.png';
    ?>
	<div class="wpg-bnr wpg-bnr-right">
		<a class="wpg-a-img" href="<?php 
    echo $_url_wpglobus_plus_store;
    ?>
">
			<img src="<?php 
    echo $_url_wpglobus_plus_logo;
    ?>
"
			     alt="WPGlobus Plus"/>
		</a>

		<div class="wpg-text-block">