| @@ -1,0 +1,42 @@ | ||
| 1 | +<?php | |
| 2 | +namespace ABlocks\CreatePage\Page; | |
| 3 | + | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; // Exit if accessed directly. | |
| 6 | +} | |
| 7 | + | |
| 8 | +class ShowPageState { | |
| 9 | + public static function init() : void { | |
| 10 | + $instance = new static(); | |
| 11 | + add_filter( 'display_post_states', [ $instance, 'show_page_state' ], 10, 2 ); | |
| 12 | + } | |
| 13 | + public function show_page_state( $states, $post ) { | |
| 14 | + if ( $post->post_type !== 'page' ) { | |
| 15 | + return $states; | |
| 16 | + } | |
| 17 | + | |
| 18 | + $pages = []; | |
| 19 | + if ( property_exists( $GLOBALS['ablocks_settings'] ?? '', 'login_page' ) ) { | |
| 20 | + $pages[ $GLOBALS['ablocks_settings']->login_page ] = 'login_page'; | |
| 21 | + } | |
| 22 | + if ( property_exists( $GLOBALS['ablocks_settings'] ?? '', 'registration_page' ) ) { | |
| 23 | + $pages[ $GLOBALS['ablocks_settings']->registration_page ] = 'registration_page'; | |
| 24 | + } | |
| 25 | + if ( property_exists( $GLOBALS['ablocks_settings'] ?? '', 'forget_password_page' ) ) { | |
| 26 | + $pages[ $GLOBALS['ablocks_settings']->forget_password_page ] = 'forget_password_page'; | |
| 27 | + } | |
| 28 | + $page_type = get_post_meta( $post->ID, 'ablock_page_type', true ); | |
| 29 | + if ( | |
| 30 | + ! empty( $page_type ) | |
| 31 | + ) { | |
| 32 | + $states[] = esc_html( str_replace( '_', ' ', ucfirst( $page_type ) ) . ' page' ); | |
| 33 | + } elseif ( | |
| 34 | + array_key_exists( $post->ID, $pages ) | |
| 35 | + ) { | |
| 36 | + $states[] = esc_html( str_replace( '_', ' ', ucfirst( $pages[ $post->ID ] ) ) . ' page' ); | |
| 37 | + } | |
| 38 | + | |
| 39 | + return $states; | |
| 40 | + } | |
| 41 | + | |
| 42 | +} | |