1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php // Prevent loading this file directly defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'RWMB_Group' ) ) { /** * Extension main class. */ class RWMB_Group { /** * Indicate that the meta box is saved or not. * This variable is used inside group field to show child fields. * * @var bool */ static $saved = false;
/** * Add hooks to meta box. */ public function __construct() { /** * Hook to 'init' with priority 5 to make sure all actions are registered before Meta Box 4.9.0 runs */ add_action( 'init', array( $this, 'load_files' ), 5 );
add_action( 'rwmb_before', array( $this, 'set_saved' ) ); add_action( 'rwmb_after', array( $this, 'unset_saved' ) ); }
/** * Load field group class. */ public function load_files() { if ( class_exists( 'RWMB_Field' ) && ! class_exists( 'RWMB_Group_Field' ) ) { require plugin_dir_path( __FILE__ ) . 'class-group-field.php'; } }
/** * Check if current meta box is saved. * This variable is used inside group field to show child fields. * * @param object $obj Meta Box object */ public function set_saved( $obj ) { self::$saved = $obj->is_saved(); }
/** * Unset 'saved' variable, to be ready for next meta box. */ public function unset_saved() { self::$saved = false; } }
new RWMB_Group; }
|