PluginProbe
Easy Hotel – Powerful Hotel Booking / 2.0.4
Easy Hotel – Powerful Hotel Booking v2.0.4
2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.9.9 1.9.8 1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 All 110 releases
easy-hotel / admin / includes / framework / fields / link / link.php

link.php in Easy Hotel – Powerful Hotel Booking 2.0.4, at admin/includes/framework/fields/link/link.php

83 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: link
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ESHB_Field_link' ) ) {
11 class ESHB_Field_link extends ESHB_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( $this->field, array(
20 'add_title' => esc_html__( 'Add Link', 'easy-hotel' ),
21 'edit_title' => esc_html__( 'Edit Link', 'easy-hotel' ),
22 'remove_title' => esc_html__( 'Remove Link', 'easy-hotel' ),
23 ) );
24
25 $default_values = array(
26 'url' => '',
27 'text' => '',
28 'target' => '',
29 );
30
31 $value = wp_parse_args( $this->value, $default_values );
32
33 $hidden = ( ! empty( $value['url'] ) || ! empty( $value['url'] ) || ! empty( $value['url'] ) ) ? ' hidden' : '';
34
35 $maybe_hidden = ( empty( $hidden ) ) ? ' hidden' : '';
36
37 echo wp_kses_post($this->field_before());
38
39 echo '<textarea readonly="readonly" class="csf--link hidden"></textarea>';
40
41 echo '<div class="'. esc_attr( $maybe_hidden ) .'"><div class="csf--result">'. sprintf( '{url:"%s", text:"%s", target:"%s"}', esc_url($value['url']), esc_html($value['text']), esc_html($value['target'] )) .'</div></div>';
42
43 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[url]' ) ) .'" value="'. esc_attr( $value['url'] ) .'"'. esc_attr($this->field_attributes( array( 'class' => esc_attr('csf--url' )) )) .' />';
44 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[text]' ) ) .'" value="'. esc_attr( $value['text'] ) .'" class="csf--text" />';
45 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[target]' ) ) .'" value="'. esc_attr( $value['target'] ) .'" class="csf--target" />';
46
47 echo '<a href="#" class="button button-primary csf--add'. esc_attr( $hidden ) .'">'. esc_html($args['add_title']) .'</a> ';
48 echo '<a href="#" class="button csf--edit'. esc_attr( $maybe_hidden ) .'">'. esc_html($args['edit_title']) .'</a> ';
49 echo '<a href="#" class="button csf-warning-primary csf--remove'. esc_attr( $maybe_hidden ) .'">'. esc_html($args['remove_title']) .'</a>';
50
51 echo wp_kses_post($this->field_after());
52
53 }
54
55 public function enqueue() {
56
57 if ( ! wp_script_is( 'wplink' ) ) {
58 wp_enqueue_script( 'wplink' );
59 }
60
61 if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
62 wp_enqueue_script( 'jquery-ui-autocomplete' );
63 }
64
65 add_action( 'admin_print_footer_scripts', array( $this, 'add_wp_link_dialog' ) );
66
67 }
68
69 public function add_wp_link_dialog() {
70
71 if ( ! class_exists( '_WP_Editors' ) ) {
72 require_once ABSPATH . WPINC .'/class-wp-editor.php';
73 }
74
75 wp_print_styles( 'editor-buttons' );
76
77 _WP_Editors::wp_link_dialog();
78
79 }
80
81 }
82 }
83