PluginProbe
Polylang / 3.3
Polylang v3.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 | include/class-polylang.php +16 -9 2.83.3 View file →
@@ -94,12 +94,12 @@
94 94 * @return bool
95 95 */
96 96 public static function is_rest_request() {
97 97 // Handle pretty permalinks.
98 - $home_path = trim( wp_parse_url( home_url(), PHP_URL_PATH ), '/' );
98 + $home_path = trim( (string) wp_parse_url( home_url(), PHP_URL_PATH ), '/' );
99 99 $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
100 100
101 - $req_uri = trim( wp_parse_url( pll_get_requested_url(), PHP_URL_PATH ), '/' );
101 + $req_uri = trim( (string) wp_parse_url( pll_get_requested_url(), PHP_URL_PATH ), '/' );
102 102 $req_uri = preg_replace( $home_path_regex, '', $req_uri );
103 103 $req_uri = trim( $req_uri, '/' );
104 104 $req_uri = str_replace( 'index.php', '', $req_uri );
105 105 $req_uri = trim( $req_uri, '/' );
@@ -105,9 +105,9 @@
105 105 $req_uri = trim( $req_uri, '/' );
106 106
107 107 // And also test rest_route query string parameter is not empty for plain permalinks.
108 108 $query_string = array();
109 - wp_parse_str( wp_parse_url( pll_get_requested_url(), PHP_URL_QUERY ), $query_string );
109 + wp_parse_str( (string) wp_parse_url( pll_get_requested_url(), PHP_URL_QUERY ), $query_string );
110 110 $rest_route = isset( $query_string['rest_route'] ) ? trim( $query_string['rest_route'], '/' ) : false;
111 111
112 112 return 0 === strpos( $req_uri, rest_get_url_prefix() . '/' ) || ! empty( $rest_route );
113 113 }
@@ -127,8 +127,10 @@
127 127 * Defines constants
128 128 * May be overridden by a plugin if set before plugins_loaded, 1
129 129 *
130 130 * @since 1.6
131 + *
132 + * @return void
131 133 */
132 134 public static function define_constants() {
133 135 // Cookie name. no cookie will be used if set to false
134 136 if ( ! defined( 'PLL_COOKIE' ) ) {
@@ -155,8 +157,10 @@
155 157 * Polylang initialization
156 158 * setups models and separate admin and frontend
157 159 *
158 160 * @since 1.2
161 + *
162 + * @return void
159 163 */
160 164 public function init() {
161 165 global $polylang;
162 166
@@ -188,11 +192,10 @@
188 192 * @param string $class either PLL_Model or PLL_Admin_Model
189 193 */
190 194 $class = apply_filters( 'pll_model', PLL_SETTINGS || self::is_wizard() ? 'PLL_Admin_Model' : 'PLL_Model' );
191 195 $model = new $class( $options );
192 - $links_model = $model->get_links_model();
193 196
194 - if ( ! $model->get_languages_list() ) {
197 + if ( ! $model->has_languages() ) {
195 198 /**
196 199 * Fires when no language has been defined yet
197 200 * Used to load overridden textdomains
198 201 *
@@ -208,9 +211,9 @@
208 211 } elseif ( PLL_ADMIN ) {
209 212 $class = 'PLL_Admin';
210 213 } elseif ( self::is_rest_request() ) {
211 214 $class = 'PLL_REST_Request';
212 - } elseif ( $model->get_languages_list() && empty( $_GET['deactivate-polylang'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
215 + } elseif ( $model->has_languages() ) {
213 216 $class = 'PLL_Frontend';
214 217 }
215 218
216 219 /**
@@ -222,9 +225,10 @@
222 225 */
223 226 $class = apply_filters( 'pll_context', $class );
224 227
225 228 if ( ! empty( $class ) ) {
226 - $polylang = new $class( $links_model );
229 + $links_model = $model->get_links_model();
230 + $polylang = new $class( $links_model );
227 231
228 232 /**
229 233 * Fires after the $polylang object is created and before the API is loaded
230 234 *
@@ -236,10 +240,13 @@
236 240
237 241 require_once __DIR__ . '/api.php'; // Loads the API
238 242
239 243 // Loads the modules.
240 - foreach ( glob( POLYLANG_DIR . '/modules/*/load.php', GLOB_NOSORT ) as $load_script ) { // phpcs:ignore WordPressVIPMinimum.Variables.VariableAnalysis.UnusedVariable
241 - require_once $load_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
244 + $load_scripts = glob( POLYLANG_DIR . '/modules/*/load.php', GLOB_NOSORT );
245 + if ( is_array( $load_scripts ) ) {
246 + foreach ( $load_scripts as $load_script ) {
247 + require_once $load_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
248 + }
242 249 }
243 250
244 251 $polylang->init();
245 252