1 | <?php |
||
10 | class SettingsMetaBox extends RW_Meta_Box |
||
11 | { |
||
12 | public function __construct( $metabox ) |
||
13 | { |
||
14 | parent::__construct( $metabox ); |
||
15 | $this->meta_box = static::normalize( $this->meta_box ); |
||
16 | remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] ); |
||
17 | |||
18 | add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
||
19 | add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @param mixed $meta |
||
24 | * @param bool $meta |
||
25 | * @return mixed |
||
26 | */ |
||
27 | public function _get_field_meta( $meta, array $field, $saved ) |
||
28 | { |
||
29 | if( !$this->is_edit_screen() || !empty( $meta ) || empty( $field['slug'] )) { |
||
30 | return $meta; |
||
31 | } |
||
32 | $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
||
33 | ? (new SiteMeta)->get( $this->meta_box['slug'], $field['slug'], $meta ) |
||
34 | : $field['std'] |
||
35 | )); |
||
36 | return $this->_normalize_field_meta( $meta, $field ); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param mixed $meta |
||
41 | * @return array |
||
42 | */ |
||
43 | public function _normalize_field_meta( $meta, array $field ) |
||
56 | |||
57 | /** |
||
58 | * @return void |
||
59 | */ |
||
60 | public function add_meta_boxes() |
||
71 | |||
72 | /** |
||
73 | * @return bool |
||
74 | */ |
||
75 | public function is_edit_screen( $screen = null ) |
||
79 | |||
80 | /** |
||
81 | * @return bool |
||
82 | */ |
||
83 | public function is_saved() |
||
92 | |||
93 | /** |
||
94 | * @param array $metabox |
||
95 | * @return array |
||
96 | */ |
||
97 | public static function normalize( $metabox ) |
||
102 | } |
||
103 |