public static function controller() { /** * @see \WP_Customize_Manager::wp_loaded * It calls the `customize_register` action first, * and then - the `customize_preview_init` action */ /* add_action( 'customize_register', array( 'WPGlobus_Customize', 'action__customize_register' ) ); */ /** * @since 1.5.0 */ if (WPGlobus_WP::is_pagenow('customize.php')) { require_once 'admin/wpglobus-customize-filters.php'; } add_action('customize_preview_init', array('WPGlobus_Customize', 'action__customize_preview_init')); /** * This is called by wp-admin/customize.php */ add_action('customize_controls_enqueue_scripts', array('WPGlobus_Customize', 'action__customize_controls_enqueue_scripts'), 1000); if (WPGlobus_WP::is_admin_doing_ajax()) { add_filter('clean_url', array('WPGlobus_Customize', 'filter__clean_url'), 10, 2); } }
/** * @covers WPGlobus_WP::is_admin_doing_ajax */ public function test_is_is_admin_doing_ajax() { if (!defined('DOING_AJAX')) { define('DOING_AJAX', true); } /** * POST */ unset($_GET['action'], $_POST['action']); foreach (array('inline-save', 'save-widget') as $action) { $_POST['action'] = $action; self::assertTrue(WPGlobus_WP::is_admin_doing_ajax(), $action); } /** * GET */ unset($_GET['action'], $_POST['action']); foreach (array('ajax-tag-search') as $action) { $_GET['action'] = $action; self::assertTrue(WPGlobus_WP::is_admin_doing_ajax(), $action); } /** Cleanup */ unset($_GET['action'], $_POST['action']); }
* Initialize */ WPGlobus::$PLUGIN_DIR_PATH = plugin_dir_path(__FILE__); WPGlobus::$PLUGIN_DIR_URL = plugin_dir_url(__FILE__); WPGlobus::Config(); require_once 'includes/class-wpglobus-filters.php'; require_once 'includes/wpglobus-controller.php'; if (defined('WPSEO_VERSION')) { require_once 'includes/class-wpglobus-wpseo.php'; WPGlobus_WPSEO::controller(); } /** * Theme compatibility */ /** * Fix multilingual strings in basic `Customize` * * @since 1.2.1 */ require_once 'includes/class-wpglobus-customize.php'; WPGlobus_Customize::controller(); /** * Support of theme option panels and customizer * @since 1.3.0 */ if (WPGlobus_WP::in_wp_admin() && !WPGlobus_WP::is_admin_doing_ajax()) { require_once 'includes/admin/class-wpglobus-wp-theme.php'; WPGlobus::Config()->WPGlobus_WP_Theme = new WPGlobus_WP_Theme(); } require_once 'updater/class-wpglobus-updater.php'; # --- EOF
/** * 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; }