PluginProbe
Polylang / 2.8
Polylang v2.8
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | admin/admin-base.php +19 -56 2.7.12.8 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Base class for both admin
5 8 *
@@ -19,9 +22,9 @@
19 22 public function __construct( &$links_model ) {
20 23 parent::__construct( $links_model );
21 24
22 25 // Plugin i18n, only needed for backend
23 - load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' );
26 + load_plugin_textdomain( 'polylang' );
24 27
25 28 // Adds the link to the languages panel in the WordPress admin menu
26 29 add_action( 'admin_menu', array( $this, 'add_menus' ) );
27 30
@@ -29,15 +32,8 @@
29 32 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
30 33 add_action( 'admin_print_footer_scripts', array( $this, 'admin_print_footer_scripts' ), 0 ); // High priority in case an ajax request is sent by an immediately invoked function
31 34
32 35 add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls_enqueue_scripts' ) );
33 -
34 - if ( defined( 'POLYLANG_PRO' ) ) {
35 - new PLL_Pro();
36 - } elseif ( ! defined( 'PLL_LINGOTEK_AD' ) || PLL_LINGOTEK_AD ) {
37 - require_once POLYLANG_DIR . '/lingotek/lingotek.php'; // Lingotek
38 - add_action( 'wp_loaded', array( new PLL_Lingotek(), 'init' ) );
39 - }
40 36 }
41 37
42 38 /**
43 39 * Setups filters and action needed on all admin pages and on plugins page
@@ -49,16 +45,8 @@
49 45 parent::init();
50 46
51 47 $this->notices = new PLL_Admin_Notices( $this );
52 48
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 49 if ( ! $this->model->get_languages_list() ) {
62 50 return;
63 51 }
64 52
@@ -72,14 +60,8 @@
72 60 add_filter( 'request', array( $this, 'request' ) );
73 61
74 62 // Adds the languages in admin bar
75 63 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100 ); // 100 determines the position
76 -
77 - // Translate slugs, only for pretty permalinks
78 - if ( get_option( 'permalink_structure' ) && class_exists( 'PLL_Translate_Slugs' ) ) {
79 - $slugs_model = new PLL_Translate_Slugs_Model( $this );
80 - $this->translate_slugs = new PLL_Translate_Slugs( $slugs_model, $this->curlang );
81 - }
82 64 }
83 65
84 66 /**
85 67 * Adds the link to the languages panel in the WordPress admin menu
@@ -134,22 +116,23 @@
134 116 }
135 117
136 118 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
137 119
138 - // For each script:
139 - // 0 => the pages on which to load the script
140 - // 1 => the scripts it needs to work
141 - // 2 => 1 if loaded even if languages have not been defined yet, 0 otherwise
142 - // 3 => 1 if loaded in footer
143 - // FIXME: check if I can load more scripts in footer
120 + /*
121 + * For each script:
122 + * 0 => the pages on which to load the script
123 + * 1 => the scripts it needs to work
124 + * 2 => 1 if loaded even if languages have not been defined yet, 0 otherwise
125 + * 3 => 1 if loaded in footer
126 + */
144 127 $scripts = array(
145 - 'post' => array( array( 'edit', 'upload' ), array( 'jquery', 'wp-ajax-response' ), 0, 1 ),
146 - 'term' => array( array( 'edit-tags', 'term' ), array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), 0, 1 ),
147 - 'user' => array( array( 'profile', 'user-edit' ), array( 'jquery' ), 0, 0 ),
148 - 'widgets' => array( array( 'widgets' ), array( 'jquery' ), 0, 0 ),
128 + 'user' => array( array( 'profile', 'user-edit' ), array( 'jquery' ), 0, 0 ),
129 + 'widgets' => array( array( 'widgets' ), array( 'jquery' ), 0, 0 ),
149 130 );
150 131
151 132 if ( ! empty( $screen->post_type ) && $this->model->is_translated_post_type( $screen->post_type ) ) {
133 + $scripts['post'] = array( array( 'edit', 'upload' ), array( 'jquery', 'wp-ajax-response' ), 0, 1 );
134 +
152 135 // Classic editor.
153 136 if ( ! method_exists( $screen, 'is_block_editor' ) || ! $screen->is_block_editor() ) {
154 137 $scripts['classic-editor'] = array( array( 'post', 'media', 'async-upload' ), array( 'jquery', 'wp-ajax-response', 'post' ), 0, 1 );
155 138 }
@@ -159,8 +142,12 @@
159 142 $scripts['block-editor'] = array( array( 'post' ), array( 'jquery', 'wp-ajax-response', 'wp-api-fetch' ), 0, 1 );
160 143 }
161 144 }
162 145
146 + if ( ! empty( $screen->taxonomy ) && $this->model->is_translated_taxonomy( $screen->taxonomy ) ) {
147 + $scripts['term'] = array( array( 'edit-tags', 'term' ), array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), 0, 1 );
148 + }
149 +
163 150 foreach ( $scripts as $script => $v ) {
164 151 if ( in_array( $screen->base, $v[0] ) && ( $v[2] || $this->model->get_languages_list() ) ) {
165 152 wp_enqueue_script( 'pll_' . $script, plugins_url( '/js/' . $script . $suffix . '.js', POLYLANG_FILE ), $v[1], POLYLANG_VERSION, $v[3] );
166 153 }
@@ -189,24 +176,8 @@
189 176 *
190 177 * @since 2.4.0
191 178 */
192 179 public function localize_scripts() {
193 - if ( wp_script_is( 'pll_classic-editor', 'enqueued' ) ) {
194 - wp_localize_script(
195 - 'pll_classic-editor',
196 - 'confirm_text',
197 - __( 'You are about to overwrite an existing translation. Are you sure you want to proceed?', 'polylang' )
198 - );
199 - }
200 -
201 - if ( wp_script_is( 'pll_block-editor', 'enqueued' ) ) {
202 - wp_localize_script(
203 - 'pll_block-editor',
204 - 'confirm_text',
205 - __( 'You are about to overwrite an existing translation. Are you sure you want to proceed?', 'polylang' )
206 - );
207 - }
208 -
209 180 if ( wp_script_is( 'pll_widgets', 'enqueued' ) ) {
210 181 wp_localize_script(
211 182 'pll_widgets',
212 183 'pll_widgets',
@@ -433,14 +404,6 @@
433 404 'meta' => 'all' === $lang->slug ? array() : array( 'lang' => esc_attr( $lang->get_locale( 'display' ) ) ),
434 405 )
435 406 );
436 407 }
437 - }
438 - /**
439 - * Instantiate PLL_Wizard_Pro class.
440 - *
441 - * @since 2.7
442 - */
443 - public function instantiate_wizard_pro() {
444 - $this->wizard_pro = new PLL_Wizard_Pro( $this );
445 408 }
446 409 }