Esempio n. 1
0
function rbhn_tgmpa_register( ) {

	$plugins = RBHN_Settings::get_instance( )->selected_plugins( 'rbhn_plugin_extension' );
	
	$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', 'role-based-help-notes-text-domain' ),
					'menu_title'                      => __( 'Install Plugins', 'role-based-help-notes-text-domain' ),
					'installing'                      => __( 'Installing Plugin: %s', 'role-based-help-notes-text-domain' ), // %s = plugin name.
					'oops'                            => __( 'Something went wrong with the plugin API.', 'role-based-help-notes-text-domain' ),
					'notice_can_install_required'     => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'role-based-help-notes-text-domain' ), // %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.', 'role-based-help-notes-text-domain' ), // %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.', 'role-based-help-notes-text-domain' ), // %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.', 'role-based-help-notes-text-domain' ), // %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.', 'role-based-help-notes-text-domain' ), // %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.', 'role-based-help-notes-text-domain' ), // %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.', 'role-based-help-notes-text-domain' ), // %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.', 'role-based-help-notes-text-domain' ), // %1$s = plugin name( s ).
					'install_link'                    => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'role-based-help-notes-text-domain' ),
					'activate_link'                   => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'role-based-help-notes-text-domain' ),
					'return'                          => __( 'Return to Required Plugins Installer', 'role-based-help-notes-text-domain' ),
					'plugin_activated'                => __( 'Plugin activated successfully.', 'role-based-help-notes-text-domain' ),
					'complete'                        => __( 'All plugins installed and activated successfully. %s', 'role-based-help-notes-text-domain' ), // %s = dashboard link.
					'nag_type'                        => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
			)
	);


	tgmpa( $plugins, $config );

}
Esempio n. 2
0
	/**
     * Creates or returns an instance of this class.
     *
     * @return   A single instance of this class.
     */
    public static function get_instance( ) {

		$role_based_help_notes = RBHN_Role_Based_Help_Notes::get_instance( );
		
		$config = array(
				'default_tab_key' => 'rbhn_general',						// Default settings tab, opened on first settings page open.
				'menu_parent' => 'options-general.php',    					
				'menu_access_capability' => 'promote_users',    			// menu capability make this the lowest of all 'access_capability' defined in the settings array.
				'menu' => $role_based_help_notes->menu,    					
				'menu_title' => $role_based_help_notes->menu_title,    		
				'page_title' => $role_based_help_notes->page_title,    		
				);
				
				
		$settings = 	apply_filters( 'rbhn_settings', 
									array(								
										'rbhn_general' => array(
											'access_capability' => 'edit_theme_options',
											'title' 		=> __( 'General', 'role-based-help-notes-text-domain' ),
											'description' 	=> __( 'Settings for general purpose.', 'role-based-help-notes-text-domain' ),
											'settings' 		=> array(		
																	array(
																		'name' 		=> 'rbhn_general_enabled',
																		'std' 		=> false,
																		'label' 	=> __( 'General Help Notes', 'role-based-help-notes-text-domain' ),
																		'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																		'desc'		=> __( "Enabling the 'General' option gives you global Help Notes, which are not limited to any one role, these will be accessible to all and follow the capabilities of the normal wordpress 'post' post type.", 'role-based-help-notes-text-domain' ),
																		'type'      => 'field_checkbox_option'
																		),
																	array(
																		'name' 		=> 'rbhn_widgets_enabled',
																		'std' 		=> false,
																		'label' 	=> _x( 'Widgets', 'settings title for enabling the widgets for help notes.', 'role-based-help-notes-text-domain' ),
																		'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																		'desc'		=> __( "Enabling will allow you to place the Help Notes widgets into your sidebars.", 'role-based-help-notes-text-domain' ),
																		'type'      => 'field_checkbox_option'
																		),
																	array(
																		'name' 		=> 'rbhn_contents_page',
																		'std' 		=> '0',
																		'label' 	=> __( 'Contents Page', 'role-based-help-notes-text-domain' ),
																		'desc'		=> __( 'If you wish to create a contents page add a new page and select it here so that the Help Note Contents are displayed.', 'role-based-help-notes-text-domain' ),
																		'type'      => 'field_page_select_list_option',
																		),
																	array(
																		'name' 		=> 'rbhn_welcome_page',
																		'std' 		=> '0',
																		'label' 	=> __( 'Welcome Page', 'role-based-help-notes-text-domain' ),
																		'desc'		=> __( 'A welcome page has been created and used for your menu landing page, you can edit the page directly to customise or select "- None -" to deactivate.', 'role-based-help-notes-text-domain' ),
																		'type'      => 'field_page_select_list_option',
																		),
																	array(
																		'name' 		=> 'rbhn_make_clickable',
																		'std' 		=> '0',
																		'label' 	=> __( 'Click-able Links', 'role-based-help-notes-text-domain' ),
																		'desc'		=> __( 'Turn valid URLs into click able text.', 'role-based-help-notes-text-domain' ),
																		'type'      => 'field_checkbox_option',
																		),	
																),
										),
										'rbhn_roles' => array(
											'access_capability' => 'edit_theme_options',
											'title' 		=> __( 'Roles', 'role-based-help-notes-text-domain' ),
											'description' 	=> __( 'Select the Roles that you wish to create Help Notes for.', 'role-based-help-notes-text-domain' ),
											'settings' 		=> array(					
																	array(
																		'name' 		=> 'rbhn_post_types',
																		'std' 		=> array(),
																		'label' 	=> __( 'Help Notes', 'role-based-help-notes-text-domain' ),
																		'desc'		=> '',
																		'type'      => 'field_help_notes_post_types_option'
																		),					
																	),
										),
										'rbhn_plugin_extension' => array(
												'access_capability' => 'install_plugins',
												'title' 		=> __( 'Plugin Suggestions', 'role-based-help-notes-text-domain' ),
												'description' 	=> __( 'These settings are optional.  Selection of any suggested plugin here will prompt you through the installation.  The plugin will be forced active while this is selected; deselecting will not remove the plugin, you will need to manually uninstall.', 'role-based-help-notes-text-domain' ),					
												'settings' 		=> array(
																		array(
																			'name' 		=> 'rbhn_user_role_editor',
																			'std' 		=> true,
																			'label' 	=> 'User Role Editor',
																			'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																			'desc'		=> __( 'This is a useful plugin for Administrators to set multiple WordPress roles to users', 'role-based-help-notes-text-domain' ),
																			'type'      => 'field_plugin_checkbox_option',
																			// the following are for tgmpa_register activation of the plugin
																			'plugin_dir'			=> HELP_PLUGIN_DIR,
																			'slug'      			=> 'user-role-editor', 
																			'required'              => false,
																			'force_deactivation' 	=> false,
																			'force_activation'      => true,												
																			),									
																		array(
																			'name' 		=> 'rbhn_menu_items_visibility_control',
																			'filename'  => 'init',
																			'std' 		=> false,
																			'label' 	=> 'Menu Item Visibility Control',
																			'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																			'desc'		=> __( 'This is a useful plugin for Administrators to define Menus to be visible for users according to their allocated roles.', 'role-based-help-notes-text-domain' ),
																			'type'      => 'field_plugin_checkbox_option',
																			// the following are for tgmpa_register activation of the plugin
																			'plugin_dir'			=> HELP_PLUGIN_DIR,
																			'slug'      			=> 'menu-items-visibility-control', 
																			'required'              => false,
																			'force_deactivation' 	=> false,
																			'force_activation'      => true,												
																			),		
																		array(
																			'name' 		=> 'rbhn_user_switching',
																			'std' 		=> false,
																			'label' 	=> 'User Switching',
																			'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																			'desc'		=> __( 'This is a useful plugin for Administrators to test the accessibility of users with different roles, you can simply switch to their account to check how the Help Notes appear for them.', 'role-based-help-notes-text-domain' ),
																			'type'      => 'field_plugin_checkbox_option',
																			// the following are for tgmpa_register activation of the plugin
																			'plugin_dir'			=> HELP_PLUGIN_DIR,
																			'slug'      			=> 'user-switching', 
																			'required'              => false,
																			'force_deactivation' 	=> false,
																			'force_activation'      => true,												
																			),						
																		array(
																			'name' 		=> 'rbhn_simple_page_ordering',
																			'std' 		=> false,
																			'label' 	=> 'Simple Page Ordering',
																			'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																			'desc'		=> __( 'Once installed go you can drag pages up/down within the admin side to re-order Help Notes.', 'role-based-help-notes-text-domain' ),
																			'type'      => 'field_plugin_checkbox_option',
																			// the following are for tgmpa_register activation of the plugin
																			'plugin_dir'			=> HELP_PLUGIN_DIR,
																			'slug'      			=> 'simple-page-ordering', 
																			'required'              => false,
																			'force_deactivation' 	=> false,
																			'force_activation'      => true,												
																			),					
																		array(
																			'name' 		=> 'rbhn_simple_footnotes_plugin',
																			'std' 		=> false,
																			'label' 	=> 'Simple Footnotes',
																			'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																			'desc'		=> __( "Once installed go you can use the 'ref' shortcode for example... [ref]Add footnote text here[/ref] within your posts.", 'role-based-help-notes-text-domain' ),
																			'type'      => 'field_plugin_checkbox_option',
																			// the following are for tgmpa_register activation of the plugin
																			'plugin_dir'			=> HELP_PLUGIN_DIR,
																			'slug'      			=> 'simple-footnotes',
																			'required'              => false,
																			'force_deactivation' 	=> false,
																			'force_activation'      => true,		
																			),					
																		array(
																			'name' 		=> 'rbhn_disable_comments_plugin',
																			'std' 		=> false,
																			'label' 	=> 'Disable Comments',
																			'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																			'desc'		=> __( 'Comments are of less value for Help Notes and this plugin will allow you to easily remove comments from use.', 'role-based-help-notes-text-domain' ),
																			'type'      => 'field_plugin_checkbox_option',
																			// the following are for tgmpa_register activation of the plugin
																			'plugin_dir'			=> HELP_PLUGIN_DIR,
																			'slug'      			=> 'disable-comments',
																			'required'              => false,
																			'force_deactivation' 	=> false,
																			'force_activation'      => true,		
																			),					
																		array(
																			'name' 		=> 'rbhn_email_post_changes_plugin',
																			'std' 		=> false,
																			'label' 	=> 'Email Post Changes',
																			'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																			'desc'		=> __( 'Allows for emailing of the standard General Help notes only along with Post, Page and other custom post types you have.  To email all other Help note changes automatically, tighter control is necessary for security reasons, for this you can purchase and download the <a href="//justinandco.com/plugins/role-based-help-notes-extra/" target="_blank">role-based-help-notes-extra plugin</a>.', 'role-based-help-notes-text-domain' ),
																			'type'      => 'field_plugin_checkbox_option',
																			// the following are for tgmpa_register activation of the plugin
																			'plugin_dir'			=> HELP_PLUGIN_DIR,
																			'slug'      			=> 'email-post-changes',
																			'required'              => false,
																			'force_deactivation' 	=> false,
																			'force_activation'      => true,		
																			),					
																		array(
																			'name' 		=> 'rbhn_post_type_switcher_plugin',
																			'std' 		=> false,
																			'label' 	=> 'Post Type Switcher',
																			'cb_label'  => _x( 'Enable', 'enable the setting option.', 'role-based-help-notes-text-domain' ),
																			'desc'		=> __( "This plugin will allow users with two or more roles the ability to change the role assigned to a help note.  Once installed you will find a new selection/edit option in the 'Publish' area.", 'role-based-help-notes-text-domain' ),
																			'type'      => 'field_plugin_checkbox_option',
																			// the following are for tgmpa_register activation of the plugin
																			'plugin_dir'			=> HELP_PLUGIN_DIR,
																			'slug'      			=> 'post-type-switcher', 
																			'required'              => false,
																			'force_deactivation' 	=> false,
																			'force_activation'      => true,		
																			),					
																		),
										),
									)
								);

        if ( null == self::$instance ) {
            self::$instance = new Tabbed_Settings( $settings, $config );
        }
 
        return self::$instance;
 
    }
	/**
	 * Display the admin warnings.
	 *
	 * @access public
	 * @return null
	 */
	public function action_admin_notices( ) {
	
		$plugins = RBHN_Settings::get_instance( )->selected_plugins( 'rbhn_plugin_extension' );

		foreach ( $plugins as $plugin ) {
			$this->action_admin_plugin_forced_active_notices( $plugin["slug"] );
		}
		
		// Prompt for rating
		$this->action_admin_rating_prompt_notices( );	
		
	}