esc_html_x( 'Page Headers', 'advanced-header general name', 'astra-addon' ), 'singular_name' => esc_html_x( 'Page Header', 'advanced-header singular name', 'astra-addon' ), 'search_items' => esc_html__( 'Search Page Header', 'astra-addon' ), 'all_items' => esc_html__( 'All Page Headers', 'astra-addon' ), 'edit_item' => esc_html__( 'Edit Page Header', 'astra-addon' ), 'add_new' => esc_html__( 'Add New', 'astra-addon' ), 'update_item' => esc_html__( 'Update Page Header', 'astra-addon' ), 'add_new_item' => esc_html__( 'Add New', 'astra-addon' ), 'new_item_name' => esc_html__( 'New Page Header Name', 'astra-addon' ), ); $args = array( 'labels' => $labels, 'show_in_menu' => false, 'public' => false, 'show_ui' => true, 'query_var' => true, 'can_export' => true, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'exclude_from_search' => true, 'supports' => apply_filters( 'astra_advanced_headers_supports', array( 'title' ) ), ); register_post_type( 'astra_adv_header', apply_filters( 'astra_advanced_headers_post_type_args', $args ) ); } /** * Enqueues scripts and styles for the theme layout * post type on the WordPress admin edit post screen. * * @since 1.0.0 * @return void */ public function admin_enqueue_scripts() { global $pagenow; global $post; $screen = get_current_screen(); if ( ( ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) && 'astra_adv_header' == $screen->post_type ) || ( 'astra_adv_header' == $screen->post_type && 'edit.php' === $pagenow ) ) { $rtl = ''; if ( is_rtl() ) { $rtl = '-rtl'; } // Styles. wp_enqueue_media(); /** * Localize wp-color-picker & wpColorPickerL10n. * * This is only needed in WordPress version >= 5.5 because wpColorPickerL10n has been removed. * * @see https://github.com/WordPress/WordPress/commit/7e7b70cd1ae5772229abb769d0823411112c748b * * This is should be removed once the issue is fixed from wp-color-picker-alpha repo. * @see https://github.com/kallookoo/wp-color-picker-alpha/issues/35 * * @since 2.6.3 */ global $wp_version; if ( version_compare( $wp_version, '5.4.99', '>=' ) ) { wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', array( 'clear' => __( 'Clear', 'astra-addon' ), 'clearAriaLabel' => __( 'Clear color', 'astra-addon' ), 'defaultString' => __( 'Default', 'astra-addon' ), 'defaultAriaLabel' => __( 'Select default color', 'astra-addon' ), 'pick' => __( 'Select Color', 'astra-addon' ), 'defaultLabel' => __( 'Color value', 'astra-addon' ), ) ); } // Scripts. if ( SCRIPT_DEBUG ) { wp_enqueue_style( 'astra-advanced-headers-admin-edit', ASTRA_ADDON_EXT_ADVANCED_HEADERS_URL . 'assets/css/unminified/astra-advanced-headers-admin-edit' . $rtl . '.css', array( 'wp-color-picker' ), ASTRA_EXT_VER ); wp_enqueue_script( 'astra-advanced-headers-admin', ASTRA_ADDON_EXT_ADVANCED_HEADERS_URL . 'assets/js/unminified/astra-advanced-headers-admin.js', array( 'jquery', 'wp-color-picker', 'astra-color-alpha', 'jquery-ui-tooltip' ), ASTRA_EXT_VER, false ); } else { wp_enqueue_style( 'astra-advanced-headers-admin-edit', ASTRA_ADDON_EXT_ADVANCED_HEADERS_URL . 'assets/css/minified/astra-advanced-headers-admin-edit' . $rtl . '.min.css', array( 'wp-color-picker' ), ASTRA_EXT_VER ); wp_enqueue_script( 'astra-advanced-headers-admin', ASTRA_ADDON_EXT_ADVANCED_HEADERS_URL . 'assets/js/minified/astra-advanced-headers-admin.min.js', array( 'jquery', 'wp-color-picker', 'astra-color-alpha', 'jquery-ui-tooltip' ), ASTRA_EXT_VER, false ); } wp_localize_script( 'astra-advanced-headers-admin', 'astraPageHeaderVars', apply_filters( 'astra_addon_page_headers_edit_localization', array( 'home_slug' => apply_filters( 'astra_theme_page_slug', 'astra' ), ) ) ); } if ( 'astra_adv_header' == $screen->post_type && 'edit.php' === $pagenow ) { wp_enqueue_style( 'astra-admin-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap', array(), ASTRA_EXT_VER ); // Styles. if ( defined( 'ASTRA_THEME_ADMIN_URL' ) && ASTRA_THEME_ADMIN_URL ) { wp_enqueue_style( 'astra-admin-dashboard-app', ASTRA_THEME_ADMIN_URL . 'assets/build/dashboard-app.css', null, ASTRA_EXT_VER ); } wp_enqueue_style( 'astra-addon-admin-dashboard-app', ASTRA_EXT_URI . 'admin/core/assets/css/admin-custom.css', null, ASTRA_EXT_VER ); } } /** * HTML Template for custom layout header preview. * * @since 4.0.0 */ public function ast_advanced_admin_top_header() { $screen = get_current_screen(); global $pagenow; if ( 'astra_adv_header' === $screen->post_type && 'edit.php' === $pagenow ) { $title = __( 'Page Headers', 'astra-addon' ); $tabs = false; $button_url = '/post-new.php?post_type=astra_adv_header'; $kb_docs_url = 'https://wpastra.com/docs-category/astra-pro-modules/page-headers/?utm_source=wp&utm_medium=dashboard'; Astra_Addon_Admin_Loader::admin_dashboard_header( $title, $tabs, $button_url, $kb_docs_url ); } } /** * Add Update messages for any custom post type * * @param array $messages Array of default messages. */ public function custom_post_type_post_update_messages( $messages ) { $custom_post_type = get_post_type( get_the_ID() ); if ( 'astra_adv_header' == $custom_post_type ) { $obj = get_post_type_object( $custom_post_type ); $singular_name = $obj->labels->singular_name; $messages[ $custom_post_type ] = array( 0 => '', // Unused. Messages start at index 1. /* translators: %s: singular custom post type name */ 1 => sprintf( __( '%s updated.', 'astra-addon' ), $singular_name ), /* translators: %s: singular custom post type name */ 2 => sprintf( __( 'Custom %s updated.', 'astra-addon' ), $singular_name ), /* translators: %s: singular custom post type name */ 3 => sprintf( __( 'Custom %s deleted.', 'astra-addon' ), $singular_name ), /* translators: %s: singular custom post type name */ 4 => sprintf( __( '%s updated.', 'astra-addon' ), $singular_name ), /* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */ 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'astra-addon' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, // phpcs:ignore WordPress.Security.NonceVerification.Recommended /* translators: %s: singular custom post type name */ 6 => sprintf( __( '%s published.', 'astra-addon' ), $singular_name ), /* translators: %s: singular custom post type name */ 7 => sprintf( __( '%s saved.', 'astra-addon' ), $singular_name ), /* translators: %s: singular custom post type name */ 8 => sprintf( __( '%s submitted.', 'astra-addon' ), $singular_name ), /* translators: %s: singular custom post type name */ 9 => sprintf( __( '%s scheduled for.', 'astra-addon' ), $singular_name ), /* translators: %s: singular custom post type name */ 10 => sprintf( __( '%s draft updated.', 'astra-addon' ), $singular_name ), ); } return $messages; } /** * Adds or removes list table column headings. * * @param array $columns Array of columns. * @return array */ public static function column_headings( $columns ) { unset( $columns['date'] ); $columns['advanced_headers_display_rules'] = __( 'Display Rules', 'astra-addon' ); $columns['date'] = __( 'Date', 'astra-addon' ); return $columns; } /** * Adds the custom list table column content. * * @since 1.0 * @param array $column Name of column. * @param int $post_id Post id. * @return void */ public function column_content( $column, $post_id ) { if ( 'advanced_headers_display_rules' == $column ) { $locations = get_post_meta( $post_id, 'ast-advanced-headers-location', true ); if ( ! empty( $locations ) ) { echo '