PluginProbe
Polylang / 2.1
Polylang v2.1
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.php +37 -117 2.92.1 View file →
@@ -1,93 +1,36 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 - * Admin side controller
4 + * admin side controller
8 5 * accessible in $polylang global object
9 6 *
10 - * Properties:
11 - * options => inherited, reference to Polylang options array
12 - * model => inherited, reference to PLL_Model object
13 - * links_model => inherited, reference to PLL_Links_Model object
14 - * links => inherited, reference to PLL_Admin_Links object
15 - * static_pages => inherited, reference to PLL_Admin_Static_Pages object
16 - * filters_links => inherited, reference to PLL_Filters_Links object
17 - * curlang => inherited, optional, current language used to filter the content (language of the post or term being edited, equal to filter_lang otherwise)
18 - * filter_lang => inherited, optional, current status of the admin languages filter (in the admin bar)
19 - * pref_lang => inherited, preferred language used as default when saving posts or terms
20 - * posts => reference to PLL_CRUD_Posts object
21 - * terms => reference to PLL_CRUD_Terms object
22 - * filters => reference to PLL_Admin_Filters object
23 - * filters_sanitization => reference to PLL_Filters_Sanitization object
24 - * filters_columns => reference to PLL_Admin_Filters_Columns object
25 - * filters_post => reference to PLL_Admin_Filters_Post object
26 - * filters_term => reference to PLL_Admin_filters_Term object
27 - * nav_menu => reference to PLL_Admin_Nav_Menu object
28 - * block_editor => reference to PLL_Admin_Block_Editor object
29 - * classic_editor => reference to PLL_Admin_Classic_Editor object
30 - * filters_media => optional, reference to PLL_Admin_Filters_Media object
7 + * properties:
8 + * options => inherited, reference to Polylang options array
9 + * model => inherited, reference to PLL_Model object
10 + * links_model => inherited, reference to PLL_Links_Model object
11 + * links => inherited, reference to PLL_Admin_Links object
12 + * static_pages => inherited, reference to PLL_Admin_Static_Pages object
13 + * filters_links => inherited, reference to PLL_Filters_Links object
14 + * curlang => inherited, optional, current language used to filter the content (language of the post or term being edited, equal to filter_lang otherwise)
15 + * filter_lang => inherited, optional, current status of the admin languages filter (in the admin bar)
16 + * pref_lang => inherited, preferred language used as default when saving posts or terms
17 + * filters => reference to PLL_Filters object
18 + * filters_columns => reference to PLL_Admin_Filters_Columns object
19 + * filters_post => reference to PLL_Admin_Filters_Post object
20 + * filters_term => reference to PLL_Admin_filters_Term object
21 + * nav_menu => reference to PLL_Admin_Nav_Menu object
22 + * filters_media => optional, reference to PLL_Admin_Filters_Media object
31 23 *
32 24 * @since 1.2
33 25 */
34 26 class PLL_Admin extends PLL_Admin_Base {
35 - /**
36 - * Instance of PLL_Admin_Filters
37 - *
38 - * @var PLL_Admin_Filters
39 - */
40 - public $filters;
27 + public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media;
41 28
42 29 /**
43 - * Instance of PLL_Admin_Filters_Columns
30 + * loads the polylang text domain
31 + * setups filters and action needed on all admin pages and on plugins page
44 32 *
45 - * @var PLL_Admin_Filters_Columns
46 - */
47 - public $filters_columns;
48 -
49 - /**
50 - * Instance of PLL_Admin_Filters_Post
51 - *
52 - * @var PLL_Admin_Filters_Post
53 - */
54 - public $filters_post;
55 -
56 - /**
57 - * Instance of PLL_Admin_filters_Term
58 - *
59 - * @var PLL_Admin_filters_Term
60 - */
61 - public $filters_term;
62 -
63 - /**
64 - * Instance of PLL_Admin_Nav_Menu
65 - *
66 - * @var PLL_Admin_Nav_Menu
67 - */
68 - public $nav_menu;
69 -
70 - /**
71 - * Instance of PLL_Admin_Filters_Media
72 - *
73 - * @var PLL_Admin_Filters_Media
74 - */
75 - public $filters_media;
76 -
77 - /**
78 - * Instance of PLL_Filters_Sanitization
79 - *
80 - * @since 2.9
81 - *
82 - * @var PLL_Filters_Sanitization
83 - */
84 - public $filters_sanitization;
85 -
86 - /**
87 - * Loads the polylang text domain
88 - * Setups filters and action needed on all admin pages and on plugins page
89 - *
90 33 * @since 1.2
91 34 *
92 35 * @param object $links_model
93 36 */
@@ -93,24 +36,26 @@
93 36 */
94 37 public function __construct( &$links_model ) {
95 38 parent::__construct( $links_model );
96 39
97 - // Adds a 'settings' link in the plugins table
40 + // adds a 'settings' link in the plugins table
98 41 add_filter( 'plugin_action_links_' . POLYLANG_BASENAME, array( $this, 'plugin_action_links' ) );
99 42 add_action( 'in_plugin_update_message-' . POLYLANG_BASENAME, array( $this, 'plugin_update_message' ), 10, 2 );
100 43 }
101 44
102 45 /**
103 - * Setups filters and action needed on all admin pages and on plugins page
104 - * Loads the settings pages or the filters base on the request
46 + * setups filters and action needed on all admin pages and on plugins page
47 + * loads the settings pages or the filters base on the request
105 48 *
106 49 * @since 1.2
50 + *
51 + * @param object $links_model
107 52 */
108 53 public function init() {
109 54 parent::init();
110 55
111 - // Setup filters for admin pages
112 - // Priority 5 to make sure filters are there before customize_register is fired
56 + // setup filters for admin pages
57 + // priority 5 to make sure filters are there before customize_register is fired
113 58 if ( $this->model->get_languages_list() ) {
114 59 add_action( 'wp_loaded', array( $this, 'add_filters' ), 5 );
115 60 }
116 61 }
@@ -115,9 +60,9 @@
115 60 }
116 61 }
117 62
118 63 /**
119 - * Adds a 'settings' link in the plugins table
64 + * adds a 'settings' link in the plugins table
120 65 *
121 66 * @since 0.1
122 67 *
123 68 * @param array $links list of links associated to the plugin
@@ -128,16 +73,16 @@
128 73 return $links;
129 74 }
130 75
131 76 /**
132 - * Adds the upgrade notice in plugins table
77 + * adds the upgrade notice in plugins table
133 78 *
134 79 * @since 1.1.6
135 80 *
136 - * @param array $plugin_data Not used
137 - * @param object $r Plugin update data
81 + * @param array $plugin_data not used
82 + * @param object $r plugin update data
138 83 */
139 - public function plugin_update_message( $plugin_data, $r ) {
84 + function plugin_update_message( $plugin_data, $r ) {
140 85 if ( isset( $r->upgrade_notice ) ) {
141 86 printf( '<p style="margin: 3px 0 0 0; border-top: 1px solid #ddd; padding-top: 3px">%s</p>', esc_html( $r->upgrade_notice ) );
142 87 }
143 88 }
@@ -142,19 +87,17 @@
142 87 }
143 88 }
144 89
145 90 /**
146 - * Setup filters for admin pages
91 + * setup filters for admin pages
147 92 *
148 93 * @since 1.2
149 - * @since 2.7 instantiate a PLL_Bulk_Translate instance.
150 94 */
151 95 public function add_filters() {
152 - $this->filters_sanitization = new PLL_Filters_Sanitization( $this->get_locale_for_sanitization() );
153 - // All these are separated just for convenience and maintainability
154 - $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Classic_Editor', 'Block_Editor' );
96 + // all these are separated just for convenience and maintainability
97 + $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Sync' );
155 98
156 - // Don't load media filters if option is disabled or if user has no right
99 + // don't load media filters if option is disabled or if user has no right
157 100 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 ) ) ) {
158 101 $classes[] = 'Filters_Media';
159 102 }
160 103
@@ -161,9 +104,9 @@
161 104 foreach ( $classes as $class ) {
162 105 $obj = strtolower( $class );
163 106
164 107 /**
165 - * Filter the class to instantiate when loading admin filters
108 + * Filter the class to instantiate when loding admin filters
166 109 *
167 110 * @since 1.5
168 111 *
169 112 * @param string $class class name
@@ -170,29 +113,6 @@
170 113 */
171 114 $class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class );
172 115 $this->$obj = new $class( $this );
173 116 }
174 - }
175 - /**
176 - * Retrieve the locale according to the current language instead of the language
177 - * of the admin interface.
178 - *
179 - * @since 2.0
180 - *
181 - * @return string
182 - */
183 - public function get_locale_for_sanitization() {
184 - $locale = get_locale();
185 -
186 - if ( isset( $_POST['post_lang_choice'] ) && $lang = $this->model->get_language( sanitize_key( $_POST['post_lang_choice'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
187 - $locale = $lang->locale;
188 - } elseif ( isset( $_POST['term_lang_choice'] ) && $lang = $this->model->get_language( sanitize_key( $_POST['term_lang_choice'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
189 - $locale = $lang->locale;
190 - } elseif ( isset( $_POST['inline_lang_choice'] ) && $lang = $this->model->get_language( sanitize_key( $_POST['inline_lang_choice'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
191 - $locale = $lang->locale;
192 - } elseif ( ! empty( $this->curlang ) ) {
193 - $locale = $this->curlang->locale;
194 - }
195 -
196 - return $locale;
197 117 }
198 118 }