'siteorigin_panels_plugin_activation', 'plugin' => urlencode( $plugin['slug'] ), 'plugin_name' => urlencode( $plugin['name'] ), 'plugin_source' => urlencode( $plugin['source'] ), 'siteorigin-pa-install' => 'install-plugin', ), admin_url( 'themes.php' ) ), 'siteorigin-pa-install' ); $method = ''; // Leave blank so WP_Filesystem can populate it as necessary $fields = array( sanitize_key( 'siteorigin-pa-install' ) ); // Extra fields to pass to WP_Filesystem if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, $fields ) ) ) { return true; } if ( ! WP_Filesystem( $creds ) ) { request_filesystem_credentials( $url, $method, true, false, $fields ); // Setup WP_Filesystem return true; } require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // Need for plugins_api require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // Need for upgrade classes /** Prep variables for Plugin_Installer_Skin class */ $title = sprintf( __( 'Installing %s', 'siteorigin-panels' ), $plugin['name'] ); $url = add_query_arg( array( 'action' => 'install-plugin', 'plugin' => urlencode( $plugin['slug'] ) ), 'update.php' ); if ( isset( $_GET['from'] ) ) { $url .= add_query_arg( 'from', urlencode( stripslashes( $_GET['from'] ) ), $url ); } $nonce = 'install-plugin_' . $plugin['slug']; // Find the source of the plugin $source = ! empty( $plugin['source'] ) ? $plugin['source'] : 'http://downloads.wordpress.org/plugin/' . urlencode( $plugin['slug'] ) . '.zip'; /** Create a new instance of Plugin_Upgrader */ $upgrader = new Plugin_Upgrader( $skin = new Plugin_Installer_Skin( compact( 'type', 'title', 'url', 'nonce', 'plugin', 'api' ) ) ); /** Perform the action and install the plugin from the $source urldecode() */ $upgrader->install( $source ); /** Flush plugins cache so we can make sure that the installed plugins list is always up to date */ wp_cache_flush(); } ?>
'siteorigin_panels_plugin_activation', 'plugin' => $plugin, 'plugin_name' => $plugin_name, 'plugin_source' => ! empty( $source ) ? urlencode( $source ) : false, 'siteorigin-pa-install' => 'install-plugin', ), admin_url( 'plugins.php' ) ), 'siteorigin-pa-install' ); } } }