| @@ -1,5 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * @package Polylang | |
| 4 | + */ | |
| 2 | 5 | |
| 3 | 6 | /** |
| 4 | 7 | * Admin side controller |
| 5 | 8 | * accessible in $polylang global object |
| @@ -20,21 +23,16 @@ | ||
| 20 | 23 | * filters_columns => reference to PLL_Admin_Filters_Columns object |
| 21 | 24 | * filters_post => reference to PLL_Admin_Filters_Post object |
| 22 | 25 | * filters_term => reference to PLL_Admin_filters_Term object |
| 23 | 26 | * nav_menu => reference to PLL_Admin_Nav_Menu object |
| 24 | - * sync => reference to PLL_Admin_Sync object | |
| 25 | 27 | * block_editor => reference to PLL_Admin_Block_Editor object |
| 26 | 28 | * classic_editor => reference to PLL_Admin_Classic_Editor object |
| 27 | 29 | * filters_media => optional, reference to PLL_Admin_Filters_Media object |
| 28 | - * bulk_translate => reference, a PLL_Bulk_Translate subclass instance | |
| 29 | - * wizard => reference, a PLL_Wizard object | |
| 30 | 30 | * |
| 31 | 31 | * @since 1.2 |
| 32 | - * @since 2.7 Added a reference to a PLL_Bulk_Translate instance. | |
| 33 | - * @since 2.7 Added a reference to a PLL_Wizard object. | |
| 34 | 32 | */ |
| 35 | 33 | class PLL_Admin extends PLL_Admin_Base { |
| 36 | - public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media; | |
| 34 | + public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $filters_media; | |
| 37 | 35 | |
| 38 | 36 | /** |
| 39 | 37 | * Loads the polylang text domain |
| 40 | 38 | * Setups filters and action needed on all admin pages and on plugins page |
| @@ -63,9 +61,8 @@ | ||
| 63 | 61 | // Setup filters for admin pages |
| 64 | 62 | // Priority 5 to make sure filters are there before customize_register is fired |
| 65 | 63 | if ( $this->model->get_languages_list() ) { |
| 66 | 64 | add_action( 'wp_loaded', array( $this, 'add_filters' ), 5 ); |
| 67 | - add_action( 'admin_init', array( $this, 'maybe_load_sync_post' ), 20 ); // After fusion Builder. | |
| 68 | 65 | } |
| 69 | 66 | } |
| 70 | 67 | |
| 71 | 68 | /** |
| @@ -102,9 +99,9 @@ | ||
| 102 | 99 | * @since 2.7 instantiate a PLL_Bulk_Translate instance. |
| 103 | 100 | */ |
| 104 | 101 | public function add_filters() { |
| 105 | 102 | // All these are separated just for convenience and maintainability |
| 106 | - $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Sync', 'Classic_Editor', 'Block_Editor' ); | |
| 103 | + $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Classic_Editor', 'Block_Editor' ); | |
| 107 | 104 | |
| 108 | 105 | // Don't load media filters if option is disabled or if user has no right |
| 109 | 106 | if ( $this->options['media_support'] && ( $obj = get_post_type_object( 'attachment' ) ) && ( current_user_can( $obj->cap->edit_posts ) || current_user_can( $obj->cap->create_posts ) ) ) { |
| 110 | 107 | $classes[] = 'Filters_Media'; |
| @@ -122,91 +119,6 @@ | ||
| 122 | 119 | */ |
| 123 | 120 | $class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class ); |
| 124 | 121 | $this->$obj = new $class( $this ); |
| 125 | 122 | } |
| 126 | - | |
| 127 | - $this->posts = new PLL_CRUD_Posts( $this ); | |
| 128 | - $this->terms = new PLL_CRUD_Terms( $this ); | |
| 129 | - | |
| 130 | - // Bulk Translate | |
| 131 | - // Needs to be loaded before other modules. | |
| 132 | - if ( class_exists( 'PLL_Bulk_Translate' ) ) { | |
| 133 | - $this->bulk_translate = new PLL_Bulk_Translate( $this->model ); | |
| 134 | - add_action( 'current_screen', array( $this->bulk_translate, 'init' ) ); | |
| 135 | - } | |
| 136 | - | |
| 137 | - // Advanced media | |
| 138 | - if ( $this->options['media_support'] && class_exists( 'PLL_Admin_Advanced_Media' ) ) { | |
| 139 | - $this->advanced_media = new PLL_Admin_Advanced_Media( $this ); | |
| 140 | - } | |
| 141 | - | |
| 142 | - // Share term slugs | |
| 143 | - if ( get_option( 'permalink_structure' ) && $this->options['force_lang'] && class_exists( 'PLL_Admin_Share_Term_Slug' ) ) { | |
| 144 | - $this->share_term_slug = new PLL_Admin_Share_Term_Slug( $this ); | |
| 145 | - } | |
| 146 | - | |
| 147 | - // Duplicate content | |
| 148 | - if ( class_exists( 'PLL_Duplicate' ) ) { | |
| 149 | - $this->duplicate = new PLL_Duplicate( $this ); | |
| 150 | - } | |
| 151 | - | |
| 152 | - if ( class_exists( 'PLL_Duplicate_REST' ) ) { | |
| 153 | - $this->duplicate_rest = new PLL_Duplicate_REST(); | |
| 154 | - } | |
| 155 | - | |
| 156 | - if ( class_exists( 'PLL_Sync_Post_Model' ) ) { | |
| 157 | - $this->sync_post_model = new PLL_Sync_Post_Model( $this ); | |
| 158 | - } | |
| 159 | - | |
| 160 | - // Block editor metabox | |
| 161 | - if ( pll_use_block_editor_plugin() ) { | |
| 162 | - $this->block_editor_plugin = new PLL_Block_Editor_Plugin( $this ); | |
| 163 | - } | |
| 164 | - | |
| 165 | - // FIXME: Specific for WP CRON and WP CLI as the action admin_init is not fired. | |
| 166 | - // Waiting for a better way to handle the cases without loading the complete admin. | |
| 167 | - if ( wp_doing_cron() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { | |
| 168 | - $this->maybe_load_sync_post(); | |
| 169 | - } | |
| 170 | - | |
| 171 | - } | |
| 172 | - | |
| 173 | - /** | |
| 174 | - * Load the post synchronization object, depending on the editor in use. | |
| 175 | - * | |
| 176 | - * @since 2.6 | |
| 177 | - */ | |
| 178 | - public function maybe_load_sync_post() { | |
| 179 | - // Post synchronization | |
| 180 | - if ( 'post-new.php' === $GLOBALS['pagenow'] && function_exists( 'use_block_editor_for_post' ) ) { | |
| 181 | - // We need to wait until we know which editor is in use | |
| 182 | - add_filter( 'use_block_editor_for_post', array( $this, '_maybe_load_sync_post' ), 999 ); // After the plugin Classic Editor | |
| 183 | - } elseif ( 'post.php' === $GLOBALS['pagenow'] && function_exists( 'use_block_editor_for_post' ) && isset( $_GET['post'] ) && empty( $_GET['meta-box-loader'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 184 | - $this->_maybe_load_sync_post( use_block_editor_for_post( (int) $_GET['post'] ) ); // phpcs:ignore WordPress.Security.NonceVerification | |
| 185 | - } else { | |
| 186 | - $this->_maybe_load_sync_post( false ); | |
| 187 | - } | |
| 188 | - } | |
| 189 | - | |
| 190 | - /** | |
| 191 | - * Load the post synchronization object, depending on the editor in use. | |
| 192 | - * | |
| 193 | - * We must make sure to instantiate the class only once, as the function may be called from a filter, | |
| 194 | - * and that the synchronization model has been instantiated (due to InfiniteWP messing the actions wp_loaded and admin_init). | |
| 195 | - * | |
| 196 | - * @since 2.6 | |
| 197 | - * | |
| 198 | - * @param bool $is_block_editor Whether to use the block editor or not. | |
| 199 | - * @return bool | |
| 200 | - */ | |
| 201 | - public function _maybe_load_sync_post( $is_block_editor ) { | |
| 202 | - if ( ! isset( $this->sync_post ) && isset( $this->sync_post_model ) ) { | |
| 203 | - if ( class_exists( 'PLL_Sync_Post_REST' ) && pll_use_block_editor_plugin() && $is_block_editor ) { | |
| 204 | - $this->sync_post = new PLL_Sync_Post_REST( $this ); | |
| 205 | - } elseif ( class_exists( 'PLL_Sync_Post' ) ) { | |
| 206 | - $this->sync_post = new PLL_Sync_Post( $this ); | |
| 207 | - } | |
| 208 | - } | |
| 209 | - | |
| 210 | - return $is_block_editor; | |
| 211 | 123 | } |
| 212 | 124 | } |