Esempio n. 1
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);
 }
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 
}