_label, // Already translated. 'singular_name' => $singular_label, // Already translated. 'all_items' => sprintf( __( 'All %s', 'elementor' ), $plural_label ), 'add_new' => esc_html__( 'Add New', 'elementor' ), 'add_new_item' => sprintf( __( 'Add New %s', 'elementor' ), $singular_label ), 'edit_item' => sprintf( __( 'Edit %s', 'elementor' ), $singular_label ), 'new_item' => sprintf( __( 'New %s', 'elementor' ), $singular_label ), 'view_item' => sprintf( __( 'View %s', 'elementor' ), $singular_label ), 'search_items' => sprintf( __( 'Search %s', 'elementor' ), $plural_label ), 'not_found' => sprintf( __( 'No %s found.', 'elementor' ), strtolower( $plural_label ) ), 'not_found_in_trash' => sprintf( __( 'No %s found in Trash.', 'elementor' ), strtolower( $plural_label ) ), 'parent_item_colon' => '', 'menu_name' => $plural_label, ]; return $labels; } /** * @since 2.0.0 * @access public * @static * @param Document $document */ public static function register_post_fields_control( $document ) { $document->start_injection( [ 'of' => 'post_status', 'fallback' => [ 'of' => 'post_title', ], ] ); if ( post_type_supports( $document->post->post_type, 'excerpt' ) ) { $document->add_control( 'post_excerpt', [ 'label' => esc_html__( 'Excerpt', 'elementor' ), 'type' => Controls_Manager::TEXTAREA, 'default' => $document->post->post_excerpt, 'separator' => 'before', 'ai' => [ 'type' => 'excerpt', ], ] ); } if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( $document->post->post_type, 'thumbnail' ) ) { $document->add_control( 'post_featured_image', [ 'label' => esc_html__( 'Featured Image', 'elementor' ), 'type' => Controls_Manager::MEDIA, 'default' => [ 'id' => get_post_thumbnail_id(), 'url' => (string) get_the_post_thumbnail_url( $document->post->ID ), ], 'separator' => 'before', ] ); } if ( is_post_type_hierarchical( $document->post->post_type ) ) { $document->add_control( 'menu_order', [ 'label' => esc_html__( 'Order', 'elementor' ), 'type' => Controls_Manager::NUMBER, 'default' => $document->post->menu_order, 'separator' => 'before', ] ); } if ( post_type_supports( $document->post->post_type, 'comments' ) ) { $document->add_control( 'comment_status', [ 'label' => esc_html__( 'Allow Comments', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'open', 'default' => $document->post->comment_status, 'separator' => 'before', ] ); } $document->end_injection(); } /** * @since 2.0.0 * @access public * * @param array $data * * @throws \Exception Exception If the post ID is not set. */ public function __construct( array $data = [] ) { if ( $data ) { $template = get_post_meta( $data['post_id'], '_wp_page_template', true ); if ( empty( $template ) ) { $template = 'default'; } $data['settings']['template'] = $template; } parent::__construct( $data ); } protected function get_remote_library_config() { $config = parent::get_remote_library_config(); $config['category'] = ''; $config['type'] = 'block'; $config['default_route'] = 'templates/blocks'; return $config; } }