/**
  * Load up the mu-plugin packages!
  */
 function loadPlugins()
 {
     // do we have packages? maybe no if json/file error
     if (!empty($this->packageData['packages'])) {
         // get the mu-plugins path relative to plugins so that plugins_url functions work properly
         $muPath = $this->muPluginsRelPath();
         foreach ($this->packageData['packages'] as $pluginFile) {
             if (file_exists($realPath = __DIR__ . '/' . $pluginFile)) {
                 $this->plugins[] = $realPath;
                 // in case this directory is symlinked, inform WP about the symlink vs. real path
                 wp_register_plugin_realpath("{$muPath}/{$pluginFile}");
                 include_once $realPath;
             }
         }
     }
     $this->pluginHooks();
 }
Example #2
0
     if (!isset($_GET['failure']) && !isset($_GET['success'])) {
         wp_redirect(admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode($plugin) . '&_wpnonce=' . $_GET['_wpnonce']));
         activate_plugin($plugin, '', !empty($_GET['networkwide']), true);
         wp_redirect(admin_url('update.php?action=activate-plugin&success=true&plugin=' . urlencode($plugin) . '&_wpnonce=' . $_GET['_wpnonce']));
         die;
     }
     iframe_header(__('Plugin Reactivation'), true);
     if (isset($_GET['success'])) {
         echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
     }
     if (isset($_GET['failure'])) {
         echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>';
         error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
         @ini_set('display_errors', true);
         //Ensure that Fatal errors are displayed.
         wp_register_plugin_realpath(WP_PLUGIN_DIR . '/' . $plugin);
         include WP_PLUGIN_DIR . '/' . $plugin;
     }
     iframe_footer();
 } elseif ('install-plugin' == $action) {
     if (!current_user_can('install_plugins')) {
         wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
     }
     include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     //for plugins_api..
     check_admin_referer('install-plugin_' . $plugin);
     $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false)));
     //Save on a bit of bandwidth.
     if (is_wp_error($api)) {
         wp_die($api);
     }
Example #3
0
 /**
  * @param string $plugin
  */
 function plugin_sandbox_scrape($plugin)
 {
     wp_register_plugin_realpath(WP_PLUGIN_DIR . '/' . $plugin);
     include WP_PLUGIN_DIR . '/' . $plugin;
 }
Example #4
0
/**
 * Uninstall a single plugin.
 *
 * Calls the uninstall hook, if it is available.
 *
 * @since 2.7.0
 *
 * @param string $plugin Relative plugin path from Plugin Directory.
 * @return true True if a plugin's uninstall.php file has been found and included.
 */
function uninstall_plugin($plugin) {
	$file = plugin_basename($plugin);

	$uninstallable_plugins = (array) get_option('uninstall_plugins');
	if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) {
		if ( isset( $uninstallable_plugins[$file] ) ) {
			unset($uninstallable_plugins[$file]);
			update_option('uninstall_plugins', $uninstallable_plugins);
		}
		unset($uninstallable_plugins);

		define('WP_UNINSTALL_PLUGIN', $file);
		wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . dirname( $file ) );
		include( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' );

		return true;
	}

	if ( isset( $uninstallable_plugins[$file] ) ) {
		$callable = $uninstallable_plugins[$file];
		unset($uninstallable_plugins[$file]);
		update_option('uninstall_plugins', $uninstallable_plugins);
		unset($uninstallable_plugins);

		wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
		include( WP_PLUGIN_DIR . '/' . $file );

		add_action( 'uninstall_' . $file, $callable );

		/**
		 * Fires in uninstall_plugin() once the plugin has been uninstalled.
		 *
		 * The action concatenates the 'uninstall_' prefix with the basename of the
		 * plugin passed to {@see uninstall_plugin()} to create a dynamically-named action.
		 *
		 * @since 2.7.0
		 */
		do_action( 'uninstall_' . $file );
	}
}
Example #5
0
}
// Define constants after multisite is loaded.
wp_cookie_constants();
// Define and enforce our SSL constants
wp_ssl_constants();
// Create common globals.
require ABSPATH . WPINC . '/vars.php';
// Make taxonomies and posts available to plugins and themes.
// @plugin authors: warning: these get registered again on the init hook.
create_initial_taxonomies();
create_initial_post_types();
// Register the default theme directory root
register_theme_directory(get_theme_root());
// Load active plugins.
foreach (wp_get_active_and_valid_plugins() as $plugin) {
    wp_register_plugin_realpath($plugin);
    include_once $plugin;
}
unset($plugin);
// Load pluggable functions.
require ABSPATH . WPINC . '/pluggable.php';
require ABSPATH . WPINC . '/pluggable-deprecated.php';
// Set internal encoding.
wp_set_internal_encoding();
// Run wp_cache_postload() if object cache is enabled and the function exists.
if (WP_CACHE && function_exists('wp_cache_postload')) {
    wp_cache_postload();
}
/**
 * Fires once activated plugins have loaded.
 *
Example #6
0
 /**
  * Check and load a discovered file. Handle problems if file is invalid or unreadable.
  *
  * @param  string $key
  * @param  string $file
  * @param  bool   $refresh
  * @param  string $transient
  * @return bool
  */
 private function loadPlugin($key, $file, $refresh, $transient)
 {
     if (is_readable($file) && strtolower(pathinfo($file, PATHINFO_EXTENSION)) === 'php') {
         wp_register_plugin_realpath($file);
         if (in_array($file, $this->regular, true)) {
             $this->regularLoaded[] = $file;
         }
         include_once $file;
         $this->loaded[] = $file;
         return true;
     }
     if ($refresh) {
         // remove non-readable or non-php files from array of files to be saved
         unset($this->plugins[$key]);
         return true;
     }
     // If here, a non-readable or non-php file is cached: let's delete cache and restart
     delete_site_transient(self::PREFIX . $transient);
     delete_site_transient(self::PREFIX . self::TRANSIENT);
     $this->__invoke(true);
     return false;
 }
Example #7
0
 protected function update_active_plugins($plugins, $redirect)
 {
     if (!$plugins) {
         $plugins = array();
     }
     // make sure including any of the plugins will not generate a fatal error
     foreach ($plugins as $plugin) {
         wp_redirect(add_query_arg(array('_error_nonce' => wp_create_nonce('plugin-activation-error_' . $plugin), 'error' => true, 'plugin' => $plugin), $redirect));
         ob_start();
         wp_register_plugin_realpath(WP_PLUGIN_DIR . '/' . $plugin);
         include_once WP_PLUGIN_DIR . '/' . $plugin;
         ob_get_clean();
     }
     wp_redirect(admin_url('admin.php?page=gravityformsdebug&action=active-plugins-updated'));
     return update_user_meta(get_current_user_id(), $this->prefix('ct_active_plugins'), $plugins);
 }