/**
  * Static "controller"
  */
 public static function controller()
 {
     if (is_admin()) {
         if (!WPGlobus_WP::is_doing_ajax()) {
             /** @see WPGlobus::__construct */
             WPGlobus::O()->vendors_scripts['WPSEO'] = true;
             if (WPGlobus_WP::is_pagenow('edit.php')) {
                 /**
                  * @since 1.5.3
                  */
                 add_filter('wpseo_replacements_filter_sep', array(__CLASS__, 'filter__get_separator'), 999);
                 /**
                  * To translate Yoast columns on edit.php page
                  */
                 add_filter('esc_html', array('WPGlobus_YoastSEO', 'filter__wpseo_columns'), 0);
             }
             add_action('admin_print_scripts', array('WPGlobus_YoastSEO', 'action__admin_print_scripts'));
             add_action('wpseo_tab_content', array('WPGlobus_YoastSEO', 'action__wpseo_tab_content'), 11);
             if (WPGlobus_WP::is_pagenow(array('edit-tags.php', 'term.php'))) {
                 add_filter('wp_default_editor', array('WPGlobus_YoastSEO', 'set_default_editor'));
             }
         }
     } else {
         /**
          * Filter SEO title and meta description on front only, when the page header HTML tags are generated.
          * AJAX is probably not required (waiting for a case).
          */
         add_filter('wpseo_title', array('WPGlobus_Filters', 'filter__text'), PHP_INT_MAX);
         add_filter('wpseo_metadesc', array('WPGlobus_Filters', 'filter__text'), PHP_INT_MAX);
         add_filter('get_post_metadata', array(__CLASS__, 'filter__get_post_metadata'), 0, 4);
     }
 }
 public static function controller()
 {
     if (is_admin()) {
         if (!WPGlobus_WP::is_doing_ajax()) {
             /** @see \WPGlobus::__construct */
             WPGlobus::O()->vendors_scripts['WPSEO'] = true;
             if (WPGlobus_WP::is_pagenow('edit.php')) {
                 /**
                  * To translate Yoast columns on edit.php page
                  */
                 add_filter('esc_html', array('WPGlobus_YoastSEO', 'filter__wpseo_columns'), 0);
             }
             add_action('admin_print_scripts', array('WPGlobus_YoastSEO', 'action__admin_print_scripts'));
             add_action('wpseo_tab_content', array('WPGlobus_YoastSEO', 'action__wpseo_tab_content'), 11);
             /**
              * Filter for @see wpseo_linkdex_results
              * @scope admin
              * @since 1.2.2		 
              */
             /*
             				 * PHP Notice:  wpseo_linkdex_results filter/action is <strong>deprecated</strong> since version WPSEO 3.0! Use javascript instead. in C:\cygwin\home\www.wpg.dev\wp-includes\functions.php on line 3406
             				 *	
             				add_filter( 'wpseo_linkdex_results', array(
             					'WPGlobus_YoastSEO',
             					'filter__wpseo_linkdex_results'
             				), 10, 3 );	
             				// */
         }
     } else {
         /**
          * Filter SEO title and meta description on front only, when the page header HTML tags are generated.
          * AJAX is probably not required (waiting for a case).
          */
         //			add_filter( 'wpseo_title', array( 'WPGlobus_Filters', 'filter__text' ), 0 );
         //add_filter( 'wpseo_metadesc', array( 'WPGlobus_Filters', 'filter__text' ), 0 );
         /**
          * Filter for @see wpseo_title
          * @scope front
          * @since 1.4.0	 
          */
         add_filter('wpseo_title', array('WPGlobus_YoastSEO', 'filter__title'), 0);
         /**
          * Filter for @see wpseo_description
          * @scope front
          * @since 1.1.1		 
          */
         add_filter('wpseo_metadesc', array('WPGlobus_YoastSEO', 'wpseo_metadesc'), 0);
         /**
          * Filter for metadata
          * @scope front
          * @since 1.4.0	 
          */
         //add_filter( 'get_post_metadata', array( 'WPGlobus_YoastSEO', 'filter__metadata' ), 0, 4 );
     }
 }
 /**
  * @covers WPGlobus_WP::is_doing_ajax
  */
 public function test_is_doing_ajax()
 {
     if (!defined('DOING_AJAX')) {
         define('DOING_AJAX', true);
     }
     if (DOING_AJAX) {
         self::assertTrue(WPGlobus_WP::is_doing_ajax());
     } else {
         self::assertFalse(WPGlobus_WP::is_doing_ajax());
     }
 }
Esempio n. 4
0
 public static function controller()
 {
     if (is_admin()) {
         if (!WPGlobus_WP::is_doing_ajax()) {
             if ('off' == WPGLobus::Config()->toggle) {
                 return;
             }
             /** @see \WPGlobus::__construct */
             WPGlobus::O()->vendors_scripts['WPSEO'] = true;
             if (WPGlobus_WP::is_pagenow('edit.php')) {
                 /**
                  * To translate Yoast columns on edit.php page
                  */
                 add_filter('esc_html', array('WPGlobus_WPSEO', 'filter__wpseo_columns'), 0);
             }
             add_action('admin_print_scripts', array('WPGlobus_WPSEO', 'action__admin_print_scripts'));
             add_action('wpseo_tab_content', array('WPGlobus_WPSEO', 'action__wpseo_tab_content'), 11);
             /**
              * Filter for @see wpseo_linkdex_results
              * @scope admin
              * @since 1.2.2		 
              */
             add_filter('wpseo_linkdex_results', array('WPGlobus_WPSEO', 'filter__wpseo_linkdex_results'), 10, 3);
         }
     } else {
         /**
          * Filter SEO title and meta description on front only, when the page header HTML tags are generated.
          * AJAX is probably not required (waiting for a case).
          */
         add_filter('wpseo_title', array('WPGlobus_Filters', 'filter__text'), 0);
         //add_filter( 'wpseo_metadesc', array( 'WPGlobus_Filters', 'filter__text' ), 0 );
         /**
          * Filter for @see wpseo_title
          * @scope front
          * @since 1.1.1		 
          */
         //			add_filter( 'wpseo_title', array( 'WPGlobus_WPSEO', 'filter__title' ), 0 );
         /**
          * Filter for @see wpseo_description
          * @scope front
          * @since 1.1.1		 
          */
         add_filter('wpseo_metadesc', array('WPGlobus_WPSEO', 'wpseo_metadesc'), 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;
         }
     }
 }
Esempio n. 6
0
 */
add_filter('locale', array('WPGlobus_Filters', 'filter__get_locale'), PHP_INT_MAX);
/** @todo Move the filter to Filters class */
add_action('activated_plugin', array('WPGlobus', 'activated'));
add_action('admin_init', array('WPGlobus_Filters', 'action__admin_init'), 0);
/**
 * Translate metadata
 * @since 1.2.1
 */
add_action('wp', array('WPGlobus_Filters', 'set_multilingual_meta_keys'));
add_filter('get_post_metadata', array('WPGlobus_Filters', 'filter__postmeta'), 0, 4);
/**
 * ACF filters
 * @todo Move to a separate controller
 */
if (WPGlobus_WP::is_doing_ajax() || !is_admin()) {
    add_filter('acf/load_value/type=text', array('WPGlobus_Filters', 'filter__text'), 0);
    add_filter('acf/load_value/type=textarea', array('WPGlobus_Filters', 'filter__text'), 0);
    add_filter('acf/load_value/type=wysiwyg', array('WPGlobus_Filters', 'filter__text'), 0);
}
/**
 * All In One SEO Pack filters
 */
if (defined('AIOSEOP_VERSION')) {
    if (is_admin()) {
        /**
         * Filter for @see localization
         * @scope admin
         * @since 1.2.1
         */
        add_filter('localization', array('WPGlobus_Filters', 'filter__text'), 0);
 /**
  * Filter for @see get_locale
  *
  * @param string $locale
  *
  * @return string
  * @todo    Do we need to do setlocale(LC_???, $locale)? (*** NOT HERE )
  * @see     setlocale
  * @link    http://php.net/manual/en/function.setlocale.php
  * @example echo setlocale(LC_ALL, 'Russian'); => Russian_Russia.1251
  */
 public static function filter__get_locale($locale)
 {
     /**
      * @todo This caching breaks the admin language switcher.
      */
     /*		static $cached_locale = null;
     		if ( null !== $cached_locale ) {
     			return $cached_locale;
     		}*/
     /**
      * Special case: in admin area, show everything in the language of admin interface.
      * (set in the General Settings in WP 4.1)
      */
     /**
      * @internal
      * We need to exclude is_admin when it's a front-originated AJAX,
      * so we are doing a "hack" checking @see WPGlobus_WP::is_admin_doing_ajax.
      */
     if (is_admin() && (!WPGlobus_WP::is_doing_ajax() || WPGlobus_WP::is_admin_doing_ajax())) {
         /**
          * @todo is_multisite
          * @todo Pre-WP4, WPLANG constant from wp-config
          */
         $WPLANG = get_option('WPLANG');
         if (empty($WPLANG)) {
             $WPLANG = 'en_US';
         }
         WPGlobus::Config()->set_language($WPLANG);
     }
     if (is_admin()) {
         /**
          * Checking case for set locale which does not set in WPGlobus
          */
         if (WPGlobus::Config()->is_enabled_locale($locale)) {
             $locale = WPGlobus::Config()->locale[WPGlobus::Config()->language];
         }
     } else {
         $locale = WPGlobus::Config()->locale[WPGlobus::Config()->language];
     }
     /*		$cached_locale = $locale;*/
     return $locale;
 }