PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
ablocks / includes / create-page / page / show-page-state.php

show-page-state.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.14.0, at includes/create-page/page/show-page-state.php

43 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
43