diff --git a/tgm-plugin-activation/auto-install.php b/tgm-plugin-activation/auto-install.php new file mode 100644 index 00000000..29602f1b --- /dev/null +++ b/tgm-plugin-activation/auto-install.php @@ -0,0 +1,218 @@ + + * @copyright Copyright (c) 2011, Thomas Griffin + * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License + * @link https://github.com/thomasgriffin/TGM-Plugin-Activation + * + */ + + +/* Copyright 2011 Thomas Griffin (email : thomas@thomasgriffinmedia.com) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 3, as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + + +if ( ! is_admin() ) // If we are not in the admin section, bail out + return; + + +class TGM_Plugin_Activation { + + var $instance; // DO NOT MODIFY THIS + + // All of the variables below can be modified to suit your specific plugin. + + var $plugin = 'tgm-example-plugin/tgm-example-plugin.php'; // The main plugin file (you must include the plugin folder) + var $plugin_name = 'TGM Example Plugin'; // The name of your plugin + var $zip = 'tgm-example-plugin.zip'; // The name of the zip file that contains your plugin + var $menu = 'tgm-example-plugin'; // The name of your menu page (will appear in the URL as themes.php?page=tgm-example-plugin) + var $nonce = 'tgm_plugins'; // You can set your own nonce name if you would + + + /** + * Adds actions for class methods. + * + * Adds two new methods for the class: admin_menu and admin_notices. + * admin_notices handles the nag; admin_menu handles the rest. + * + * @since 1.0.0 + * + * @access public + */ + public function __construct() { + + $this->instance =& $this; + + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); + add_action( 'admin_notices', array( $this, 'admin_notices' ) ); + + } + + + /** + * Adds submenu page under 'Appearance' tab. + * + * This method adds the submenu page letting users know that a required plugin needs to be installed. + * This page disappears once the plugin has been installed and activated. + * + * @since 1.0.0 + * + * @access public + */ + public function admin_menu() { + + if ( is_plugin_active( $this->plugin ) ) // No need to output the page if our plugin is already installed and activated + return; + + add_submenu_page( 'themes.php', __( 'Install Required Plugins', 'tgmpa' ), __( 'Install Plugins', 'tgmpa' ), 'edit_theme_options', $this->menu, array( $this, 'tgm_install_plugins_page' ) ); + + } + + + /** + * Outputs plugin installation form. + * + * This method is the callback for the admin_menu method function. + * This displays the admin page and form area where the user can select to install and activate the plugin. + * + * @since 1.0.0 + * + * @access public + */ + public function tgm_install_plugins_page() { + + if ( $this->tgm_do_plugin_install() ) // No need to output the form if tgm_do_plugin_install has been successfully run + return; + + ?> +
plugin_name . ' plugin is required for this theme. Click on the big blue button below to install and activate ' . $this->plugin_name . '!', 'tgmpa' ); ?>
+ +' . $install_error . '
' . $activate_error . '
Congratulations! ' . $this->plugin_name . ' has been successfully installed, activated and is ready for use. Return to the dashboard.
%1$s