post_type, __( 'Help & Demos - Advanced Posts', 'advanced-post-block' ), __( 'Help & Demos', 'advanced-post-block' ), 'manage_options', 'advanced-post-block', [ \APBPlugin::class, 'renderDashboard' ] ); } function adminEnqueueScripts( $hook ){ if( 'edit.php' === $hook || 'post.php' === $hook ){ wp_enqueue_style( 'apb-admin-post', APB_DIR_URL . 'build/admin/post.css', [], APB_VERSION ); wp_enqueue_script( 'apb-admin-post', APB_DIR_URL . 'build/admin/post.js', [], APB_VERSION, true ); wp_set_script_translations( 'apb-admin-post', 'advanced-post-block', APB_DIR_PATH . 'languages' ); } } function onInit(){ $menuIcon = ""; register_post_type( $this->post_type, [ 'labels' => [ 'name' => __( 'Advanced Posts', 'advanced-post-block' ), 'singular_name' => __( 'ShortCode', 'advanced-post-block' ), 'all_items' => __( 'ShortCode Generator', 'advanced-post-block' ), 'add_new' => __( 'Add New ShortCode', 'advanced-post-block' ), 'add_new_item' => __( 'Add New ShortCode', 'advanced-post-block' ), 'edit_item' => __( 'Edit ShortCode', 'advanced-post-block' ), 'new_item' => __( 'New ShortCode', 'advanced-post-block' ), 'view_item' => __( 'View ShortCode', 'advanced-post-block' ), 'search_items' => __( 'Search ShortCode', 'advanced-post-block' ), 'not_found' => __( 'Sorry, we couldn\'t find the ShortCode 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 ); global $allowedposttags; $allowed_html = wp_parse_args( ['style' => [] ], $allowedposttags ); return wp_kses( render_block( $blocks[0] ), $allowed_html ); } 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 '