Plugin Directory

Changeset 1635318


Ignore:
Timestamp:
04/11/2017 12:42:54 PM (9 years ago)
Author:
createandcode
Message:

Fix for admin notice error

Location:
woo-product-image-gallery-options/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • woo-product-image-gallery-options/trunk/changelog.txt

    r1635203 r1635318  
    332017.04.10 - version 1.0.0
    44* Initial release
     5
     62017.04.11 - version 1.0.1
     7* Fixed some basic errors for admin notices when WooCommerce is not active
  • woo-product-image-gallery-options/trunk/readme.txt

    r1635216 r1635318  
    1616== Installation ==
    1717
    18 1. Upload `woo-product-image-gallery-options` to the `/wp-content/plugins/` directory
     181. Upload `woocommerce-product-image-gallery-options` to the `/wp-content/plugins/` directory
    19192. Activate the plugin through the 'Plugins' menu in WordPress
    20203. Done!
     
    3535Initial release.
    3636
     37= 1.0.1 - 04.11.2017 =
     38Fixed some basic errors for admin notices when WooCommerce is not active
     39
    3740
    3841== Upgrade Notice ==
  • woo-product-image-gallery-options/trunk/woocommerce-product-image-gallery-options.php

    r1635216 r1635318  
    1111 * Plugin URI:        https://createandcode.com/plugins/woocommerce-product-image-gallery-options
    1212 * Description:       Switch on/off WooCommerce 3.0+ Product Image Gallery options on a per product basis.
    13  * Version:           1.0.0
    14  * Author:            CreateandCode
     13 * Version:           1.0.1
     14 * Author:            Create and Code
    1515 * Author URI:        https://createandcode.com
    1616 * Requires at least: 4.7
     
    4949         * @var string
    5050         */
    51         const VERSION = '1.0.0';
     51        const VERSION = '1.0.1';
     52
     53        /**
     54         * Notices (array)
     55         * @var array
     56         */
     57        public $notices = array();
    5258
    5359        public function __construct() {
    5460            add_action( 'admin_init', array( $this, 'check_environment' ) );
     61            add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 );
    5562            add_action( 'plugins_loaded', array( $this, 'init' ) );
    5663            add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
     
    113120
    114121        /**
     122         * Display any notices we've collected thus far
     123         */
     124        public function admin_notices() {
     125            foreach ( (array) $this->notices as $notice_key => $notice ) {
     126                echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>";
     127                echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
     128                echo "</p></div>";
     129            }
     130        }
     131
     132        /**
     133         * Allow this class and other classes to add slug keyed notices (to avoid duplication)
     134         */
     135        public function add_admin_notice( $slug, $class, $message ) {
     136            $this->notices[ $slug ] = array(
     137                'class'   => $class,
     138                'message' => $message
     139            );
     140        }
     141
     142        /**
    115143         * Load the plugin text domain for translation.
    116144         *
Note: See TracChangeset for help on using the changeset viewer.