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 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.9.0 4.9.1 5.0.1 5.0.2 5.1.1 5.1.2 5.1.3 5.2.0 5.2.1 5.3.2 5.3.3.1 5.3.4 5.3.5 5.3.6 5.3.7
woocommerce-multilingual / vendor / otgs / installer / includes / class-wp-installer-channels.php
woocommerce-multilingual / vendor / otgs / installer / includes Last commit date
CDTClient 1 month ago admin-notices 1 month ago buy-url 1 month ago debug 1 month ago exceptions 5 years ago instances 1 month ago loader 5 years ago products 1 month ago repository 1 month ago rest 1 month ago site-key 1 month ago support 1 month ago template-service 1 month ago upgrade 1 month ago utilities 1 month ago wpml-content-stats 1 month ago class-installer-dependencies.php 1 month ago class-installer-theme.php 1 month ago class-installer-upgrader-skins.php 1 month ago class-otgs-installer-autoloader.php 5 years ago class-otgs-installer-cloned-sites-handler.php 1 month ago class-otgs-installer-debug-info.php 1 month ago class-otgs-installer-factory.php 1 month ago class-otgs-installer-filename-hooks.php 1 month ago class-otgs-installer-icons.php 1 month ago class-otgs-installer-loader.php 10 months ago class-otgs-installer-package-product-finder.php 1 month ago class-otgs-installer-package-product.php 1 month ago class-otgs-installer-package.php 5 years ago class-otgs-installer-php-functions.php 1 month ago class-otgs-installer-plugin-factory.php 1 month ago class-otgs-installer-plugin-finder.php 1 month ago class-otgs-installer-plugin.php 1 month ago class-otgs-installer-plugins-page-notice.php 1 month ago class-otgs-installer-plugins-update-cache-cleaner.php 5 years ago class-otgs-installer-settings.php 1 month ago class-otgs-installer-source-factory.php 5 years ago class-otgs-installer-source.php 1 month ago class-otgs-installer-subscription-factory.php 5 years ago class-otgs-installer-subscription-warning-message.php 1 month ago class-otgs-installer-subscription.php 1 month ago class-otgs-installer-wp-components-hooks.php 1 month ago class-otgs-installer-wp-components-sender.php 1 month ago class-otgs-installer-wp-components-setting-ajax.php 1 month ago class-otgs-installer-wp-components-setting-resources.php 1 month ago class-otgs-installer-wp-components-storage.php 1 month ago class-otgs-installer-wp-share-local-components-setting-hooks.php 1 month ago class-otgs-installer-wp-share-local-components-setting.php 1 month ago class-translation-service-info.php 1 month ago class-wp-installer-api.php 1 month ago class-wp-installer-channels.php 1 month ago class-wp-installer.php 1 month ago functions-core.php 1 month ago functions-templates.php 1 month ago otgs-installer-autoload-classmap.php 10 months ago
class-wp-installer-channels.php
225 lines
1 <?php
2
3 use OTGS\Installer\Settings;
4
5 class WP_Installer_Channels{
6
7 const CHANNEL_PRODUCTION = 'production';
8 const CHANNEL_BETA = 'beta';
9 const CHANNEL_DEVELOPMENT = 'development';
10
11 protected static $_instance = null;
12
13 function __construct() {
14 add_action( 'init', array( $this, 'init' ), 20 );
15 }
16
17 public static function instance() {
18
19 if ( is_null( self::$_instance ) ) {
20 self::$_instance = new self();
21 }
22
23 return self::$_instance;
24 }
25
26 public static function channel_name_by_id( $id ) {
27 if ( self::CHANNEL_DEVELOPMENT === $id ) {
28 $channel = __( 'Development', 'installer' );
29 } elseif ( self::CHANNEL_BETA === $id ) {
30 $channel = __( 'Beta', 'installer' );
31 } else {
32 $channel = __( 'Production', 'installer' );
33 }
34
35 return $channel;
36 }
37
38 public function init(){
39 global $pagenow;
40
41 if ( defined( 'DOING_AJAX' ) ) {
42 add_action( 'wp_ajax_installer_set_channel', array( $this, 'set_channel' ) );
43 }
44
45 if ( $pagenow === 'plugin-install.php' && isset( $_GET['tab'] ) && $_GET['tab'] === 'commercial' ) {
46 wp_enqueue_script( 'installer-channels', WP_Installer()->res_url() . '/res/js/channels.js', array( 'jquery' ), WP_Installer()->version() );
47 }
48
49 }
50
51 public function set_channel(){
52 $repository_id = sanitize_text_field( $_POST['repository_id'] );
53 $channel = sanitize_text_field( $_POST['channel'] );
54 $installer = WP_Installer::instance();
55 $settings = $installer->get_settings();
56
57 $response = array();
58 if ( wp_verify_nonce( $_POST['nonce'], 'installer_set_channel:' . $repository_id ) ) {
59 if( isset( $settings['repositories'][$repository_id] ) ){
60 $settings['repositories'][$repository_id]['channel'] = $channel;
61 $settings['repositories'][$repository_id]['no-prompt'] = $_POST['noprompt'] === 'true';
62 $installer->save_settings( $settings );
63 }
64
65 $installer->refresh_repositories_data();
66
67 $response['status'] = 'OK';
68 }
69
70 echo json_encode( $response );
71 exit;
72 }
73
74 public function get_channel( $repository_id ){
75 $channel = self::CHANNEL_PRODUCTION;
76 $settings = Settings::load_channels();
77 if( isset( $settings['repositories'][$repository_id]['channel'] ) ){
78 $channel = $settings['repositories'][$repository_id]['channel'];
79 }
80 return $channel;
81 }
82
83 private function get_no_prompt( $repository_id ) {
84 $settings = WP_Installer()->settings;
85
86 return ! empty( $settings['repositories'][ $repository_id ]['no-prompt'] );
87 }
88
89 public function load_channel_selector( $repository_id, $downloads ) {
90
91 $available_channels = $this->get_available_channels( $repository_id );
92
93 if ( $available_channels ) {
94 $args = array(
95 'can_switch' => $this->can_use_unstable_channels( $downloads )
96 || $this->get_channel( $repository_id ) != self::CHANNEL_PRODUCTION,
97 'channels' => $available_channels,
98 'repository_id' => $repository_id,
99 'current_channel' => $this->get_channel( $repository_id ),
100 'no_prompt' => $this->get_no_prompt( $repository_id ),
101 'nonce' => wp_create_nonce( 'installer_set_channel:' . $repository_id )
102 );
103 extract( $args );
104 include WP_Installer()->plugin_path() . '/templates/channel-selector.php';
105 }
106 }
107
108 public function can_use_unstable_channels( $downloads ){
109
110 $can = true;
111 foreach( $downloads as $download ){
112 $available_version = $download['version'];
113 $installed_version = WP_Installer()->plugin_is_installed( $download['name'], $download['slug'] );
114 if( $installed_version !== false && version_compare( $available_version, $installed_version, '>' ) ){
115 $can = false;
116 break;
117 }
118 }
119
120 return $can;
121 }
122
123 public function get_available_channels( $repository_id ) {
124
125 $beta = false;
126 $dev = false;
127
128 $downloads = WP_Installer()->settings['repositories'][ $repository_id ]['data']['downloads'];
129 foreach ( $downloads as $type => $download_types ) {
130 foreach ( $download_types as $download ) {
131 $extra_channels = isset( $download['extra_channels'] ) ? array_keys( $download['extra_channels'] ) : array();
132 if ( ! $beta && in_array( self::CHANNEL_BETA, $extra_channels ) ) {
133 $beta = true;
134 }
135 if ( ! $dev && in_array( self::CHANNEL_DEVELOPMENT, $extra_channels ) ) {
136 $dev = true;
137 }
138 if ( $beta && $dev ) {
139 break;
140 }
141 }
142 }
143
144 $channels = array();
145 if ( $beta || $dev ) {
146 $channels[ self::CHANNEL_PRODUCTION ] = self::channel_name_by_id( self::CHANNEL_PRODUCTION );
147 if ( $beta ) {
148 $channels[ self::CHANNEL_BETA ] = self::channel_name_by_id( self::CHANNEL_BETA );
149 }
150 if ( $dev ) {
151 $channels[ self::CHANNEL_DEVELOPMENT ] = self::channel_name_by_id( self::CHANNEL_DEVELOPMENT );
152 }
153 }
154
155 return $channels;
156 }
157
158 public function filter_downloads_by_channel( $repository_id, $downloads ) {
159
160 $current_channel = $this->get_channel( $repository_id );
161
162 foreach ( $downloads as $type => $type_downloads ) {
163 foreach ( $type_downloads as $slug => $download ) {
164
165 $override_download = array();
166 if ( $current_channel === self::CHANNEL_DEVELOPMENT ) {
167 if( ! empty( $download['channels']['development'] ) ){
168 $override_download = $download['channels']['development'];
169 $override_download['channel'] = self::CHANNEL_DEVELOPMENT;
170 }elseif( ! empty( $download['channels']['beta'] ) ){
171 $override_download = $download['channels']['beta'];
172 $override_download['channel'] = self::CHANNEL_BETA;
173 }
174 }elseif ( $current_channel === self::CHANNEL_BETA && ! empty( $download['channels']['beta'] ) ) {
175 $override_download = $download['channels']['beta'];
176 $override_download['channel'] = self::CHANNEL_BETA;
177 }
178
179 if ( $override_download ) {
180 foreach ( $override_download as $key => $value ) {
181 $downloads[ $type ][ $slug ][ $key ] = $value;
182 }
183 } else {
184 $downloads[ $type ][ $slug ]['channel'] = self::CHANNEL_PRODUCTION;
185 }
186 unset ( $downloads[ $type ][ $slug ]['channels'] );
187
188 $downloads[ $type ][ $slug ]['extra_channels'] = array();
189 if( isset( $download['channels'] ) ) {
190 foreach( $download['channels'] as $channel_id => $channel ){
191 $downloads[ $type ][ $slug ]['extra_channels'][$channel_id] = array(
192 'version' => $channel['version']
193 );
194 }
195 }
196
197 }
198 }
199
200 return $downloads;
201 }
202
203 public function get_download_source_channel( $version, $repository_id, $download_id, $download_kind ) {
204
205 $version_channel = '';
206 $installer_settings = WP_Installer()->get_settings();
207 if ( isset( $installer_settings['repositories'][ $repository_id ] ) ) {
208 $repository_data = $installer_settings['repositories'][ $repository_id ]['data'];
209 if ( isset( $repository_data['downloads'][ $download_kind ][ $download_id ]['extra_channels'] ) ) {
210
211 foreach ( $repository_data['downloads'][ $download_kind ][ $download_id ]['extra_channels'] as $channel_id => $channel_data ) {
212 if ( $version === $channel_data['version'] ) {
213 $version_channel = self::channel_name_by_id( $channel_id );
214 break;
215 }
216
217 }
218 }
219
220 }
221
222 return $version_channel;
223 }
224 }
225