PluginProbe
Slider Ultimate / 2.2.10
Slider Ultimate v2.2.10
2.2.10 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 All 54 releases
ultimate-slider / lib / simple-admin-pages / classes / AdminPageSetting.Address.class.php
AdminPageSetting.Address.class.php
159 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Register, display and save a textarea field setting in the admin menu
5 *
6 * @since 2.0.a.5
7 * @package Simple Admin Pages
8 */
9
10 class sapAdminPageSettingAddress_2_6_19 extends sapAdminPageSetting_2_6_19 {
11
12 /*
13 * Size of this textarea
14 *
15 * This is put directly into a css class [size]-text,
16 * and setting this to 'large' will link into WordPress's existing textarea
17 * style for full-width textareas.
18 */
19 public $size = 'small';
20
21 /*
22 * A Google Maps API key for geolocating addresses
23 */
24 public $api_key = '';
25
26 /*
27 * A jQuery selector pointing to the input element where the Google Maps API
28 * key can be retrieved.
29 */
30 public $api_key_selector = '';
31
32 /**
33 * Scripts that must be loaded for this component
34 * @since 2.0.a.5
35 */
36 public $scripts = array(
37 'sap-address' => array(
38 'path' => 'js/address.js',
39 'dependencies' => array( 'jquery' ),
40 'version' => SAP_VERSION,
41 'footer' => true,
42 ),
43 );
44
45 public $sanitize_callback = 'sanitize_text_field';
46
47 /**
48 * Translateable strings required for this component
49 * @since 2.0.a.8
50 */
51 public $strings = array(
52 'sep-action-links' => null, // _x( ' | ', 'separator between admin action links in address component', 'textdomain' ),
53 'sep-lat-lon' => null, // _x( ', ', 'separates latitude and longitude', 'textdomain' ),
54 'no-setting' => null, // __( 'No map coordinates set.', 'textdomain' ),
55 'retrieving' => null, // __( 'Requesting new coordinates', 'textdomain' ),
56 'select' => null, // __( 'Select a match below', 'textdomain' ),
57 'view' => null, // __( 'View', 'textdomain' ),
58 'retrieve' => null, // __( 'Retrieve map coordinates', 'textdomain' ),
59 'remove' => null, // __( 'Remove map coordinates', 'textdomain' ),
60 'try_again' => null, // __( 'Try again?', 'textdomain' ),
61 'result_error' => null, // __( 'Error', 'textdomain' ),
62 'result_invalid' => null, // __( 'Invalid request. Be sure to fill out the address field before retrieving coordinates.', 'textdomain' ),
63 'result_denied' => null, // __( 'Request denied.', 'textdomain' ),
64 'result_limit' => null, // __( 'Request denied because you are over your request quota.', 'textdomain' ),
65 'result_empty' => null, // __( 'Nothing was found at that address', 'textdomain' ),
66 );
67
68 /**
69 * Escape the value to display it safely HTML textarea fields
70 * @since 2.0.a.5
71 */
72 public function esc_value( $val ) {
73
74 $escaped = array();
75 $escaped['text'] = empty( $val['text'] ) ? '' : esc_textarea( $val['text'] );
76 $escaped['lat'] = empty( $val['lat'] ) ? '' : esc_textarea( $val['lat'] );
77 $escaped['lon'] = empty( $val['lon'] ) ? '' : esc_textarea( $val['lon'] );
78
79 return $escaped;
80 }
81
82 /**
83 * Set the size of this textarea field
84 * @since 1.0
85 */
86 public function set_size( $size ) {
87 $this->size = esc_attr( $size );
88 }
89
90 /**
91 * Wrapper for the sanitization callback function.
92 *
93 * This just reduces code duplication for child classes that need a custom
94 * callback function.
95 * @since 2.0.a.5
96 */
97 public function sanitize_callback_wrapper( $value ) {
98
99 $sanitized = array();
100 $sanitized['text'] = empty( $value['text'] ) ? '' : wp_kses_post( $value['text'] );
101 $sanitized['lat'] = empty( $value['lat'] ) ? '' : sanitize_text_field( $value['lat'] );
102 $sanitized['lon'] = empty( $value['lon'] ) ? '' : sanitize_text_field( $value['lon'] );
103
104 return $sanitized;
105 }
106
107 /**
108 * Display this setting
109 * @since 2.0.a.5
110 */
111 public function display_setting() {
112
113 wp_localize_script(
114 'sap-address',
115 'sap_address',
116 array(
117 'strings' => $this->strings,
118 'api_key' => $this->api_key,
119 'api_key_selector' => $this->api_key_selector,
120 )
121 );
122
123 $this->display_description();
124
125 ?>
126
127 <fieldset <?php $this->print_conditional_data(); ?>>
128 <div class="sap-address" id="<?php echo esc_attr( $this->id ); ?>">
129 <textarea name="<?php echo esc_attr( $this->get_input_name() ); ?>[text]" id="<?php echo esc_attr( $this->get_input_name() ); ?>" class="<?php echo esc_attr( $this->size ); ?>-text"<?php echo !empty( $this->placeholder ) ? ' placeholder="' . esc_attr( $this->placeholder ) . '"' : ''; ?> <?php echo ( $this->disabled ? 'disabled' : ''); ?>><?php echo esc_textarea( $this->value['text'] ); ?></textarea>
130 <p class="sap-map-coords-wrapper">
131 <span class="dashicons dashicons-location-alt"></span>
132 <span class="sap-map-coords">
133 <?php if ( empty( $this->value['lat'] ) || empty( $this->value['lon'] ) ) : ?>
134 <?php echo esc_html( $this->strings['no-setting'] ); ?>
135 <?php else : ?>
136 <?php echo esc_html( $this->value['lat'] . $this->strings['sep-lat-lon'] . $this->value['lon'] ); ?>
137 <a href="//maps.google.com/maps?q=<?php echo esc_attr( $this->value['lat'] ) . ',' . esc_attr( $this->value['lon'] ); ?>" class="sap-view-coords" target="_blank"><?php echo esc_html( $this->strings['view'] ); ?></a>
138 <?php endif; ?>
139 </span>
140 </p>
141 <p class="sap-coords-action-wrapper">
142 <a href="#" class="sap-get-coords">
143 <?php echo esc_html( $this->strings['retrieve'] ); ?>
144 </a>
145 <?php echo $this->strings['sep-action-links']; ?>
146 <a href="#" class="sap-remove-coords">
147 <?php echo esc_html( $this->strings['remove'] ); ?>
148 </a>
149 </p>
150 <input type="hidden" class="lat" name="<?php echo esc_attr( $this->get_input_name() ); ?>[lat]" value="<?php echo esc_attr( $this->value['lat'] ); ?>">
151 <input type="hidden" class="lon" name="<?php echo esc_attr( $this->get_input_name() ); ?>[lon]" value="<?php echo esc_attr( $this->value['lon'] ); ?>">
152 </div>
153 </fieldset>
154
155 <?php
156 }
157
158 }
159