tgm register required plugin activation hook not working - wordpress

I am facing a problem with tgm i have just download the setup from tgm site
http://tgmpluginactivation.com/download/
and when i follow the steps as described on the site and in the downloaded zip file but after follow the steps when i activate my custom theme its simply activated its did not showing any message regarding activating the required plugins
my themes function.php file code is below
<?php
require_once get_template_directory() . '/includes/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'custom_register_required_plugins' );
function custom_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' => esc_html__('Visual Composer','custom'),
'slug' => 'js_composer',
'source' => get_template_directory() . '/plugins/js-composer.zip',
'required' => false,
'version' => '5.1.1',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
),
);
$config = array(
'id' => 'custom', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'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.
);
tgmpa( $plugins, $config );
}
please tell me whats wrong in this code why after acitvate the theme did not show any message about activate the required plugins

Related

Not show hr through teeny_mce_buttons filter

I'm building custom tinymce bar buttons for my wp theme, using wp_editor and teeny, but I have a problem. When I add hr and charmap, these buttons not appear in the tinymce bar.
This is the wp_editor configuration:
$settings = array(
'textarea_name' => 'xor_options[' . $editor . ']',
'quicktags' => array( 'buttons' => 'strong,em,del,ul,ol,li,close' ),
'media_buttons' => true,
'wpautop' => false,
'textarea_rows' => 5,
'editor_height' => 200,
'teeny' => true,
'tinymce' => true
);
wp_editor( $xor_output, $xor_editor_id, $settings );
Now I'm using the filter for teeny buttons.
add_filter( 'teeny_mce_buttons', 'xor_editor_buttons', 10, 2 );
function xor_editor_buttons( $buttons, $editor_id ) {
if( $editor_id != 'footer-editor' ) return $buttons;
$buttons = array(
'undo',
'redo',
'formatselect',
'bold',
'italic',
'underline',
'strikethrough',
'blockquote',
'bullist',
'numlist',
'outdent',
'indent',
'alignleft',
'alignright',
'aligncenter',
'alignjustify',
'link',
'unlink',
'hr', // not appears!
'charmap', // not appears!
'removeformat',
'fullscreen'
);
return $buttons;
}
Where is the error in my code or this is a little bug? I'm using Wordpress 4.9. Thanks!
SOLVED
I set on false teeny. Then I set tinymce as array:
'tinymce' => array(
'toolbar1' => $b,
'toolbar2' => '',
'toolbar3' => '',
)
Where $b is all buttons that I need (included hr and charmap). See:
Wordpress Developers
Before you can load the toolbar buttons you need to load the plugins:
https://www.tinymce.com/docs/plugins/hr/
https://www.tinymce.com/docs/plugins/charmap/
You first need to see if the TinyMCE embedded in your WP version includes these plugins (they are in a standard WordPress setup). You then need to add these plugins to the list of loaded plugins. Once they are loaded adding the buttons to the toolbar will work.
I don't know anything about teenymce but (as an example) this is how TinyMCE Advanced loads extra plugins via a WordPress hook:
add_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ), 999 );
(The array is a list of plugin folder names)

Add Role to Registration in WP

I am looking for a way to add a dropdown for users in the registration form to select their role (except administrator).
Currently running wordpress 4.7.4 with buddypress 2.8.0., found some snippets and such but none of them are actually working.
Any help is much appreciated
You have to create user-role.php fileand include it in functions.php file.
<?php
if( get_role('subscriber') ){
remove_role( 'subscriber' );
}
if( get_role('client') ){
remove_role( 'client' );
}
// Add a Country (Others) role
$result = add_role( 'country', __(
'Country (Others)' ),
array(
'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'edit_pages' => true, // Allows user to edit pages
'edit_others_posts' => true, // Allows user to edit others posts not just their own
'create_posts' => true, // Allows user to create new posts
'manage_categories' => true, // Allows user to manage post categories
'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
'edit_themes' => false, // false denies this capability. User can’t edit your theme
'install_plugins' => false, // User cant add new plugins
'update_plugin' => false, // User can’t update any plugins
'update_core' => false // user cant perform core updates
)
);

How to include mailchimp plugin with wordpress theme

I’m working on WordPress theme, and this theme has email subscription widget. So I want to include MailChimp plugin to the theme. How to do that?
Sorry bro you can't use mailchimp plugin in you theme as a embedded plugin. But you can use TGM plugin activation file to include plugin to your theme. Download a copy of TGM class file from here TGM plugin activation class and just copy the class-tgm-plugin-activation.php file to your theme directory and add below codes to your theme's functions.php file ..
<?php
require get_template_directory() . '/class-tgm-plugin-activation.php'; //add your file path where you put the file
add_action( 'tgmpa_register', 'something_register_required_plugins' );
function something_register_required_plugins() {
$plugins = array(
array(
'name' => 'Mailchimp',
'slug' => 'mailchimp',
'required' => true,
),
);
$config = array(
'id' => 'something', // 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.
);
tgmpa( $plugins, $config );
}
?>
This will create a suggestion to your users to install mailchimp plugin from the wordpress.org repository

how to automatically install a wordpress plugin when activating a wordpress theme?

I am new to wordpress. I want to install a wordpress plugin automatically when I activate a particular wordpress theme and when I deactivate that theme at that time that plugin should also be deactivated. How can I do that? Thanks in advance.
you can activate plugin with http://tgmpluginactivation.com/ site
after download put inside theme and put this code in function.php below is just example plugin code you can change with your's
require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'my_theme_register_required_plugins' );
/**
* Register the required plugins for this theme.
*
* In this example, we register two plugins - one included with the TGMPA library
* and one from the .org repo.
*
* The variable passed to tgmpa_register_plugins() should be an array of plugin
* arrays.
*
* This function is hooked into tgmpa_init, which is fired within the
* TGM_Plugin_Activation class constructor.
*/
function my_theme_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(
// WooCommerce
array(
'name' => 'Page Builder by SiteOrigin',
'slug' => 'siteorigin-panels',
'required' => true,
'force_activation' => true,
'force_deactivation' => true
),
// WooCommerce
array(
'name' => 'SiteOrigin Widgets Bundle',
'slug' => 'so-widgets-bundle',
'required' => true,
'force_activation' => true,
'force_deactivation' => true
)
);
/**
* Array of configuration settings. Amend each line as needed.
* If you want the default strings to be available under your own theme domain,
* leave the strings uncommented.
* Some of the strings are added into a sprintf, so see the comments at the
* end of each line for what each argument will be.
*/
$config = array(
'default_path' => '', // Default absolute path to pre-packaged plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'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', 'tgmpa' ),
'menu_title' => __( 'Install Plugins', 'tgmpa' ),
'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), // %s = plugin name.
'oops' => __( 'Something went wrong with the plugin API.', 'tgmpa' ),
'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s).
'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s).
'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s).
'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s).
'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s).
'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s).
'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.' ), // %1$s = plugin name(s).
'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s).
'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins' ),
'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ),
'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ),
'complete' => __( 'All plugins installed and activated successfully. %s', 'tgmpa' ), // %s = dashboard link.
'nag_type' => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
)
);
tgmpa( $plugins, $config );
}
In addition with Corlax's answer, this is a list of services and open sources that might be useful:
WP Package Editor
WP2E is a service allowing developers to create and manage installation
packages to deliver and maintain sets of interdependent themes and
plugins.
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).
WPFavs
It is a Free WordPress plugin manager and bulk installation tool
WP Plugin Dependencies
This meta-plugin allows regular plugins to specify other plugins that
they depend upon.
WP Dependency Installer
A lightweight class to add to WordPress plugins/themes to
automatically install plugin dependencies.

Drupal 7 .10 hook_menu implementation error

I am trying to figure out why hook_menu implementation is not working anymore after upgrade from 7.4 to 7.10 for a custom module Menu links were working properly until update to latest version. after update all custom module links are deleted from table menu_links and menu_router.
After many attempts, I also installed a fresh version for D7.10 and created a simple custom module with one item link only (see code below) for testing purpose only. The link is not implemented once the module is enabled. Tables menu_links and menu_routers are not updated.
I have been looking around many possible errors and solution without success.
Really stacked now. What makes me doubt is that I do not see anybody else having the same issue... Any suggestion? Thank you
function misite_menu() {
$items = array();
$items['a/main'] = array(
'title' => 'main',
'page callback' => 'main',
'description' => t('Main front page'),
'access callback' => TRUE,
);
return $items;
}
function misite_theme() {
return array(
'main' => array
(
'template' => 'main',
'variables' => array('title' => NULL),
),
);
}
function main() {
$path = drupal_get_path('module', 'a');
$title = t('');
$build['mainelement'] = array(
'#theme' => 'main',
'#title' => $title,
);
$output = drupal_render($build);
return $output;
}
From the looks of this line:
$path = drupal_get_path('module', 'a');
Your module is called a.
In Drupal, the convention for hook naming is MODULE_NAME_name_of_hook() (see http://api.drupal.org/api/drupal/includes--module.inc/group/hooks/7).
This is true for both hook_menu() and hook_theme() so in your case if the module is called a your functions should be names a_menu() and a_theme().
If you make changes to any hooks make sure you clear Drupal's cache so the relevant registrys are updated.

Resources