dist
1 year ago
includes
4 weeks ago
locale
2 months ago
res
1 year ago
src
4 weeks ago
templates
4 weeks ago
vendor-bin
3 years ago
Makefile
5 years ago
README.md
5 years ago
installer.php
4 weeks ago
loader.php
4 weeks ago
phpcs.compatibility.xml
1 year ago
phpcs.xml
5 years ago
phpunit.xml
10 months ago
repositories.xml
3 years ago
webpack.config.js
1 year ago
loader.php
231 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if ( ! function_exists( 'otgs_is_rest_request' ) ) { |
| 8 | function otgs_is_rest_request() { |
| 9 | $rest_url_prefix = 'wp-json'; |
| 10 | |
| 11 | if ( function_exists( 'rest_get_url_prefix' ) ) { |
| 12 | $rest_url_prefix = rest_get_url_prefix(); |
| 13 | } |
| 14 | |
| 15 | return array_key_exists( 'rest_route', $_REQUEST ) || false !== strpos( $_SERVER['REQUEST_URI'], $rest_url_prefix ) || ( defined( 'REST_REQUEST' ) && REST_REQUEST ); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | if ( file_exists( __DIR__ . '/../../otgs/icons/loader.php' ) ) { |
| 20 | $vendor_root_url = plugins_url( '/', __FILE__ ) . '../..'; |
| 21 | require_once __DIR__ . '/../../otgs/icons/loader.php'; |
| 22 | } |
| 23 | |
| 24 | global $otgs_installer_version; |
| 25 | $otgs_installer_version = '3.1.14'; |
| 26 | |
| 27 | if ( ! function_exists( 'wpml_installer_force_load' ) ) { |
| 28 | function wpml_installer_force_load() { |
| 29 | if ( function_exists( 'OTGS_Installer' ) ) { |
| 30 | return \OTGS_Installer(); |
| 31 | } |
| 32 | |
| 33 | global $otgs_installer_version; |
| 34 | $delegate = [ 'version' => $otgs_installer_version, 'bootfile' => dirname( __FILE__ ) . '/installer.php' ]; |
| 35 | |
| 36 | include_once $delegate['bootfile']; |
| 37 | include_once dirname( __FILE__ ) . '/includes/functions-core.php'; |
| 38 | |
| 39 | return \OTGS_Installer(); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | $is_cron_request = defined( 'DOING_CRON' ) && DOING_CRON; |
| 44 | $is_wp_cli_request = defined( 'WP_CLI' ) && WP_CLI; |
| 45 | |
| 46 | if ( ! $is_cron_request && ! $is_wp_cli_request && ! is_admin() && ! otgs_is_rest_request() ) { |
| 47 | if ( ! function_exists( 'WP_Installer_Setup' ) ) { |
| 48 | function WP_Installer_Setup( $wp_installer_instance, $args = [] ) { |
| 49 | if ( isset( $args['site_key_nags'][0]['repository_id'] ) ) { |
| 50 | require_once __DIR__ . '/includes/class-otgs-installer-settings.php'; |
| 51 | require_once __DIR__ . '/includes/class-otgs-installer-subscription.php'; |
| 52 | |
| 53 | $settings = OTGS\Installer\Settings::load_subscriptions(); |
| 54 | |
| 55 | $repository_id = $args['site_key_nags'][0]['repository_id']; |
| 56 | |
| 57 | $getSiteKey = function () use ( $repository_id, $settings ) { |
| 58 | if ( in_array( $repository_id, [ 'wpml', 'toolset' ] ) |
| 59 | && isset( $settings['repositories'][ $repository_id ]['subscription']['key'] ) |
| 60 | ) { |
| 61 | return $settings['repositories'][ $repository_id ]['subscription']['key']; |
| 62 | } |
| 63 | |
| 64 | return null; |
| 65 | }; |
| 66 | |
| 67 | add_filter( 'otgs_installer_get_sitekey_'.$repository_id, $getSiteKey ); |
| 68 | |
| 69 | if ( in_array( $repository_id, [ 'wpml', 'toolset' ] ) |
| 70 | && isset( $settings['repositories'][ $repository_id ]['subscription']['key_type'] ) |
| 71 | && $settings['repositories'][ $repository_id ]['subscription']['key_type'] === OTGS_Installer_Subscription::SITE_KEY_TYPE_DEVELOPMENT |
| 72 | ) { |
| 73 | |
| 74 | $showFrontendBanner = function () use ( $repository_id ) { |
| 75 | $removeFrontendBannerLink = 'https://wpml.org/faq/how-to-remove-the-this-site-is-registered-on-wpml-org-as-a-development-site-notice/?utm_source=plugin&utm_medium=gui&utm_campaign=wpml-core&utm_term=footer-notice'; |
| 76 | $wpmlText = sprintf( |
| 77 | __( 'This site is registered on %s as a development site. Switch to a production site key to %s.', 'installer' ), |
| 78 | '<a href="https://wpml.org">wpml.org</a>', '<a href="' . $removeFrontendBannerLink . '">remove this banner</a>' |
| 79 | ); |
| 80 | $message = $repository_id === 'wpml' |
| 81 | ? $wpmlText |
| 82 | : __( 'This site is registered on Toolset.com as a development site.', 'installer' ); |
| 83 | |
| 84 | ?> |
| 85 | <style> |
| 86 | .otgs-development-site-front-end a { color: white; } |
| 87 | .otgs-development-site-front-end .icon { |
| 88 | background: url(<?php echo plugins_url( '/', __FILE__ ) . '/res/img/icon-wpml-info-white.svg'; ?>) no-repeat; |
| 89 | width: 20px; |
| 90 | height: 20px; |
| 91 | display: inline-block; |
| 92 | position: absolute; |
| 93 | margin-left: -23px; |
| 94 | } |
| 95 | .otgs-development-site-front-end { |
| 96 | background-size: 32px; |
| 97 | padding: 22px 0px; |
| 98 | font-size: 12px; |
| 99 | font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif; |
| 100 | line-height: 18px; |
| 101 | text-align: center; |
| 102 | color: white; |
| 103 | background-color: #0369a1; |
| 104 | } |
| 105 | </style> |
| 106 | <?php |
| 107 | echo '<div class="otgs-development-site-front-end"><span class="icon"></span>' . $message . '</div >'; |
| 108 | }; |
| 109 | |
| 110 | add_action( 'wp_footer', $showFrontendBanner, 999 ); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | $wp_installer_instance = null; |
| 116 | |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | $wp_installer_instance = dirname( __FILE__ ) . '/installer.php'; |
| 121 | |
| 122 | global $wp_installer_instances; |
| 123 | $wp_installer_instances[ $wp_installer_instance ] = [ |
| 124 | 'bootfile' => $wp_installer_instance, |
| 125 | 'version' => $otgs_installer_version, |
| 126 | ]; |
| 127 | |
| 128 | if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '<' ) ) { |
| 129 | foreach ( $wp_installer_instances as $key => $instance ) { |
| 130 | if ( isset( $instance['args']['site_key_nags'] ) ) { |
| 131 | $wp_installer_instances[ $key ]['version'] = '9.9'; |
| 132 | } else { |
| 133 | $wp_installer_instances[ $key ]['version'] = '0'; |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.3.1', '<' ) ) { |
| 139 | |
| 140 | $installer_171_plus_on = false; |
| 141 | foreach ( $wp_installer_instances as $key => $instance ) { |
| 142 | if ( version_compare( $instance['version'], '1.7.1', '>=' ) ) { |
| 143 | $installer_171_plus_on = true; |
| 144 | break; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if ( $installer_171_plus_on ) { |
| 149 | foreach ( $wp_installer_instances as $key => $instance ) { |
| 150 | |
| 151 | if ( version_compare( $instance['version'], '1.7.0', '<' ) ) { |
| 152 | unset( $wp_installer_instances[ $key ] ); |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | if ( isset( $_POST['installer_instance'] ) && isset( $wp_installer_instances[ $_POST['installer_instance'] ] ) ) { |
| 159 | $wp_installer_instances[ $_POST['installer_instance'] ]['version'] = '999'; |
| 160 | } |
| 161 | |
| 162 | remove_action( 'after_setup_theme', 'wpml_installer_instance_delegator', 1 ); |
| 163 | add_action( 'after_setup_theme', 'wpml_installer_instance_delegator', 1 ); |
| 164 | |
| 165 | if ( ! function_exists( 'wpml_installer_instance_delegator' ) ) { |
| 166 | function wpml_installer_instance_delegator() { |
| 167 | global $wp_installer_instances; |
| 168 | |
| 169 | $delegated_instance_key = null; |
| 170 | foreach ( $wp_installer_instances as $instance_key => $instance ) { |
| 171 | $wp_installer_instances[ $instance_key ]['delegated'] = false; |
| 172 | |
| 173 | if ( ! isset( $delegate ) || version_compare( $instance['version'], $delegate['version'], '>' ) ) { |
| 174 | $delegate = $instance; |
| 175 | $delegated_instance_key = $instance_key; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | $wp_installer_instances[ $delegated_instance_key ]['delegated'] = true; |
| 180 | |
| 181 | $highest_priority = null; |
| 182 | foreach ( $wp_installer_instances as $instance ) { |
| 183 | if ( isset( $instance['args']['high_priority'] ) ) { |
| 184 | if ( is_null( $highest_priority ) || $instance['args']['high_priority'] <= $highest_priority ) { |
| 185 | $highest_priority = $instance['args']['high_priority']; |
| 186 | $delegate = $instance; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '<' ) ) { |
| 192 | foreach ( $wp_installer_instances as $key => $instance ) { |
| 193 | if ( isset( $instance['args']['site_key_nags'] ) ) { |
| 194 | $delegate = $instance; |
| 195 | $wp_installer_instances = array( $key => $delegate ); |
| 196 | break; |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | include_once $delegate['bootfile']; |
| 202 | |
| 203 | require_once dirname( __FILE__ ) . '/includes/loader/Config.php'; |
| 204 | $delegate = OTGS\Installer\Loader\Config::merge( $delegate, $wp_installer_instances ); |
| 205 | |
| 206 | $template_path = realpath( get_template_directory() ); |
| 207 | if ( $template_path && strpos( (string) realpath( $delegate['bootfile'] ), (string) $template_path ) === 0 ) { |
| 208 | $filepath = str_replace( (string) realpath( get_template_directory() ), '', (string) realpath( $delegate['bootfile'] ) ); |
| 209 | $delegate['args']['in_theme_folder'] = dirname( ltrim( $filepath, '\\/' ) ); |
| 210 | } |
| 211 | |
| 212 | if ( isset( $delegate['args'] ) && is_array( $delegate['args'] ) ) { |
| 213 | foreach ( $delegate['args'] as $key => $value ) { |
| 214 | WP_Installer()->set_config( $key, $value ); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | if ( ! function_exists( 'WP_Installer_Setup' ) ) { |
| 222 | |
| 223 | function WP_Installer_Setup( $wp_installer_instance, $args = array() ) { |
| 224 | global $wp_installer_instances; |
| 225 | |
| 226 | if ( $wp_installer_instance ) { |
| 227 | $wp_installer_instances[ $wp_installer_instance ]['args'] = $args; |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 |