PluginProbe
Polylang / 2.7.3
Polylang v2.7.3
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 | settings/settings.php +31 -16 2.8.32.7.3 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * A class for the Polylang settings pages
8 5 * accessible in $polylang global object
@@ -35,8 +32,15 @@
35 32 */
36 33 protected $modules;
37 34
38 35 /**
36 + * Reference to PLL_Import_Export
37 + *
38 + * @var PLL_Import_Export $import_export
39 + */
40 + protected $import_export;
41 +
42 + /**
39 43 * Constructor
40 44 *
41 45 * @since 1.2
42 46 *
@@ -50,8 +54,13 @@
50 54 }
51 55
52 56 PLL_Admin_Strings::init();
53 57
58 + if ( class_exists( 'PLL_Import_Export' ) ) {
59 + $this->import_export = new PLL_Import_Export( $this );
60 + }
61 +
62 + // FIXME put this as late as possible
54 63 add_action( 'admin_init', array( $this, 'register_settings_modules' ) );
55 64
56 65 // Adds screen options and the about box in the languages admin panel
57 66 add_action( 'load-toplevel_page_mlang', array( $this, 'load_page' ) );
@@ -66,21 +75,28 @@
66 75 *
67 76 * @since 1.8
68 77 */
69 78 public function register_settings_modules() {
70 - $modules = array();
79 + $modules = array(
80 + 'PLL_Settings_Licenses',
81 + );
71 82
72 83 if ( $this->model->get_languages_list() ) {
73 - $modules = array(
74 - 'PLL_Settings_Url',
75 - 'PLL_Settings_Browser',
76 - 'PLL_Settings_Media',
77 - 'PLL_Settings_CPT',
84 + $modules = array_merge(
85 + array(
86 + 'PLL_Settings_Url',
87 + 'PLL_Settings_Browser',
88 + 'PLL_Settings_Media',
89 + 'PLL_Settings_CPT',
90 + 'PLL_Settings_Sync',
91 + 'PLL_Settings_WPML',
92 + 'PLL_Settings_Share_Slug',
93 + 'PLL_Settings_Translate_Slugs',
94 + ),
95 + $modules
78 96 );
79 97 }
80 98
81 - $modules[] = 'PLL_Settings_Licenses';
82 -
83 99 /**
84 100 * Filter the list of setting modules
85 101 *
86 102 * @since 1.8
@@ -100,9 +116,9 @@
100 116 *
101 117 * @since 0.8
102 118 */
103 119 public function metabox_about() {
104 - include __DIR__ . '/view-about.php';
120 + include PLL_SETTINGS_INC . '/view-about.php';
105 121 }
106 122
107 123 /**
108 124 * Adds screen options and the about box in the languages admin panel
@@ -183,9 +199,9 @@
183 199 } else {
184 200 add_settings_error( 'general', 'pll_languages_created', __( 'Language added.', 'polylang' ), 'updated' );
185 201 $locale = sanitize_text_field( wp_unslash( $_POST['locale'] ) ); // phpcs:ignore WordPress.Security
186 202
187 - if ( 'en_US' !== $locale && current_user_can( 'install_languages' ) ) {
203 + if ( 'en_US' !== $locale ) {
188 204 // Attempts to install the language pack
189 205 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
190 206 if ( ! wp_download_language_pack( $locale ) ) {
191 207 add_settings_error( 'general', 'pll_download_mo', __( 'The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang' ) );
@@ -311,9 +327,9 @@
311 327 $this->handle_actions( $action );
312 328 }
313 329
314 330 // Displays the page
315 - include __DIR__ . '/view-languages.php';
331 + include PLL_SETTINGS_INC . '/view-languages.php';
316 332 }
317 333
318 334 /**
319 335 * Enqueues scripts and styles
@@ -324,9 +340,8 @@
324 340 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
325 341
326 342 wp_enqueue_script( 'pll_admin', plugins_url( '/js/admin' . $suffix . '.js', POLYLANG_FILE ), array( 'jquery', 'wp-ajax-response', 'postbox', 'jquery-ui-selectmenu' ), POLYLANG_VERSION );
327 343 wp_localize_script( 'pll_admin', 'pll_flag_base_url', plugins_url( '/flags/', POLYLANG_FILE ) );
328 - wp_localize_script( 'pll_admin', 'pll_dismiss_notice', esc_html__( 'Dismiss this notice.', 'polylang' ) );
329 344
330 345 wp_enqueue_style( 'pll_selectmenu', plugins_url( '/css/selectmenu' . $suffix . '.css', POLYLANG_FILE ), array(), POLYLANG_VERSION );
331 346 }
332 347
@@ -371,9 +386,9 @@
371 386 */
372 387 public static function get_predefined_languages() {
373 388 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
374 389
375 - $languages = include __DIR__ . '/languages.php';
390 + $languages = include PLL_SETTINGS_INC . '/languages.php';
376 391 $translations = wp_get_available_translations();
377 392
378 393 // Keep only languages with existing WP language pack
379 394 // Unless the transient has expired and we don't have an internet connection to refresh it