slug ); add_filter( 'post_row_actions', array( $this, 'post_row_actions' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'list_tables_style' ) ); } /** * Register the custom post type. * * @return void */ public function register_post_type() { $labels = array( 'name' => _x( 'Custom Blocks', 'post type general name', 'advanced-custom-blocks' ), 'singular_name' => _x( 'Custom Block', 'post type singular name', 'advanced-custom-blocks' ), 'menu_name' => _x( 'Custom Blocks', 'admin menu', 'advanced-custom-blocks' ), 'name_admin_bar' => _x( 'Custom Block', 'add new on admin bar', 'advanced-custom-blocks' ), 'add_new' => _x( 'Add New', 'book', 'advanced-custom-blocks' ), 'add_new_item' => __( 'Add New Custom Block', 'advanced-custom-blocks' ), 'new_item' => __( 'New Custom Block', 'advanced-custom-blocks' ), 'edit_item' => __( 'Edit Custom Block', 'advanced-custom-blocks' ), 'view_item' => __( 'View Custom Block', 'advanced-custom-blocks' ), 'all_items' => __( 'Custom Blocks', 'advanced-custom-blocks' ), 'search_items' => __( 'Search Custom Blocks', 'advanced-custom-blocks' ), 'parent_item_colon' => __( 'Parent Custom Blocks:', 'advanced-custom-blocks' ), 'not_found' => __( 'No custom blocks found.', 'advanced-custom-blocks' ), 'not_found_in_trash' => __( 'No custom blocks found in Trash.', 'advanced-custom-blocks' ) ); $args = array( 'labels' => $labels, 'public' => false, 'show_ui' => true, 'show_in_menu' => 'acb', 'query_var' => true, 'rewrite' => array( 'slug' => 'acb_block' ), 'capability_type' => 'post', 'supports' => array( 'title' ) ); register_post_type( $this->slug, $args ); } /** * Enqueue scripts and styles used by the Block post type. * * @return void */ public function enqueue_scripts() { $screen = get_current_screen(); if ( ! is_object( $screen ) ) { return; } // Enqueue scripts and styles on the edit screen of the Block post type. if ( $this->slug === $screen->post_type && 'post' === $screen->base ) { wp_enqueue_style( 'block-post', $this->plugin->get_url( 'css/admin.block-post.css' ), array(), filemtime( $this->plugin->get_path( 'css/admin.block-post.css' ) ) ); wp_enqueue_script( 'block-post', $this->plugin->get_url( 'js/admin.block-post.js' ), array( 'jquery', 'jquery-ui-sortable', 'wp-util', 'wp-blocks' ), filemtime( $this->plugin->get_path( 'js/admin.block-post.js' ) ) ); } } /** * Add meta boxes. * * @return void */ public function add_meta_boxes() { add_meta_box( 'acb_block_properties', __( 'Block Properties', 'advanced-custom-blocks' ), array( $this, 'render_properties_meta_box' ), $this->slug, 'normal', 'high' ); add_meta_box( 'acb_block_fields', __( 'Block Fields', 'advanced-custom-blocks' ), array( $this, 'render_fields_meta_box' ), $this->slug, 'normal', 'high' ); add_meta_box( 'acb_block_template', __( 'Template', 'advanced-custom-blocks' ), array( $this, 'render_template_meta_box' ), $this->slug, 'side', 'default' ); } /** * Render the Block Fields meta box. * * @return void */ public function render_properties_meta_box() { global $post; $block = new Custom_Block( $post->ID ); ?>
|
|
|
|
|
|
|
|
|
| fields as $field ) { $this->render_fields_meta_box_row( $field, uniqid() ); } ?> | |||
post_name . '.php'; $parent_template = str_replace( get_theme_root(), '', get_template_directory() ) . '/blocks/block-' . $post->post_name . '.php'; if ( $child_template !== $parent_template ) { ?>
post_name . '.php'; $parent_template = str_replace( get_theme_root(), '', get_template_directory() ) . '/blocks/block-' . $post->post_name . '.php'; if ( $child_template !== $parent_template ) { ?>