extras_dir .'*'); foreach ((array)$files as $file) { $plugin = basename($file); $avail_plugins[$plugin] = get_file_data($file, array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain')); } // Create Array of Installed amazon-link-extra Plugins from 'plugin' directory // // Get List of Plugins matching 'amazon-link-*' // Get Plugin Details for Each File and Activation Status $installed_plugins = array(); $files = glob(WP_PLUGIN_DIR .'/amazon-link-*.php'); foreach ((array)$files as $file) { $plugin = basename($file); $installed_plugins[$plugin] = get_file_data($file, array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain')); $installed_plugins[$plugin]['Activated'] = is_plugin_active($plugin); } /*****************************************************************************************/ // Get the Plugin ID if selected. if (isset($_POST['ID'])) { $plugin_ID=$_POST['ID']; } $action = (isset($_POST[ 'ALExtrasAction' ]) && check_admin_referer( 'update-AmazonLink-extras')) ? $_POST[ 'ALExtrasAction' ] : 'No Action'; // See if the user has posted us some information // If they did, the admin Nonce should be set. $update = False; $error = False; // ********************************************************** // Install the plugin into the WordPress plugin directory if( ($action == __('Install', 'amazon-link') ) || ( $action == __('Update','amazon-link'))) { $result = copy ($this->extras_dir . $plugin_ID, WP_PLUGIN_DIR .'/'. $plugin_ID); if ($result) { $update = sprintf( __('Plugin %1$s - has been Installed', 'amazon-link'), $avail_plugins[$plugin_ID]['Name'] ); $installed_plugins[$plugin_ID] = $avail_plugins[$plugin_ID]; $action = __('Activate','amazon-link'); } else { $error = sprintf( __('Plugin %1$s - failed to Install', 'amazon-link'), $avail_plugins[$plugin_ID]['Name'] ); } } // ********************************************************** // Activate the selected plugin if ( $action == __('Activate','amazon-link')) { $result = activate_plugins($plugin_ID); if (!is_wp_error($result)) { if ($update !== False) { $update .= __(' and Activated', 'amazon-link'); } else { $update = sprintf( __('Plugin %1$s - has been Activated', 'amazon-link'), $installed_plugins[$plugin_ID]['Name'] ); } $installed_plugins[$plugin_ID]['Activated'] = True; } else { $error = $plugin_ID . "---" .$result->get_error_message(); $installed_plugins[$plugin_ID]['Activated'] = False; } // ********************************************************** // Uninstall the selected plugin } // ********************************************************** // Deactivate the selected plugin if ( $action == __('Deactivate', 'amazon-link') || ( $action == __('Uninstall', 'amazon-link'))) { $result = deactivate_plugins($plugin_ID); if (!is_wp_error($result)) { $update = sprintf( __('Plugin %1$s - has been Deactivated', 'amazon-link'), $installed_plugins[$plugin_ID]['Name'] ); if (isset($installed_plugins[$plugin_ID])) $installed_plugins[$plugin_ID]['Activated'] = False; } else { $error = $result->get_error_message(); } } if ( $action == __('Uninstall', 'amazon-link')) { $result = delete_plugins((array)$plugin_ID); if (!is_wp_error($result)) { if ($update !== False) { $update .= __(' and Uninstalled', 'amazon-link'); } else { $update = sprintf( __('Plugin %1$s - has been Uninstalled', 'amazon-link'), $installed_plugins[$plugin_ID]['Name'] ); } unset($installed_plugins[$plugin_ID]); } else { $error = $result->get_error_message(); } } // ********************************************************** /*****************************************************************************************/ // ********************************************************** // Put an update/error message on the screen as appropriate if ($update !== False) { echo '
' . $update. '
' . $error . '