/** * Add admin notices for the current entity depending on the current rating. * * @since 3.3.0 * * @param WP_Post $post Post object. */ public function in_admin_header() { // Return safely if get_current_screen() is not defined (yet) if (FALSE === function_exists('get_current_screen')) { return; } // If you're not in the entity post edit page, return. if (self::TYPE_NAME !== get_current_screen()->id) { return; } // Retrieve the current global post global $post; // If it's not an entity, return. if (!$this->is_entity($post->ID)) { return; } // Retrieve an updated rating for the current entity $rating = $this->get_rating_for($post->ID, true); // If there is at least 1 warning if (isset($rating['warnings']) && 0 < count($rating['warnings'])) { // TODO - Pass Wordlift_Notice_Service trough the service constructor $this->notice_service->add_suggestion($rating['warnings']); } }
/** * Create an instance of the Notice service. * * @since 3.2.0 */ public function __construct() { // Hook to be called when to display notices. add_action('admin_notices', array($this, 'admin_notices')); self::$instance = $this; }
/** * Check WordLift's configuration. * * @since 3.0.0 * * @return bool True if the configuration is set otherwise false. */ function wl_configuration_validate() { // Check that the WordLift key has been set or show a notice. if ('' !== wl_configuration_get_key()) { return; } Wordlift_Notice_Service::get_instance()->add_error(sprintf(__('application-key-not-set', 'wordlift'), 'http://join.wordlift.it')); }