| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) { |
| 2 |
die; } // Cannot access directly. |
| 3 |
/** |
| 4 |
* |
| 5 |
* Field: upload |
| 6 |
* |
| 7 |
* @since 1.0.0 |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
if ( ! class_exists( 'SP_PC_Fields_upload' ) ) { |
| 11 |
class SP_PC_Fields_upload extends SP_PC_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 |
$args = wp_parse_args( |
| 20 |
$this->field, |
| 21 |
array( |
| 22 |
'library' => array(), |
| 23 |
'button_title' => esc_html__( 'Upload', 'smart-post-show' ), |
| 24 |
'remove_title' => esc_html__( 'Remove', 'smart-post-show' ), |
| 25 |
) |
| 26 |
); |
| 27 |
|
| 28 |
echo $this->field_before(); |
| 29 |
|
| 30 |
$library = ( is_array( $args['library'] ) ) ? $args['library'] : array_filter( (array) $args['library'] ); |
| 31 |
$library = ( ! empty( $library ) ) ? implode( ',', $library ) : ''; |
| 32 |
$hidden = ( empty( $this->value ) ) ? ' hidden' : ''; |
| 33 |
|
| 34 |
echo '<div class="spf--wrap">'; |
| 35 |
echo '<input type="text" name="' . $this->field_name() . '" value="' . $this->value . '"' . $this->field_attributes() . '/>'; |
| 36 |
echo '<a href="#" class="button button-primary spf--button" data-library="' . esc_attr( $library ) . '">' . $args['button_title'] . '</a>'; |
| 37 |
echo '<a href="#" class="button button-secondary spf-warning-primary spf--remove' . $hidden . '">' . $args['remove_title'] . '</a>'; |
| 38 |
echo '</div>'; |
| 39 |
|
| 40 |
echo $this->field_after(); |
| 41 |
|
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|