"; register_post_type( 'apb', [ 'labels' => [ 'name' => __( 'Advanced Posts', 'advanced-post-block'), 'singular_name' => __( 'Advanced Posts', 'advanced-post-block' ), 'add_new' => __( 'Add New', 'advanced-post-block' ), 'add_new_item' => __( 'Add New', 'advanced-post-block' ), 'edit_item' => __( 'Edit', 'advanced-post-block' ), 'new_item' => __( 'New', 'advanced-post-block' ), 'view_item' => __( 'View', 'advanced-post-block' ), 'search_items' => __( 'Search', 'advanced-post-block'), 'not_found' => __( 'Sorry, we couldn\'t find the that you are looking for.', 'advanced-post-block' ) ], 'public' => false, 'show_ui' => true, 'show_in_rest' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'menu_position' => 14, 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode( $menuIcon ), 'has_archive' => false, 'hierarchical' => false, 'capability_type' => 'page', 'rewrite' => [ 'slug' => 'apb' ], 'supports' => [ 'title', 'editor' ], 'template' => [ ['ap-block/posts'] ], 'template_lock' => 'all', ]); // Register Post Type } function onAddShortcode( $atts ) { $post_id = $atts['id']; $post = get_post( $post_id ); if ( !$post ) { return ''; } if ( post_password_required( $post ) ) { return get_the_password_form( $post ); } switch ( $post->post_status ) { case 'publish': return $this->displayContent( $post ); case 'private': if (current_user_can('read_private_posts')) { return $this->displayContent( $post ); } return ''; case 'draft': case 'pending': case 'future': if ( current_user_can( 'edit_post', $post_id ) ) { return $this->displayContent( $post ); } return ''; default: return ''; } } function displayContent( $post ){ $blocks = parse_blocks( $post->post_content ); return render_block( $blocks[0] ); } function manageAPBPostsColumns( $defaults ) { unset( $defaults['date'] ); $defaults['shortcode'] = 'ShortCode'; $defaults['date'] = 'Date'; return $defaults; } function manageAPBPostsCustomColumns( $column_name, $post_ID ) { if ( $column_name == 'shortcode' ) { echo '
' . esc_html__( 'Copy To Clipboard' ) . '
'; } } function useBlockEditorForPost($use, $post){ if ( $this->post_type === $post->post_type ) { return true; } return $use; } function orderSubMenu( $menu_ord ){ global $submenu; $sMenu = $submenu['edit.php?post_type=apb'] ?? []; $arr = []; if( apbIsPremium() ){ if( isset( $sMenu[5] ) ){ $arr[] = $sMenu[5]; // Advanced Posts } if( isset( $sMenu[10] ) ){ $arr[] = $sMenu[10]; // Add New } } if( isset( $sMenu[11] ) ){ $arr[] = $sMenu[11]; // Help } if( ( !apbIsPremium() || APB_HAS_PRO ) && isset( $sMenu[12] ) ){ $arr[] = $sMenu[12]; // Upgrade || Pricing || Account } $submenu['edit.php?post_type=apb'] = $arr; return $menu_ord; } } new APBCustomPost();