/**
  * Retrieve the referring translation service (if any)
  *
  * @since 1.6.5
  *
  * @param string The repository id (e.g. wpml)
  * @return string The translation service id or false
  */
 public static function get_ts_referal($repository_id = 'wpml')
 {
     if (isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'])) {
         return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'];
     }
     return false;
 }
Example #2
0
 function wpml_installer_instance_delegator()
 {
     global $wp_installer_instances;
     // version based election
     foreach ($wp_installer_instances as $instance) {
         if (!isset($delegate)) {
             $delegate = $instance;
             continue;
         }
         if (version_compare($instance['version'], $delegate['version'], '>')) {
             $delegate = $instance;
         }
     }
     // priority based election
     $highest_priority = null;
     foreach ($wp_installer_instances as $instance) {
         if (isset($instance['args']['high_priority'])) {
             if (is_null($highest_priority) || $instance['args']['high_priority'] <= $highest_priority) {
                 $highest_priority = $instance['args']['high_priority'];
                 $delegate = $instance;
             }
         }
     }
     include_once $delegate['bootfile'];
     // set configuration
     if (strpos(realpath($delegate['bootfile']), realpath(TEMPLATEPATH)) === 0) {
         $delegate['args']['in_theme_folder'] = dirname(ltrim(str_replace(realpath(TEMPLATEPATH), '', realpath($delegate['bootfile'])), '\\/'));
     }
     if (isset($delegate['args']) && is_array($delegate['args'])) {
         foreach ($delegate['args'] as $key => $value) {
             WP_Installer()->set_config($key, $value);
         }
     }
 }
 public static function check_register()
 {
     if (!function_exists('WP_Installer')) {
         return false;
     }
     $repos = array('toolset');
     foreach ($repos as $repository_id) {
         $key = WP_Installer()->repository_has_subscription($repository_id);
         if (empty($key)) {
             continue;
         }
         return true;
     }
     return false;
 }
 function save_info($data, $repository_id)
 {
     $ts_info = isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']) ? WP_Installer()->settings['repositories'][$repository_id]['ts_info'] : false;
     $save_settings = false;
     if (isset($data->ts_info['preferred']) && empty($ts_info['preferred'])) {
         WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'] = $data->ts_info['preferred'];
         $save_settings = true;
     }
     if (isset($data->ts_info['referal']) && empty($ts_info['referal'])) {
         WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'] = $data->ts_info['referal'];
         $save_settings = true;
     }
     if ($save_settings) {
         WP_Installer()->save_settings();
     }
 }
 /**
  * Create and configure project (Translation Service)
  *
  * @param string $url
  * @param string $name
  * @param string $description
  * @param string $delivery
  *
  * @return bool
  * @throws TranslationProxy_Api_Error
  * @throws Exception
  */
 public function create($url, $name, $description, $delivery = 'xmlrpc')
 {
     global $sitepress;
     $networking = wpml_tm_load_tp_networking();
     $project_creation = new WPML_TP_Project_Creation($this, $sitepress, $networking, array('name' => $name, 'description' => $description, 'url' => $url, 'delivery_method' => $delivery, 'sitekey' => WP_Installer()->get_site_key('wpml')));
     $response_project = $project_creation->run();
     $this->id = $response_project->id;
     $this->access_key = $response_project->accesskey;
     $this->ts_id = $response_project->ts_id;
     $this->ts_access_key = $response_project->ts_accesskey;
     if (isset($response_project->polling_method) && $response_project->polling_method != $delivery) {
         $this->update_delivery_method($response_project->polling_method);
         $this->service->delivery_method = $response_project->polling_method;
     }
     return true;
 }
Example #6
0
 function wpml_installer_instance_delegator()
 {
     global $wp_installer_instances;
     // version based election
     foreach ($wp_installer_instances as $instance) {
         if (!isset($delegate)) {
             $delegate = $instance;
             continue;
         }
         if (version_compare($instance['version'], $delegate['version'], '>')) {
             $delegate = $instance;
         }
     }
     // priority based election
     $highest_priority = null;
     foreach ($wp_installer_instances as $instance) {
         if (isset($instance['args']['high_priority'])) {
             if (is_null($highest_priority) || $instance['args']['high_priority'] <= $highest_priority) {
                 $highest_priority = $instance['args']['high_priority'];
                 $delegate = $instance;
             }
         }
     }
     // Exception: When WPML prior 3.2 is used, that instance must be used regardless of another newer instance
     // Case 2: WPML loaded after Types
     if (defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '<')) {
         foreach ($wp_installer_instances as $key => $instance) {
             if (isset($instance['args']['site_key_nags'])) {
                 $delegate = $instance;
                 $wp_installer_instances = array($key => $delegate);
                 //Eliminate other instances
                 break;
             }
         }
     }
     include_once $delegate['bootfile'];
     // set configuration
     if (strpos(realpath($delegate['bootfile']), realpath(TEMPLATEPATH)) === 0) {
         $delegate['args']['in_theme_folder'] = dirname(ltrim(str_replace(realpath(TEMPLATEPATH), '', realpath($delegate['bootfile'])), '\\/'));
     }
     if (isset($delegate['args']) && is_array($delegate['args'])) {
         foreach ($delegate['args'] as $key => $value) {
             WP_Installer()->set_config($key, $value);
         }
     }
 }
Example #7
0
     if ($_POST['button_action'] == 'later') {
         //success
         $ret['success'] = sprintf(__('WPML will work on your site, but you will not receive updates. WPML updates are essential for keeping your site running smoothly and secure. To receive automated updates, you need to complete the registration, in the %splugins admin%s page.', 'sitepress'), '<a href="' . admin_url('plugin-install.php?tab=commercial') . '">', '</a>');
     } elseif ($_POST['button_action'] == 'finish') {
         $iclsettings['setup_complete'] = 1;
     } else {
         if (empty($_POST['installer_site_key'])) {
             $ret['error'] = __('Missing site key.');
         } else {
             $iclsettings['site_key'] = $_POST['installer_site_key'];
             if (class_exists('WP_Installer')) {
                 $args['repository_id'] = 'wpml';
                 $args['nonce'] = wp_create_nonce('save_site_key_' . $args['repository_id']);
                 $args['site_key'] = $_POST['installer_site_key'];
                 $args['return'] = 1;
                 $r = WP_Installer()->save_site_key($args);
                 if (!empty($r['error'])) {
                     $ret['error'] = $r['error'];
                 } else {
                     //success
                     $ret['success'] = __('Thank you for registering WPML on this site. You will receive automatic updates when new versions are available.', 'sitepress');
                 }
             }
         }
     }
     if (!empty($iclsettings)) {
         $this->save_settings($iclsettings);
     }
     echo json_encode($ret);
     break;
 case 'icl_admin_language_options':
Example #8
0
 public function is_uploading_allowed()
 {
     if (!isset($this->uploading_allowed)) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         require_once WP_Installer()->plugin_path() . '/includes/installer-upgrader-skins.php';
         $upgrader_skins = new Installer_Upgrader_Skins();
         //use our custom (mute) Skin
         $upgrader = new Plugin_Upgrader($upgrader_skins);
         ob_start();
         $res = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR));
         ob_end_clean();
         if (!$res || is_wp_error($res)) {
             $this->uploading_allowed = false;
         } else {
             $this->uploading_allowed = true;
         }
     }
     return $this->uploading_allowed;
 }
Example #9
0
function WP_Installer_Show_Products($args = array())
{
    WP_Installer()->show_products($args);
}
Example #10
0
                }
                ?>
 />
                        </div>
                    <?php 
            }
            ?>

                </div> <!-- .wcml-section-content -->
            </div> <!-- .wpml-section-languages -->
            
        <?php 
        } elseif ($setup_wizard_step == 4) {
            ?>
        <?php 
            $site_key = WP_Installer()->get_site_key('wpml');
            ?>
    
        <div class="wpml-section" id="lang-sec-0">
            <div class="wpml-section-header">
                <h3><?php 
            _e('Registration', 'sitepress');
            ?>
</h3>
            </div>
            <div class="wpml-section-content">
                
                <?php 
            if (is_multisite() && !empty($site_key)) {
                ?>
                
 private function site_key_exist()
 {
     if (class_exists('WP_Installer')) {
         $repository_id = 'wpml';
         $site_key = WP_Installer()->get_site_key($repository_id);
     }
     return $does_exist = $site_key !== false ? true : false;
 }
Example #12
0
                    <br />

                    <div class="installer-error-box">
                    <?php 
if (!WP_Installer()->dependencies->is_uploading_allowed()) {
    ?>
                        <p><?php 
    printf(__('Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s.', 'installer'), '<a href="http://codex.wordpress.org/Changing_File_Permissions">', '</a>');
    ?>
</p>
                    <?php 
} elseif (WP_Installer()->dependencies->is_win_paths_exception($repository_id)) {
    ?>
                        <p><?php 
    echo WP_Installer()->dependencies->win_paths_exception_message();
    ?>
</p>
                    <?php 
}
?>
                    </div>

                    <input type="submit" class="button-secondary" value="<?php 
esc_attr_e('Download', 'installer');
?>
" disabled="disabled" />
                    &nbsp;
                    <label><input name="activate" type="checkbox" value="1" disabled="disabled" />&nbsp;<?php 
_e('Activate after download', 'installer');
?>
Example #13
0
    ?>
</span>
                                </td>
                                <td class="for_spinner_js"><span class="spinner"></span></td>
                            </tr>
                        <?php 
}
?>
                        </tbody>
                    </table>

                    <br />

                    <div class="installer-error-box">
                    <?php 
if (!WP_Installer()->is_uploading_allowed()) {
    ?>
                        <p>
                        <?php 
    printf(__('Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s.', 'installer'), '<a href="http://codex.wordpress.org/Changing_File_Permissions">', '</a>');
    ?>
                        </p>
                    <?php 
}
?>
                    </div>

                    <input type="submit" class="button-secondary" value="<?php 
esc_attr_e('Download', 'installer');
?>
" disabled="disabled" />
 public function prevent_plugins_update_on_updates_screen()
 {
     if (isset($_REQUEST['action'])) {
         $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
         $installer_settings = WP_Installer()->settings;
         //bulk mode
         if ('update-selected' == $action) {
             global $plugins;
             if (isset($plugins) && is_array($plugins)) {
                 foreach ($plugins as $k => $plugin) {
                     $wp_plugin_slug = dirname($plugin);
                     foreach ($installer_settings['repositories'] as $repository_id => $repository) {
                         if ($this->is_win_paths_exception($repository_id)) {
                             foreach ($repository['data']['packages'] as $package) {
                                 foreach ($package['products'] as $product) {
                                     foreach ($product['plugins'] as $plugin_slug) {
                                         $download = $installer_settings['repositories'][$repository_id]['data']['downloads']['plugins'][$plugin_slug];
                                         if ($download['slug'] == $wp_plugin_slug && empty($download['free-on-wporg'])) {
                                             echo '<div class="updated error"><p>' . $this->win_paths_exception_message() . ' <strong>(' . $download['name'] . ')</strong>' . '</p></div>';
                                             unset($plugins[$k]);
                                             break 3;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ('upgrade-plugin' == $action || 'update-plugin' == $action) {
             $plugin = isset($_REQUEST['plugin']) ? trim(sanitize_text_field($_REQUEST['plugin'])) : '';
             $wp_plugin_slug = dirname($plugin);
             foreach ($installer_settings['repositories'] as $repository_id => $repository) {
                 if ($this->is_win_paths_exception($repository_id)) {
                     foreach ($repository['data']['packages'] as $package) {
                         foreach ($package['products'] as $product) {
                             foreach ($product['plugins'] as $plugin_slug) {
                                 $download = $installer_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 && empty($download['free-on-wporg'])) {
                                     echo '<div class="updated error"><p>' . $this->win_paths_exception_message() . '</p></div>';
                                     echo '<div class="wrap">';
                                     echo '<h2>' . __('Update Plugin') . '</h2>';
                                     echo '<a href="' . admin_url('update-core.php') . '">' . __('Return to the updates page', 'installer') . '</a>';
                                     echo '</div>';
                                     require_once ABSPATH . 'wp-admin/admin-footer.php';
                                     exit;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * @param TranslationProxy_Service $service
  * @param bool                     $force
  *
  * @throw TranslationProxy_Project
  * @return TranslationProxy_Project
  */
 private static function create_project($service, $force = false)
 {
     $icl_translation_projects = self::get_translation_projects();
     $delivery_method = self::get_delivery_method();
     $delivery = $delivery_method == ICL_PRO_TRANSLATION_PICKUP_XMLRPC ? "xmlrpc" : "polling";
     $project_index = TranslationProxy_Project::generate_service_index($service);
     if (!$force && isset($icl_translation_projects[$project_index])) {
         $project = self::load_existing_project($service, $delivery);
     } else {
         $url = get_option('siteurl');
         $name = get_option('blogname');
         $description = get_option('blogdescription');
         $project = new TranslationProxy_Project($service);
         $site_key = WP_Installer()->get_site_key('wpml');
         $result = $project->create($url, $name, $description, $delivery, $site_key);
         if (!$result || count($project->errors)) {
             self::append_errors($project->errors);
             $project = false;
         }
     }
     return $project;
 }
 /**
  * Retrieve the site key corresponding to a repository.
  * This is a wrapper of WP_Installer::get_site_key()
  * @see WP_Installer::get_site_key()
  *
  * @since 1.7.9
  *
  * @param string The repository id (e.g. wpml)
  * @return string The site key (or false)
  */
 public static function get_site_key($repository_id = 'wpml')
 {
     return WP_Installer()->get_site_key($repository_id);
 }
 public function get_repository_downloads($repository_id)
 {
     if (!isset($this->repository_downloads[$repository_id])) {
         $downloads = array();
         $installer_settings = WP_Installer()->get_settings();
         if (isset($installer_settings['repositories'][$repository_id])) {
             foreach ($installer_settings['repositories'][$repository_id]['data']['packages'] as $package) {
                 foreach ($package['products'] as $product) {
                     foreach ($product['downloads'] as $download) {
                         if (!isset($downloads[$download['basename']])) {
                             $d['name'] = $download['name'];
                             $d['basename'] = $download['basename'];
                             $d['version'] = $download['version'];
                             $d['date'] = $download['date'];
                             $d['url'] = $download['url'] . '&theme_key=' . $this->config[$repository_id]['key'] . '&theme_name=' . urlencode(wp_get_theme());
                             $downloads[$d['basename']] = $d;
                         }
                     }
                 }
             }
         }
         $this->repository_downloads[$repository_id] = $downloads;
     }
     return $this->repository_downloads[$repository_id];
 }
 public static function get_product_price($repository_id, $package_id, $product_id, $incl_discount = false)
 {
     $price = WP_Installer()->get_product_price($repository_id, $package_id, $product_id, $incl_discount);
     return $price;
 }
 /** Get themes by subscription type */
 protected function installer_theme_get_themes_by_subscription($subscription_type, $repo)
 {
     $themes_associated_with_subscription = array();
     if (isset(WP_Installer()->settings['repositories'][$repo]['data']['packages'])) {
         //Set
         $packages = WP_Installer()->settings['repositories'][$repo]['data']['packages'];
         $available_themes_subscription = array();
         foreach ($packages as $package_id => $package_details) {
             if (isset($package_details['products'])) {
                 $the_products = $package_details['products'];
                 foreach ($the_products as $product_slug => $product_details) {
                     if (isset($product_details['subscription_type'])) {
                         $subscription_type_from_settings = intval($product_details['subscription_type']);
                         if ($subscription_type_from_settings == $subscription_type) {
                             //We found the subscription
                             if (isset($product_details['themes'])) {
                                 $themes_associated_with_subscription = $product_details['themes'];
                                 return $themes_associated_with_subscription;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $themes_associated_with_subscription;
 }
 public function get_repository_downloads($repository_id, $config)
 {
     if (!isset($this->repository_downloads[md5(serialize($config))][$repository_id])) {
         $downloads = array();
         $installer_settings = WP_Installer()->get_settings();
         if (isset($installer_settings['repositories'][$repository_id])) {
             foreach ($installer_settings['repositories'][$repository_id]['data']['packages'] as $package) {
                 foreach ($package['products'] as $product) {
                     $available_in_installer = WP_Installer()->is_product_available_for_download($product['name'], $repository_id);
                     foreach ($product['downloads'] as $download) {
                         if (!isset($downloads[$download['basename']]) || empty($d['_installer_download_url']) && $available_in_installer) {
                             $d['name'] = $download['name'];
                             $d['basename'] = $download['basename'];
                             $d['version'] = $download['version'];
                             $d['date'] = $download['date'];
                             $d['_installer_url'] = $available_in_installer;
                             /*
                             $format = 'standard';
                             foreach($config['repositories'][$repository_id]['plugins'] as $p){
                                 if($p['name'] == $d['basename']){
                                     if(isset($p['format'])){
                                         $format = $p['format'];
                                     }
                                     break;
                                 }
                             }
                             */
                             //case of valid subscription
                             if ($available_in_installer) {
                                 $d['url'] = WP_Installer()->append_site_key_to_download_url($download['url'], WP_Installer()->get_site_key($repository_id), $repository_id);
                             } else {
                                 $d['url'] = $download['url'] . '&theme_key=' . $config['repositories'][$repository_id]['key'] . '&theme_name=' . urlencode($config['name']);
                                 //. '&format=' . $format;
                             }
                             $downloads[$d['basename']] = $d;
                         }
                     }
                 }
             }
         }
         $this->repository_downloads[md5(serialize($config))][$repository_id] = $downloads;
     }
     return $this->repository_downloads[md5(serialize($config))][$repository_id];
 }