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 | include/class-polylang.php +59 -13 2.8.42.7.3 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 if ( ! defined( 'ABSPATH' ) ) {
7 4 exit; // Don't access directly
8 5 };
@@ -29,9 +26,10 @@
29 26 *
30 27 * @since 0.1
31 28 */
32 29 public function __construct() {
33 - require_once __DIR__ . '/functions.php'; // VIP functions
30 + require_once PLL_INC . '/functions.php'; // VIP functions
31 + spl_autoload_register( array( $this, 'autoload' ) ); // Autoload classes
34 32
35 33 // register an action when plugin is activating.
36 34 register_activation_hook( POLYLANG_BASENAME, array( 'PLL_Wizard', 'start_wizard' ) );
37 35
@@ -51,18 +49,66 @@
51 49 if ( ! defined( 'PLL_OLT' ) || PLL_OLT ) {
52 50 PLL_OLT_Manager::instance();
53 51 }
54 52
55 - /*
56 - * Loads the compatibility with some plugins and themes.
57 - * Loaded as soon as possible as we may need to act before other plugins are loaded.
58 - */
53 + // Extra code for compatibility with some plugins
54 + // Loaded as soon as possible as we may need to act before other plugins are loaded
59 55 if ( ! defined( 'PLL_PLUGINS_COMPAT' ) || PLL_PLUGINS_COMPAT ) {
60 - PLL_Integrations::instance();
56 + PLL_Plugins_Compat::instance();
61 57 }
62 58 }
63 59
64 60 /**
61 + * Autoload classes
62 + *
63 + * @since 1.2
64 + *
65 + * @param string $class
66 + */
67 + public function autoload( $class ) {
68 + // Not a Polylang class
69 + if ( 0 !== strncmp( 'PLL_', $class, 4 ) ) {
70 + return;
71 + }
72 +
73 + $class = str_replace( '_', '-', strtolower( substr( $class, 4 ) ) );
74 + $dirs = array();
75 + $parts = explode( '-', $class );
76 + $parts = array_values( array_diff( $parts, array( 'frontend', 'admin', 'settings', 'advanced' ) ) );
77 + if ( isset( $parts[0] ) ) {
78 + $dirs[] = PLL_MODULES_INC . "/{$parts[0]}";
79 + if ( isset( $parts[1] ) ) {
80 + $dirs[] = PLL_MODULES_INC . "/{$parts[0]}-{$parts[1]}";
81 + if ( isset( $parts[2] ) && in_array( $parts[1], array( 'post', 'term' ) ) ) {
82 + $dirs[] = PLL_MODULES_INC . "/{$parts[0]}-{$parts[2]}";
83 + }
84 + }
85 + }
86 +
87 + $dirs = array_merge(
88 + array(
89 + PLL_FRONT_INC,
90 + PLL_MODULES_INC,
91 + ),
92 + $dirs,
93 + array(
94 + PLL_MODULES_INC . '/plugins',
95 + PLL_INSTALL_INC,
96 + PLL_ADMIN_INC,
97 + PLL_SETTINGS_INC,
98 + PLL_INC,
99 + )
100 + );
101 +
102 + foreach ( $dirs as $dir ) {
103 + if ( file_exists( $file = "$dir/$class.php" ) ) {
104 + require_once $file; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
105 + return;
106 + }
107 + }
108 + }
109 +
110 + /**
65 111 * Tells whether the current request is an ajax request on frontend or not
66 112 *
67 113 * @since 2.2
68 114 *
@@ -233,13 +279,13 @@
233 279 * @param object $polylang
234 280 */
235 281 do_action_ref_array( 'pll_pre_init', array( &$polylang ) );
236 282
237 - require_once __DIR__ . '/api.php'; // Loads the API
283 + require_once PLL_INC . '/api.php'; // Loads the API
238 284
239 - // 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
285 + if ( ! defined( 'PLL_WPML_COMPAT' ) || PLL_WPML_COMPAT ) {
286 + PLL_WPML_Compat::instance(); // WPML API
287 + PLL_WPML_Config::instance(); // wpml-config.xml
242 288 }
243 289
244 290 $polylang->init();
245 291