Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TGM-Plugin-Activation - Multisite Installs can download from WordPress Plugin Directory #105

Closed
wants to merge 3 commits into from

4 participants

@moyarich

Added additional support for multisite. Allows installation of wordpress plugins from the WordPress Plugin Directory

Made changes because I could not install wordpress plugins from the WordPress Plugin Directory.

when using wordpress version 3.4.2 with multisite installed
the plugins listed did not correctly point to the WordPress Plugin Directory.

The problem was with the actual location of the plugin-install.php.

single site install of wordpress uses:
wp-admin/plugin-install.php

multisite uses
wp-admin/network/plugin-install.php

Added the code

if ( is_multisite() ) {
$this->plugin_install_file = admin_url( 'network/plugin-install.php' );}

else{
$this->plugin_install_file = admin_url( 'plugin-install.php' ); }

-----replaced code------------------------

replaced: admin_url( 'plugin-install.php' )
with: $this->plugin_install_file

@moyarich moyarich Added additional support for multisite. All installation of wordpress…
… plugins from the WordPress Plugin Directory

Made changes because I could not install wordpress plugins from the WordPress Plugin Directory.
-------------------

when using wordpress version 3.4.2 with multisite installed
the plugins listed did not correctly point to the WordPress Plugin Directory.


The problem was with the actual location of the plugin-install.php.

single site install of wordpress uses:
wp-admin/plugin-install.php 

multisite uses
wp-admin/network/plugin-install.php 

Added the code
--------------
if ( is_multisite() ) {
     $this->plugin_install_file = admin_url( 'network/plugin-install.php' );}

else{
     $this->plugin_install_file = admin_url( 'plugin-install.php' ); }

-----replaced  code------------------------


replaced:  admin_url( 'plugin-install.php' )
with:      $this->plugin_install_file
54c03e1
@thomasgriffin

We don't need the brackets here.

@thomasgriffin

It would be nice to have some docblock for this describing what it's purpose is. :-)

@thomasgriffin

Thanks for the pull request. It's definitely a bug that needs to be fixed. I've left a couple comments on the commit, so if you could adjust those that would be great and I'll make the pull. Also, notice the indentation of your commit. Make sure your are using tabs for proper indentation.

moyarich added some commits
@moyarich moyarich Added docblock, removed brackets
Added docblock to describe the purpose of the code changes.
Removed bracket from if and else statements.
888b675
@moyarich moyarich Updated to use the proper function for a multisite install
Updated  to use the proper function for a multisite install.
//uses network_admin_url() to pull the url of the base blog, because multisite plugins can only be installed from the base blog.


$this->plugin_install_file = admin_url( 'network/plugin-install.php' );

$this->plugin_install_file = network_admin_url('plugin-install.php');
e50ca7e
@webmandesign

Hi guys,

This works for my multisite on WP3.5:
In "class-tgm-plugin-activation.php" file just overwrite all "admin_url" functions with "network_admin_url" as this function falls back to "admin_url" if WP network not installed.

Oliver

@moyarich

Did you test to see if network_admin_url() links back to the current blog when you click
the link (Activate installed plugin), That link and a few others needs admin_url() to link back to the current blog's plugin dashboard menu. The current version i edited 6 days ago uses network_admin_url() for where it is needed, it works on wordpress 3.5, you can download it from here https://github.com/moyarich/TGM-Plugin-Activation

@webmandesign

Hi, sorry for being such enthusiastic before ;) I haven't tested it that deep (obviously because I'm superadmin), my bad.
I think I've downloaded this script like 4-5 days ago... But I might be wrong and I could download the previous version. Will check this one. Thanks.

@dovy

@moyarich @webmandesign Did you ever finish looking into this?

@moyarich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 18, 2012
  1. @moyarich

    Added additional support for multisite. All installation of wordpress…

    moyarich authored
    … plugins from the WordPress Plugin Directory
    
    Made changes because I could not install wordpress plugins from the WordPress Plugin Directory.
    -------------------
    
    when using wordpress version 3.4.2 with multisite installed
    the plugins listed did not correctly point to the WordPress Plugin Directory.
    
    
    The problem was with the actual location of the plugin-install.php.
    
    single site install of wordpress uses:
    wp-admin/plugin-install.php 
    
    multisite uses
    wp-admin/network/plugin-install.php 
    
    Added the code
    --------------
    if ( is_multisite() ) {
         $this->plugin_install_file = admin_url( 'network/plugin-install.php' );}
    
    else{
         $this->plugin_install_file = admin_url( 'plugin-install.php' ); }
    
    -----replaced  code------------------------
    
    
    replaced:  admin_url( 'plugin-install.php' )
    with:      $this->plugin_install_file
Commits on Oct 24, 2012
  1. @moyarich

    Added docblock, removed brackets

    moyarich authored
    Added docblock to describe the purpose of the code changes.
    Removed bracket from if and else statements.
Commits on Dec 28, 2012
  1. @moyarich

    Updated to use the proper function for a multisite install

    moyarich authored
    Updated  to use the proper function for a multisite install.
    //uses network_admin_url() to pull the url of the base blog, because multisite plugins can only be installed from the base blog.
    
    
    $this->plugin_install_file = admin_url( 'network/plugin-install.php' );
    
    $this->plugin_install_file = network_admin_url('plugin-install.php');
This page is out of date. Refresh to see the latest.
Showing with 40 additions and 6 deletions.
  1. +40 −6 tgm-plugin-activation/class-tgm-plugin-activation.php
View
46 tgm-plugin-activation/class-tgm-plugin-activation.php
@@ -146,9 +146,21 @@ class TGM_Plugin_Activation {
*
* @var array
*/
+
public $strings = array();
/**
+ * Path to the Wordpress plugin install administration API file
+ *
+ * @since 2.3.6
+ *
+ * Value is added in the constructor.
+ */
+ private $plugin_install_file = '';
+
+
+
+ /**
* Adds a reference of this object to $instance, populates default strings,
* does the tgmpa_init action hook, and hooks in the interactions to init.
*
@@ -156,10 +168,12 @@ class TGM_Plugin_Activation {
*
* @see TGM_Plugin_Activation::init()
*/
+
public function __construct() {
self::$instance =& $this;
+
$this->strings = array(
'page_title' => __( 'Install Required Plugins', $this->domain ),
'menu_title' => __( 'Install Plugins', $this->domain ),
@@ -179,8 +193,27 @@ public function __construct() {
'plugin_activated' => __( 'Plugin activated successfully.', $this->domain ),
'complete' => __( 'All plugins installed and activated successfully. %1$s', $this->domain ),
);
-
- /** Annouce that the class is ready, and pass the object (for advanced use) */
+
+ /**
+ * Assign to $plugin_install_file the path to the WordPress plugin install administration API file (plugin-install.php)
+ *
+ * @since 2.3.6
+ *
+ */
+ if ( is_multisite() ) //Determine if Multisite support is enabled.
+
+ /** multisite supported, so grab the path to the plugin-install.php from the network folder*/
+ /*uses network_admin_url() to pull the url of the base blog, because multisite plugins can only be installed from the base blog. */
+
+
+ $this->plugin_install_file = network_admin_url('plugin-install.php' );
+
+ else /** multisite is not supported so use the regular plugin-install.php file*/
+ $this->plugin_install_file = admin_url( 'plugin-install.php' );
+
+
+
+ /** Announce that the class is ready, and pass the object (for advanced use) */
do_action_ref_array( 'tgmpa_init', array( &$this ) );
/** When the rest of WP has loaded, kick-start the rest of the class */
@@ -664,7 +697,8 @@ public function notices() {
$linked_plugin_groups[] = '<a href="' . esc_url( $external_url ) . '" title="' . $plugin_group_single_name . '" target="_blank">' . $plugin_group_single_name . '</a>';
}
elseif ( ! $source || preg_match( '|^http://wordpress.org/extend/plugins/|', $source ) ) {
- $url = add_query_arg(
+
+ $url = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => $this->_get_plugin_data_from_name( $plugin_group_single_name ),
@@ -672,7 +706,7 @@ public function notices() {
'width' => '640',
'height' => '500',
),
- admin_url( 'plugin-install.php' )
+ $this->plugin_install_file
);
$linked_plugin_groups[] = '<a href="' . esc_url( $url ) . '" class="thickbox" title="' . $plugin_group_single_name . '">' . $plugin_group_single_name . '</a>';
@@ -1074,7 +1108,7 @@ protected function _gather_plugin_data() {
'width' => '640',
'height' => '500',
),
- admin_url( 'plugin-install.php' )
+ $this->plugin_install_file
);
$table_data[$i]['plugin'] = '<strong><a href="' . esc_url( $url ) . '" class="thickbox" title="' . $plugin['name'] . '">' . $plugin['name'] . '</a></strong>';
@@ -2089,4 +2123,4 @@ public function after_flush_output() {
}
}
-}
+}
Something went wrong with that request. Please try again.