Events::EVENT, 'page' => self::PAGE ] + $filters, admin_url( 'edit.php' ) ); } public static function menu(): void { $label = __( 'Loop Presets', 'eventlabs-loop-builder' ); $page = add_submenu_page( 'edit.php?post_type=' . Events::EVENT, $label, $label, Templates::CAPABILITY, self::PAGE, [ self::class, 'render' ] ); if ( $page ) { add_action( 'admin_enqueue_scripts', static function ( string $screen ) use ( $page ): void { if ( $page === $screen ) { wp_enqueue_style( ASSET . '-library', plugins_url( 'assets/library.css', FILE ), [ ASSET . '-presets' ], VERSION ); } } ); } } public static function list_link( string $position ): void { $screen = get_current_screen(); if ( 'top' === $position && $screen && Templates::POST_TYPE === $screen->post_type && current_user_can( Templates::CAPABILITY ) ) { echo '' . esc_html__( 'Browse loop presets', 'eventlabs-loop-builder' ) . ''; } } private static function selected( string $key, array $options ): string { $value = isset( $_GET[ $key ] ) && is_string( $_GET[ $key ] ) ? sanitize_key( wp_unslash( $_GET[ $key ] ) ) : ''; return isset( $options[ $value ] ) ? $value : ''; } public static function render(): void { if ( ! current_user_can( Templates::CAPABILITY ) ) { wp_die( esc_html__( 'You cannot view loop presets.', 'eventlabs-loop-builder' ), '', [ 'response' => 403 ] ); } $layouts = Presets::layouts(); $families = Presets::families(); $layout = self::selected( 'ell_layout', $layouts ); $family = self::selected( 'ell_family', $families ); $presets = array_filter( Presets::catalog(), static fn( array $style ): bool => ( ! $layout || $layout === $style['layout'] ) && ( ! $family || $family === $style['family'] ) ); ?>

__( 'All layouts', 'eventlabs-loop-builder' ) ] + $layouts, $layout ); ?> __( 'All styles', 'eventlabs-loop-builder' ) ] + $families, $family ); ?>

$style ) : ?>