slug = $slug; $this->args = wp_parse_args( $args, array( 'content' => '', 'type' => self::TYPE_INFO, 'active_callback' => null, 'dismissible' => false, ) ); } /** * Gets the notice slug. * * @since 1.0.0 * * @return string Unique notice slug. */ public function get_slug() { return $this->slug; } /** * Checks whether the notice is active. * * This method executes the active callback in order to determine whether the notice should be active or not. * * @since 1.0.0 * * @param string $hook_suffix The current admin screen hook suffix. * @return bool True if the notice is active, false otherwise. */ public function is_active( $hook_suffix ) { if ( ! $this->args['content'] ) { return false; } if ( ! $this->args['active_callback'] ) { return true; } return (bool) call_user_func( $this->args['active_callback'], $hook_suffix ); } /** * Renders the notice. * * @since 1.0.0 */ public function render() { if ( is_callable( $this->args['content'] ) ) { $content = call_user_func( $this->args['content'] ); if ( empty( $content ) ) { return; } } else { $content = '

' . wp_kses( $this->args['content'], 'googlesitekit_admin_notice' ) . '

'; } $class = 'notice notice-' . $this->args['type']; if ( $this->args['dismissible'] ) { $class .= ' is-dismissible'; } ?>