| 1 |
<?php |
| 2 |
namespace Enteraddons\Core; |
| 3 |
/** |
| 4 |
* Enteraddons Post Type Meta class |
| 5 |
* |
| 6 |
* @package EnterAddons Pro |
| 7 |
* @author ThemeLooks |
| 8 |
* @copyright 2022 ThemeLooks |
| 9 |
* @license GPL-2.0-or-later |
| 10 |
* |
| 11 |
* |
| 12 |
*/ |
| 13 |
|
| 14 |
trait Text { |
| 15 |
|
| 16 |
protected static $args; |
| 17 |
|
| 18 |
protected static $type = ''; |
| 19 |
|
| 20 |
public function text_meta( $args ) { |
| 21 |
self::$type = 'meta'; |
| 22 |
$this->text( $args ); |
| 23 |
} |
| 24 |
|
| 25 |
public function text( $args ) { |
| 26 |
|
| 27 |
$default = [ |
| 28 |
'title' => '', |
| 29 |
'name' => '', |
| 30 |
'description' => '', |
| 31 |
'placeholder' => '', |
| 32 |
'wrapperclass' => '', |
| 33 |
'class' => '', |
| 34 |
'condition' => '' |
| 35 |
]; |
| 36 |
|
| 37 |
self::$args = wp_parse_args( $args, $default ); |
| 38 |
self::text_markup(); |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
protected static function text_markup() { |
| 43 |
|
| 44 |
$args = self::$args; |
| 45 |
$uniqName = $args['name']; |
| 46 |
|
| 47 |
if( self::$type != 'meta' ) { |
| 48 |
$wrapTypeClass = ''; |
| 49 |
$optionName = self::$optionName; |
| 50 |
$getData = self::$getOptionData; |
| 51 |
$fieldName = esc_attr( $optionName ).'['.$uniqName.']'; |
| 52 |
$value = !empty( $getData[$uniqName] ) ? $getData[$uniqName] : ''; |
| 53 |
|
| 54 |
} else { |
| 55 |
$wrapTypeClass = 'ea-meta-field '; |
| 56 |
$fieldName = $uniqName; |
| 57 |
$value = get_post_meta( get_the_ID(), $uniqName, true ); |
| 58 |
} |
| 59 |
|
| 60 |
$conditionData = ''; |
| 61 |
if( !empty( $args['condition'] ) ) { |
| 62 |
$conditionData = wp_json_encode( $args['condition'] ); |
| 63 |
} |
| 64 |
?> |
| 65 |
<div class="eap-admin-field <?php echo esc_attr( $args['wrapperclass'] ); ?>" data-condition="<?php echo esc_html($conditionData); ?>"> |
| 66 |
<h4><?php echo esc_html( $args['title'] ); ?></h4> |
| 67 |
<div class="fb-field-group"> |
| 68 |
<input type="text" class="<?php echo esc_attr( $args['class'] ); ?>" name="<?php echo esc_attr( $fieldName ); ?>" placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" value="<?php echo esc_attr( $value ); ?>" /> |
| 69 |
<?php |
| 70 |
if( !empty( $args['description'] ) ) { |
| 71 |
echo '<p>'. esc_html( $args['description'] ) .'</p>'; |
| 72 |
} |
| 73 |
?> |
| 74 |
</div> |
| 75 |
</div> |
| 76 |
<?php |
| 77 |
} |
| 78 |
} |
| 79 |
|