| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) { |
| 2 |
die; } // Cannot access directly. |
| 3 |
/** |
| 4 |
* |
| 5 |
* Field: textarea |
| 6 |
* |
| 7 |
* @since 1.0.0 |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
if ( ! class_exists( 'DRK_LITE_Field_textarea' ) ) { |
| 11 |
class DRK_LITE_Field_textarea extends DRK_LITE_Fields { |
| 12 |
|
| 13 |
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 14 |
parent::__construct( $field, $value, $unique, $where, $parent ); |
| 15 |
} |
| 16 |
|
| 17 |
public function render() { |
| 18 |
|
| 19 |
echo wp_kses_post( $this->field_before() ); |
| 20 |
echo esc_html( $this->shortcoder() ); |
| 21 |
echo '<textarea name="' . esc_attr( $this->field_name() ) . '"' . wp_kses_post( $this->field_attributes() ) . '>' . wp_kses_post($this->value) . '</textarea>'; |
| 22 |
echo wp_kses_post( $this->field_after() ); |
| 23 |
} |
| 24 |
|
| 25 |
public function shortcoder() { |
| 26 |
|
| 27 |
if ( ! empty( $this->field['shortcoder'] ) ) { |
| 28 |
|
| 29 |
$shortcodes = ( is_array( $this->field['shortcoder'] ) ) ? $this->field['shortcoder'] : array_filter( (array) $this->field['shortcoder'] ); |
| 30 |
$instances = ( ! empty( DRK_LITE::$shortcode_instances ) ) ? DRK_LITE::$shortcode_instances : array(); |
| 31 |
|
| 32 |
if ( ! empty( $shortcodes ) && ! empty( $instances ) ) { |
| 33 |
|
| 34 |
foreach ( $shortcodes as $shortcode ) { |
| 35 |
|
| 36 |
foreach ( $instances as $instance ) { |
| 37 |
|
| 38 |
if ( $instance['modal_id'] === $shortcode ) { |
| 39 |
|
| 40 |
$id = $instance['modal_id']; |
| 41 |
$title = $instance['button_title']; |
| 42 |
|
| 43 |
echo '<a href="#" class="button button-primary drk_lite-shortcode-button" data-modal-id="' . esc_attr( $id ) . '">' . esc_html( $title ) . '</a>'; |
| 44 |
|
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
|