ns' ); } } } elseif ( $connection_error ) { $ret = false; $message = sprintf( __( 'Connection failed! Please refresh the page and try again. (%s)', 'installer' ), '' . $connection_error . '' ); } else { //subscription not valid $ret = false; $message = __( 'Your subscription appears to no longer be valid. Please try to register again using a valid site key.', 'installer' ); } if ( $message ) { $this->store_log( $data_url, $data_url_args, OTGS_Installer_Logger_Storage::COMPONENT_DOWNLOAD, $message ); } $response['version'] = isset( $plugin_version ) ? $plugin_version : 0; $response['non_stable']= isset( $non_stable ) ? $non_stable : ''; $response['plugin_id'] = $plugin_id; $response['nonce'] = wp_create_nonce( 'activate_' . $plugin_id ); $response['success'] = $ret; $response['message'] = $message; echo json_encode( $response ); exit; } private function is_plugin_out_of_date( $plugin ) { $current = get_site_transient( 'update_plugins' ); return isset( $current->response[ $plugin ] ); } public function download_plugin( $slug, $url ) { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; require_once $this->plugin_path() . '/includes/class-installer-upgrader-skins.php'; $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin $upgrader = new Plugin_Upgrader( $upgrader_skins ); remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); $plugins = get_plugins(); $plugin_id = false; //upgrade or install? foreach ( $plugins as $id => $plugin ) { $wp_plugin_slug = dirname( $id ); if ( $wp_plugin_slug == $slug ) { /** @var string $plugin_id */ $plugin_id = $id; break; } } if ( $plugin_id ) { //upgrade $plugin_is_active = is_plugin_active( $plugin_id ); $ret = $upgrader->upgrade( $plugin_id ); if ( $plugin_is_active ) { activate_plugin( $plugin_id ); } } else { //install $ret = $upgrader->install( $url ); } return $ret; } public function activate_plugin() { $error = ''; $plugin_id = sanitize_text_field( $_POST['plugin_id'] ); if ( isset( $_POST['nonce'] ) && $plugin_id && wp_verify_nonce( $_POST['nonce'], 'activate_' . $plugin_id ) ) { // Deactivate any embedded version $plugin_slug = dirname( $plugin_id ); $active_plugins = get_option( 'active_plugins' ); foreach ( $active_plugins as $plugin ) { $wp_plugin_slug = dirname( $plugin ); if ( $wp_plugin_slug == $plugin_slug . '-embedded' ) { deactivate_plugins( array( $plugin ) ); break; } } //prevent redirects add_filter( 'wp_redirect', '__return_false', 10000 ); $return = activate_plugin( $plugin_id ); if ( is_wp_error( $return ) ) { $error = $return->get_error_message(); } } else { $error = 'error'; } $ret = array( 'error' => $error ); echo json_encode( $ret ); exit; } public function custom_plugins_api_call( $result, $action, $args ) { if ( $action == 'plugin_information' ) { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugins = get_plugins(); $installed_plugins = array(); foreach ( $plugins as $plugin_id => $plugin ) { // plugins by WP slug which (plugin folder) which can be different // will use this to compare by title $installed_plugins[ dirname( $plugin_id ) ] = array( 'name' => $plugin['Name'], 'title' => $plugin['Title'], 'is_lite' => false !== stripos( $plugin['Version'], '-lite' ), ); } $slug = $args->slug; $custom_plugin = false; foreach ( $this->settings['repositories'] as $repository_id => $repository ) { if ( ! $this->repository_has_valid_subscription( $repository_id ) ) { $site_key = false; } else { $site_key = $repository['subscription']['key']; } foreach ( $repository['data']['packages'] as $package ) { foreach ( $package['products'] as $product ) { foreach ( $product['plugins'] as $plugin_slug ) { $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ]; if ( $download['slug'] == $slug || isset( $installed_plugins[ $slug ] ) && ( $installed_plugins[ $slug ]['name'] == $download['name'] || $installed_plugins[ $slug ]['title'] == $download['name'] ) ) { $this_plugin = new stdClass(); $this_plugin->external = true; $this_plugin->is_free = $this->should_fallback_under_wp_org_repo( $download, $site_key ); $this_plugin->is_lite = ! empty( $download['is-lite'] ); $this_plugin->is_download_available = $this->is_product_available_for_download( $product['name'], $repository_id ); if ( $custom_plugin ) { if ( ( ! $custom_plugin->is_free && $this_plugin->is_free ) || ( ! $custom_plugin->is_lite && $custom_plugin->is_download_available ) || ( $custom_plugin->is_lite && ! $this_plugin->is_download_available && $installed_plugins[ $slug ]['is_lite'] ) ) { continue; } } $custom_plugin = $this_plugin; $custom_plugin->name = $download['name']; $custom_plugin->slug = $slug; $custom_plugin->version = $download['version']; $custom_plugin->author = ''; $custom_plugin->author_profile = ''; $custom_plugin->last_updated = $download['date']; $custom_plugin->tested = isset( $download['tested'] ) ? $download['tested'] : ''; if ( $site_key ) { $custom_plugin->download_link = $this->append_site_key_to_download_url( $download['url'], $site_key, $repository_id ); } $custom_plugin->homepage = $repository['data']['url']; $custom_plugin->sections = array( 'Description' => $download['description'], 'Changelog' => $download['changelog'] ); } } } } } if ( $custom_plugin ) { if ( $custom_plugin->is_free ) { $result = false; } else { $result = $custom_plugin; } } } return $result; } private function should_fallback_under_wp_org_repo( $download, $site_key ) { return ( ! empty( $download['free-on-wporg'] ) || isset( $download['fallback-free-on-wporg'] ) && $download['fallback-free-on-wporg'] && ! $site_key ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION; } private function has_non_wporg_upgrade_available( $plugin_id ){ $plugins_update_data = get_site_transient( 'update_plugins' ); return ! empty( $plugins_update_data->response[ $plugin_id ] ) && ! preg_match('/w\.org/', $plugins_update_data->response[ $plugin_id ]->id ); } public function setup_plugins_page_notices() { $plugins = get_plugins(); $template_service = OTGS_Template_Service_Factory::create( $this->plugin_path() . '/templates/php/components-setting/' ); $plugin_page_notice = new OTGS_Installer_Plugins_Page_Notice( $template_service, $this->get_plugin_finder() ); foreach ( $plugins as $plugin_id => $plugin ) { $slug = dirname( $plugin_id ); if ( empty( $slug ) ) { continue; } $name = $plugin['Name']; foreach ( $this->settings['repositories'] as $repository_id => $repository ) { if ( ! $this->repository_has_valid_subscription( $repository_id ) ) { $site_key = false; } else { $site_key = $repository['subscription']['key']; } foreach ( $repository['data']['packages'] as $package ) { foreach ( $package['products'] as $product ) { foreach ( $product['plugins'] as $plugin_slug ) { $plugin_finder = $this->get_plugin_finder(); $plugin_found = $plugin_finder->get_plugin( $plugin_slug, $repository_id ); if( ! $plugin_found ) { continue; } $external_repo = $plugin_found->get_external_repo(); if ( $external_repo && $this->plugin_is_registered( $external_repo, $plugin_slug ) ) { continue; } $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ]; $display_subscription_notice = false; $display_setting_notice = false; if ( $download['slug'] == $slug || $download['name'] == $name ) { if ( in_array( $name, array( 'Toolset Types', 'WPML Multilingual CMS' ), true ) ) { $display_setting_notice = true; } if ( ! $site_key || ! $this->plugin_is_registered( $repository_id, $download['slug'] ) ) { $display_setting_notice = false; if ( self::isFreeToolsetTypes( $name, $plugin) || $this->isComplementaryWithWPMLSubscription( $name, $slug ) || $download['fallback-free-on-wporg'] ) { $display_subscription_notice = false; } else { if( $this->repository_has_in_grace_subscription( $repository_id, self::GRACE_TIME ) ) { $display_subscription_notice = [ 'type' => 'in_grace', 'repo' => $repository_id, 'product' => $repository['data']['product-name'] ]; } elseif( $this->repository_has_expired_subscription( $repository_id ) ) { $display_subscription_notice = [ 'type' => 'expired', 'repo' => $repository_id, 'product' => $repository['data']['product-name'] ]; } elseif ( $this->repository_has_refunded_subscription( $repository_id ) ) { $display_subscription_notice = [ 'type' => 'refunded', 'repo' => $repository_id, 'product' => $repository['data']['product-name'] ]; } elseif ( !$this->repository_has_subscription( $repository_id ) ) { $display_subscription_notice = apply_filters( 'otgs_installer_display_subscription_notice', [ 'type' => 'register', 'repo' => $repository_id, 'product' => $repository['data']['product-name'] ] ); } } } if ( $this->plugin_is_registered( $repository_id, $download['slug'] ) && $this->repository_has_legacy_free_subscription( $repository_id ) ) { $display_subscription_notice = [ 'type' => 'legacy_free', 'repo' => $repository_id, 'product' => $repository['data']['product-name'] ]; } } if ( $display_setting_notice || $display_subscription_notice ) { $plugin_page_notice->add_plugin( $plugin_id, array( OTGS_Installer_Plugins_Page_Notice::DISPLAY_SUBSCRIPTION_NOTICE_KEY => $display_subscription_notice, OTGS_Installer_Plugins_Page_Notice::DISPLAY_SETTING_NOTICE_KEY => $display_setting_notice, ) ); } } } } } } $plugin_page_notice->add_hooks(); } public function localize_strings() { if ( ! empty( $this->settings['repositories'] ) ) { foreach ( $this->settings['repositories'] as $repository_id => $repository ) { //set name as call2action when don't have any //products foreach ( $repository['data']['packages'] as $package_id => $package ) { foreach ( $package['products'] as $product_id => $product ) { if ( empty( $product['call2action'] ) ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['call2action'] = $product['name']; } foreach ( $product['upgrades'] as $idx => $upg ) { if ( empty( $upg['call2action'] ) ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $idx ]['call2action'] = $upg['name']; } } foreach ( $product['renewals'] as $idx => $rnw ) { if ( empty( $rnw['call2action'] ) ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['renewals'][ $idx ]['call2action'] = $rnw['name']; } } } } } } global $sitepress; if ( is_null( $sitepress ) ) { return; } // default strings are always in English $user_admin_language = $sitepress->get_admin_language(); if ( $user_admin_language != 'en' ) { foreach ( $this->settings['repositories'] as $repository_id => $repository ) { $localization = $repository['data']['localization']; //packages foreach ( $repository['data']['packages'] as $package_id => $package ) { if ( isset( $localization['packages'][ $package_id ]['name'][ $user_admin_language ] ) ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['name'] = $localization['packages'][ $package_id ]['name'][ $user_admin_language ]; } if ( isset( $localization['packages'][ $package_id ]['description'][ $user_admin_language ] ) ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['description'] = $localization['packages'][ $package_id ]['description'][ $user_admin_language ]; } } //products foreach ( $repository['data']['packages'] as $package_id => $package ) { foreach ( $package['products'] as $product_id => $product ) { if ( isset( $localization['products'][ $product_id ]['name'][ $user_admin_language ] ) ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['name'] = $localization['products'][ $product_id ]['name'][ $user_admin_language ]; } if ( isset( $localization['products'][ $product_id ]['description'][ $user_admin_language ] ) ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['description'] = $localization['products'][ $product_id ]['description'][ $user_admin_language ]; } if ( isset( $localization['products'][ $product_id ]['call2action'][ $user_admin_language ] ) ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['name'] = $localization['products'][ $product_id ]['call2action'][ $user_admin_language ]; } } } //subscription info if ( isset( $repository['data']['subscriptions_meta']['expiration'] ) ) { foreach ( $repository['data']['subscriptions_meta']['expiration'] as $subscription_id => $note ) { if ( isset( $localization['subscriptions-notes'][ $subscription_id ]['expiration-warning'][ $user_admin_language ] ) ) { $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_id ]['warning_message'] = $localization['subscriptions-notes'][ $subscription_id ]['expiration-warning'][ $user_admin_language ]; } } } } } } public function get_matching_cp( $repository, $args = array() ) { $match = false; $cp_name = $cp_author = false; if ( isset( $this->config['src_name'] ) && isset( $this->config['src_author'] ) ) { $cp_name = $this->config['src_name']; $cp_author = $this->config['src_author']; } elseif ( isset( $args['src_name'] ) && isset( $args['src_author'] ) ) { $cp_name = $args['src_name']; $cp_author = $args['src_author']; } if ( isset( $repository['data']['marketing_cp'] ) ) { foreach ( $repository['data']['marketing_cp'] as $cp ) { if ( ! empty( $cp['exp'] ) && time() > $cp['exp'] ) { continue; } //Use theme_name for plugins too if ( ! empty( $cp['theme_name'] ) ) { if ( $cp['author_name'] == $cp_author && $cp['theme_name'] == $cp_name ) { $match = $cp; continue; } } else { if ( $cp['author_name'] == $cp_author ) { $match = $cp; continue; } } } } return $match; } public function set_filtered_prices( $args = array() ) { foreach ( $this->settings['repositories'] as $repository_id => $repository ) { $match = $this->get_matching_cp( $repository, $args ); if ( empty( $match ) ) { continue; } foreach ( $repository['data']['packages'] as $package_id => $package ) { foreach ( $package['products'] as $product_id => $product ) { if ( $match['dtp'] == '%' ) { $fprice = round( $product['price'] * ( 1 - $match['amt'] / 100 ), 2 ); $fprice = $fprice != round( $fprice ) ? sprintf( '%.2f', $fprice ) : round( $fprice, 0 ); } elseif ( $match['dtp'] == '-' ) { $fprice = $product['price'] - $match['amt']; } else { $fprice = $product['price']; } if ( $fprice ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['price_disc'] = $fprice; $url_glue = false !== strpos( $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['url'], '?' ) ? '&' : '?'; $cpndata = base64_encode( (string) json_encode( array( 'theme_author' => $match['author_name'], 'theme_name' => $match['theme_name'], 'vlc' => $match['vlc'] ) ) ); $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['url'] .= $url_glue . 'cpn=' . $cpndata; foreach ( $product['upgrades'] as $upgrade_id => $upgrade ) { $fprice = false; if ( $match['dtp'] == '%' ) { $fprice = round( $upgrade['price'] * ( 1 - $match['amt'] / 100 ), 2 ); $fprice = $fprice != round( $fprice ) ? sprintf( '%.2f', $fprice ) : round( $fprice, 0 ); } elseif ( $match['dtp'] == '-' ) { $fprice = $upgrade['price'] - $match['amt']; } if ( $fprice ) { $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $upgrade_id ]['price_disc'] = $fprice; $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $upgrade_id ]['url'] .= $url_glue . 'cpn=' . $cpndata; } } } } } } } public function set_hierarchy_and_order() { //2 levels if ( ! empty( $this->settings['repositories'] ) ) { foreach ( $this->settings['repositories'] as $repository_id => $repository ) { if ( empty( $repository['data']['packages'] ) ) { continue; } $all_packages = $repository['data']['packages']; $ordered_packages = array(); //backward compatibility - 'order' foreach ( $all_packages as $k => $v ) { if ( ! isset( $v['order'] ) ) { $all_packages[ $k ]['order'] = 0; } } //select parents foreach ( $all_packages as $package_id => $package ) { if ( empty( $package['parent'] ) ) { $ordered_packages[ $package_id ] = $package; } } //add sub-packages foreach ( $all_packages as $package_id => $package ) { if ( ! empty( $package['parent'] ) ) { if ( isset( $ordered_packages[ $package['parent'] ] ) ) { $ordered_packages[ $package['parent'] ]['sub-packages'][ $package_id ] = $package; } } } // order parents usort( $ordered_packages, array( $this, 'compare_package_order' ) ); //order sub-packages foreach ( $ordered_packages as $package_id => $package ) { if ( ! empty( $package['sub-packages'] ) ) { usort( $ordered_packages[ $package_id ]['sub-packages'], array( $this, 'compare_package_order' ) ); } } $this->settings['repositories'][ $repository_id ]['data']['packages'] = $ordered_packages; } } } public function compare_package_order( $a, $b ) { return $a['order'] - $b['order']; } public function get_support_tag_by_name( $name, $repository ) { if ( is_array( $this->settings['repositories'][ $repository ]['data']['support_tags'] ) ) { foreach ( $this->settings['repositories'][ $repository ]['data']['support_tags'] as $support_tag ) { if ( $support_tag['name'] == $name ) { return $support_tag['url']; } } } return false; } /** * @return OTGS_Installer_Plugin_Finder */ private function get_plugin_finder() { if ( ! $this->plugin_finder ) { $this->plugin_finder = new OTGS_Installer_Plugin_Finder( new OTGS_Installer_Plugin_Factory(), $this->settings['repositories'] ); } return $this->plugin_finder; } private function clean_plugins_update_cache() { do_action( 'otgs_installer_clean_plugins_update_cache' ); } public function plugin_upgrade_custom_errors() { if ( isset( $_REQUEST['action'] ) ) { $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; //bulk mode if ( 'update-selected' == $action ) { global $plugins; if ( isset( $plugins ) && is_array( $plugins ) ) { foreach ( $plugins as $k => $plugin ) { $plugin_repository = false; $wp_plugin_slug = dirname( $plugin ); foreach ( $this->settings['repositories'] as $repository_id => $repository ) { foreach ( $repository['data']['packages'] as $package ) { foreach ( $package['products'] as $product ) { foreach ( $product['plugins'] as $plugin_slug ) { if ( $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ]['slug'] == $wp_plugin_slug ) { $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ]; $plugin_repository = $repository_id; $product_name = $repository['data']['product-name']; $plugin_name = $download['name']; $free_on_wporg = ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION; break; } } } } } if ( $plugin_repository ) { //validate subscription static $sub_cache = array(); if ( empty( $sub_cache[ $plugin_repository ] ) ) { $subscription_data = false; $site_key = $this->get_repository_site_key( $plugin_repository ); if ( ! $site_key ) { list( $plugin_repository, $site_key ) = $this->match_product_in_external_repository( $plugin_repository, $wp_plugin_slug ); } if ( $site_key ) { try { $subscriptionManagerFactory = new SubscriptionManagerFactory( $this->get_settings() ); $subscriptionManager = $subscriptionManagerFactory->create($plugin_repository, $this->repositories[ $plugin_repository ]['api-url']); list ($subscription_data, $site_key_data) = $subscriptionManager->fetch($site_key,self::SITE_KEY_VALIDATION_SOURCE_REVALIDATION ); } catch ( Exception $e ) { } } $sub_cache[ $plugin_repository ]['site_key'] = $site_key; $sub_cache[ $plugin_repository ]['subscription_data'] = $subscription_data; } else { $site_key = $sub_cache[ $plugin_repository ]['site_key']; $subscription_data = $sub_cache[ $plugin_repository ]['subscription_data']; } if ( ! $site_key && ( ! empty( $free_on_wporg ) || $this->should_fallback_under_wp_org_repo( $download, $site_key ) ) ) { // allow the download from wp.org continue; } if ( empty( $site_key ) || empty( $subscription_data ) ) { $error_message = sprintf( __( "%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first.", 'installer' ), '' . $plugin_name . '', '', $product_name, '' ); echo '

' . $error_message . '

'; unset( $plugins[ $k ] ); } } } } } if ( 'upgrade-plugin' == $action || 'update-plugin' == $action ) { $plugin = isset( $_REQUEST['plugin'] ) ? trim( sanitize_text_field( $_REQUEST['plugin'] ) ) : ''; $wp_plugin_slug = dirname( $plugin ); $plugin_repository = false; foreach ( $this->settings['repositories'] as $repository_id => $repository ) { foreach ( $repository['data']['packages'] as $package ) { foreach ( $package['products'] as $product ) { foreach ( $product['plugins'] as $plugin_slug ) { $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ]; //match by folder, will change to match by name and folder if ( $download['slug'] == $wp_plugin_slug ) { $plugin_repository = $repository_id; $product_name = $repository['data']['product-name']; $plugin_name = $download['name']; $free_on_wporg = ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION; break; } } } } } if ( $plugin_repository ) { //validate subscription $site_key = $this->get_repository_site_key( $plugin_repository ); if ( ! $site_key ) { list( $plugin_repository, $site_key ) = $this->match_product_in_external_repository( $plugin_repository, $wp_plugin_slug ); } if ( $site_key ) { try { $subscriptionManagerFactory = new SubscriptionManagerFactory( $this->get_settings() ); $subscriptionManager = $subscriptionManagerFactory->create($plugin_repository, $this->repositories[ $plugin_repository ]['api-url']); list ($subscription_data, $site_key_data) = $subscriptionManager->fetch($site_key,self::SITE_KEY_VALIDATION_SOURCE_REVALIDATION ); } catch ( Exception $e ) { $subscription_data = false; } } $no_subscription = empty( $site_key ) || empty( $subscription_data ); $not_on_wporg = empty( $free_on_wporg ) && ! $this->should_fallback_under_wp_org_repo( $download, $site_key ); if ( $no_subscription && $not_on_wporg ) { $error_message = sprintf( __( "%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first.", 'installer' ), '' . $plugin_name . '', '', $product_name, '' ); if ( defined( 'DOING_AJAX' ) ) { //WP 4.2 $status = array( 'update' => 'plugin', 'plugin' => $plugin, 'slug' => sanitize_key( $_POST['slug'] ), 'oldVersion' => '', 'newVersion' => '', ); $status['errorCode'] = 'wp_installer_invalid_subscription'; $status['error'] = $error_message; wp_send_json_error( $status ); } else { // WP 4.1.1 echo '

' . $error_message . '

'; echo '
'; echo '

' . __( 'Update Plugin', 'installer' ) . '

'; echo '' . __( 'Return to the plugins page', 'installer' ) . ''; echo '
'; require_once( ABSPATH . 'wp-admin/admin-footer.php' ); exit; } } } } } } private function store_log( $url, $url_args, $component, $response ) { $log = new OTGS_Installer_Log(); $log->set_request_url( $url ) ->set_component( $component ) ->set_response( $response ) ->set_request_args( $url_args ); otgs_installer_get_logger_storage()->add( $log ); } public function get_api_debug() { return $this->api_debug; } /** * @param string $current_repository * @param string $plugin_slug * * @return array */ private function match_product_in_external_repository( $current_repository, $plugin_slug ) { foreach( $this->get_repositories() as $repo => $repo_data ) { if ( $repo !== $current_repository ) { $plugin_finder = $this->get_plugin_finder(); $plugin_obj = $plugin_finder->get_plugin( $plugin_slug, $repo ); if ( $plugin_obj ) { $site_key = $this->get_repository_site_key( $repo ); if ( $site_key ) { return array( $repo, $site_key ); } } } } return array( '', '' ); } /** * @param $name * @param $slug * * @return bool */ private function isComplementaryWithWPMLSubscription( $name, $slug ) { return Collection::of( ['Toolset Types', 'Toolset Module Manager'] )->contains( $name ) && $this->plugin_is_registered( 'wpml', $slug ); } /** * @param string $repository_id * @param string $plugin_slug * * @return bool */ private function isPluginAvailableInRepositoryDownloads( $repository_id, $plugin_slug ) { return $plugin_slug && isset( $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ] ); } }