balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

Metabox.php (2847B)


      1 <?php
      2 namespace welbim\Helper\Admin\Metabox;
      3 
      4 class Metabox {
      5 
      6 
      7 
      8 	/**
      9 	 * Initialize the class
     10 	 */
     11 	function __construct() {
     12 		// Register the post type
     13 		add_filter( 'rwmb_meta_boxes', array( $this, 'welbim_register_framework_post_meta_box' ) );
     14 	}
     15 
     16 
     17 	/**
     18 	 * Register meta boxes
     19 	 *
     20 	 * Remember to change "your_prefix" to actual prefix in your project
     21 	 *
     22 	 * @return void
     23 	 */
     24 	function welbim_register_framework_post_meta_box( $meta_boxes ) {
     25 
     26 		global $wp_registered_sidebars;
     27 
     28 		/**
     29 		 * prefix of meta keys (optional)
     30 		 * Use underscore (_) at the beginning to make keys hidden
     31 		 * Alt.: You also can make prefix empty to disable it
     32 		 */
     33 		// Better has an underscore as last sign
     34 
     35 		$sidebars = array();
     36 
     37 		foreach ( $wp_registered_sidebars as $key => $value ) {
     38 			$sidebars[ $key ] = $value['name'];
     39 		}
     40 
     41 		$opacities = array();
     42 		for ( $o = 0.0, $n = 0; $o <= 1.0; $o += 0.1, $n++ ) {
     43 			$opacities[ $n ] = $o;
     44 		}
     45 		$prefix     = 'welbim_core';
     46 		$posts_page = get_option( 'page_for_posts' );
     47 		if ( ! isset( $_GET['post'] ) || intval( $_GET['post'] ) != $posts_page ) {
     48 			$meta_boxes[] = array(
     49 				'id'       => $prefix . '_page_wiget_meta_box',
     50 				'title'    => esc_html__( 'Page Settings', 'welbim' ),
     51 				'pages'    => array(
     52 					'page',
     53 				),
     54 				'context'  => 'normal',
     55 				'priority' => 'core',
     56 				'fields'   => array(
     57 					array(
     58 						'name'    => 'Header Style',
     59 						'id'      => "{$prefix}_header_style",
     60 						'type'    => 'select',
     61 						'options' => array(
     62 							'1' => 'Header 01',
     63 							'2' => 'Header 02',
     64 							'3' => 'Header 03',
     65 							'4' => 'Header 04',
     66 						),
     67 					),
     68 					array(
     69 						'id'      => "{$prefix}_show_breadcrumb",
     70 						'name'    => esc_html__( 'show breadcrumb', 'welbim' ),
     71 						'desc'    => '',
     72 						'type'    => 'radio',
     73 						'std'     => 'on',
     74 						'options' => array(
     75 							'on'  => 'on',
     76 							'off' => 'off',
     77 						),
     78 					),
     79 					array(
     80 						'name'    => 'Enable Sidebar',
     81 						'id'      => "{$prefix}_page_col",
     82 						'desc'    => '',
     83 						'type'    => 'radio',
     84 						'std'     => 'off',
     85 						'options' => array(
     86 							'on'  => 'on',
     87 							'off' => 'off',
     88 						),
     89 					),
     90 					array(
     91 						'name'            => 'Left widget for page',
     92 						'id'              => "{$prefix}_page_widget_left",
     93 						'type'            => 'select',
     94 						'options'         => welbim_sidebar_list(),
     95 						'multiple'        => false,
     96 						'placeholder'     => 'Select an Item',
     97 						'select_all_none' => false,
     98 					),
     99 					array(
    100 						'id'      => "{$prefix}_page_widget_left_right",
    101 						'name'    => esc_html__( 'Page widget left or right', 'welbim' ),
    102 						'desc'    => '',
    103 						'type'    => 'radio',
    104 						'std'     => 'left',
    105 						'options' => array(
    106 							'left'  => 'Left',
    107 							'right' => 'right',
    108 						),
    109 					),
    110 				),
    111 			);
    112 		}
    113 		return $meta_boxes;
    114 	}
    115 }