show_notification = ! empty( $options['show_onboarding_notice'] ); } /** * Returns the content of the notification. * * @return string A string with the notification HTML, or empty string when no notification is needed. */ public function notify() { if ( ! $this->show_notification() ) { return ''; } $notification = '
'; $notification .= sprintf( '', esc_url( plugin_dir_url( WPSEO_FILE ) . 'images/new-to-configuration-notice.svg' ), 60, 60 ); $notification .= '
'; $notification .= '

' . esc_html__( 'First-time SEO configuration', 'wordpress-seo' ) . '

'; $notification .= '

'; $notification .= sprintf( /* translators: %1$s expands to Yoast SEO, %2$s is a link start tag to the Onboarding Wizard, %3$s is the link closing tag. */ esc_html__( 'Get started quickly with the %1$s %2$sconfiguration wizard%3$s!', 'wordpress-seo' ), 'Yoast SEO', '', '' ); $notification .= '

'; $notification .= '
'; $notification .= sprintf( '%2$s', esc_url( admin_url( 'admin.php?page=wpseo_dashboard&dismiss_get_started=1' ) ), esc_html__( 'Dismiss this item.', 'wordpress-seo' ) ); $notification .= '
'; return $notification; } /** * Listens to an argument in the request URL. When triggered just set the notification to dismissed. * * @return void */ public function listen() { if ( ! $this->show_notification() || ! $this->dismissal_is_triggered() ) { return; } $this->set_dismissed(); } /** * Checks if the dismissal should be triggered. * * @return bool True when action has been triggered. */ protected function dismissal_is_triggered() { return filter_input( INPUT_GET, 'dismiss_get_started' ) === '1'; } /** * Checks if the current user has dismissed the notification. * * @return bool True when the notification has been dismissed. */ protected function is_dismissed() { return get_user_meta( get_current_user_id(), self::META_NAME, true ) === self::META_VALUE; } /** * Sets the dismissed state for the current user. * * @return void */ protected function set_dismissed() { update_user_meta( get_current_user_id(), self::META_NAME, self::META_VALUE ); } /** * Checks if the notification should be shown. * * @return bool True when notification should be shown. */ protected function show_notification() { return $this->show_notification && ! $this->is_dismissed(); } }