From 9d4123cee1867ee7199b06bdc92d40611f547ecc Mon Sep 17 00:00:00 2001 From: Zach van Rijn Date: Wed, 21 Jul 2021 14:54:07 -0500 Subject: Initial unmodified import from Astra (Version: 3.6.5) @ /wp-content/themes/astra/. --- inc/metabox/class-astra-meta-boxes.php | 435 +++++++++++++++++++++++++++++++++ 1 file changed, 435 insertions(+) create mode 100644 inc/metabox/class-astra-meta-boxes.php (limited to 'inc/metabox/class-astra-meta-boxes.php') diff --git a/inc/metabox/class-astra-meta-boxes.php b/inc/metabox/class-astra-meta-boxes.php new file mode 100644 index 0000000..7fe3b87 --- /dev/null +++ b/inc/metabox/class-astra-meta-boxes.php @@ -0,0 +1,435 @@ + array( + 'sanitize' => 'FILTER_DEFAULT', + ), + 'ast-main-header-display' => array( + 'sanitize' => 'FILTER_DEFAULT', + ), + 'ast-hfb-below-header-display' => array( + 'sanitize' => 'FILTER_DEFAULT', + ), + 'ast-hfb-mobile-header-display' => array( + 'sanitize' => 'FILTER_DEFAULT', + ), + 'footer-sml-layout' => array( + 'sanitize' => 'FILTER_DEFAULT', + ), + 'footer-adv-display' => array( + 'sanitize' => 'FILTER_DEFAULT', + ), + 'site-post-title' => array( + 'sanitize' => 'FILTER_DEFAULT', + ), + 'site-sidebar-layout' => array( + 'default' => 'default', + 'sanitize' => 'FILTER_DEFAULT', + ), + 'site-content-layout' => array( + 'default' => 'default', + 'sanitize' => 'FILTER_DEFAULT', + ), + 'ast-featured-img' => array( + 'sanitize' => 'FILTER_DEFAULT', + ), + 'ast-breadcrumbs-content' => array( + 'sanitize' => 'FILTER_DEFAULT', + ), + ) + ); + } + + /** + * Setup Metabox + */ + public function setup_meta_box() { + + // Get all public posts. + $post_types = get_post_types( + array( + 'public' => true, + ) + ); + + $post_types['fl-theme-layout'] = 'fl-theme-layout'; + + $metabox_name = sprintf( + // Translators: %s is the theme name. + __( '%s Settings', 'astra' ), + astra_get_theme_name() + ); + + // Enable for all posts. + foreach ( $post_types as $type ) { + + if ( 'attachment' !== $type ) { + add_meta_box( + 'astra_settings_meta_box', // Id. + $metabox_name, // Title. + array( $this, 'markup_meta_box' ), // Callback. + $type, // Post_type. + 'side', // Context. + 'default' // Priority. + ); + } + } + } + + /** + * Get metabox options + */ + public static function get_meta_option() { + return self::$meta_option; + } + + /** + * Metabox Markup + * + * @param object $post Post object. + * @return void + */ + public function markup_meta_box( $post ) { + + wp_nonce_field( basename( __FILE__ ), 'astra_settings_meta_box' ); + $stored = get_post_meta( $post->ID ); + + if ( is_array( $stored ) ) { + + // Set stored and override defaults. + foreach ( $stored as $key => $value ) { + self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : ''; + } + } + + // Get defaults. + $meta = self::get_meta_option(); + + /** + * Get options + */ + $site_sidebar = ( isset( $meta['site-sidebar-layout']['default'] ) ) ? $meta['site-sidebar-layout']['default'] : 'default'; + $site_content_layout = ( isset( $meta['site-content-layout']['default'] ) ) ? $meta['site-content-layout']['default'] : 'default'; + $site_post_title = ( isset( $meta['site-post-title']['default'] ) ) ? $meta['site-post-title']['default'] : ''; + $footer_bar = ( isset( $meta['footer-sml-layout']['default'] ) ) ? $meta['footer-sml-layout']['default'] : ''; + $footer_widgets = ( isset( $meta['footer-adv-display']['default'] ) ) ? $meta['footer-adv-display']['default'] : ''; + $above_header = ( isset( $meta['ast-hfb-above-header-display']['default'] ) ) ? $meta['ast-hfb-above-header-display']['default'] : 'default'; + $primary_header = ( isset( $meta['ast-main-header-display']['default'] ) ) ? $meta['ast-main-header-display']['default'] : ''; + $below_header = ( isset( $meta['ast-hfb-below-header-display']['default'] ) ) ? $meta['ast-hfb-below-header-display']['default'] : 'default'; + $mobile_header = ( isset( $meta['ast-hfb-mobile-header-display']['default'] ) ) ? $meta['ast-hfb-mobile-header-display']['default'] : 'default'; + $ast_featured_img = ( isset( $meta['ast-featured-img']['default'] ) ) ? $meta['ast-featured-img']['default'] : ''; + $breadcrumbs_content = ( isset( $meta['ast-breadcrumbs-content']['default'] ) ) ? $meta['ast-breadcrumbs-content']['default'] : ''; + + $show_meta_field = ! self::is_bb_themer_layout(); + do_action( 'astra_meta_box_markup_before', $meta ); + + /** + * Option: Sidebar + */ + ?> +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+ +
+ $data ) { + + // Sanitize values. + $sanitize_filter = ( isset( $data['sanitize'] ) ) ? $data['sanitize'] : 'FILTER_DEFAULT'; + + switch ( $sanitize_filter ) { + + case 'FILTER_SANITIZE_STRING': + $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING ); + break; + + case 'FILTER_SANITIZE_URL': + $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_URL ); + break; + + case 'FILTER_SANITIZE_NUMBER_INT': + $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT ); + break; + + default: + $meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT ); + break; + } + + // Store values. + if ( $meta_value ) { + update_post_meta( $post_id, $key, $meta_value ); + } else { + delete_post_meta( $post_id, $key ); + } + } + + } + } +} + +/** + * Kicking this off by calling 'get_instance()' method + */ +Astra_Meta_Boxes::get_instance(); -- cgit v1.2.3-70-g09d2