public function pre_set_site_transient_update_themes($data)
 {
     //
     // Only run after other themes are checked.
     //
     if (empty($data->checked)) {
         return $data;
     }
     Themeco_Update_Api::refresh();
     $update_cache = Themeco_Update_Api::get_update_cache();
     if (!isset($update_cache['themes']) || !isset($update_cache['themes']['x'])) {
         return $data;
     }
     $themes = is_multisite() ? $this->multisite_get_themes() : wp_get_themes();
     if (isset($themes['x'])) {
         $remote = $update_cache['themes']['x'];
         if (version_compare($remote['new_version'], $themes['x']->get('Version'), '<=')) {
             return $data;
         }
         if (!$remote['package']) {
             $remote['new_version'] = $remote['new_version'] . '<br/>' . X_Update_API::get_validation_html_theme_updates();
         }
         $data->response['x'] = $remote;
     }
     return $data;
 }
Example #2
0
 function x_register_theme_plugins()
 {
     //
     // Bundled plugins.
     //
     $bundled = array('cornerstone' => array('name' => 'Cornerstone', 'slug' => 'cornerstone', 'source' => X_TEMPLATE_URL . '/framework/plugins/cornerstone.zip', 'required' => true, 'version' => '', 'force_activation' => true, 'force_deactivation' => false, 'external_url' => '', 'x_plugin' => 'cornerstone/cornerstone.php', 'x_author' => 'Themeco', 'x_description' => 'This plugin is required to run X. It provides a front end page editor and all the shortcodes used in X.', 'x_logo' => '//theme.co/media/x_extensions/200-200-no-title-cornerstone.png', 'x_manage_upgrade' => false), 'revslider' => array('name' => 'Slider Revolution', 'slug' => 'revslider', 'source' => X_TEMPLATE_URL . '/framework/plugins/revslider.zip', 'required' => false, 'version' => '4.6.93', 'force_activation' => false, 'force_deactivation' => false, 'external_url' => '', 'x_plugin' => 'revslider/revslider.php', 'x_author' => 'ThemePunch', 'x_description' => 'Create responsive sliders with must-see-effects, all while maintaining your search engine optimization.', 'x_logo' => '//theme.co/media/x_extensions/200-200-no-title-slider-revolution.png', 'x_manage_upgrade' => true), 'js_composer' => array('name' => 'Visual Composer', 'slug' => 'js_composer', 'source' => X_TEMPLATE_URL . '/framework/plugins/js_composer.zip', 'required' => false, 'version' => '4.5.3', 'force_activation' => false, 'force_deactivation' => false, 'external_url' => '', 'x_plugin' => 'js_composer/js_composer.php', 'x_author' => 'WPBakery', 'x_description' => 'We recommend using <a href="//theme.co/cornerstone/" title="Cornerstone" target="_blank">Cornerstone</a> for page building in X as it is built and managed by Themeco; however, Visual Composer is an alternate choice.', 'x_logo' => '//theme.co/media/x_extensions/200-200-no-title-visual-composer.png', 'x_manage_upgrade' => true));
     //
     // Remote plugins.
     //
     $extensions = array();
     $addons = X_Update_API::get_cached_addons();
     if (is_array($addons) && !isset($addons['error'])) {
         foreach ($addons as $ext => $data) {
             $data['force_activation'] = $data['force_activation'] == 'on' ? true : false;
             $data['force_deactivation'] = $data['force_deactivation'] == 'on' ? true : false;
             $extensions[$ext] = array('name' => $data['title'], 'slug' => $data['slug'], 'source' => $data['download_url'], 'required' => false, 'version' => $data['latest_version'], 'force_activation' => $data['force_activation'], 'force_deactivation' => false, 'external_url' => '', 'x_plugin' => $data['plugin_file'], 'x_author' => $data['author'], 'x_description' => $data['description'], 'x_logo' => $data['logo_url'], 'x_manage_upgrade' => false);
         }
     }
     //
     // Merge bundled and remote plugins.
     //
     $plugins = array_merge($bundled, $extensions);
     //
     // TMG configuration.
     //
     $config = array('domain' => '__x__', 'default_path' => 'tgmpa-install-plugins', 'parent_menu_slug' => 'themes.php', 'parent_url_slug' => 'themes.php', 'menu' => 'install-required-plugins', 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'is_automatic' => true, 'message' => '', 'strings' => array('page_title' => __('Install Required Plugins', '__x__'), 'menu_title' => __('Install Plugins', '__x__'), 'installing' => __('Installing Plugin: %s', '__x__'), 'oops' => __('Something went wrong with the plugin API.', '__x__'), 'notice_can_install_required' => _n_noop('This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.'), 'notice_can_install_recommended' => _n_noop('This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.'), 'notice_cannot_install' => _n_noop('Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.'), 'notice_can_activate_required' => _n_noop('The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.'), 'notice_can_activate_recommended' => _n_noop('The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.'), 'notice_cannot_activate' => _n_noop('Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.'), 'notice_ask_to_update' => _n_noop('The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.'), 'notice_cannot_update' => _n_noop('Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.'), 'install_link' => _n_noop('Begin installing plugin', 'Begin installing plugins'), 'activate_link' => _n_noop('Activate installed plugin', 'Activate installed plugins'), 'return' => __('Return to Required Plugins Installer', '__x__'), 'plugin_activated' => __('Plugin activated successfully.', '__x__'), 'complete' => __('All plugins installed and activated successfully. %s', '__x__'), 'nag_type' => 'updated'));
     tgmpa($plugins, $config);
 }
 public function __construct()
 {
     self::$instance = $this;
     add_filter('themeco_update_api', array($this, 'register'));
     add_filter('themeco_update_cache', array($this, 'cache_updates'), 10, 2);
     add_action('themeco_update_api_response', array($this, 'update'));
     add_action('init', array($this, 'init'));
     // add_action( 'upgrader_pre_download', array( $this, 'upgrader_screen_message' ), 10, 3 );
 }
 public function pre_set_site_transient_update_themes($data)
 {
     $theme = $this->get_theme_meta();
     //
     // Only check once.
     //
     if (!empty($theme) && !empty($data->checked)) {
         $remote = X_Update_API::get_x_theme();
         $update = array('new_version' => $remote['download_url'] == NULL ? $remote['latest_version'] . '<br/>' . X_Update_API::get_validation_html_theme_updates() : $remote['latest_version'], 'url' => 'http://theme.co/changelog/?iframe=true', 'package' => $remote['download_url']);
         $remote_is_newer = 1 === version_compare($remote['latest_version'], $theme->local_version);
         if ($remote_is_newer) {
             $data->response[$theme->stylesheet] = $update;
         }
     }
     return $data;
 }
function x_addons_product_validation()
{
    if (isset($_POST['validate']) && check_admin_referer('x-addons-product-validation')) {
        if (strip_tags($_POST['x_addons_product_validation_submitted']) == 'submitted') {
            //
            // If $input is set and an empty string, delete the option and provide a
            // message to confirm that the key has been removed.
            //
            // Else, check the value returned by $response['code'] and provide an
            // appropriate action and message.
            //
            // $response['code'] == 1 - Success
            // $response['code'] == 2 - General Error
            // $response['code'] == 3 - Invalid API Key
            // $response['code'] == 4 - Connection Error
            //
            $name = x_addons_get_api_key_option_name();
            $input = strip_tags($_POST[$name]);
            if (isset($input) && $input == '') {
                delete_option($name);
                echo '<div class="updated"><p>API key removed successfully!</p></div>';
            } else {
                $response = X_Update_API::validate_key($input);
                if ($response['code'] == 2 || $response['code'] == 3 || $response['code'] == 4) {
                    delete_option($name);
                    echo '<div class="error"><p>' . $response['message'] . '</p></div>';
                    if (isset($_GET['x-verbose']) && $_GET['x-verbose'] == 1) {
                        x_dump(X_Update_API::get_errors(), 350, 'var_dump');
                    }
                } else {
                    update_option($name, $input);
                    echo '<div class="updated"><p>' . $response['message'] . '</p></div>';
                }
            }
            delete_site_option('x_addon_list_cache');
        }
    }
}
function x_addons_page_extensions()
{
    ?>

  <?php 
    //
    // Allow cache to be cleared manually.
    //
    if (isset($_GET['force-check']) && $_GET['force-check'] == 1) {
        delete_site_option('x_addon_list_cache');
    }
    //
    // Retrieve addons from cache, or check immediately if they were just cleared.
    //
    $addons_cache = X_Update_API::get_cached_addons();
    //
    // Show connection errors on screen.
    //
    if (isset($_GET['x-verbose']) && $_GET['x-verbose'] == 1) {
        delete_site_option('x_addon_list_cache');
        x_dump(X_Update_API::get_errors(), 350, 'var_dump');
    }
    ?>

  <div class="wrap x-addons-extensions">

    <header class="x-addons-header">
      <h2>Extensions</h2>
      <p>Custom and third party plugins you can use for free (over $1,000 in value) with updates!</p>

      <?php 
    if (isset($addons_cache['error']) && $addons_cache['error']) {
        ?>
        <div class="error"><p><?php 
        echo $addons_cache['message'];
        ?>
</p></div>
      <?php 
    }
    ?>

    </header>

    <ul class="x-addons-extensions-list cf" id="x-addons-extensions-list">

      <?php 
    $plugins = TGM_Plugin_Activation::$instance->plugins;
    foreach ($plugins as $key => $plugin) {
        if ($plugin['slug'] == 'cornerstone') {
            $cornerstone = $plugin;
            unset($plugins[$key]);
        }
    }
    array_unshift($plugins, $cornerstone);
    foreach ($plugins as $plugin) {
        ?>

        <?php 
        if (x_plugin_exists($plugin['x_plugin'])) {
            if (is_plugin_active($plugin['x_plugin'])) {
                $status = 'active';
                $status_message = 'Active';
            } else {
                $status = 'inactive';
                $status_message = 'Inactive';
            }
            $button = '<a class="x-addon-button button" href="' . admin_url('plugins.php') . '">Manage Plugin</a>';
        } else {
            if ($plugin['source'] == NULL) {
                $url = x_addons_get_link_product_validation();
                $text = 'Validate Purchase to Install';
                $class = 'x-addon-button button';
            } else {
                $url = wp_nonce_url(add_query_arg(array('page' => TGM_Plugin_Activation::$instance->menu, 'plugin' => $plugin['slug'], 'plugin_name' => $plugin['name'], 'plugin_source' => $plugin['source'], 'tgmpa-install' => 'install-plugin'), admin_url(TGM_Plugin_Activation::$instance->parent_url_slug)), 'tgmpa-install');
                $text = 'Install Plugin';
                $class = 'x-addon-button button button-primary';
            }
            $status = 'not-installed';
            $status_message = 'Not Installed';
            $button = '<a class="' . $class . '" href="' . $url . '">' . $text . '</a>';
        }
        ?>

        <li class="x-addons-extension <?php 
        echo $status;
        ?>
" id="<?php 
        echo $plugin['slug'];
        ?>
">
          <div class="top cf">
            <img src="<?php 
        echo $plugin['x_logo'];
        ?>
" class="img">
            <div class="info">
              <h4 class="title"><?php 
        echo $plugin['name'];
        ?>
</h4>
              <span class="status <?php 
        echo $status;
        ?>
"><?php 
        echo $status_message;
        ?>
</span>
              <p class="desc"><?php 
        echo $plugin['x_description'];
        ?>
</p>
              <p class="author"><cite>By <?php 
        echo $plugin['x_author'];
        ?>
</cite></p>
            </div>
          </div>
          <div class="bottom cf"><?php 
        echo $button;
        ?>
</div>
        </li>

      <?php 
    }
    ?>

    </ul>

  </div>

<?php 
}
 public static function store_error($wp_error)
 {
     if (!isset(self::$errors)) {
         self::$errors = array();
     }
     array_push(self::$errors, (array) $wp_error);
 }
function x_addons_product_validation()
{
    if (isset($_POST['validate']) && check_admin_referer('x-addons-product-validation')) {
        if (strip_tags($_POST['x_addons_product_validation_submitted']) == 'submitted') {
            $name = x_addons_get_api_key_option_name();
            $input = strip_tags($_POST[$name]);
            if (isset($input) && $input == '') {
                delete_option($name);
                Themeco_Update_Api::refresh();
                echo '<div class="updated"><p>' . __('API key removed successfully!', '__x__') . '</p></div>';
            } else {
                $validation = X_Update_API::validate_key($input);
                if ($validation['valid']) {
                    update_option($name, $input);
                    echo '<div class="updated"><p>' . $validation['message'] . '</p></div>';
                } else {
                    delete_option($name);
                    echo '<div class="error"><p>' . $validation['message'] . '</p></div>';
                    if (isset($_GET['x-verbose']) && $_GET['x-verbose'] == 1) {
                        x_dump($validation['verbose'], 350, 'var_dump');
                    }
                }
            }
        }
    }
}
 function custom_plugin_update_row($file, $plugin_data)
 {
     $current = get_site_transient('update_plugins');
     if (!isset($current->response[$file])) {
         return false;
     }
     $r = $current->response[$file];
     $allowed_tags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array());
     $plugin_name = wp_kses($plugin_data['Name'], $allowed_tags);
     $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&section=changelog&TB_iframe=true&width=600&height=800');
     $wp_list_table = _get_list_table('WP_Plugins_List_Table');
     if (is_network_admin() || !is_multisite()) {
         echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
         if (!current_user_can('update_plugins')) {
             printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version);
         } else {
             if (empty($r->package)) {
                 printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. %5$s'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, X_Update_API::get_validation_html_plugin_main());
             } else {
                 printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file));
             }
         }
         //
         // Fires at the end of the update message container in each row of the
         // plugins list table.
         //
         // The dymaic portion of the hook name, $file, refers to the path of
         // the plugin's primary file relative to the plugins directory.
         //
         // $plugin_data is an array of plugin metadata:
         //
         // * $name        (string) - The human-readable name of the plugin.
         // * $title       (string) - The human-readable title of the plugin.
         // * $plugin_uri  (string) - The plugin URI.
         // * $version     (string) - The plugin version.
         // * $description (string) - The plugin description.
         // * $author      (string) - The plugin author.
         // * $author_uri  (string) - The plugin author URI.
         // * $author_name (string) - The plugin author's name.
         // * $text_domain (string) - The plugin text domain.
         // * $domain_path (string) - The relative path to the plugin's .mo file(s).
         // * $network       (bool) - Whether the plugin can only be activated network wide.
         // * $update        (bool) - Whether there's an available update. Default is NULL.
         //
         // $r is an array of metadata about the available plugin update.
         //
         // * $id             (int) - The plugin ID.
         // * $slug        (string) - The plugin slug.
         // * $new_version (string) - The new plugin version.
         // * $url         (string) - The plugin URL.
         // * $package     (string) - The plugin update package URL.
         //
         do_action('in_plugin_update_message-' . $file, $plugin_data, $r);
         echo '</div></td></tr>';
     }
 }