Skip to content
wiki.fftac.org

Adminpages - Source Excerpt 02

Back to Adminpages

Summary

This source excerpt preserves a bounded section of Antichrist.net/wp-content/plugins/uaix-locale-router/src/Admin/AdminPages.php so readers can inspect the evidence without opening the full source file.

**Source path:** Antichrist.net/wp-content/plugins/uaix-locale-router/src/Admin/AdminPages.php

return;
		}

		$review = Plugin::locale_link_review_diagnostics();

		if ( 'good' === $review['severity'] ) {
			return;
		}

		$status_link = sprintf(
			'<a href="%s">%s</a>',
			esc_url( self::page_url( 'uaixlr-status' ) ),
			esc_html__( 'Open Status for the full link review.', 'uaix-locale-router' )
		);

		echo '<div class="notice notice-warning"><p>';
		echo '<strong>' . esc_html__( 'UAIX Locale Router link review:', 'uaix-locale-router' ) . '</strong> ';
		echo esc_html( $review['summary'] );
		echo ' ';
		echo wp_kses_post( $status_link );
		echo '</p>';

		if ( ! empty( $review['findings'] ) ) {
			echo '<ul class="uaixlr-admin-notice-list">';

			foreach ( array_slice( $review['findings'], 0, 3 ) as $finding ) {
				$line = isset( $finding['line'] ) ? absint( $finding['line'] ) : 0;
				$path = isset( $finding['path'] ) ? (string) $finding['path'] : '';
				$label = isset( $finding['label'] ) ? (string) $finding['label'] : __( 'Finding', 'uaix-locale-router' );

				echo '<li><strong>' . esc_html( $label ) . ':</strong> ';
				echo esc_html( $path );

				if ( $line > 0 ) {
					echo ':' . esc_html( (string) $line );
				}

				echo '</li>';
			}

			echo '</ul>';
		}

		echo '</div>';
	}

	/**
	 * Build an admin page URL.
	 *
	 * @param string $slug Page slug.
	 * @param array  $args Extra query args.
	 * @return string
	 */
	public static function page_url( $slug, array $args = array() ) {
		$slug = self::normalize_page_slug( $slug );

		return add_query_arg(
			$args,
			admin_url( 'admin.php?page=' . rawurlencode( $slug ) )
		);
	}

	/**
	 * Map deprecated NS12 admin slugs to their UAIX equivalents.
	 *
	 * @param string $slug Page slug.
	 * @return string
	 */
	private static function normalize_page_slug( $slug ) {
		$slug = (string) $slug;

		if ( 0 === strpos( $slug, 'ns12lr-' ) ) {
			return 'uaixlr-' . substr( $slug, strlen( 'ns12lr-' ) );
		}

		return $slug;
	}
}