| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* LP_Meta_Box_Field |
| 5 |
* |
| 6 |
* @author nhamdv |
| 7 |
* @version 1.0.0 |
| 8 |
* @since 4.0.0 |
| 9 |
*/ |
| 10 |
class LP_Meta_Box_Field { |
| 11 |
/** |
| 12 |
* Key id of field |
| 13 |
* |
| 14 |
* @var string |
| 15 |
*/ |
| 16 |
public $id = ''; |
| 17 |
|
| 18 |
/** |
| 19 |
* Label of field |
| 20 |
* |
| 21 |
* @var string |
| 22 |
*/ |
| 23 |
public $label = ''; |
| 24 |
|
| 25 |
/** |
| 26 |
* Description of field |
| 27 |
* |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
public $description = ''; |
| 31 |
|
| 32 |
/** |
| 33 |
* Value default of field |
| 34 |
* |
| 35 |
* @var mixed |
| 36 |
*/ |
| 37 |
public $default; |
| 38 |
|
| 39 |
/** |
| 40 |
* Extra array. |
| 41 |
* |
| 42 |
* @var string $class |
| 43 |
*/ |
| 44 |
public $extra = array(); |
| 45 |
|
| 46 |
/** |
| 47 |
* Condition logic show or hide when checkbox, select or... |
| 48 |
*/ |
| 49 |
public $condition = false; |
| 50 |
|
| 51 |
/** |
| 52 |
* LP_Meta_Box_Attribute constructor. |
| 53 |
* |
| 54 |
* @param string $id |
| 55 |
* @param string $label |
| 56 |
* @param string $description |
| 57 |
* @param mixed $default |
| 58 |
* @param mixed $desc_tip |
| 59 |
* @param mixed $class |
| 60 |
* @param mixed $style |
| 61 |
* @param array $custom_attributes |
| 62 |
*/ |
| 63 |
public function __construct( $label = '', $description = '', $default = '', $extra = array() ) { |
| 64 |
$this->label = $label; |
| 65 |
$this->description = $description; |
| 66 |
$this->default = $default; |
| 67 |
$this->extra = $extra; |
| 68 |
|
| 69 |
$show = ! empty( $extra['show'] ) ? htmlentities( wp_json_encode( $extra['show'] ) ) : false; |
| 70 |
$hide = ! empty( $extra['hide'] ) ? htmlentities( wp_json_encode( $extra['hide'] ) ) : false; |
| 71 |
|
| 72 |
if ( $show ) { |
| 73 |
$this->condition = 'data-show="' . $show . '"'; |
| 74 |
} elseif ( $hide ) { |
| 75 |
$this->condition = 'data-hide="' . $hide . '"'; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
public function meta_value( $thepostid ) { |
| 80 |
return get_post_meta( $thepostid, $this->id, true ); |
| 81 |
} |
| 82 |
|
| 83 |
public function output( $thepostid ) { |
| 84 |
return ''; |
| 85 |
} |
| 86 |
|
| 87 |
public function save( $post_id ) { |
| 88 |
} |
| 89 |
} |
| 90 |
|