TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.76k stars 429 forks source link

Redirects not working after installing plugins in bulk #641

Open a1iraxa opened 7 years ago

a1iraxa commented 7 years ago

Once I have bulk installed the plugins, it says return to the plugin installation menu and when I click it, it takes me to an error page which says Sorry, you are not allowed to access this page. after looking at the URL I found out it takes me to

wp-admin/themes.php?page=tgmpa-install-plugins

require_once get_template_directory() . '/core/class-tgm-plugin-activation.php';

add_action( 'tgmpa_register', 'tff_register_required_plugins' );

function tff_register_required_plugins() {
    $plugins = array(

        // This is an example of how to include a plugin bundled with a theme.
        array(
            'name'               => 'abc',
            'slug'               => 'tff-essentials',
            'source'             => get_template_directory() . '/path/to/plugins/abc.zip',
            'required'           => true,
            'version'            => '',
            'force_activation'   => false,
            'force_deactivation' => false,
            'external_url'       => '',
            'is_callable'        => '',
        ),
        array(
            'name'      => 'Contact Form 7',
            'slug'      => 'contact-form-7',
            'required'  => false,
            'version'   => '',
        ),
    );
    $config = array(
        'id'           => 'four',
        'default_path' => '',
        'menu'         => 'tgmpa-install-plugins',
        'has_notices'  => true,
        'dismissable'  => true,
        'dismiss_msg'  => '',
        'is_automatic' => false,
        'message'      => '',
        'strings'      => array(
            'page_title'                      => __( 'Install Required Plugins', 'four' ),
            'menu_title'                      => __( 'Install Plugins', 'four' ),
            'installing'                      => __( 'Installing Plugin: %s', 'four' ),
            'updating'                        => __( 'Updating Plugin: %s', 'four' ),
            'oops'                            => __( 'Something went wrong with the plugin API.', 'four' ),
            'notice_can_install_required'     => _n_noop(
                'This theme requires the following plugin: %1$s.',
                'This theme requires the following plugins: %1$s.',
                'four'
            ),
            'notice_can_install_recommended'  => _n_noop(
                'This theme recommends the following plugin: %1$s.',
                'This theme recommends the following plugins: %1$s.',
                'four'
            ),
            'notice_ask_to_update'            => _n_noop(
                'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.',
                'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.',
                'four'
            ),
            'notice_ask_to_update_maybe'      => _n_noop(
                'There is an update available for: %1$s.',
                'There are updates available for the following plugins: %1$s.',
                'four'
            ),
            'notice_can_activate_required'    => _n_noop(
                'The following required plugin is currently inactive: %1$s.',
                'The following required plugins are currently inactive: %1$s.',
                'four'
            ),
            'notice_can_activate_recommended' => _n_noop(
                'The following recommended plugin is currently inactive: %1$s.',
                'The following recommended plugins are currently inactive: %1$s.',
                'four'
            ),
            'install_link'                    => _n_noop(
                'Begin installing plugin',
                'Begin installing plugins',
                'four'
            ),
            'update_link'                     => _n_noop(
                'Begin updating plugin',
                'Begin updating plugins',
                'four'
            ),
            'activate_link'                   => _n_noop(
                'Begin activating plugin',
                'Begin activating plugins',
                'four'
            ),
            'return'                          => __( 'Return to Required Plugins Installer', 'four' ),
            'plugin_activated'                => __( 'Plugin activated successfully.', 'four' ),
            'activated_successfully'          => __( 'The following plugin was activated successfully:', 'four' ),
            'plugin_already_active'           => __( 'No action taken. Plugin %1$s was already active.', 'four' ),
            'plugin_needs_higher_version'     => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'four' ),
            'complete'                        => __( 'All plugins installed and activated successfully. %1$s', 'four' ),
            'dismiss'                         => __( 'Dismiss this notice', 'four' ),
            'notice_cannot_install_activate'  => __( 'There are one or more required or recommended plugins to install, update or activate.', 'four' ),
            'contact_admin'                   => __( 'Please contact the administrator of this site for help.', 'four' ),
            'nag_type'                        => '',
        ),
    );

    tgmpa( $plugins, $config );
}

TGMPA_VERSION = 2.6.1, WordPress = 4.7. how to remove this bug?

a1iraxa commented 7 years ago

anyone ?

gfirem commented 7 years ago

I get the same problem @a1iraxa how do you resolve?

a1iraxa commented 7 years ago

simple remove _forceactivation and _forcedeactivation from array,

array(
            'name'               => 'abc',
            'slug'               => 'abc',
            'source'             => get_template_directory() . '/path/to/plugins/abc.zip',
            'required'           => true,
            'version'            => '',
            'force_activation'   => false, // remove this
            'force_deactivation' => false,  // remove this
            'external_url'       => '',  // remove this
            'is_callable'        => '',  // remove this
        ),

and update to this

array(
            'name'               => 'ABC',
            'slug'               => 'abc',
            'source'             => get_template_directory() . '/path/to/plugins/abc.zip',
            'required'           => true,
            'version'            => '1.0',
        ),
gfirem commented 7 years ago

@a1iraxa Thanks. Is not a fix but resolve the immediate problem.

gfirem commented 7 years ago

@jrfnl Thanks, let me know if i can help.

notrealdev commented 6 years ago

Hi, i have the same issue here

array(
    'name'               => esc_html__( 'Maintain', 'domain' ),
    'slug'               => 'my-maintain',
    'source'             => 'https://bitbucket.org/my-team/my-maintain/get/1.1.zip',
    'required'           => true,
    'version'            => '1.1',
),

Redirects not working, /wp-admin/themes.php?page=tgmpa-install-plugins and Sorry, you are not allowed to access this page.