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.75k stars 431 forks source link

Install Recommended plugins not showing after activating child theme #702

Closed personanomada closed 6 years ago

personanomada commented 6 years ago

Hi, This is probably me screwing something up, but I followed the tutorial here to install a mix of wordpress hosted and self-hosted plugins installed. I thought it all went well, but when I activate the child theme, there is not option to install the required/recommended plugins.

I'm sure I screwed up along the way. Not sure if "Text-domain" can be anything, I was thinking that might be it. I'm using the Divi theme.

Sorry if this is just me having a dumb.

functions.php code:

<?php

add_action( 'wp_enqueue_scripts', 'my_enqueue_assets' );

function my_enqueue_assets() {

    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );

    /**
     * Plugin activation.
     */
    require_once get_stylesheet_directory() . '/inc/plugin-activation.php';

}

?>

plugin-activation.php code:


<?php
/**
 * @package    TGM-Plugin-Activation
 * @subpackage Example
 * @version    2.6.1 for child theme Premio Solutions
 * @author     Thomas Griffin, Gary Jones, Juliette Reinders Folmer
 * @copyright  Copyright (c) 2011, Thomas Griffin
 * @license    http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
 * @link       https://github.com/TGMPA/TGM-Plugin-Activation
 */

/**
 * Include the TGM_Plugin_Activation class.
 *
 * Depending on your implementation, you may want to change the include call:
 *
 * Parent Theme:
 * require_once get_template_directory() . '/path/to/class-tgm-plugin-activation.php';
 *
 * Child Theme:
 * require_once get_stylesheet_directory() . '/path/to/class-tgm-plugin-activation.php';
 *
 * Plugin:
 * require_once dirname( __FILE__ ) . '/path/to/class-tgm-plugin-activation.php';
 */
require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php';

add_action( 'tgmpa_register', 'premio_solutions_register_required_plugins' );

function premio_solutions_register_required_plugins() {
    /*
     * Array of plugin arrays. Required keys are name and slug.
     * If the source is NOT from the .org repo, then source is also required.
     */
    $plugins = array(

        // This is an example of how to include a plugin bundled with a theme.

        /*array(
            'name'               => 'TGM Example Plugin', // The plugin name.
            'slug'               => 'tgm-example-plugin', // The plugin slug (typically the folder name).
            'source'             => get_stylesheet_directory() . '/lib/plugins/tgm-example-plugin.zip', // The plugin source.
            'required'           => true, // If false, the plugin is only 'recommended' instead of required.
            'version'            => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin.
            'force_activation'   => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.
            'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.
            'external_url'       => '', // If set, overrides default API URL and points to an external URL.
            'is_callable'        => '', // If set, this callable will be be checked for availability to determine if a plugin is active.
        ),*/

        // This is an example of how to include a plugin from an arbitrary external source in your theme.
        array(
            'name'         => 'TGM New Media Plugin', // The plugin name.
            'slug'         => 'tgm-new-media-plugin', // The plugin slug (typically the folder name).
            'source'       => 'https://s3.amazonaws.com/tgm/tgm-new-media-plugin.zip', // The plugin source.
            'required'     => true, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://github.com/thomasgriffin/New-Media-Image-Uploader', // If set, overrides default API URL and points to an external URL.
        ),

        //Premio Solutions hosted 3rd party plugins

        array(
            'name'         => 'BackupBuddy', // The plugin name.
            'slug'         => 'backupbuddy', // The plugin slug (typically the folder name).
            'source'       => 'https://premiosolutions.com/wp/plugins/backupbuddy.zip', // The plugin source.
            'required'     => true, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://premiosolutions.com', // If set, overrides default API URL and points to an external URL.
        ),

        array(
            'name'         => 'Divi Booster', // The plugin name.
            'slug'         => 'divi-booster', // The plugin slug (typically the folder name).
            'source'       => 'https://premiosolutions.com/wp/plugins/divi-booster.zip', // The plugin source.
            'required'     => true, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://premiosolutions.com', // If set, overrides default API URL and points to an external URL.
        ),

        array(
            'name'         => 'Divi Tweaker', // The plugin name.
            'slug'         => 'divi-tweaker', // The plugin slug (typically the folder name).
            'source'       => 'https://premiosolutions.com/wp/plugins/divi-tweaker.zip', // The plugin source.
            'required'     => false, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://premiosolutions.com', // If set, overrides default API URL and points to an external URL.
        ),

        array(
            'name'         => 'Divi Custom Fullwidth Header Extended', // The plugin name.
            'slug'         => 'dwd-custom-fullwidth-header-extended', // The plugin slug (typically the folder name).
            'source'       => 'https://premiosolutions.com/wp/plugins/dwd-custom-fullwidth-header-extended.zip', // The plugin source.
            'required'     => true, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://premiosolutions.com', // If set, overrides default API URL and points to an external URL.
        ),

        array(
            'name'         => 'Divi Map Module Extended', // The plugin name.
            'slug'         => 'dwd-map-extended', // The plugin slug (typically the folder name).
            'source'       => 'https://premiosolutions.com/wp/plugins/dwd-map-extended.zip', // The plugin source.
            'required'     => true, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://premiosolutions.com', // If set, overrides default API URL and points to an external URL.
        ),

        array(
            'name'         => 'iThemes Security Pro', // The plugin name.
            'slug'         => 'ithemes-security-pro', // The plugin slug (typically the folder name).
            'source'       => 'https://premiosolutions.com/wp/plugins/ithemes-security-pro.zip', // The plugin source.
            'required'     => true, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://premiosolutions.com', // If set, overrides default API URL and points to an external URL.
        ),

        array(
            'name'         => 'Yoast SEO Premium', // The plugin name.
            'slug'         => 'wordpress-seo-premium', // The plugin slug (typically the folder name).
            'source'       => 'https://premiosolutions.com/wp/plugins/wordpress-seo-premium.zip', // The plugin source.
            'required'     => false, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://premiosolutions.com', // If set, overrides default API URL and points to an external URL.
        ),

        array(
            'name'         => 'Yoast SEO: Local', // The plugin name.
            'slug'         => 'wpseo-local', // The plugin slug (typically the folder name).
            'source'       => 'https://premiosolutions.com/wp/plugins/wpseo-local.zip', // The plugin source.
            'required'     => false, // If false, the plugin is only 'recommended' instead of required.
            'external_url' => 'https://premiosolutions.com', // If set, overrides default API URL and points to an external URL.
        ),

        // This is an example of how to include a plugin from a GitHub repository in your theme.
        // This presumes that the plugin code is based in the root of the GitHub repository
        // and not in a subdirectory ('/src') of the repository.

        /*array(
            'name'      => 'Adminbar Link Comments to Pending',
            'slug'      => 'adminbar-link-comments-to-pending',
            'source'    => 'https://github.com/jrfnl/WP-adminbar-comments-to-pending/archive/master.zip',
        ),*/

        // This is an example of how to include a plugin from the WordPress Plugin Repository.

        /*array(
            'name'      => 'BuddyPress',
            'slug'      => 'buddypress',
            'required'  => false,
        ),*/

        //Premio Solutions Wordpress Repository required plugins

        array(
            'name'      => 'Activity Log',
            'slug'      => 'aryo-activity-log',
            'required'  => true,
        ),

        array(
            'name'      => 'WordPress Importer',
            'slug'      => 'wordpress-importer',
            'required'  => true,
        ),

        array(
            'name'      => 'SiteOrigin CSS',
            'slug'      => 'so-css',
            'required'  => true,
        ),

        array(
            'name'      => 'Coming Soon Page & Maintenance Mode by SeedProd',
            'slug'      => 'coming-soon',
            'required'  => true,
        ),

        // This is an example of the use of 'is_callable' functionality. A user could - for instance -
        // have WPSEO installed *or* WPSEO Premium. The slug would in that last case be different, i.e.
        // 'wordpress-seo-premium'.
        // By setting 'is_callable' to either a function from that plugin or a class method
        // `array( 'class', 'method' )` similar to how you hook in to actions and filters, TGMPA can still
        // recognize the plugin as being installed.
        array(
            'name'        => 'WordPress SEO by Yoast',
            'slug'        => 'wordpress-seo',
            'is_callable' => 'wpseo_init',
        ),

    );

    $config = array(
        'id'           => 'premio-solutions',                 // Unique ID for hashing notices for multiple instances of TGMPA.
        'default_path' => '',                      // Default absolute path to bundled plugins.
        'menu'         => 'tgmpa-install-plugins', // Menu slug.
        'parent_slug'  => 'themes.php',            // Parent menu slug.
        'capability'   => 'edit_theme_options',    // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
        'has_notices'  => true,                    // Show admin notices or not.
        'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.
        'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.
        'is_automatic' => false,                   // Automatically activate plugins after installation or not.
        'message'      => '',                      // Message to output right before the plugins table.

        /*
        'strings'      => array(
            'page_title'                      => __( 'Install Required Plugins', 'premio-solutions' ),
            'menu_title'                      => __( 'Install Plugins', 'premio-solutions' ),
            /* translators: %s: plugin name. * /
            'installing'                      => __( 'Installing Plugin: %s', 'premio-solutions' ),
            /* translators: %s: plugin name. * /
            'updating'                        => __( 'Updating Plugin: %s', 'premio-solutions' ),
            'oops'                            => __( 'Something went wrong with the plugin API.', 'premio-solutions' ),
            'notice_can_install_required'     => _n_noop(
                /* translators: 1: plugin name(s). * /
                'This theme requires the following plugin: %1$s.',
                'This theme requires the following plugins: %1$s.',
                'premio-solutions'
            ),
            'notice_can_install_recommended'  => _n_noop(
                /* translators: 1: plugin name(s). * /
                'This theme recommends the following plugin: %1$s.',
                'This theme recommends the following plugins: %1$s.',
                'premio-solutions'
            ),
            'notice_ask_to_update'            => _n_noop(
                /* translators: 1: plugin name(s). * /
                '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.',
                'premio-solutions'
            ),
            'notice_ask_to_update_maybe'      => _n_noop(
                /* translators: 1: plugin name(s). * /
                'There is an update available for: %1$s.',
                'There are updates available for the following plugins: %1$s.',
                'premio-solutions'
            ),
            'notice_can_activate_required'    => _n_noop(
                /* translators: 1: plugin name(s). * /
                'The following required plugin is currently inactive: %1$s.',
                'The following required plugins are currently inactive: %1$s.',
                'premio-solutions'
            ),
            'notice_can_activate_recommended' => _n_noop(
                /* translators: 1: plugin name(s). * /
                'The following recommended plugin is currently inactive: %1$s.',
                'The following recommended plugins are currently inactive: %1$s.',
                'premio-solutions'
            ),
            'install_link'                    => _n_noop(
                'Begin installing plugin',
                'Begin installing plugins',
                'premio-solutions'
            ),
            'update_link'                     => _n_noop(
                'Begin updating plugin',
                'Begin updating plugins',
                'premio-solutions'
            ),
            'activate_link'                   => _n_noop(
                'Begin activating plugin',
                'Begin activating plugins',
                'premio-solutions'
            ),
            'return'                          => __( 'Return to Required Plugins Installer', 'premio-solutions' ),
            'plugin_activated'                => __( 'Plugin activated successfully.', 'premio-solutions' ),
            'activated_successfully'          => __( 'The following plugin was activated successfully:', 'premio-solutions' ),
            /* translators: 1: plugin name. * /
            'plugin_already_active'           => __( 'No action taken. Plugin %1$s was already active.', 'premio-solutions' ),
            /* translators: 1: plugin name. * /
            'plugin_needs_higher_version'     => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'premio-solutions' ),
            /* translators: 1: dashboard link. * /
            'complete'                        => __( 'All plugins installed and activated successfully. %1$s', 'premio-solutions' ),
            'dismiss'                         => __( 'Dismiss this notice', 'premio-solutions' ),
            'notice_cannot_install_activate'  => __( 'There are one or more required or recommended plugins to install, update or activate.', 'premio-solutions' ),
            'contact_admin'                   => __( 'Please contact the administrator of this site for help.', 'premio-solutions' ),

            'nag_type'                        => '', // Determines admin notice type - can only be one of the typical WP notice classes, such as 'updated', 'update-nag', 'notice-warning', 'notice-info' or 'error'. Some of which may not work as expected in older WP versions.
        ),
        */
    );

    tgmpa( $plugins, $config );
}
personanomada commented 6 years ago

I figured it out. Was easier to just put all the plugin code into the functions.php file.