Skip to content

Commit

Permalink
Fixed bug in show_notice()
Browse files Browse the repository at this point in the history
  • Loading branch information
dmhendricks committed Jul 21, 2017
1 parent 83860ed commit c74cb2f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@ public function __construct($_settings) {

// Initialize Carbon Fields and verify dependencies
add_action( 'plugins_loaded', array( 'Carbon_Fields\\Carbon_Fields', 'boot' ) );
add_action( 'carbon_fields_loaded', array( $this, 'verify_dependencies' ) );
add_action( 'plugins_loaded', array( &$this, 'verify_dependencies' ) );

}

public function verify_dependencies() {

// Check if outdated version of Carbon Fields loaded
$error = null;

if(!defined('\\Carbon_Fields\\VERSION')) {
if( !defined('\\Carbon_Fields\\VERSION') ) {
$error = '<strong>' . self::$settings['data']['Name'] . ':</strong> ' . __('A fatal error occurred while trying to initialize plugin.');
} else if( version_compare( \Carbon_Fields\VERSION, self::$settings['deps']['carbon_fields'], '<' ) ) {
$error = '<strong>' . self::$settings['data']['Name'] . ':</strong> ' . __('Unable to load. An outdated version of Carbon Fields has been loaded:' . ' ' . \Carbon_Fields\VERSION) . ' (&gt;= '.self::$settings['deps']['carbon_fields'] . ' ' . __('required') . ')';
}

if($error) $this->show_notice($error, 'error', false);
return !$error;

}

/**
* Helper function to display a notice in the WP Admin
*/
private function show_notice($msg, $type = 'error', $is_dismissible = false) {
if(is_admin()) {
$class = 'notice notice-'.$type.($is_dismissible ? ' is-dismissible' : '');
$msg = __( $msg, self::$settings['data']['TextDomain'] );

if( is_admin() ) {
$class = 'notice notice-' . $type . ( $is_dismissible ? ' is-dismissible' : '' );
printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $msg );
}
}
Expand Down

0 comments on commit c74cb2f

Please sign in to comment.