diff --git a/functions.php b/functions.php index cbb1572..d58e030 100644 --- a/functions.php +++ b/functions.php @@ -68,6 +68,9 @@ function ipt_kb_setup() { // Add post thumbnail add_theme_support( 'post-thumbnails', array( 'post' ) ); + // Add new theme title-tag WP4.1 + add_theme_support( 'title-tag' ); + add_image_size( 'ipt_kb_medium', 256, 128, true ); add_image_size( 'ipt_kb_large', 9999, 200, true ); @@ -77,6 +80,18 @@ function ipt_kb_setup() { endif; // ipt_kb_setup add_action( 'after_setup_theme', 'ipt_kb_setup' ); +/** + * Backward compatibility + */ +if ( ! function_exists( '_wp_render_title_tag' ) ) : + function ipt_kb_render_title() { +?> +<?php wp_title( '|', true, 'right' ); ?> + -<?php wp_title( '|', true, 'right' ); ?> diff --git a/header.php b/header.php index 882d6f5..53c698b 100644 --- a/header.php +++ b/header.php @@ -12,7 +12,6 @@ -<?php wp_title( '|', true, 'right' ); ?> diff --git a/inc/class-tgm-plugin-activation.php b/inc/class-tgm-plugin-activation.php index 5e1f7aa..ae01321 100644 --- a/inc/class-tgm-plugin-activation.php +++ b/inc/class-tgm-plugin-activation.php @@ -62,15 +62,6 @@ class TGM_Plugin_Activation { */ public $plugins = array(); - /** - * Name of the unique ID to hash notices. - * - * @since 2.4.0 - * - * @var string - */ - public $id = 'tgmpa'; - /** * Name of the querystring argument for the admin page. * @@ -166,6 +157,29 @@ public function __construct() { self::$instance = $this; + $this->strings = array( + 'page_title' => __( 'Install Required Plugins', 'tgmpa' ), + 'menu_title' => __( 'Install Plugins', 'tgmpa' ), + 'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), + 'oops' => __( 'Something went wrong.', 'tgmpa' ), + '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( 'Begin activating plugin', 'Begin activating plugins' ), + 'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ), + 'dashboard' => __( 'Return to the dashboard', 'tgmpa' ), + 'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ), + 'activated_successfully' => __( 'The following plugin was activated successfully:', 'tgmpa' ), + 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'tgmpa' ), + 'dismiss' => __( 'Dismiss this notice', 'tgmpa' ), + ); + // Set the current WordPress version. global $wp_version; $this->wp_version = $wp_version; @@ -191,30 +205,6 @@ public function __construct() { */ public function init() { - // Load class strings. - $this->strings = array( - 'page_title' => __( 'Install Required Plugins', 'tgmpa' ), - 'menu_title' => __( 'Install Plugins', 'tgmpa' ), - 'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), - 'oops' => __( 'Something went wrong.', 'tgmpa' ), - 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'tgmpa' ), - 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'tgmpa' ), - '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.', 'tgmpa' ), - 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'tgmpa' ), - 'notice_can_activate_recommended'=> _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'tgmpa' ), - '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.', 'tgmpa' ), - '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.', 'tgmpa' ), - '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.', 'tgmpa' ), - 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'tgmpa' ), - 'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'tgmpa' ), - 'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ), - 'dashboard' => __( 'Return to the dashboard', 'tgmpa' ), - 'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ), - 'activated_successfully' => __( 'The following plugin was activated successfully:', 'tgmpa' ), - 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'tgmpa' ), - 'dismiss' => __( 'Dismiss this notice', 'tgmpa' ), - ); - do_action( 'tgmpa_register' ); // After this point, the plugins should be registered and the configuration set. @@ -321,7 +311,7 @@ public function admin_init() { */ public function thickbox() { - if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { + if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice', true ) ) { add_thickbox(); } @@ -387,9 +377,6 @@ public function install_plugins_page() { ?>
- wp_version, '3.8', '<' ) ) { - screen_icon( apply_filters( 'tgmpa_default_screen_icon', 'themes' ) ); - } ?>

prepare_items(); ?> @@ -450,7 +437,7 @@ protected function do_plugin_install() { 'plugin_source' => $plugin['source'], 'tgmpa-install' => 'install-plugin', ), - admin_url( 'themes.php' ) + network_admin_url( 'themes.php' ) ), 'tgmpa-install' ); @@ -514,7 +501,7 @@ protected function do_plugin_install() { if ( is_wp_error( $activate ) ) { echo '

' . $activate->get_error_message() . '

'; - echo '

' . $this->strings['return'] . '

'; + echo '

' . $this->strings['return'] . '

'; return true; // End it here if there is an error with automatic activation } else { @@ -526,7 +513,7 @@ protected function do_plugin_install() { $complete = array(); foreach ( $this->plugins as $plugin ) { if ( ! is_plugin_active( $plugin['file_path'] ) ) { - echo '

' . $this->strings['return'] . '

'; + echo '

' . $this->strings['return'] . '

'; $complete[] = $plugin; break; } @@ -541,7 +528,7 @@ protected function do_plugin_install() { // All plugins are active, so we display the complete string and hide the plugin menu. if ( empty( $complete ) ) { - echo '

' . sprintf( $this->strings['complete'], '' . __( 'Return to the Dashboard', 'tgmpa' ) . '' ) . '

'; + echo '

' . sprintf( $this->strings['complete'], '' . __( 'Return to the Dashboard', 'tgmpa' ) . '' ) . '

'; echo ''; } @@ -563,13 +550,13 @@ protected function do_plugin_install() { if ( is_wp_error( $activate ) ) { echo '

' . $activate->get_error_message() . '

'; - echo '

' . $this->strings['return'] . '

'; + echo '

' . $this->strings['return'] . '

'; return true; // End it here if there is an error with activation. } else { // Make sure message doesn't display again if bulk activation is performed immediately after a single activation. if ( ! isset( $_POST['action'] ) ) { - $msg = $this->strings['activated_successfully'] . ' ' . $plugin['name'] . '.'; + $msg = $this->strings['activated_successfully'] . ' ' . $plugin['name'] . ''; echo '

' . $msg . '

'; } } @@ -601,7 +588,7 @@ public function notices() { } // Return early if the nag message has been dismissed. - if ( get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { + if ( get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice', true ) ) { return; } @@ -712,7 +699,7 @@ public function notices() { 'width' => '640', 'height' => '500', ), - admin_url( 'plugin-install.php' ) + network_admin_url( 'plugin-install.php' ) ); $linked_plugin_groups[] = '' . $plugin_group_single_name . ''; @@ -733,8 +720,8 @@ public function notices() { } // Setup variables to determine if action links are needed. - $show_install_link = $install_link ? '' . translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ) . '' : ''; - $show_activate_link = $activate_link ? '' . translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ) . '' : ''; + $show_install_link = $install_link ? '' . translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ) . '' : ''; + $show_activate_link = $activate_link ? '' . translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ) . '' : ''; // Define all of the action links. $action_links = apply_filters( @@ -777,7 +764,7 @@ public function notices() { public function dismiss() { if ( isset( $_GET['tgmpa-dismiss'] ) ) { - update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 ); + update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice', 1 ); } } @@ -817,7 +804,7 @@ public function register( $plugin ) { */ public function config( $config ) { - $keys = array( 'id', 'default_path', 'has_notices', 'dismissable', 'dismiss_msg', 'menu', 'is_automatic', 'message', 'strings' ); + $keys = array( 'default_path', 'has_notices', 'dismissable', 'dismiss_msg', 'menu', 'is_automatic', 'message', 'strings' ); foreach ( $keys as $key ) { if ( isset( $config[$key] ) ) { @@ -952,7 +939,7 @@ protected function is_tgmpa_page() { */ public function update_dismiss() { - delete_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id ); + delete_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice' ); } @@ -995,7 +982,7 @@ public function force_activation() { * is set to true. * * This allows theme authors to specify certain plugins that must be - * deactivated upon switching from the current theme to another. + * deactived upon switching from the current theme to another. * * Please take special care when using this parameter as it has the * potential to be harmful if not used correctly. @@ -1008,7 +995,7 @@ public function force_deactivation() { $this->populate_file_path(); foreach ( $this->plugins as $plugin ) { - // Only proceed forward if the parameter is set to true and plugin is active. + // Only proceed forward if the paramter is set to true and plugin is active. if ( isset( $plugin['force_deactivation'] ) && $plugin['force_deactivation'] && is_plugin_active( $plugin['file_path'] ) ) { deactivate_plugins( $plugin['file_path'] ); } @@ -1100,9 +1087,14 @@ class TGMPA_List_Table extends WP_List_Table { * and stores it in the global object TGM_Plugin_Activation::$instance. * * @since 2.2.0 + * + * @global unknown $status + * @global string $page */ public function __construct() { + global $status, $page; + parent::__construct( array( 'singular' => 'plugin', @@ -1155,7 +1147,7 @@ protected function _gather_plugin_data() { 'width' => '640', 'height' => '500', ), - admin_url( 'plugin-install.php' ) + network_admin_url( 'plugin-install.php' ) ); $table_data[$i]['plugin'] = '' . $plugin['name'] . ''; @@ -1261,7 +1253,12 @@ protected function _get_plugin_data_from_name( $name, $data = 'slug' ) { */ public function column_default( $item, $column_name ) { - return $item[$column_name]; + switch ( $column_name ) { + case 'source': + case 'type': + case 'status': + return $item[$column_name]; + } } @@ -1297,7 +1294,7 @@ public function column_plugin( $item ) { 'plugin_source' => $item['url'], 'tgmpa-install' => 'install-plugin', ), - admin_url( 'themes.php' ) + network_admin_url( 'themes.php' ) ), 'tgmpa-install' ), @@ -1319,7 +1316,7 @@ public function column_plugin( $item ) { 'tgmpa-activate' => 'activate-plugin', 'tgmpa-activate-nonce' => wp_create_nonce( 'tgmpa-activate' ), ), - admin_url( 'themes.php' ) + network_admin_url( 'themes.php' ) ), $item['sanitized_plugin'] ), @@ -1358,7 +1355,7 @@ public function column_cb( $item ) { */ public function no_items() { - printf( __( 'No plugins to install or activate. Return to the Dashboard', 'tgmpa' ), admin_url() ); + printf( __( 'No plugins to install or activate. Return to the Dashboard', 'tgmpa' ), network_admin_url() ); echo ''; } @@ -1505,7 +1502,6 @@ public function process_bulk_actions() { // No need to proceed further if we have no plugins to install. if ( empty( $plugin_installs ) ) { - echo '

' . __( 'No plugins are available to be installed at this time.', 'tgmpa' ) . '

'; return false; } @@ -1529,7 +1525,7 @@ public function process_bulk_actions() { 'plugin_paths' => urlencode( implode( ',', $plugin_paths ) ), 'plugin_names' => urlencode( implode( ',', $plugin_names ) ), ), - admin_url( 'themes.php' ) + network_admin_url( 'themes.php' ) ), 'bulk-plugins' ); @@ -1572,7 +1568,7 @@ public function process_bulk_actions() { } // Finally, all the data is prepared to be sent to the installer. - $url = add_query_arg( array( 'page' => TGM_Plugin_Activation::$instance->menu ), admin_url( 'themes.php' ) ); + $url = add_query_arg( array( 'page' => TGM_Plugin_Activation::$instance->menu ), network_admin_url( 'themes.php' ) ); $nonce = 'bulk-plugins'; $names = $plugin_names; @@ -1581,9 +1577,6 @@ public function process_bulk_actions() { // Wrap the install process with the appropriate HTML. echo '
'; - if ( version_compare( TGM_Plugin_Activation::$instance->wp_version, '3.8', '<' ) ) { - screen_icon( apply_filters( 'tgmpa_default_screen_icon', 'themes' ) ); - } echo '

' . esc_html( get_admin_page_title() ) . '

'; // Process the bulk installation submissions. $installer->bulk_install( $sources ); @@ -1613,8 +1606,7 @@ public function process_bulk_actions() { // Return early if there are no plugins to activate. if ( empty( $plugins_to_activate ) ) { - echo '

' . __( 'No plugins are available to be activated at this time.', 'tgmpa' ) . '

'; - return false; + return; } $plugins = array(); @@ -1635,7 +1627,7 @@ public function process_bulk_actions() { if ( is_wp_error( $activate ) ) { echo '

' . $activate->get_error_message() . '

'; } else { - printf( '

%1$s %2$s.

', _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'tgmpa' ), $imploded ); + printf( '

%1$s %2$s

', _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'tgmpa' ), $imploded ); } // Update recently activated plugins option. @@ -1650,8 +1642,6 @@ public function process_bulk_actions() { update_option( 'recently_activated', $recent ); unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another. - - return true; } } @@ -1662,6 +1652,7 @@ public function process_bulk_actions() { */ public function prepare_items() { + $per_page = 100; // Set it high so we shouldn't have to worry about pagination. $columns = $this->get_columns(); // Get all necessary column information. $hidden = array(); // No columns to hide, but we must set as an array. $sortable = array(); // No reason to make sortable columns. @@ -1688,517 +1679,512 @@ public function prepare_items() { * * @since 2.2.0 */ -add_action( 'admin_init', 'tgmpa_load_bulk_installer' ); -function tgmpa_load_bulk_installer() { +if ( ! class_exists( 'WP_Upgrader' ) && ( isset( $_GET['page'] ) && TGM_Plugin_Activation::$instance->menu === $_GET['page'] ) ) { + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; - if ( ! class_exists( 'WP_Upgrader' ) && ( isset( $_GET['page'] ) && TGM_Plugin_Activation::$instance->menu === $_GET['page'] ) ) { - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + if ( ! class_exists( 'TGM_Bulk_Installer' ) ) { + /** + * Installer class to handle bulk plugin installations. + * + * Extends WP_Upgrader and customizes to suit the installation of multiple + * plugins. + * + * @since 2.2.0 + * + * @package TGM-Plugin-Activation + * @author Thomas Griffin + * @author Gary Jones + */ + class TGM_Bulk_Installer extends WP_Upgrader { - if ( ! class_exists( 'TGM_Bulk_Installer' ) ) { /** - * Installer class to handle bulk plugin installations. + * Holds result of bulk plugin installation. * - * Extends WP_Upgrader and customizes to suit the installation of multiple - * plugins. + * @since 2.2.0 + * + * @var string + */ + public $result; + + /** + * Flag to check if bulk installation is occurring or not. * * @since 2.2.0 * - * @package TGM-Plugin-Activation - * @author Thomas Griffin - * @author Gary Jones + * @var boolean */ - class TGM_Bulk_Installer extends WP_Upgrader { - - /** - * Holds result of bulk plugin installation. - * - * @since 2.2.0 - * - * @var string - */ - public $result; - - /** - * Flag to check if bulk installation is occurring or not. - * - * @since 2.2.0 - * - * @var boolean - */ - public $bulk = false; - - /** - * Processes the bulk installation of plugins. - * - * @since 2.2.0 - * - * @param array $packages The plugin sources needed for installation. - * @return string|boolean Install confirmation messages on success, false on failure. - */ - public function bulk_install( $packages ) { - - // Pass installer skin object and set bulk property to true. - $this->init(); - $this->bulk = true; - - // Set install strings and automatic activation strings (if config option is set to true). - $this->install_strings(); - if ( TGM_Plugin_Activation::$instance->is_automatic ) { - $this->activate_strings(); - } + public $bulk = false; - // Run the header string to notify user that the process has begun. - $this->skin->header(); + /** + * Processes the bulk installation of plugins. + * + * @since 2.2.0 + * + * @param array $packages The plugin sources needed for installation. + * @return string|boolean Install confirmation messages on success, false on failure. + */ + public function bulk_install( $packages ) { - // Connect to the Filesystem. - $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); - if ( ! $res ) { - $this->skin->footer(); - return false; - } + // Pass installer skin object and set bulk property to true. + $this->init(); + $this->bulk = true; + + // Set install strings and automatic activation strings (if config option is set to true). + $this->install_strings(); + if ( TGM_Plugin_Activation::$instance->is_automatic ) { + $this->activate_strings(); + } - // Set the bulk header and prepare results array. - $this->skin->bulk_header(); - $results = array(); + // Run the header string to notify user that the process has begun. + $this->skin->header(); - // Get the total number of packages being processed and iterate as each package is successfully installed. - $this->update_count = count( $packages ); - $this->update_current = 0; + // Connect to the Filesystem. + $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); + if ( ! $res ) { + $this->skin->footer(); + return false; + } - // Loop through each plugin and process the installation. - foreach ( $packages as $plugin ) { - $this->update_current++; // Increment counter. + // Set the bulk header and prepare results array. + $this->skin->bulk_header(); + $results = array(); - // Do the plugin install. - $result = $this->run( - array( - 'package' => $plugin, // The plugin source. - 'destination' => WP_PLUGIN_DIR, // The destination dir. - 'clear_destination' => false, // Do we want to clear the destination or not? - 'clear_working' => true, // Remove original install file. - 'is_multi' => true, // Are we processing multiple installs? - 'hook_extra' => array( 'plugin' => $plugin, ), // Pass plugin source as extra data. - ) - ); - - // Store installation results in result property. - $results[$plugin] = $this->result; - - // Prevent credentials auth screen from displaying multiple times. - if ( false === $result ) { - break; - } - } + // Get the total number of packages being processed and iterate as each package is successfully installed. + $this->update_count = count( $packages ); + $this->update_current = 0; - // Pass footer skin strings. - $this->skin->bulk_footer(); - $this->skin->footer(); + // Loop through each plugin and process the installation. + foreach ( $packages as $plugin ) { + $this->update_current++; // Increment counter. - // Return our results. - return $results; - - } - - /** - * Performs the actual installation of each plugin. - * - * This method also activates the plugin in the automatic flag has been - * set to true for the TGMPA class. - * - * @since 2.2.0 - * - * @param array $options The installation config options - * @return null/array Return early if error, array of installation data on success - */ - public function run( $options ) { - - // Default config options. - $defaults = array( - 'package' => '', - 'destination' => '', - 'clear_destination' => false, - 'clear_working' => true, - 'is_multi' => false, - 'hook_extra' => array(), + // Do the plugin install. + $result = $this->run( + array( + 'package' => $plugin, // The plugin source. + 'destination' => WP_PLUGIN_DIR, // The destination dir. + 'clear_destination' => false, // Do we want to clear the destination or not? + 'clear_working' => true, // Remove original install file. + 'is_multi' => true, // Are we processing multiple installs? + 'hook_extra' => array( 'plugin' => $plugin, ), // Pass plugin source as extra data. + ) ); - // Parse default options with config options from $this->bulk_upgrade and extract them. - $options = wp_parse_args( $options, $defaults ); - extract( $options ); + // Store installation results in result property. + $results[$plugin] = $this->result; - // Connect to the Filesystem. - $res = $this->fs_connect( array( WP_CONTENT_DIR, $destination ) ); - if ( ! $res ) { - return false; + // Prevent credentials auth screen from displaying multiple times. + if ( false === $result ) { + break; } + } - // Return early if there is an error connecting to the Filesystem. - if ( is_wp_error( $res ) ) { - $this->skin->error( $res ); - return $res; - } + // Pass footer skin strings. + $this->skin->bulk_footer(); + $this->skin->footer(); - // Call $this->header separately if running multiple times. - if ( ! $is_multi ) - $this->skin->header(); + // Return our results. + return $results; - // Set strings before the package is installed. - $this->skin->before(); + } - // Download the package (this just returns the filename of the file if the package is a local file). - $download = $this->download_package( $package ); - if ( is_wp_error( $download ) ) { - $this->skin->error( $download ); - $this->skin->after(); - return $download; - } + /** + * Performs the actual installation of each plugin. + * + * This method also activates the plugin in the automatic flag has been + * set to true for the TGMPA class. + * + * @since 2.2.0 + * + * @param array $options The installation cofig options + * @return null/array Return early if error, array of installation data on success + */ + public function run( $options ) { + + // Default config options. + $defaults = array( + 'package' => '', + 'destination' => '', + 'clear_destination' => false, + 'clear_working' => true, + 'is_multi' => false, + 'hook_extra' => array(), + ); - // Don't accidentally delete a local file. - $delete_package = ( $download != $package ); + // Parse default options with config options from $this->bulk_upgrade and extract them. + $options = wp_parse_args( $options, $defaults ); + extract( $options ); - // Unzip file into a temporary working directory. - $working_dir = $this->unpack_package( $download, $delete_package ); - if ( is_wp_error( $working_dir ) ) { - $this->skin->error( $working_dir ); - $this->skin->after(); - return $working_dir; - } + // Connect to the Filesystem. + $res = $this->fs_connect( array( WP_CONTENT_DIR, $destination ) ); + if ( ! $res ) { + return false; + } - // Install the package into the working directory with all passed config options. - $result = $this->install_package( - array( - 'source' => $working_dir, - 'destination' => $destination, - 'clear_destination' => $clear_destination, - 'clear_working' => $clear_working, - 'hook_extra' => $hook_extra, - ) - ); + // Return early if there is an error connecting to the Filesystem. + if ( is_wp_error( $res ) ) { + $this->skin->error( $res ); + return $res; + } - // Pass the result of the installation. - $this->skin->set_result( $result ); + // Call $this->header separately if running multiple times. + if ( ! $is_multi ) + $this->skin->header(); - // Set correct strings based on results. - if ( is_wp_error( $result ) ) { - $this->skin->error( $result ); - $this->skin->feedback( 'process_failed' ); - } - // The plugin install is successful. - else { - $this->skin->feedback( 'process_success' ); - } + // Set strings before the package is installed. + $this->skin->before(); - // Only process the activation of installed plugins if the automatic flag is set to true. - if ( TGM_Plugin_Activation::$instance->is_automatic ) { - // Flush plugins cache so we can make sure that the installed plugins list is always up to date. - wp_cache_flush(); + // Download the package (this just returns the filename of the file if the package is a local file). + $download = $this->download_package( $package ); + if ( is_wp_error( $download ) ) { + $this->skin->error( $download ); + $this->skin->after(); + return $download; + } - // Get the installed plugin file and activate it. - $plugin_info = $this->plugin_info( $package ); - $activate = activate_plugin( $plugin_info ); + // Don't accidentally delete a local file. + $delete_package = ( $download != $package ); - // Re-populate the file path now that the plugin has been installed and activated. - TGM_Plugin_Activation::$instance->populate_file_path(); + // Unzip file into a temporary working directory. + $working_dir = $this->unpack_package( $download, $delete_package ); + if ( is_wp_error( $working_dir ) ) { + $this->skin->error( $working_dir ); + $this->skin->after(); + return $working_dir; + } - // Set correct strings based on results. - if ( is_wp_error( $activate ) ) { - $this->skin->error( $activate ); - $this->skin->feedback( 'activation_failed' ); - } - // The plugin activation is successful. - else { - $this->skin->feedback( 'activation_success' ); - } - } + // Install the package into the working directory with all passed config options. + $result = $this->install_package( + array( + 'source' => $working_dir, + 'destination' => $destination, + 'clear_destination' => $clear_destination, + 'clear_working' => $clear_working, + 'hook_extra' => $hook_extra, + ) + ); + // Pass the result of the installation. + $this->skin->set_result( $result ); + + // Set correct strings based on results. + if ( is_wp_error( $result ) ) { + $this->skin->error( $result ); + $this->skin->feedback( 'process_failed' ); + } + // The plugin install is successful. + else { + $this->skin->feedback( 'process_success' ); + } + + // Only process the activation of installed plugins if the automatic flag is set to true. + if ( TGM_Plugin_Activation::$instance->is_automatic ) { // Flush plugins cache so we can make sure that the installed plugins list is always up to date. wp_cache_flush(); - // Set install footer strings. - $this->skin->after(); - if ( ! $is_multi ) { - $this->skin->footer(); - } + // Get the installed plugin file and activate it. + $plugin_info = $this->plugin_info( $package ); + $activate = activate_plugin( $plugin_info ); - return $result; + // Re-populate the file path now that the plugin has been installed and activated. + TGM_Plugin_Activation::$instance->populate_file_path(); + // Set correct strings based on results. + if ( is_wp_error( $activate ) ) { + $this->skin->error( $activate ); + $this->skin->feedback( 'activation_failed' ); + } + // The plugin activation is successful. + else { + $this->skin->feedback( 'activation_success' ); + } } - /** - * Sets the correct install strings for the installer skin to use. - * - * @since 2.2.0 - */ - public function install_strings() { - - $this->strings['no_package'] = __( 'Install package not available.', 'tgmpa' ); - $this->strings['downloading_package'] = __( 'Downloading install package from %s…', 'tgmpa' ); - $this->strings['unpack_package'] = __( 'Unpacking the package…', 'tgmpa' ); - $this->strings['installing_package'] = __( 'Installing the plugin…', 'tgmpa' ); - $this->strings['process_failed'] = __( 'Plugin install failed.', 'tgmpa' ); - $this->strings['process_success'] = __( 'Plugin installed successfully.', 'tgmpa' ); + // Flush plugins cache so we can make sure that the installed plugins list is always up to date. + wp_cache_flush(); + // Set install footer strings. + $this->skin->after(); + if ( ! $is_multi ) { + $this->skin->footer(); } - /** - * Sets the correct activation strings for the installer skin to use. - * - * @since 2.2.0 - */ - public function activate_strings() { + return $result; - $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); - $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); + } - } + /** + * Sets the correct install strings for the installer skin to use. + * + * @since 2.2.0 + */ + public function install_strings() { - /** - * Grabs the plugin file from an installed plugin. - * - * @since 2.2.0 - * - * @return string|boolean Return plugin file on success, false on failure - */ - public function plugin_info() { + $this->strings['no_package'] = __( 'Install package not available.', 'tgmpa' ); + $this->strings['downloading_package'] = __( 'Downloading install package from %s…', 'tgmpa' ); + $this->strings['unpack_package'] = __( 'Unpacking the package…', 'tgmpa' ); + $this->strings['installing_package'] = __( 'Installing the plugin…', 'tgmpa' ); + $this->strings['process_failed'] = __( 'Plugin install failed.', 'tgmpa' ); + $this->strings['process_success'] = __( 'Plugin installed successfully.', 'tgmpa' ); - // Return false if installation result isn't an array or the destination name isn't set. - if ( ! is_array( $this->result ) ) { - return false; - } + } - if ( empty( $this->result['destination_name'] ) ) { - return false; - } + /** + * Sets the correct activation strings for the installer skin to use. + * + * @since 2.2.0 + */ + public function activate_strings() { - /// Get the installed plugin file or return false if it isn't set. - $plugin = get_plugins( '/' . $this->result['destination_name'] ); - if ( empty( $plugin ) ) { - return false; - } + $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); + $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); + + } + + /** + * Grabs the plugin file from an installed plugin. + * + * @since 2.2.0 + * + * @return string|boolean Return plugin file on success, false on failure + */ + public function plugin_info() { - // Assume the requested plugin is the first in the list. - $pluginfiles = array_keys( $plugin ); + // Return false if installation result isn't an array or the destination name isn't set. + if ( ! is_array( $this->result ) ) { + return false; + } - return $this->result['destination_name'] . '/' . $pluginfiles[0]; + if ( empty( $this->result['destination_name'] ) ) { + return false; + } + /// Get the installed plugin file or return false if it isn't set. + $plugin = get_plugins( '/' . $this->result['destination_name'] ); + if ( empty( $plugin ) ) { + return false; } + // Assume the requested plugin is the first in the list. + $pluginfiles = array_keys( $plugin ); + + return $this->result['destination_name'] . '/' . $pluginfiles[0]; + } + } + } + + if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) { + /** + * Installer skin to set strings for the bulk plugin installations.. + * + * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple + * plugins. + * + * @since 2.2.0 + * + * @package TGM-Plugin-Activation + * @author Thomas Griffin + * @author Gary Jones + */ + class TGM_Bulk_Installer_Skin extends Bulk_Upgrader_Skin { - if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) { /** - * Installer skin to set strings for the bulk plugin installations.. + * Holds plugin info for each individual plugin installation. + * + * @since 2.2.0 * - * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple - * plugins. + * @var array + */ + public $plugin_info = array(); + + /** + * Holds names of plugins that are undergoing bulk installations. * * @since 2.2.0 * - * @package TGM-Plugin-Activation - * @author Thomas Griffin - * @author Gary Jones + * @var array */ - class TGM_Bulk_Installer_Skin extends Bulk_Upgrader_Skin { - - /** - * Holds plugin info for each individual plugin installation. - * - * @since 2.2.0 - * - * @var array - */ - public $plugin_info = array(); - - /** - * Holds names of plugins that are undergoing bulk installations. - * - * @since 2.2.0 - * - * @var array - */ - public $plugin_names = array(); - - /** - * Integer to use for iteration through each plugin installation. - * - * @since 2.2.0 - * - * @var integer - */ - public $i = 0; - - /** - * Constructor. Parses default args with new ones and extracts them for use. - * - * @since 2.2.0 - * - * @param array $args Arguments to pass for use within the class. - */ - public function __construct( $args = array() ) { - - // Parse default and new args. - $defaults = array( 'url' => '', 'nonce' => '', 'names' => array() ); - $args = wp_parse_args( $args, $defaults ); - - // Set plugin names to $this->plugin_names property. - $this->plugin_names = $args['names']; - - // Extract the new args. - parent::__construct( $args ); - - } - - /** - * Sets install skin strings for each individual plugin. - * - * Checks to see if the automatic activation flag is set and uses the - * the proper strings accordingly. - * - * @since 2.2.0 - */ - public function add_strings() { - - // Automatic activation strings. - if ( TGM_Plugin_Activation::$instance->is_automatic ) { - $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); - $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' ' . __( 'Show Details', 'tgmpa' ) . '.'; - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); - } - // Default installation strings. - else { - $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); - $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: %2$s.', 'tgmpa' ); - $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); - $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', 'tgmpa' ) . ' ' . __( 'Show Details', 'tgmpa' ) . '.'; - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); - } + public $plugin_names = array(); - } + /** + * Integer to use for iteration through each plugin installation. + * + * @since 2.2.0 + * + * @var integer + */ + public $i = 0; + + /** + * Constructor. Parses default args with new ones and extracts them for use. + * + * @since 2.2.0 + * + * @param array $args Arguments to pass for use within the class. + */ + public function __construct( $args = array() ) { - /** - * Outputs the header strings and necessary JS before each plugin installation. - * - * @since 2.2.0 - */ - public function before( $title = '' ) { + // Parse default and new args. + $defaults = array( 'url' => '', 'nonce' => '', 'names' => array() ); + $args = wp_parse_args( $args, $defaults ); - // We are currently in the plugin installation loop, so set to true. - $this->in_loop = true; + // Set plugin names to $this->plugin_names property. + $this->plugin_names = $args['names']; - printf( '

' . $this->upgrader->strings['skin_before_update_header'] . '

', $this->plugin_names[$this->i], $this->upgrader->update_current, $this->upgrader->update_count ); - echo ''; - echo '

'; + // Extract the new args. + parent::__construct( $args ); - // Flush header output buffer. - $this->before_flush_output(); + } + /** + * Sets install skin strings for each individual plugin. + * + * Checks to see if the automatic activation flag is set and uses the + * the proper strings accordingly. + * + * @since 2.2.0 + */ + public function add_strings() { + + // Automatic activation strings. + if ( TGM_Plugin_Activation::$instance->is_automatic ) { + $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); + $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' ' . __( 'Show Details', 'tgmpa' ) . '.'; + $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); + $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); + } + // Default installation strings. + else { + $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); + $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: %2$s.', 'tgmpa' ); + $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); + $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', 'tgmpa' ) . ' ' . __( 'Show Details', 'tgmpa' ) . '.'; + $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); + $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); } - /** - * Outputs the footer strings and necessary JS after each plugin installation. - * - * Checks for any errors and outputs them if they exist, else output - * success strings. - * - * @since 2.2.0 - */ - public function after( $title = '' ) { + } - // Close install strings. - echo '

'; + /** + * Outputs the header strings and necessary JS before each plugin installation. + * + * @since 2.2.0 + */ + public function before( $title = '' ) { - // Output error strings if an error has occurred. - if ( $this->error || ! $this->result ) { - if ( $this->error ) { - echo '

' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $this->plugin_names[$this->i], $this->error ) . '

'; - } else { - echo '

' . sprintf( $this->upgrader->strings['skin_update_failed'], $this->plugin_names[$this->i] ) . '

'; - } + // We are currently in the plugin installation loop, so set to true. + $this->in_loop = true; - echo ''; - } + printf( '

' . $this->upgrader->strings['skin_before_update_header'] . '

', $this->plugin_names[$this->i], $this->upgrader->update_current, $this->upgrader->update_count ); + echo ''; + echo '

'; - // If the result is set and there are no errors, success! - if ( ! empty( $this->result ) && ! is_wp_error( $this->result ) ) { - echo '

' . sprintf( $this->upgrader->strings['skin_update_successful'], $this->plugin_names[$this->i], 'jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').toggle();jQuery(\'span\', this).toggle(); return false;' ) . '

'; - echo ''; + // Flush header output buffer. + $this->before_flush_output(); + + } + + /** + * Outputs the footer strings and necessary JS after each plugin installation. + * + * Checks for any errors and outputs them if they exist, else output + * success strings. + * + * @since 2.2.0 + */ + public function after( $title = '' ) { + + // Close install strings. + echo '

'; + + // Output error strings if an error has occurred. + if ( $this->error || ! $this->result ) { + if ( $this->error ) { + echo '

' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $this->plugin_names[$this->i], $this->error ) . '

'; + } else { + echo '

' . sprintf( $this->upgrader->strings['skin_update_failed'], $this->plugin_names[$this->i] ) . '

'; } - // Set in_loop and error to false and flush footer output buffer. - $this->reset(); - $this->after_flush_output(); + echo ''; + } + // If the result is set and there are no errors, success! + if ( ! empty( $this->result ) && ! is_wp_error( $this->result ) ) { + echo '

' . sprintf( $this->upgrader->strings['skin_update_successful'], $this->plugin_names[$this->i], 'jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').toggle();jQuery(\'span\', this).toggle(); return false;' ) . '

'; + echo ''; } - /** - * Outputs links after bulk plugin installation is complete. - * - * @since 2.2.0 - */ - public function bulk_footer() { + // Set in_loop and error to false and flush footer output buffer. + $this->reset(); + $this->after_flush_output(); - // Serve up the string to say installations (and possibly activations) are complete. - parent::bulk_footer(); + } - // Flush plugins cache so we can make sure that the installed plugins list is always up to date. - wp_cache_flush(); + /** + * Outputs links after bulk plugin installation is complete. + * + * @since 2.2.0 + */ + public function bulk_footer() { - // Display message based on if all plugins are now active or not. - $complete = array(); - foreach ( TGM_Plugin_Activation::$instance->plugins as $plugin ) { - if ( ! is_plugin_active( $plugin['file_path'] ) ) { - echo '

' . TGM_Plugin_Activation::$instance->strings['return'] . '

'; - $complete[] = $plugin; - break; - } - // Nothing to store. - else { - $complete[] = ''; - } - } + // Serve up the string to say installations (and possibly activations) are complete. + parent::bulk_footer(); - // Filter out any empty entries. - $complete = array_filter( $complete ); + // Flush plugins cache so we can make sure that the installed plugins list is always up to date. + wp_cache_flush(); - // All plugins are active, so we display the complete string and hide the menu to protect users. - if ( empty( $complete ) ) { - echo '

' . sprintf( TGM_Plugin_Activation::$instance->strings['complete'], '' . __( 'Return to the Dashboard', 'tgmpa' ) . '' ) . '

'; - echo ''; + // Display message based on if all plugins are now active or not. + $complete = array(); + foreach ( TGM_Plugin_Activation::$instance->plugins as $plugin ) { + if ( ! is_plugin_active( $plugin['file_path'] ) ) { + echo '

' . TGM_Plugin_Activation::$instance->strings['return'] . '

'; + $complete[] = $plugin; + break; + } + // Nothing to store. + else { + $complete[] = ''; } + } + // Filter out any empty entries. + $complete = array_filter( $complete ); + + // All plugins are active, so we display the complete string and hide the menu to protect users. + if ( empty( $complete ) ) { + echo '

' . sprintf( TGM_Plugin_Activation::$instance->strings['complete'], '' . __( 'Return to the Dashboard', 'tgmpa' ) . '' ) . '

'; + echo ''; } - /** - * Flush header output buffer. - * - * @since 2.2.0 - */ - public function before_flush_output() { + } - wp_ob_end_flush_all(); - flush(); + /** + * Flush header output buffer. + * + * @since 2.2.0 + */ + public function before_flush_output() { - } + wp_ob_end_flush_all(); + flush(); - /** - * Flush footer output buffer and iterate $this->i to make sure the - * installation strings reference the correct plugin. - * - * @since 2.2.0 - */ - public function after_flush_output() { + } - wp_ob_end_flush_all(); - flush(); - $this->i++; + /** + * Flush footer output buffer and iterate $this->i to make sure the + * installation strings reference the correct plugin. + * + * @since 2.2.0 + */ + public function after_flush_output() { - } + wp_ob_end_flush_all(); + flush(); + $this->i++; } + } } - } diff --git a/style.css b/style.css index f88a2c5..af34d52 100644 --- a/style.css +++ b/style.css @@ -9,9 +9,9 @@ License: GNU General Public License License URI: license.txt Text Domain: ipt_kb Domain Path: /languages/ -Tags: gray, light, white, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, featured-images, threaded-comments, translation-ready +Tags: gray, light, white, two-columns, right-sidebar, fluid-layout, responsive-layout, custom-header, custom-menu, featured-images, threaded-comments, translation-ready -WP Knowledge Base WordPress theme, Copyright (C) 2013 iPanelThemes.com +WP Knowledge Base WordPress theme, Copyright (C) 2013-2015 iPanelThemes.com WP Knowledge Base WordPress theme is licensed under the GPL. This theme, like WordPress, is licensed under the GPL.