| @@ -47,22 +47,13 @@ | ||
| 47 | 47 | */ |
| 48 | 48 | public function init() { |
| 49 | 49 | parent::init(); |
| 50 | 50 | |
| 51 | - $this->notices = new PLL_Admin_Notices( $this ); | |
| 52 | - | |
| 53 | - if ( Polylang::is_wizard() && class_exists( 'PLL_Wizard_Pro' ) ) { | |
| 54 | - // Instantiate PLL_Wizard_Pro class after all PLL_Admin object is all initialized. | |
| 55 | - // After PLL_Admin::maybe_load_sync_post which is hooked on admin_init with priority 20. | |
| 56 | - add_action( 'admin_init', array( $this, 'instantiate_wizard_pro' ), 30 ); | |
| 57 | - } | |
| 58 | - | |
| 59 | - $this->wizard = new PLL_Wizard( $this ); | |
| 60 | - | |
| 61 | 51 | if ( ! $this->model->get_languages_list() ) { |
| 62 | 52 | return; |
| 63 | 53 | } |
| 64 | 54 | |
| 55 | + $this->notices = new PLL_Admin_Notices( $this ); | |
| 65 | 56 | $this->links = new PLL_Admin_Links( $this ); // FIXME needed here ? |
| 66 | 57 | $this->static_pages = new PLL_Admin_Static_Pages( $this ); // FIXME needed here ? |
| 67 | 58 | $this->filters_links = new PLL_Filters_Links( $this ); // FIXME needed here ? |
| 68 | 59 | |
| @@ -67,9 +58,9 @@ | ||
| 67 | 58 | $this->filters_links = new PLL_Filters_Links( $this ); // FIXME needed here ? |
| 68 | 59 | |
| 69 | 60 | // Filter admin language for users |
| 70 | 61 | // We must not call user info before WordPress defines user roles in wp-settings.php |
| 71 | - add_action( 'setup_theme', array( $this, 'init_user' ) ); | |
| 62 | + add_filter( 'setup_theme', array( $this, 'init_user' ) ); | |
| 72 | 63 | add_filter( 'request', array( $this, 'request' ) ); |
| 73 | 64 | |
| 74 | 65 | // Adds the languages in admin bar |
| 75 | 66 | add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100 ); // 100 determines the position |
| @@ -86,10 +77,8 @@ | ||
| 86 | 77 | * |
| 87 | 78 | * @since 0.1 |
| 88 | 79 | */ |
| 89 | 80 | public function add_menus() { |
| 90 | - global $admin_page_hooks; | |
| 91 | - | |
| 92 | 81 | // Prepare the list of tabs |
| 93 | 82 | $tabs = array( 'lang' => __( 'Languages', 'polylang' ) ); |
| 94 | 83 | |
| 95 | 84 | // Only if at least one language has been created |
| @@ -107,16 +96,13 @@ | ||
| 107 | 96 | * @param array $tabs list of tab names |
| 108 | 97 | */ |
| 109 | 98 | $tabs = apply_filters( 'pll_settings_tabs', $tabs ); |
| 110 | 99 | |
| 111 | - $parent = ''; | |
| 112 | - | |
| 113 | 100 | foreach ( $tabs as $tab => $title ) { |
| 114 | 101 | $page = 'lang' === $tab ? 'mlang' : "mlang_$tab"; |
| 115 | 102 | if ( empty( $parent ) ) { |
| 116 | 103 | $parent = $page; |
| 117 | 104 | add_menu_page( $title, __( 'Languages', 'polylang' ), 'manage_options', $page, null, 'dashicons-translation' ); |
| 118 | - $admin_page_hooks[ $page ] = 'languages'; // Hack to avoid the localization of the hook name. See: https://core.trac.wordpress.org/ticket/18857 | |
| 119 | 105 | } |
| 120 | 106 | |
| 121 | 107 | add_submenu_page( $parent, $title, $title, 'manage_options', $page, array( $this, 'languages_page' ) ); |
| 122 | 108 | } |
| @@ -134,23 +120,22 @@ | ||
| 134 | 120 | } |
| 135 | 121 | |
| 136 | 122 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 137 | 123 | |
| 138 | - /* | |
| 139 | - * For each script: | |
| 140 | - * 0 => the pages on which to load the script | |
| 141 | - * 1 => the scripts it needs to work | |
| 142 | - * 2 => 1 if loaded even if languages have not been defined yet, 0 otherwise | |
| 143 | - * 3 => 1 if loaded in footer | |
| 144 | - */ | |
| 124 | + // For each script: | |
| 125 | + // 0 => the pages on which to load the script | |
| 126 | + // 1 => the scripts it needs to work | |
| 127 | + // 2 => 1 if loaded even if languages have not been defined yet, 0 otherwise | |
| 128 | + // 3 => 1 if loaded in footer | |
| 129 | + // FIXME: check if I can load more scripts in footer | |
| 145 | 130 | $scripts = array( |
| 146 | - 'user' => array( array( 'profile', 'user-edit' ), array( 'jquery' ), 0, 0 ), | |
| 147 | - 'widgets' => array( array( 'widgets' ), array( 'jquery' ), 0, 0 ), | |
| 131 | + 'post' => array( array( 'edit', 'upload' ), array( 'jquery', 'wp-ajax-response' ), 0, 1 ), | |
| 132 | + 'term' => array( array( 'edit-tags', 'term' ), array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), 0, 1 ), | |
| 133 | + 'user' => array( array( 'profile', 'user-edit' ), array( 'jquery' ), 0, 0 ), | |
| 134 | + 'widgets' => array( array( 'widgets' ), array( 'jquery' ), 0, 0 ), | |
| 148 | 135 | ); |
| 149 | 136 | |
| 150 | 137 | if ( ! empty( $screen->post_type ) && $this->model->is_translated_post_type( $screen->post_type ) ) { |
| 151 | - $scripts['post'] = array( array( 'edit', 'upload' ), array( 'jquery', 'wp-ajax-response' ), 0, 1 ); | |
| 152 | - | |
| 153 | 138 | // Classic editor. |
| 154 | 139 | if ( ! method_exists( $screen, 'is_block_editor' ) || ! $screen->is_block_editor() ) { |
| 155 | 140 | $scripts['classic-editor'] = array( array( 'post', 'media', 'async-upload' ), array( 'jquery', 'wp-ajax-response', 'post' ), 0, 1 ); |
| 156 | 141 | } |
| @@ -160,12 +145,8 @@ | ||
| 160 | 145 | $scripts['block-editor'] = array( array( 'post' ), array( 'jquery', 'wp-ajax-response', 'wp-api-fetch' ), 0, 1 ); |
| 161 | 146 | } |
| 162 | 147 | } |
| 163 | 148 | |
| 164 | - if ( ! empty( $screen->taxonomy ) && $this->model->is_translated_taxonomy( $screen->taxonomy ) ) { | |
| 165 | - $scripts['term'] = array( array( 'edit-tags', 'term' ), array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), 0, 1 ); | |
| 166 | - } | |
| 167 | - | |
| 168 | 149 | foreach ( $scripts as $script => $v ) { |
| 169 | 150 | if ( in_array( $screen->base, $v[0] ) && ( $v[2] || $this->model->get_languages_list() ) ) { |
| 170 | 151 | wp_enqueue_script( 'pll_' . $script, plugins_url( '/js/' . $script . $suffix . '.js', POLYLANG_FILE ), $v[1], POLYLANG_VERSION, $v[3] ); |
| 171 | 152 | } |
| @@ -438,14 +419,6 @@ | ||
| 438 | 419 | 'meta' => 'all' === $lang->slug ? array() : array( 'lang' => esc_attr( $lang->get_locale( 'display' ) ) ), |
| 439 | 420 | ) |
| 440 | 421 | ); |
| 441 | 422 | } |
| 442 | - } | |
| 443 | - /** | |
| 444 | - * Instantiate PLL_Wizard_Pro class. | |
| 445 | - * | |
| 446 | - * @since 2.7 | |
| 447 | - */ | |
| 448 | - public function instantiate_wizard_pro() { | |
| 449 | - $this->wizard_pro = new PLL_Wizard_Pro( $this ); | |
| 450 | 423 | } |
| 451 | 424 | } |