/** * List of the premium WPGlobus extensions. * This file is created manually. */ protected static function _setup_paid_plugins() { self::$paid_plugins = array(); $data_file = WPGlobus::data_path() . '/paid_plugins.json'; if (is_readable($data_file)) { $_json = file_get_contents($data_file); self::$paid_plugins = json_decode($_json, true); uasort(self::$paid_plugins, array(__CLASS__, 'sort_paid_plugins')); } }
/** * Constructor */ public function __construct() { if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { self::$_SCRIPT_DEBUG = true; self::$_SCRIPT_SUFFIX = ''; } /** @todo maybe move this action to Class WPGlobus_Upgrade ? */ add_action('admin_init', array($this, 'on_admin_init')); global $WPGlobus_Options; global $pagenow; $config = WPGlobus::Config(); /** * Init array of supported plugins */ $this->vendors_scripts['ACF'] = false; $this->vendors_scripts['ACFPRO'] = false; /** Set to true in @see WPGlobus_WPSEO::controller */ $this->vendors_scripts['WPSEO'] = false; $this->vendors_scripts['WOOCOMMERCE'] = false; $this->vendors_scripts['AIOSEOP'] = false; // All In One SEO Pack $this->vendors_scripts['WPCF7'] = false; // Contact Form 7 if (function_exists('acf')) { /** * @todo Work on the ACF compatibility is in progress * Temporarily add CPT acf ( Advanced Custom Fields ) to the array of disabled_entities * @see 'wpglobus_disabled_entities' filter for add/remove custom post types to array disabled_entities * @since 1.0.4 */ global $acf; if (!empty($acf->settings['pro']) && $acf->settings['pro']) { /** * @since 1.2.6 */ $this->vendors_scripts['ACFPRO'] = true; $this->disabled_entities[] = 'acf-field-group'; $this->disabled_entities[] = 'acf-field'; } else { $this->vendors_scripts['ACF'] = true; $this->disabled_entities[] = 'acf'; } } if (defined('WC_VERSION') || defined('WOOCOMMERCE_VERSION')) { $this->vendors_scripts['WOOCOMMERCE'] = true; $this->disabled_entities[] = 'product'; $this->disabled_entities[] = 'product_tag'; $this->disabled_entities[] = 'product_cat'; $this->disabled_entities[] = 'shop_order'; $this->disabled_entities[] = 'shop_coupon'; /** * Gathering Woocommerce's post types in one place * @since 1.4.3 */ $this->disabled_entities[] = 'product_variation'; $this->disabled_entities[] = 'shop_order_refund'; $this->disabled_entities[] = 'shop_webhook'; } if (defined('AIOSEOP_VERSION')) { $this->vendors_scripts['AIOSEOP'] = true; } if (defined('WPCF7_VERSION')) { $this->vendors_scripts['WPCF7'] = true; /** * Disable cpt of plugin Contact Form 7 by default * * @since 1.4.6 */ $this->disabled_entities[] = 'wpcf7_contact_form'; } /** * If you need add new vendors script and disable cpt * you must add it to customizer also * @see class-wpglobus-customize-options.php:596 */ /** * Add builtin post type */ $this->disabled_entities[] = 'attachment'; /** * Add disabled post types from option */ $option = get_option('wpglobus_option'); $options_post_types = empty($option['post_type']) ? array() : $option['post_type']; foreach ($options_post_types as $post_type => $value) { if ($value != '1') { $this->disabled_entities[] = $post_type; } } /** * Set disabled entities into config * @todo maybe move code to Class WPGlobus_Config */ WPGlobus::Config()->disabled_entities = $this->disabled_entities; add_filter('wp_redirect', array($this, 'on_wp_redirect')); /** * NOTE: do not check for !DOING_AJAX here. Redux uses AJAX, for example, for disabling tracking. * So, we need to load Redux on AJAX requests, too */ if (is_admin()) { /** * Set values * @since 1.2.0 */ $this->enabled_pages[] = self::LANGUAGE_EDIT_PAGE; $this->enabled_pages[] = self::OPTIONS_PAGE_SLUG; $this->enabled_pages[] = 'post.php'; $this->enabled_pages[] = 'post-new.php'; $this->enabled_pages[] = 'nav-menus.php'; /** * @since 1.5.0 * edit-tags.php obsolete in WP 4.5 * term.php new in WP 4.5 */ $this->enabled_pages[] = 'edit-tags.php'; $this->enabled_pages[] = 'term.php'; $this->enabled_pages[] = 'edit.php'; $this->enabled_pages[] = 'options-general.php'; $this->enabled_pages[] = 'widgets.php'; $this->enabled_pages[] = 'customize.php'; /** * WPGlobus clean page * @since 1.4.3 */ $this->enabled_pages[] = self::PAGE_WPGLOBUS_CLEAN; /** * WPGlobus Admin Central page. * @since 1.6.6 */ $this->enabled_pages[] = self::PAGE_WPGLOBUS_ADMIN_CENTRAL; add_action('admin_body_class', array($this, 'on_add_admin_body_class')); add_action('wp_ajax_' . __CLASS__ . '_process_ajax', array($this, 'on_process_ajax')); require_once 'options/class-wpglobus-options.php'; new WPGlobus_Options(); if (in_array($pagenow, array('edit-tags.php', 'term.php'), true)) { /** * Need to get taxonomy to use the correct filter. */ $taxonomy_slug = WPGlobus_Utils::safe_get('taxonomy'); if ($taxonomy_slug) { add_action("{$taxonomy_slug}_pre_edit_form", array($this, 'on_add_language_tabs_edit_taxonomy'), 10, 2); add_action("{$taxonomy_slug}_edit_form", array($this, 'on_add_taxonomy_form_wrapper'), 10, 2); } } if (self::Config()->toggle == 'on' || !$this->user_can('wpglobus_toggle')) { /** * Filters for adding language column to edit.php page */ if (WPGlobus_WP::is_pagenow('edit.php') && !$this->disabled_entity()) { $post_type_filter = WPGlobus_Utils::safe_get('post_type'); if ($post_type_filter) { // This is a CPT. // Add underscore to form the // "manage_{$post->post_type}_posts_custom_column" filter. $post_type_filter = '_' . $post_type_filter; } add_filter("manage{$post_type_filter}_posts_columns", array($this, 'on_add_language_column')); add_filter("manage{$post_type_filter}_posts_custom_column", array($this, 'on_manage_language_column')); } /** * Join post content and post title for enabled languages in func wp_insert_post * @see action in wp-includes\post.php:3326 */ add_action('wp_insert_post_data', array($this, 'on_save_post_data'), 10, 2); add_action('edit_form_after_editor', array($this, 'on_add_wp_editors'), 10); add_action('edit_form_after_editor', array($this, 'on_add_language_tabs')); add_action('edit_form_after_title', array($this, 'on_add_title_fields')); add_action('admin_print_scripts', array($this, 'on_admin_scripts')); add_action('admin_print_scripts', array($this, 'on_admin_enqueue_scripts'), 99); add_action('admin_footer', array($this, 'on_admin_footer')); add_filter('admin_title', array($this, 'on_admin_title'), 10, 2); if ($this->vendors_scripts['AIOSEOP'] && WPGlobus_WP::is_pagenow(array('post.php', 'post-new.php', 'edit.php'))) { /** @global WP_Post $post */ global $post; $type = empty($post) ? '' : $post->post_type; if (!$this->disabled_entity($type)) { require_once 'vendor/class-wpglobus-aioseop.php'; if (WPGlobus_WP::is_pagenow(array('post.php', 'post-new.php'))) { /** @noinspection PhpUnusedLocalVariableInspection */ $WPGlobus_aioseop = new WPGlobus_aioseop(); } } } } // endif $devmode if (($this->vendors_scripts['ACF'] || $this->vendors_scripts['ACFPRO']) && WPGlobus_WP::is_pagenow(array('post.php', 'post-new.php'))) { require_once 'vendor/class-wpglobus-acf.php'; $WPGlobus_acf = new WPGlobus_Acf(); } add_action('admin_print_styles', array($this, 'on_admin_styles')); add_action('admin_menu', array($this, 'on_admin_menu'), 10); add_action('post_submitbox_misc_actions', array($this, 'on_add_devmode_switcher')); add_action('admin_bar_menu', array($this, 'on_admin_bar_menu')); if (WPGlobus_WP::is_pagenow('plugin-install.php')) { require_once 'admin/class-wpglobus-plugin-install.php'; WPGlobus_Plugin_Install::controller(); } } else { /** * @scope front */ $this->menus = self::_get_nav_menus(); /** * @todo This filter is currently disabled. Need to check if we need it. * The on_wp_list_pages is called directly from on_wp_page_menu */ 0 && add_filter('wp_list_pages', array($this, 'on_wp_list_pages'), 99, 2); add_filter('wp_page_menu', array($this, 'on_wp_page_menu'), 99, 2); /** * Add language switcher to navigation menu * @see on_add_item */ add_filter('wp_nav_menu_objects', array($this, 'on_add_item'), 99, 2); /** * Convert url for menu items */ add_filter('wp_nav_menu_objects', array($this, 'on_get_convert_url_menu_items'), 10, 2); add_action('wp_head', array($this, 'on_wp_head'), 11); add_action('wp_head', array($this, 'on_add_hreflang'), 11); add_action('wp_print_styles', array($this, 'on_wp_styles')); add_action('wp_enqueue_scripts', array($this, 'enqueue_wpglobus_js'), PHP_INT_MAX); } }