* @copyright (c) 2013, OnePress Ltd * * @package factory-notices * @since 1.0.0 */ // creating a license manager for each plugin created via the factory add_action('factory_notices_323_plugin_created', 'factory_notices_323_plugin_created'); function factory_notices_323_plugin_created( $plugin ) { new FactoryNotices323( $plugin ); } /** * A class to manage notices. * * @since 1.0.0 */ class FactoryNotices323 { public function __construct( $plugin ) { $this->plugin = $plugin; add_action('current_screen', array( $this, 'currentScreenAction') ); } public function currentScreenAction() { $this->notices = apply_filters('factory_notices_' . $this->plugin->pluginName, array()); if ( count( $this->notices ) == 0 ) return; $screen = get_current_screen(); $this->hasNotices = false; foreach ($this->notices as $notice) { $where = empty( $notice['where'] ) ? array('plugins','dashboard','edit') : $notice['where']; $screen = get_current_screen(); if ( in_array($screen->base, $where) ) { $this->hasNotices = true; break; }; } if ( $this->hasNotices ) { add_action('factory_bootstrap_enqueue_scripts_' . $this->plugin->pluginName, array( $this, 'enqueueBootstrapScripts' )); add_action('admin_enqueue_scripts', array( $this, 'enqueueScripts' )); add_action('admin_notices', array( $this, 'showNotices' )); } } public function enqueueBootstrapScripts() { $this->plugin->bootstrap->enqueueStyle('bootstrap.core'); } public function enqueueScripts() { wp_enqueue_style('factory-notices-323-css', FACTORY_NOTICES_323_URL . '/assets/css/notices.css'); wp_enqueue_script('factory-notices-323-js', FACTORY_NOTICES_323_URL . '/assets/js/notices.js'); } public function showNotices() { if ( count( $this->notices ) == 0 ) return; if ( !current_user_can('activate_plugins') || !current_user_can('edit_plugins') || !current_user_can('install_plugins')) return; ?> hasNotices ) { ?>