access->isAdmin() ) { return; } check_admin_referer( 'aioseo-newsroom-dismiss-' . $id ); $userId = get_current_user_id(); $dismissed = (array) get_user_meta( $userId, self::DISMISSED_META, true ); $dismissed = array_values( array_unique( array_merge( array_map( 'intval', $dismissed ), [ $id ] ) ) ); update_user_meta( $userId, self::DISMISSED_META, $dismissed ); wp_safe_redirect( remove_query_arg( [ 'aioseo-newsroom-dismiss', '_wpnonce' ] ) ); exit; } /** * Render the newest undismissed callout for the current screen. * * @since 5.0.0 * * @return void */ public function maybeRender() { if ( ! aioseo()->access->isAdmin() ) { return; } /** * Allows in-plugin feature callouts to be turned off. * * @since 5.0.0 * * @param bool $show Whether to show callouts. */ if ( ! apply_filters( 'aioseo_show_newsroom_callouts', true ) ) { return; } $item = $this->getItem(); if ( empty( $item ) ) { return; } $title = $item['callout']['title'] ?? $item['title']; $body = $item['callout']['body'] ?? $item['excerpt']; $dismissUrl = wp_nonce_url( add_query_arg( 'aioseo-newsroom-dismiss', $item['id'] ), 'aioseo-newsroom-dismiss-' . $item['id'] ); ?>
getScreenSlug(); if ( '' === $screen ) { return []; } $dismissed = array_map( 'intval', (array) get_user_meta( get_current_user_id(), self::DISMISSED_META, true ) ); $cutoff = time() - self::MAX_AGE; foreach ( aioseo()->newsroom->getItemsForScreen( $screen ) as $item ) { if ( in_array( (int) $item['id'], $dismissed, true ) ) { continue; } if ( ! empty( $item['date'] ) && strtotime( $item['date'] ) < $cutoff ) { continue; } // One at a time: the feed is newest-first, so this is the most recent. return $item; } return []; } /** * Get the current admin page slug. * * @since 5.0.0 * * @return string The slug, or empty if this isn't one of our screens. */ private function getScreenSlug() { // phpcs:ignore HM.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Recommended $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; return 0 === strpos( $page, 'aioseo-' ) ? $page : ''; } }