| @@ -1,5 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * @package Polylang | |
| 4 | + */ | |
| 2 | 5 | |
| 3 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | 7 | exit; // Don't access directly |
| 5 | 8 | }; |
| @@ -26,10 +29,9 @@ | ||
| 26 | 29 | * |
| 27 | 30 | * @since 0.1 |
| 28 | 31 | */ |
| 29 | 32 | public function __construct() { |
| 30 | - require_once PLL_INC . '/functions.php'; // VIP functions | |
| 31 | - spl_autoload_register( array( $this, 'autoload' ) ); // Autoload classes | |
| 33 | + require_once __DIR__ . '/functions.php'; // VIP functions | |
| 32 | 34 | |
| 33 | 35 | // register an action when plugin is activating. |
| 34 | 36 | register_activation_hook( POLYLANG_BASENAME, array( 'PLL_Wizard', 'start_wizard' ) ); |
| 35 | 37 | |
| @@ -49,66 +51,18 @@ | ||
| 49 | 51 | if ( ! defined( 'PLL_OLT' ) || PLL_OLT ) { |
| 50 | 52 | PLL_OLT_Manager::instance(); |
| 51 | 53 | } |
| 52 | 54 | |
| 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 | |
| 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 | + */ | |
| 55 | 59 | if ( ! defined( 'PLL_PLUGINS_COMPAT' ) || PLL_PLUGINS_COMPAT ) { |
| 56 | - PLL_Plugins_Compat::instance(); | |
| 60 | + PLL_Integrations::instance(); | |
| 57 | 61 | } |
| 58 | 62 | } |
| 59 | 63 | |
| 60 | 64 | /** |
| 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 | - /** | |
| 111 | 65 | * Tells whether the current request is an ajax request on frontend or not |
| 112 | 66 | * |
| 113 | 67 | * @since 2.2 |
| 114 | 68 | * |
| @@ -279,13 +233,13 @@ | ||
| 279 | 233 | * @param object $polylang |
| 280 | 234 | */ |
| 281 | 235 | do_action_ref_array( 'pll_pre_init', array( &$polylang ) ); |
| 282 | 236 | |
| 283 | - require_once PLL_INC . '/api.php'; // Loads the API | |
| 237 | + require_once __DIR__ . '/api.php'; // Loads the API | |
| 284 | 238 | |
| 285 | - if ( ! defined( 'PLL_WPML_COMPAT' ) || PLL_WPML_COMPAT ) { | |
| 286 | - PLL_WPML_Compat::instance(); // WPML API | |
| 287 | - PLL_WPML_Config::instance(); // wpml-config.xml | |
| 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 | |
| 288 | 242 | } |
| 289 | 243 | |
| 290 | 244 | $polylang->init(); |
| 291 | 245 | |