ID ); $template_type = isset( $values['aiea_hf_template_type'] ) ? esc_attr( $values['aiea_hf_template_type'][0] ) : ''; $canvas_enable = get_post_meta( $post->ID, 'aiea_hf_canvas_enable', true ); // We'll use this nonce field later on when saving. wp_nonce_field( 'aiea_hf_meta_nounce', 'aiea_hf_meta_nounce' ); ?> display_rules_tab(); ?>
__( 'Display Rules', 'ai-addons' ), 'value' => '[{"type":"basic-global","specific":null}]', 'tags' => 'site,enable,target,pages', 'rule_type' => 'display', 'add_rule_label' => __( 'Add Display Rule', 'ai-addons' ), ], $include_locations ); ?>
__( 'Exclude On', 'ai-addons' ), 'value' => '[]', 'tags' => 'site,enable,target,pages', 'add_rule_label' => __( 'Add Exclusion Rule', 'ai-addons' ), 'rule_type' => 'exclude', ], $exclude_locations ); ?>
__( 'Users', 'ai-addons' ), 'value' => '[]', 'tags' => 'site,enable,target,pages', 'add_rule_label' => __( 'Add User Rule', 'ai-addons' ), ], $users ); ?> __( 'AI Elementor Header & Footer Builder', 'ai-addons' ), 'singular_name' => __( 'AI Elementor Header & Footer Builder', 'ai-addons' ), 'menu_name' => __( 'AI Elementor Header & Footer Builder', 'ai-addons' ), 'name_admin_bar' => __( 'AI Elementor Header & Footer Builder', 'ai-addons' ), 'add_new' => __( 'Add New', 'ai-addons' ), 'add_new_item' => __( 'Add New Header or Footer', 'ai-addons' ), 'new_item' => __( 'New Template', 'ai-addons' ), 'edit_item' => __( 'Edit Template', 'ai-addons' ), 'view_item' => __( 'View Template', 'ai-addons' ), 'all_items' => __( 'All Templates', 'ai-addons' ), 'search_items' => __( 'Search Templates', 'ai-addons' ), 'parent_item_colon' => __( 'Parent Templates:', 'ai-addons' ), 'not_found' => __( 'No Templates found.', 'ai-addons' ), 'not_found_in_trash' => __( 'No Templates found in Trash.', 'ai-addons' ), ]; $args = [ 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_menu' => false, 'show_in_nav_menus' => false, 'exclude_from_search' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_icon' => 'dashicons-editor-kitchensink', 'supports' => [ 'title', 'elementor' ], ]; register_post_type( 'ai-hf', $args ); flush_rewrite_rules(); } public function register_admin_menu() { add_submenu_page( 'ai-addons', esc_html__( 'Header & Footer Builder', 'ai-addons' ), esc_html__( 'Header Footer', 'ai-addons' ), 'edit_pages', 'edit.php?post_type=ai-hf' ); } /** * Save meta field. * * @param POST $post_id Currennt post object which is being displayed. * * @return Void */ public function aiea_hf_save_meta( $post_id ) { // Bail if we're doing an auto save. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // if our nonce isn't there, or we can't verify it, bail. if ( ! isset( $_POST['aiea_hf_meta_nounce'] ) || ! wp_verify_nonce( $_POST['aiea_hf_meta_nounce'], 'aiea_hf_meta_nounce' ) ) { return; } // if our current user can't edit this post, bail. if ( ! current_user_can( 'edit_posts' ) ) { return; } require_once( AIEA_DIR .'core/header-footer/target-rule/target-rules-fields.php' ); $target_locations = AIEA_Target_Rules_Fields::get_format_rule_value( $_POST, 'ai-target-rules-location' ); $target_exclusion = AIEA_Target_Rules_Fields::get_format_rule_value( $_POST, 'ai-target-rules-exclusion' ); $target_users = []; if ( isset( $_POST['ai-target-rules-users'] ) ) { $target_users = array_map( 'sanitize_text_field', $_POST['ai-target-rules-users'] ); } update_post_meta( $post_id, 'aiea_hf_target_include_locations', $target_locations ); update_post_meta( $post_id, 'aiea_hf_target_exclude_locations', $target_exclusion ); update_post_meta( $post_id, 'aiea_hf_target_user_roles', $target_users ); if ( isset( $_POST['aiea_hf_template_type'] ) ) { update_post_meta( $post_id, 'aiea_hf_template_type', sanitize_text_field( $_POST['aiea_hf_template_type'] ) ); } update_post_meta( $post_id, '_wp_page_template', 'elementor_canvas' ); } } AIEA_Header_Footer_CPT::instance();