PluginProbe ʕ •ᴥ•ʔ
AddToAny Share Buttons / 1.8.9
AddToAny Share Buttons v1.8.9
0.9.9.5.7 0.9.9.5.9 0.9.9.6 0.9.9.6.1 0.9.9.6.2 0.9.9.6.3 0.9.9.6.4 0.9.9.6.5 0.9.9.6.6 0.9.9.6.7 0.9.9.6.8 0.9.9.6.9 0.9.9.7 0.9.9.7.1 0.9.9.7.10 0.9.9.7.11 0.9.9.7.12 0.9.9.7.13 0.9.9.7.14 0.9.9.7.2 0.9.9.7.3 0.9.9.7.4 0.9.9.7.5 0.9.9.7.6 0.9.9.7.7 0.9.9.7.8 0.9.9.7.9 0.9.9.8 0.9.9.8.1 0.9.9.8.2 0.9.9.9 0.9.9.9.1 0.9.9.9.2 0.9.9.9.3 0.9.9.9.4 0.9.9.9.5 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.7.1 1.2.7.2 1.2.7.3 1.2.7.4 1.2.7.5 1.2.7.6 1.2.7.7 1.2.7.8 1.2.7.9 1.2.8.0 1.2.8.2 1.2.8.3 1.2.8.4 1.2.8.5 1.2.8.6 1.2.8.7 1.2.9 1.2.9.1 1.2.9.2 1.2.9.3 1.3 1.3.0.1 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.8.1 1.4 1.4.1 1.5 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6 1.6.0.1 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7 1.7.1 1.7.10 1.7.11 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 1.7.2 1.7.20 1.7.21 1.7.22 1.7.23 1.7.24 1.7.25 1.7.26 1.7.27 1.7.28 1.7.29 1.7.3 1.7.30 1.7.31 1.7.32 1.7.33 1.7.34 1.7.35 1.7.36 1.7.37 1.7.38 1.7.39 1.7.4 1.7.40 1.7.41 1.7.42 1.7.43 1.7.44 1.7.45 1.7.46 1.7.47 1.7.48 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.11 1.8.12 1.8.13 1.8.14 1.8.15 1.8.16 1.8.17 1.8.18 1.8.2 1.8.3 1.8.4 trunk 1.8.5 0.2 1.8.6 0.3 1.8.8 0.4 1.8.9 0.5 0.6 0.7 0.8 0.9 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.5.1 0.9.5.2 0.9.6 0.9.7 0.9.8.1 0.9.8.2 0.9.8.3 0.9.8.4 0.9.8.5 0.9.8.6 0.9.8.6.1 0.9.8.6.2 0.9.8.6.3 0.9.8.6.4 0.9.8.6.5 0.9.8.6.6 0.9.8.6.7 0.9.8.6.8 0.9.8.6.9 0.9.8.7 0.9.8.7.1 0.9.8.7.2 0.9.8.7.3 0.9.8.8 0.9.8.8.1 0.9.8.8.2 0.9.8.8.3 0.9.8.8.4 0.9.8.9 0.9.8.9.1 0.9.8.9.2 0.9.9 0.9.9.1 0.9.9.2 0.9.9.2.1 0.9.9.2.2 0.9.9.2.3 0.9.9.2.4 0.9.9.2.5 0.9.9.2.6 0.9.9.2.7 0.9.9.2.8 0.9.9.2.9 0.9.9.3 0.9.9.3.1 0.9.9.3.2 0.9.9.3.3 0.9.9.3.4 0.9.9.3.5 0.9.9.4 0.9.9.4.1 0.9.9.4.2 0.9.9.4.3 0.9.9.4.4 0.9.9.4.5 0.9.9.4.6 0.9.9.4.7 0.9.9.4.8 0.9.9.4.9 0.9.9.5 0.9.9.5.1 0.9.9.5.2 0.9.9.5.3 0.9.9.5.4 0.9.9.5.5 0.9.9.5.6
add-to-any / addtoany.admin.php
add-to-any Last commit date
icons 2 years ago languages 4 years ago README.txt 2 years ago add-to-any.php 2 years ago addtoany.admin.js 9 years ago addtoany.admin.php 2 years ago addtoany.amp.css 4 years ago addtoany.compat.php 2 years ago addtoany.min.css 2 years ago addtoany.min.js 7 years ago addtoany.services.php 2 years ago addtoany.update.php 6 years ago addtoany.widgets.php 2 years ago wpml-config.xml 11 years ago
addtoany.admin.php
1370 lines
1 <?php
2
3 /**
4 * Post options
5 */
6 function A2A_SHARE_SAVE_add_meta_box() {
7 $post_types = get_post_types( array( 'public' => true ) );
8 $post_types_not_builtin = get_post_types( array( 'public' => true, '_builtin' => false ) );
9 $options = get_option( 'addtoany_options', array() );
10 $title = apply_filters( 'A2A_SHARE_SAVE_meta_box_title', __( 'AddToAny', 'add-to-any' ) );
11
12 foreach( $post_types as $post_type ) {
13 $is_cpt = in_array( $post_type, $post_types_not_builtin );
14
15 if (
16 // If automatic placement is enabled
17 // for either floating bar
18 isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical'] ||
19 isset( $options['floating_horizontal'] ) && 'none' != $options['floating_horizontal'] ||
20 // for standard buttons in posts
21 'post' == $post_type && ( ! isset( $options['display_in_posts'] ) || $options['display_in_posts'] != '-1' ) ||
22 // for standard buttons in pages
23 'page' == $post_type && ( ! isset( $options['display_in_pages'] ) || $options['display_in_pages'] != '-1' ) ||
24 // for standard buttons in a custom post type
25 $is_cpt && ( ! isset( $options['display_in_cpt_' . $post_type] ) || $options['display_in_cpt_' . $post_type] != '-1' )
26 ) {
27 // Add meta box
28 add_meta_box( 'A2A_SHARE_SAVE_meta', $title, 'A2A_SHARE_SAVE_meta_box_content', $post_type, 'side', 'default' );
29 }
30 }
31 }
32
33 function A2A_SHARE_SAVE_meta_box_content( $post ) {
34 do_action( 'start_A2A_SHARE_SAVE_meta_box_content', $post );
35
36 $disabled = get_post_meta( $post->ID, 'sharing_disabled', true ); ?>
37
38 <p>
39 <label for="enable_post_addtoany_sharing">
40 <input type="checkbox" name="enable_post_addtoany_sharing" id="enable_post_addtoany_sharing" value="1"
41 <?php checked( empty( $disabled ) );
42 /* Have other known sharing checkboxes with the same option name
43 * inherit the AddToAny checkbox value on change
44 */ ?>
45 onchange="if (jQuery) jQuery('input[name=&quot;enable_post_sharing&quot;]').attr('checked', jQuery(this).is(':checked'))">
46 <?php _e( 'Show sharing buttons.' , 'add-to-any'); ?>
47 </label>
48 <input type="hidden" name="addtoany_sharing_status_hidden" value="1" />
49 </p>
50
51 <?php
52 do_action( 'end_A2A_SHARE_SAVE_meta_box_content', $post );
53 }
54
55 function A2A_SHARE_SAVE_meta_box_save( $post_id ) {
56 // If this is an autosave, this form has not been submitted, so we don't want to do anything.
57 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
58 return $post_id;
59
60 // Save sharing_disabled if "Show sharing buttons" checkbox is unchecked
61 if ( isset( $_POST['post_type'] ) ) {
62 if ( current_user_can( 'edit_post', $post_id ) ) {
63 if ( isset( $_POST['addtoany_sharing_status_hidden'] ) ) {
64 if ( ! isset( $_POST['enable_post_addtoany_sharing'] ) ) {
65 update_post_meta( $post_id, 'sharing_disabled', 1 );
66 } else {
67 delete_post_meta( $post_id, 'sharing_disabled' );
68 }
69 }
70 }
71 }
72
73 return $post_id;
74 }
75
76 add_action( 'admin_init', 'A2A_SHARE_SAVE_add_meta_box' );
77 add_action( 'save_post', 'A2A_SHARE_SAVE_meta_box_save' );
78 add_action( 'edit_attachment', 'A2A_SHARE_SAVE_meta_box_save' );
79
80 /**
81 * Adds feature pointers
82 */
83 function A2A_SHARE_SAVE_enqueue_pointer_script_style( $hook_suffix ) {
84 // Variable required for PHP < 5.5 because empty() only supports variables
85 $options = get_option( 'addtoany_options', array() );
86
87 // Return if AddToAny options have been set
88 if ( ! empty( $options ) ) {
89 return;
90 }
91
92 // Get array list of dismissed pointers for current user and convert it to array
93 $dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
94
95 // If any one of our pointers is not among dismissed pointers
96 if (
97 ! in_array( 'addtoany_settings_pointer', $dismissed_pointers )
98 ) {
99 // Enqueue pointer CSS and JS files, if needed
100 wp_enqueue_style( 'wp-pointer' );
101 wp_enqueue_script( 'wp-pointer' );
102
103 // Add footer scripts using callback function
104 add_action( 'admin_print_footer_scripts', 'A2A_SHARE_SAVE_pointer_print_scripts' );
105 }
106 }
107
108 add_action( 'admin_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_pointer_script_style' );
109
110 function A2A_SHARE_SAVE_pointer_print_scripts() {
111 // Get array list of dismissed pointers for current user and convert it to array
112 $dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
113 ?>
114
115 <script>
116 <?php if ( ! in_array( 'addtoany_settings_pointer', $dismissed_pointers ) ) : ?>
117 jQuery(document).ready( function($) {
118 $('#menu-settings').pointer({
119 content: '<h3>AddToAny Sharing Settings</h3><p>To customize your AddToAny share buttons, click &quot;AddToAny&quot; in the Settings menu.</p>',
120 position: {
121 edge: 'left', // arrow direction
122 align: 'center' // vertical alignment
123 },
124 pointerWidth: 350,
125 close: function() {
126 $.post( ajaxurl, {
127 pointer: 'addtoany_settings_pointer', // pointer ID
128 action: 'dismiss-wp-pointer'
129 });
130 }
131 }).pointer('open');
132 });
133 <?php endif; ?>
134 </script>
135
136 <?php
137 }
138
139 function _a2a_position_in_content( $options, $option_box = false ) {
140
141 if ( ! isset( $options['position'] ) ) {
142 $options['position'] = 'bottom';
143 }
144
145 $positions = array(
146 'bottom' => array(
147 'selected' => ( 'bottom' == $options['position'] ) ? ' selected="selected"' : '',
148 'string' => __( 'bottom', 'add-to-any' )
149 ),
150 'top' => array(
151 'selected' => ( 'top' == $options['position'] ) ? ' selected="selected"' : '',
152 'string' => __( 'top', 'add-to-any' )
153 ),
154 'both' => array(
155 'selected' => ( 'both' == $options['position'] ) ? ' selected="selected"' : '',
156 'string' => __( 'top &amp; bottom', 'add-to-any' )
157 )
158 );
159
160 if ( $option_box ) {
161 $html = '</label>';
162 $html .= '<label>'; // Label needed to prevent checkmark toggle on SELECT click
163 $html .= '<select name="A2A_SHARE_SAVE_position">';
164 $html .= '<option value="bottom"' . $positions['bottom']['selected'] . '>' . $positions['bottom']['string'] . '</option>';
165 $html .= '<option value="top"' . $positions['top']['selected'] . '>' . $positions['top']['string'] . '</option>';
166 $html .= '<option value="both"' . $positions['both']['selected'] . '>' . $positions['both']['string'] . '</option>';
167 $html .= '</select>';
168
169 return $html;
170 } else {
171 $html = '<span class="A2A_SHARE_SAVE_position">';
172 $html .= $positions[$options['position']]['string'];
173 $html .= '</span>';
174
175 return $html;
176 }
177 }
178
179 function _a2a_selected_attr( $value, $option_name, $options ) {
180 if ( ! empty( $options[ $option_name ] ) && $value === $options[ $option_name ] ) {
181 echo ' selected';
182 }
183 }
184
185 function _a2a_disabled_attr() {
186 if ( ! current_user_can( 'unfiltered_html' ) ) {
187 echo ' disabled';
188 }
189 }
190
191 function _a2a_valid_hex_color( $value, $default ) {
192 if ( preg_match( '/^#[a-f0-9]{6}$/i', $value ) ) {
193 return $value;
194 }
195
196 return $default;
197 }
198
199 function _a2a_valid_content_position_selection( $value, $default ) {
200 return in_array( $value, array('top', 'bottom', 'both') ) ? $value : $default;
201 }
202
203 function _a2a_valid_floating_bg_color_selection( $value, $default ) {
204 return in_array( $value, array( 'transparent', 'custom' ) ) ? $value : $default;
205 }
206
207 function _a2a_valid_icon_color_selection( $bg_or_fg, $value, $default ) {
208 if ( 'bg' === $bg_or_fg ) {
209 $valid_selections = array('original', 'custom', 'transparent');
210 } elseif ( 'fg' === $bg_or_fg ) {
211 $valid_selections = array('original', 'custom');
212 }
213
214 return in_array( $value, $valid_selections ) ? $value : $default;
215 }
216
217 function A2A_SHARE_SAVE_options_page() {
218
219 global $A2A_SHARE_SAVE_plugin_url,
220 $A2A_SHARE_SAVE_services;
221
222 // Require admin privs
223 if ( ! current_user_can( 'manage_options' ) )
224 return false;
225
226 $new_options = array();
227
228 $namespace = 'A2A_SHARE_SAVE_';
229
230 // Make available services extensible via plugins, themes (functions.php), etc.
231 $A2A_SHARE_SAVE_services = apply_filters( 'A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services );
232
233 // Which tab is selected?
234 $possible_screens = array( 'default', 'floating' );
235 $current_screen = ( isset( $_GET['action'] ) && in_array( $_GET['action'], $possible_screens ) ) ? $_GET['action'] : 'default';
236
237 if ( isset( $_POST['Submit'] ) ) {
238
239 // Nonce verification
240 check_admin_referer( 'add-to-any-update-options' );
241
242 if ( 'floating' == $current_screen ) {
243 // Floating options screen
244
245 $possible_floating_values = array( 'left_docked', 'right_docked', 'center_docked', 'left_attached', 'right_attached', 'none' );
246
247 $new_options['floating_vertical'] = ( in_array( $_POST['A2A_SHARE_SAVE_floating_vertical'], $possible_floating_values ) ) ? $_POST['A2A_SHARE_SAVE_floating_vertical'] : 'none';
248 $new_options['floating_horizontal'] = ( in_array( $_POST['A2A_SHARE_SAVE_floating_horizontal'], $possible_floating_values ) ) ? $_POST['A2A_SHARE_SAVE_floating_horizontal'] : 'none';
249
250 $new_options['floating_horizontal_position'] = (
251 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_position'] ) &&
252 is_numeric( $_POST['A2A_SHARE_SAVE_floating_horizontal_position'] )
253 ) ? $_POST['A2A_SHARE_SAVE_floating_horizontal_position'] : '0';
254
255 $new_options['floating_horizontal_offset'] = (
256 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_offset'] ) &&
257 is_numeric( $_POST['A2A_SHARE_SAVE_floating_horizontal_offset'] )
258 ) ? $_POST['A2A_SHARE_SAVE_floating_horizontal_offset'] : '0';
259
260 $new_options['floating_horizontal_responsive'] = (
261 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_responsive'] ) &&
262 '1' == $_POST['A2A_SHARE_SAVE_floating_horizontal_responsive']
263 ) ? '1' : '-1';
264
265 $new_options['floating_horizontal_responsive_min_width'] = (
266 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_responsive_min_width'] ) &&
267 is_numeric( $_POST['A2A_SHARE_SAVE_floating_horizontal_responsive_min_width'] )
268 ) ? $_POST['A2A_SHARE_SAVE_floating_horizontal_responsive_min_width'] : '981';
269
270 $new_options['floating_horizontal_scroll_top'] = (
271 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_top'] ) &&
272 '1' == $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_top']
273 ) ? '1' : '-1';
274
275 $new_options['floating_horizontal_scroll_top_pixels'] = (
276 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_top_pixels'] ) &&
277 is_numeric( $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_top_pixels'] )
278 ) ? $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_top_pixels'] : '100';
279
280 $new_options['floating_horizontal_scroll_bottom'] = (
281 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_bottom'] ) &&
282 '1' == $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_bottom']
283 ) ? '1' : '-1';
284
285 $new_options['floating_horizontal_scroll_bottom_pixels'] = (
286 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_bottom_pixels'] ) &&
287 is_numeric( $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_bottom_pixels'] )
288 ) ? $_POST['A2A_SHARE_SAVE_floating_horizontal_scroll_bottom_pixels'] : '100';
289
290 $new_options['floating_horizontal_icon_size'] = (
291 isset( $_POST['A2A_SHARE_SAVE_floating_horizontal_icon_size'] ) &&
292 is_numeric( $_POST['A2A_SHARE_SAVE_floating_horizontal_icon_size'] )
293 ) ? $_POST['A2A_SHARE_SAVE_floating_horizontal_icon_size'] : '32';
294
295 $new_options['floating_horizontal_bg'] = _a2a_valid_floating_bg_color_selection( $_POST['A2A_SHARE_SAVE_floating_horizontal_bg'], 'transparent' );
296 $new_options['floating_horizontal_bg_color'] = _a2a_valid_hex_color( $_POST['A2A_SHARE_SAVE_floating_horizontal_bg_color'], '#ffffff' );
297
298 $new_options['floating_vertical_position'] = (
299 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_position'] ) &&
300 is_numeric( $_POST['A2A_SHARE_SAVE_floating_vertical_position'] )
301 ) ? $_POST['A2A_SHARE_SAVE_floating_vertical_position'] : '100';
302
303 $new_options['floating_vertical_attached_to'] = (
304 ! empty( $_POST['A2A_SHARE_SAVE_floating_vertical_attached_to'] )
305 ) ? sanitize_text_field( $_POST['A2A_SHARE_SAVE_floating_vertical_attached_to'] ) : 'main, [role="main"], article, .status-publish';
306
307 $new_options['floating_vertical_offset'] = (
308 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_offset'] ) &&
309 is_numeric( $_POST['A2A_SHARE_SAVE_floating_vertical_offset'] )
310 ) ? $_POST['A2A_SHARE_SAVE_floating_vertical_offset'] : '0';
311
312 $new_options['floating_vertical_responsive'] = (
313 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_responsive'] ) &&
314 '1' == $_POST['A2A_SHARE_SAVE_floating_vertical_responsive']
315 ) ? '1' : '-1';
316
317 $new_options['floating_vertical_responsive_max_width'] = (
318 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_responsive_max_width'] ) &&
319 is_numeric( $_POST['A2A_SHARE_SAVE_floating_vertical_responsive_max_width'] )
320 ) ? $_POST['A2A_SHARE_SAVE_floating_vertical_responsive_max_width'] : '980';
321
322 $new_options['floating_vertical_scroll_top'] = (
323 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_top'] ) &&
324 '1' == $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_top']
325 ) ? '1' : '-1';
326
327 $new_options['floating_vertical_scroll_top_pixels'] = (
328 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_top_pixels'] ) &&
329 is_numeric( $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_top_pixels'] )
330 ) ? $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_top_pixels'] : '100';
331
332 $new_options['floating_vertical_scroll_bottom'] = (
333 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_bottom'] ) &&
334 '1' == $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_bottom']
335 ) ? '1' : '-1';
336
337 $new_options['floating_vertical_scroll_bottom_pixels'] = (
338 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_bottom_pixels'] ) &&
339 is_numeric( $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_bottom_pixels'] )
340 ) ? $_POST['A2A_SHARE_SAVE_floating_vertical_scroll_bottom_pixels'] : '100';
341
342 $new_options['floating_vertical_icon_size'] = (
343 isset( $_POST['A2A_SHARE_SAVE_floating_vertical_icon_size'] ) &&
344 is_numeric( $_POST['A2A_SHARE_SAVE_floating_vertical_icon_size'] )
345 ) ? $_POST['A2A_SHARE_SAVE_floating_vertical_icon_size'] : '32';
346
347 $new_options['floating_vertical_bg'] = _a2a_valid_floating_bg_color_selection( $_POST['A2A_SHARE_SAVE_floating_vertical_bg'], 'transparent' );
348 $new_options['floating_vertical_bg_color'] = _a2a_valid_hex_color( $_POST['A2A_SHARE_SAVE_floating_vertical_bg_color'], '#ffffff' );
349
350 } else {
351 // Standard options screen
352
353 $new_options['position'] = _a2a_valid_content_position_selection( $_POST['A2A_SHARE_SAVE_position'], 'bottom' );
354 $new_options['display_in_posts_on_front_page'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_posts_on_front_page'] ) && $_POST['A2A_SHARE_SAVE_display_in_posts_on_front_page'] == '1' ) ? '1' : '-1';
355 $new_options['display_in_posts_on_archive_pages'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_posts_on_archive_pages'] ) && $_POST['A2A_SHARE_SAVE_display_in_posts_on_archive_pages'] == '1' ) ? '1' : '-1';
356 $new_options['display_in_excerpts'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_excerpts'] ) && $_POST['A2A_SHARE_SAVE_display_in_excerpts'] == '1' ) ? '1' : '-1';
357 $new_options['display_in_posts'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_posts'] ) && $_POST['A2A_SHARE_SAVE_display_in_posts'] == '1' ) ? '1' : '-1';
358 $new_options['display_in_pages'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_pages'] ) && $_POST['A2A_SHARE_SAVE_display_in_pages'] == '1' ) ? '1' : '-1';
359 $new_options['display_in_attachments'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_attachments'] ) && $_POST['A2A_SHARE_SAVE_display_in_attachments'] == '1' ) ? '1' : '-1';
360 $new_options['display_in_feed'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_feed'] ) && $_POST['A2A_SHARE_SAVE_display_in_feed'] == '1' ) ? '1' : '-1';
361 $new_options['icon_size'] = ( ! empty( $_POST['A2A_SHARE_SAVE_icon_size'] ) && is_numeric( $_POST['A2A_SHARE_SAVE_icon_size'] ) ) ? $_POST['A2A_SHARE_SAVE_icon_size'] : '32';
362 $new_options['icon_bg'] = _a2a_valid_icon_color_selection( 'bg', $_POST['A2A_SHARE_SAVE_icon_bg'], 'original' );
363 $new_options['icon_bg_color'] = _a2a_valid_hex_color( $_POST['A2A_SHARE_SAVE_icon_bg_color'], '#2a2a2a' );
364 $new_options['icon_fg'] = _a2a_valid_icon_color_selection( 'fg', $_POST['A2A_SHARE_SAVE_icon_fg'], 'original' );
365 $new_options['icon_fg_color'] = _a2a_valid_hex_color( $_POST['A2A_SHARE_SAVE_icon_fg_color'], '#ffffff' );
366 $new_options['button'] = ( isset( $_POST['A2A_SHARE_SAVE_button'] ) ) ? sanitize_text_field( $_POST['A2A_SHARE_SAVE_button'] ) : '';
367 $new_options['button_custom'] = ( isset( $_POST['A2A_SHARE_SAVE_button_custom'] ) ) ? sanitize_text_field( $_POST['A2A_SHARE_SAVE_button_custom'] ) : '';
368 $new_options['button_show_count'] = ( isset( $_POST['A2A_SHARE_SAVE_button_show_count'] ) && $_POST['A2A_SHARE_SAVE_button_show_count'] == '1' ) ? '1' : '-1';
369 $new_options['header'] = ( isset( $_POST['A2A_SHARE_SAVE_header'] ) && current_user_can( 'unfiltered_html' ) ) ? wp_kses_post( $_POST['A2A_SHARE_SAVE_header'] ) : '';
370 $new_options['additional_js_variables'] = ( isset( $_POST['A2A_SHARE_SAVE_additional_js_variables'] ) && current_user_can( 'unfiltered_html' ) ) ? trim( $_POST['A2A_SHARE_SAVE_additional_js_variables'] ) : '';
371 $new_options['additional_css'] = ( isset( $_POST['A2A_SHARE_SAVE_additional_css'] ) && current_user_can( 'unfiltered_html' ) ) ? trim( $_POST['A2A_SHARE_SAVE_additional_css'] ) : '';
372 $new_options['custom_icons'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons'] ) && $_POST['A2A_SHARE_SAVE_custom_icons'] == 'url' ) ? 'url' : '-1';
373 $new_options['custom_icons_url'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_url'] ) ) ? trailingslashit( sanitize_text_field( $_POST['A2A_SHARE_SAVE_custom_icons_url'] ) ) : '';
374 $new_options['custom_icons_type'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_type'] ) ) ? sanitize_text_field( $_POST['A2A_SHARE_SAVE_custom_icons_type'] ) : 'png';
375 $new_options['custom_icons_width'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_width'] ) && is_numeric( $_POST['A2A_SHARE_SAVE_custom_icons_width'] ) ) ? $_POST['A2A_SHARE_SAVE_custom_icons_width'] : '';
376 $new_options['custom_icons_height'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_height'] ) && is_numeric( $_POST['A2A_SHARE_SAVE_custom_icons_height'] ) ) ? $_POST['A2A_SHARE_SAVE_custom_icons_height'] : '';
377 $new_options['cache'] = ( isset( $_POST['A2A_SHARE_SAVE_cache'] ) && $_POST['A2A_SHARE_SAVE_cache'] == '1' ) ? '1' : '-1';
378
379 $custom_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' ) );
380 foreach ( $custom_post_types as $custom_post_type_obj ) {
381 $placement_name = $custom_post_type_obj->name;
382 $new_options['display_in_cpt_' . $placement_name] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_cpt_' . $placement_name] )
383 && $_POST['A2A_SHARE_SAVE_display_in_cpt_' . $placement_name] == '1' ) ? '1' : '-1';
384 }
385
386 // Schedule cache refresh?
387 if ( isset( $_POST['A2A_SHARE_SAVE_cache'] ) && $_POST['A2A_SHARE_SAVE_cache'] == '1' ) {
388 A2A_SHARE_SAVE_schedule_cache();
389 } else {
390 A2A_SHARE_SAVE_unschedule_cache();
391 }
392
393 // Store desired text for text-only:
394 $new_options['button_text'] = ( trim( $_POST['A2A_SHARE_SAVE_button_text'] ) != '' ) ? sanitize_text_field( $_POST['A2A_SHARE_SAVE_button_text'] ) : __('Share','add-to-any');
395
396 // Store chosen individual services to make active
397 $active_services = array();
398 if ( ! isset( $_POST['A2A_SHARE_SAVE_active_services'] ) )
399 $_POST['A2A_SHARE_SAVE_active_services'] = array();
400 foreach ( $_POST['A2A_SHARE_SAVE_active_services'] as $dummy=>$sitename ) {
401 $service = substr( $sitename, 7 );
402 $active_services[] = $service;
403
404 // AddToAny counter enabled?
405 if ( in_array( $service, array( 'pinterest', 'reddit', 'tumblr' ) ) ) {
406 $new_options['special_' . $service . '_options'] = array(
407 'show_count' => ( ( isset( $_POST['addtoany_' . $service . '_show_count'] ) && $_POST['addtoany_' . $service . '_show_count'] == '1') ? '1' : '-1' )
408 );
409 }
410 }
411
412 $new_options['active_services'] = $active_services;
413
414 // Store special service options
415 $new_options['special_facebook_like_options'] = array(
416 'show_count' => ( ( isset( $_POST['addtoany_facebook_like_show_count'] ) && $_POST['addtoany_facebook_like_show_count'] == '1' ) ? '1' : '-1' ),
417 'verb' => ( ( isset( $_POST['addtoany_facebook_like_verb'] ) && $_POST['addtoany_facebook_like_verb'] == 'recommend') ? 'recommend' : 'like' ),
418 );
419 $new_options['special_twitter_tweet_options'] = array(
420 'show_count' => '-1' // Twitter doesn't provide counts anymore
421 );
422 $new_options['special_pinterest_pin_options'] = array(
423 'show_count' => ( ( isset( $_POST['addtoany_pinterest_pin_show_count'] ) && $_POST['addtoany_pinterest_pin_show_count'] == '1' ) ? '1' : '-1' )
424 );
425
426 }
427
428 // Get all existing AddToAny options
429 $existing_options = get_option( 'addtoany_options', array() );
430
431 // Merge $new_options into $existing_options to retain AddToAny options from all other screens/tabs
432 if ( $existing_options ) {
433 $new_options = array_merge( $existing_options, $new_options );
434 }
435
436 update_option( 'addtoany_options', $new_options );
437
438 ?>
439 <div class="updated"><p><?php _e( 'Settings saved.' ); ?></p></div>
440 <?php
441
442 } else if ( isset( $_POST['Reset'] ) ) {
443 // Nonce verification
444 check_admin_referer( 'add-to-any-update-options' );
445
446 delete_option( 'addtoany_options' );
447 }
448
449 $options = stripslashes_deep( get_option( 'addtoany_options', array() ) );
450
451 ?>
452
453 <div class="wrap">
454
455 <h1><?php _e( 'AddToAny Share Settings', 'add-to-any' ); ?></h1>
456
457 <h2 class="nav-tab-wrapper">
458 <a href="<?php echo admin_url( 'options-general.php?page=addtoany' ); ?>" class="nav-tab<?php if ( 'default' == $current_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Standard' ); ?></a>
459 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'floating' ), admin_url( 'options-general.php?page=addtoany' ) ) ); ?>" class="nav-tab<?php if ( 'floating' == $current_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Floating' ); ?></a>
460 </h2>
461
462 <form id="addtoany_admin_form" method="post" action="">
463
464 <?php wp_nonce_field('add-to-any-update-options'); ?>
465
466 <table class="form-table">
467
468 <?php if ( 'default' == $current_screen ) : ?>
469 <tr valign="top">
470 <th scope="row"><?php _e("Icon Style", 'add-to-any'); ?></th>
471 <td><fieldset>
472 <label><input class="small-text" name="A2A_SHARE_SAVE_icon_size" type="number" max="300" min="10" maxlength="3" step="2" oninput="if(this.value.length > 3) this.value=this.value.slice(0, 3)" placeholder="32" value="<?php echo ! empty( $options['icon_size'] ) ? esc_attr( $options['icon_size'] ) : '32'; ?>"> pixels</label>
473 <br>
474 <label>
475 <select class="addtoany_icon_color" name="A2A_SHARE_SAVE_icon_bg">
476 <option value="original"<?php _a2a_selected_attr('original', 'icon_bg', $options); ?>>Original</option>
477 <option value="transparent"<?php _a2a_selected_attr('transparent', 'icon_bg', $options); ?>>Transparent</option>
478 <option value="custom"<?php _a2a_selected_attr('custom', 'icon_bg', $options); ?>>Custom&#8230;</option>
479 </select>
480 background
481 </label>
482 <div class="color-field-container"><input name="A2A_SHARE_SAVE_icon_bg_color" class="color-field" type="text" value="<?php echo ! empty( $options['icon_bg_color'] ) ? esc_attr( $options['icon_bg_color'] ) : '#2a2a2a'; ?>" data-default-color="#2a2a2a"></div>
483 <br>
484 <label>
485 <select class="addtoany_icon_color" name="A2A_SHARE_SAVE_icon_fg">
486 <option value="original"<?php _a2a_selected_attr('original', 'icon_fg', $options); ?>>Original</option>
487 <option value="transparent" disabled="disabled">Transparent</option>
488 <option value="custom"<?php _a2a_selected_attr('custom', 'icon_fg', $options); ?>>Custom&#8230;</option>
489 </select>
490 foreground
491 </label>
492 <div class="color-field-container"><input name="A2A_SHARE_SAVE_icon_fg_color" class="color-field" type="text" value="<?php echo ! empty( $options['icon_fg_color'] ) ? esc_attr( $options['icon_fg_color'] ) : '#ffffff'; ?>" data-default-color="#ffffff"></div>
493 </fieldset></td>
494 </tr>
495
496 <tr valign="top">
497 <th scope="row"><?php _e("Share Buttons", 'add-to-any'); ?></th>
498 <td><fieldset>
499 <ul id="addtoany_services_sortable" class="addtoany_admin_list addtoany_override">
500 <li class="dummy"><img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ); ?>/icons/transparent.gif" width="32" height="32" alt="" /></li>
501 </ul>
502 <p id="addtoany_services_info"><?php _e("Choose the services you want below. &nbsp;Click a chosen service again to remove. &nbsp;Reorder services by dragging and dropping as they appear above.", 'add-to-any'); ?></p>
503 <ul id="addtoany_services_selectable" class="addtoany_admin_list">
504 <?php
505 // Show all services
506 foreach ($A2A_SHARE_SAVE_services as $service_safe_name=>$site) {
507 if ( isset( $site['href'] ) )
508 $custom_service = true;
509 else
510 $custom_service = false;
511
512 if ( ! isset( $site['icon'] ) )
513 $site['icon'] = 'default';
514
515 $is_special_service = in_array( $service_safe_name, array( 'pinterest', 'reddit', 'tumblr', ) );
516 ?>
517 <li data-addtoany-icon-name="<?php echo esc_attr( $site['icon'] ); ?>"<?php if ( $is_special_service ) echo ' class="addtoany_special_service"'; ?> id="a2a_wp_<?php echo esc_attr( $service_safe_name ); ?>" title="<?php echo esc_attr( $site['name'] ); ?>">
518 <img src="<?php echo esc_attr( isset( $site['icon_url'] ) ? $site['icon_url'] : $A2A_SHARE_SAVE_plugin_url.'/icons/'.$site['icon'].'.svg' ); ?>" width="<?php echo isset( $site['icon_width'] ) ? esc_attr( $site['icon_width'] ) : '24'; ?>" height="<?php echo isset( $site['icon_height'] ) ? esc_attr( $site['icon_height'] ) : '24'; ?>"<?php if ( isset( $site['color'] ) ) : ?> style="background-color:#<?php echo esc_attr( $site['color'] ); endif; ?>"><?php echo esc_html( $site['name'] ); ?>
519 </li>
520 <?php
521 } ?>
522 <li style="clear:left" id="a2a_wp_facebook_like" class="addtoany_special_service addtoany_3p_button" title="Facebook Like button">
523 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ).'/icons/facebook_like_2x.png'; ?>" width="101" height="40" alt="Facebook Like" />
524 </li>
525 <li id="a2a_wp_twitter_tweet" class="addtoany_special_service addtoany_3p_button" title="Twitter Tweet button">
526 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ).'/icons/twitter_tweet_2x.png'; ?>" width="122" height="40" alt="Twitter Tweet" />
527 </li>
528 <li id="a2a_wp_pinterest_pin" class="addtoany_special_service addtoany_3p_button" title="Pinterest Pin It button">
529 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ).'/icons/pinterest_pin_2x.png'; ?>" width="80" height="40" alt="Pinterest Pin It" />
530 </li>
531 </ul>
532 <div id="addtoany_services_tip">
533 <p style="line-height:0">
534 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ); ?>/icons/instagram.svg" width="24" height="24" style="margin-right:8px">
535 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ); ?>/icons/threads.svg" width="24" height="24" style="margin-right:8px">
536 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ); ?>/icons/tiktok.svg" width="24" height="24" style="margin-right:8px">
537 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ); ?>/icons/youtube.svg" width="24" height="24" style="margin-right:8px">
538 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ); ?>/icons/discord.svg" width="24" height="24" style="margin-right:8px">
539 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ); ?>/icons/snapchat.svg" width="24" height="24">
540 </p>
541 <p>You can setup Instagram, YouTube, Snapchat, and other buttons in an AddToAny Follow widget.</p><p>Add the &quot;AddToAny Follow&quot; widget in <a href="customize.php?autofocus[panel]=widgets&amp;return=options-general.php%3Fpage%3Daddtoany">Customize</a> or <a href="widgets.php">Widgets</a>.</p>
542 </div>
543 </fieldset></td>
544 </tr>
545
546 <tr valign="top">
547 <th scope="row"><?php _e("Universal Button", 'add-to-any'); ?></th>
548 <td><fieldset id="addtoany_extra_section_universal_button" class="addtoany_extra_section">
549 <div class="addtoany_extra_element addtoany_icon_size_large">
550 <label class="addtoany_override a2a_kit_size_32">
551 <input name="A2A_SHARE_SAVE_button" value="A2A_SVG_32" type="radio"<?php if ( ! isset( $options['button'] ) || 'A2A_SVG_32' == $options['button'] ) echo ' checked="checked"'; ?> style="margin:9px 0;vertical-align:middle">
552 <img src="<?php echo esc_url( $A2A_SHARE_SAVE_plugin_url ).'/icons/a2a.svg'; ?>" width="32" height="32" alt="AddToAny" onclick="this.parentNode.firstChild.checked=true" />
553 </label>
554 <br>
555 </div>
556 <div class="addtoany_extra_element">
557 <label>
558 <input name="A2A_SHARE_SAVE_button" value="CUSTOM" id="A2A_SHARE_SAVE_button_is_custom" type="radio"<?php if ( isset( $options['button'] ) && 'CUSTOM' == $options['button'] ) echo ' checked="checked"'; ?> style="margin:9px 0;vertical-align:middle">
559 <span style="margin:0 9px;vertical-align:middle"><?php _e("Image URL"); ?>:</span>
560 </label>
561 <input name="A2A_SHARE_SAVE_button_custom" type="text" class="code" size="50" onclick="document.getElementById('A2A_SHARE_SAVE_button_is_custom').checked=true" style="vertical-align:middle" value="<?php if ( isset( $options['button_custom'] ) ) echo esc_attr( $options['button_custom'] ); ?>" />
562 </div>
563 <div class="addtoany_extra_element">
564 <label>
565 <input name="A2A_SHARE_SAVE_button" value="TEXT" id="A2A_SHARE_SAVE_button_is_text" type="radio"<?php if ( isset( $options['button'] ) && 'TEXT' == $options['button'] ) echo ' checked="checked"'; ?> style="margin:9px 0;vertical-align:middle">
566 <span style="margin:0 9px;vertical-align:middle"><?php _e("Text only"); ?>:</span>
567 </label>
568 <input name="A2A_SHARE_SAVE_button_text" type="text" class="code" size="50" onclick="document.getElementById('A2A_SHARE_SAVE_button_is_text').checked=true" style="vertical-align:middle;width:150px" value="<?php echo ( isset( $options['button_text'] ) && trim( '' != $options['button_text'] ) ) ? esc_attr( $options['button_text'] ) : __('Share','add-to-any'); ?>" />
569 </div>
570 <div class="addtoany_extra_element">
571 <label>
572 <input name="A2A_SHARE_SAVE_button" value="NONE" type="radio"<?php if ( isset( $options['button'] ) && 'NONE' == $options['button'] ) echo ' checked="checked"'; ?> onclick="return confirm('<?php _e('This option will disable universal sharing. Are you sure you want to disable universal sharing?', 'add-to-any' ) ?>')" style="margin:9px 0;vertical-align:middle">
573 <span style="margin:0 9px;vertical-align:middle"><?php _e("None"); ?></span>
574 </label>
575 </div>
576 <div class="addtoany_extra_element">
577 <label>
578 <input id="A2A_SHARE_SAVE_button_show_count" name="A2A_SHARE_SAVE_button_show_count" type="checkbox"<?php
579 if ( isset( $options['button_show_count'] ) && $options['button_show_count'] == '1' ) echo ' checked="checked"'; ?> value="1">
580 <span style="margin-left:5px">Show count</span>
581 </label>
582 </div>
583
584 </fieldset></td>
585 </tr>
586
587 <tr valign="top">
588 <th scope="row"><?php _e('Sharing Header', 'add-to-any'); ?></th>
589 <td><fieldset id="addtoany_extra_section_sharing_header" class="addtoany_extra_section<?php if ( ! empty( $options['header'] ) ) echo ' addtoany_show_extra'; ?>" role="region">
590 <label>
591 <input name="A2A_SHARE_SAVE_header" type="text" class="code" placeholder="<?php esc_attr_e( 'Share this:' ); ?>" size="50" value="<?php if ( isset( $options['header'] ) ) echo esc_attr( $options['header'] ); ?>"<?php _a2a_disabled_attr(); ?>>
592 </label>
593 </fieldset></td>
594 </tr>
595
596 <tr valign="top">
597 <th scope="row"><?php _e('Placement', 'add-to-any'); ?></th>
598 <td><fieldset>
599 <label>
600 <input id="A2A_SHARE_SAVE_display_in_posts" name="A2A_SHARE_SAVE_display_in_posts" type="checkbox"<?php
601 if ( ! isset( $options['display_in_posts'] ) || $options['display_in_posts'] != '-1' ) echo ' checked="checked"'; ?> value="1"/>
602 <?php printf( __( 'Display at the %s of posts', 'add-to-any' ), _a2a_position_in_content( $options, true ) ); ?>
603 </label>
604 <br/>
605 <label>
606 &nbsp; &nbsp; &nbsp; <input class="A2A_SHARE_SAVE_child_of_display_in_posts" name="A2A_SHARE_SAVE_display_in_posts_on_front_page" type="checkbox"<?php
607 if ( ! isset( $options['display_in_posts_on_front_page'] ) || $options['display_in_posts_on_front_page'] != '-1' ) echo ' checked="checked"';
608 if ( isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) echo ' disabled="disabled"';
609 ?> value="1"/>
610 <?php printf( __( 'Display at the %s of posts on the front page', 'add-to-any' ), _a2a_position_in_content( $options ) ); ?>
611 </label>
612 <br/>
613 <label>
614 &nbsp; &nbsp; &nbsp; <input class="A2A_SHARE_SAVE_child_of_display_in_posts" name="A2A_SHARE_SAVE_display_in_posts_on_archive_pages" type="checkbox"<?php
615 if ( ! isset( $options['display_in_posts_on_archive_pages'] ) || $options['display_in_posts_on_archive_pages'] != '-1' ) echo ' checked="checked"';
616 if ( isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) echo ' disabled="disabled"';
617 ?> value="1"/>
618 <?php printf( __( 'Display at the %s of posts on archive pages', 'add-to-any' ), _a2a_position_in_content( $options ) ); ?>
619 </label>
620 <br/>
621 <label>
622 &nbsp; &nbsp; &nbsp; <input class="A2A_SHARE_SAVE_child_of_display_in_posts" name="A2A_SHARE_SAVE_display_in_feed" type="checkbox"<?php
623 if ( ! isset( $options['display_in_feed'] ) || $options['display_in_feed'] != '-1' ) echo ' checked="checked"';
624 if ( isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) echo ' disabled="disabled"';
625 ?> value="1"/>
626 <?php printf( __( 'Display at the %s of posts in the feed', 'add-to-any' ), _a2a_position_in_content( $options ) ); ?>
627 </label>
628 <br/>
629 <label>
630 <input name="A2A_SHARE_SAVE_display_in_excerpts" type="checkbox"<?php
631 if ( ! isset( $options['display_in_excerpts'] ) || $options['display_in_excerpts'] != '-1' ) echo ' checked="checked"';
632 ?> value="1"/>
633 <?php printf( __( 'Display at the %s of excerpts' , 'add-to-any'), _a2a_position_in_content( $options, false ) ); ?>
634 </label>
635 <br/>
636 <label>
637 <input name="A2A_SHARE_SAVE_display_in_pages" type="checkbox"<?php if ( ! isset( $options['display_in_pages'] ) || $options['display_in_pages'] != '-1' ) echo ' checked="checked"'; ?> value="1"/>
638 <?php printf( __( 'Display at the %s of pages', 'add-to-any' ), _a2a_position_in_content( $options, false ) ); ?>
639 </label>
640 <br/>
641 <label>
642 <input name="A2A_SHARE_SAVE_display_in_attachments" type="checkbox"<?php
643 if ( ! isset( $options['display_in_attachments'] ) || $options['display_in_attachments'] != '-1' ) echo ' checked="checked"';
644 ?> value="1"/>
645 <?php printf( __( 'Display at the %s of media pages', 'add-to-any' ), _a2a_position_in_content( $options, false ) ); ?>
646 </label>
647
648 <?php
649 $custom_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' ) );
650 foreach ( $custom_post_types as $custom_post_type_obj ) :
651 $placement_label = $custom_post_type_obj->labels->name;
652 $placement_name = $custom_post_type_obj->name;
653 ?>
654 <br/>
655 <label>
656 <input name="A2A_SHARE_SAVE_display_in_cpt_<?php echo esc_attr( $placement_name ); ?>" type="checkbox"<?php if ( ! isset( $options['display_in_cpt_' . $placement_name] ) || $options['display_in_cpt_' . $placement_name] != '-1' ) echo ' checked="checked"'; ?> value="1"/>
657 <?php printf(
658 /* translators: 1: Position in content 2: Name of the custom post type */
659 __( 'Display at the %1$s of %2$s', 'add-to-any' ),
660 _a2a_position_in_content( $options, false ),
661 esc_html( $placement_label )
662 ); ?>
663 </label>
664 <?php endforeach; ?>
665
666 <br/><br/>
667 <div class="setting-description">
668 <?php _e("See <a href=\"widgets.php\" title=\"Theme Widgets\">Widgets</a> and <a href=\"options-general.php?page=addtoany&action=floating\" title=\"AddToAny Floating Share Buttons\">Floating</a> for additional placement options. For advanced placement, see <a href=\"https://wordpress.org/plugins/add-to-any/faq/\">the FAQs</a>.", 'add-to-any'); ?>
669 </div>
670 </fieldset></td>
671 </tr>
672
673 <tr valign="top">
674 <th scope="row"><?php _e('Additional JavaScript', 'add-to-any'); ?></th>
675 <td><fieldset id="addtoany_extra_section_additional_javascript" class="addtoany_extra_section" role="region">
676 <label for="A2A_SHARE_SAVE_additional_js_variables">
677 <p><?php _e('Below you can add special JavaScript code for AddToAny.', 'add-to-any'); ?>
678 <?php _e("Advanced users should explore AddToAny's <a href=\"https://www.addtoany.com/buttons/customize/wordpress\" target=\"_blank\">additional options</a>.", 'add-to-any'); ?></p>
679 </label>
680 <p>
681 <textarea name="A2A_SHARE_SAVE_additional_js_variables" id="A2A_SHARE_SAVE_additional_js_variables" class="code" style="width: 98%; font-size: 12px;" rows="6" cols="50"<?php _a2a_disabled_attr(); ?>><?php if ( isset( $options['additional_js_variables'] ) ) echo esc_textarea( $options['additional_js_variables'] ); ?></textarea>
682 </p>
683 </fieldset></td>
684 </tr>
685 <tr valign="top">
686 <th scope="row"><?php _e('Additional CSS', 'add-to-any'); ?></th>
687 <td><fieldset id="addtoany_extra_section_additional_css" class="addtoany_extra_section" role="region">
688 <label for="A2A_SHARE_SAVE_additional_css">
689 <p><?php _e('Below you can add special CSS code for AddToAny.', 'add-to-any'); ?>
690 <?php _e("Advanced users should explore AddToAny's <a href=\"https://www.addtoany.com/buttons/customize/wordpress\" target=\"_blank\">additional options</a>.", 'add-to-any'); ?></p>
691 </label>
692 <p>
693 <textarea name="A2A_SHARE_SAVE_additional_css" id="A2A_SHARE_SAVE_additional_css" class="code" style="width: 98%; font-size: 12px;" rows="6" cols="50"<?php _a2a_disabled_attr(); ?>><?php if ( isset( $options['additional_css'] ) ) echo esc_textarea( $options['additional_css'] ); ?></textarea>
694 </p>
695 </fieldset></td>
696 </tr>
697 <tr valign="top">
698 <th scope="row"><?php _e('Advanced Options', 'add-to-any'); ?></th>
699 <td><fieldset id="addtoany_extra_section_advanced_options" class="addtoany_extra_section" role="region">
700 <div class="addtoany_extra_element">
701 <label for="A2A_SHARE_SAVE_custom_icons">
702 <input name="A2A_SHARE_SAVE_custom_icons" id="A2A_SHARE_SAVE_custom_icons" type="checkbox"<?php if ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' ) echo ' checked="checked"'; ?> value="url"/>
703 <?php _e('Use custom icons. URL:', 'add-to-any'); ?>
704 </label>
705 <input name="A2A_SHARE_SAVE_custom_icons_url" type="text" class="code" size="50" style="vertical-align:middle" placeholder="//example.com/blog/uploads/addtoany/icons/custom/" value="<?php if ( isset( $options['custom_icons_url'] ) ) echo esc_attr( $options['custom_icons_url'] ); ?>" />
706 <br/>
707 <label for="A2A_SHARE_SAVE_custom_icons_type"><?php _e('Filename extension', 'add-to-any'); ?></label>
708 <input name="A2A_SHARE_SAVE_custom_icons_type" type="text" class="code" size="5" maxlength="4" placeholder="png" value="<?php if ( isset( $options['custom_icons_type'] ) ) echo esc_attr( $options['custom_icons_type'] ); else echo 'png'; ?>" />
709 <label for="A2A_SHARE_SAVE_custom_icons_width"><?php _e('Width'); ?></label>
710 <input name="A2A_SHARE_SAVE_custom_icons_width" type="number" max="300" min="10" maxlength="3" step="2" oninput="if(this.value.length > 3) this.value=this.value.slice(0, 3)" id="A2A_SHARE_SAVE_custom_icons_width" value="<?php if ( isset( $options['custom_icons_width'] ) ) echo esc_attr( $options['custom_icons_width'] ); ?>" class="small-text" />
711 <label for="A2A_SHARE_SAVE_custom_icons_height"><?php _e('Height'); ?></label>
712 <input name="A2A_SHARE_SAVE_custom_icons_height" type="number" max="300" min="10" maxlength="3" step="2" oninput="if(this.value.length > 3) this.value=this.value.slice(0, 3)" id="A2A_SHARE_SAVE_custom_icons_height" value="<?php if ( isset( $options['custom_icons_height'] ) ) echo esc_attr( $options['custom_icons_height'] ); ?>" class="small-text" />
713 <p class="description">
714 <?php _e("Specify the URL of the directory containing your custom icons. For example, a URL of <code>//example.com/blog/uploads/addtoany/icons/custom/</code> containing <code>facebook.png</code> and <code>twitter.png</code>. Be sure that custom icon filenames match the icon filenames in <code>plugins/add-to-any/icons</code>. For AddToAny's Universal Button, select Image URL and specify the URL of your AddToAny universal share icon (<a href=\"#\" onclick=\"document.getElementsByName('A2A_SHARE_SAVE_button_custom')[0].focus();return false\">above</a>).", 'add-to-any'); ?>
715 </p>
716 <br>
717 </div>
718 <div class="addtoany_extra_element">
719 <label for="A2A_SHARE_SAVE_cache">
720 <input name="A2A_SHARE_SAVE_cache" id="A2A_SHARE_SAVE_cache" type="checkbox"<?php if ( isset( $options['cache'] ) && $options['cache'] == '1' ) echo ' checked="checked"'; ?> value="1"/>
721 <?php _e('Cache AddToAny locally with daily cache updates', 'add-to-any'); ?>
722 </label>
723 <p class="description">
724 <?php _e("Most sites should not use this option. By default, AddToAny loads asynchronously and most efficiently. Since many visitors will have AddToAny cached in their browser already, serving AddToAny locally from your site will be slower for those visitors. If local caching is enabled, be sure to set far future cache/expires headers for image files in your <code>uploads/addtoany</code> directory.", 'add-to-any'); ?>
725 </p>
726 <br>
727 </div>
728 </fieldset></td>
729 </tr>
730 <?php endif; ?>
731
732 </table>
733
734 <?php if ( 'floating' == $current_screen ) : ?>
735
736 <p><?php _e('AddToAny &quot;floating&quot; share buttons stay in a fixed position even when the user scrolls.', 'add-to-any'); ?></p>
737
738 <h3><?php _e('Vertical Buttons', 'add-to-any'); ?></h3>
739 <table class="form-table">
740 <tr valign="top">
741 <th scope="row"><?php _e("Placement", 'add-to-any'); ?></th>
742 <td><fieldset>
743 <label><input type="radio" name="A2A_SHARE_SAVE_floating_vertical" value="left_docked"<?php if ( isset( $options['floating_vertical'] ) && 'left_docked' == $options['floating_vertical'] ) echo ' checked="checked"'; ?>> <?php _e('Left docked', 'add-to-any'); ?></label>
744 <br>
745 <label><input type="radio" name="A2A_SHARE_SAVE_floating_vertical" value="right_docked"<?php if ( isset( $options['floating_vertical'] ) && 'right_docked' == $options['floating_vertical'] ) echo ' checked="checked"'; ?>> <?php _e('Right docked', 'add-to-any'); ?></label>
746 <br>
747 <label><input type="radio" name="A2A_SHARE_SAVE_floating_vertical" value="left_attached"<?php if ( isset( $options['floating_vertical'] ) && 'left_attached' == $options['floating_vertical'] ) echo ' checked="checked"'; ?>> <?php _e('Attach to content', 'add-to-any'); ?></label>
748 <br>
749 <label><input type="radio" name="A2A_SHARE_SAVE_floating_vertical" value="none"<?php if ( ! isset( $options['floating_vertical'] ) || 'none' == $options['floating_vertical'] ) echo ' checked="checked"'; ?>> <?php _e('None', 'add-to-any'); ?></label>
750 <div class="addtoany_floating_vertical_attached_to">
751 <br>
752 <label>
753 Attach to <input name="A2A_SHARE_SAVE_floating_vertical_attached_to" type="text" class="regular-text code" placeholder=".content-area" value="<?php if ( isset( $options['floating_vertical_attached_to'] ) ) echo esc_attr( $options['floating_vertical_attached_to'] ); else echo esc_attr( 'main, [role="main"], article, .status-publish' ); ?>" />
754 <p class="description">Enter a <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors" class="description" rel="noopener" target="_blank">CSS selector</a>, or group of selectors, that match the HTML element you want to attach to.</p>
755 </label>
756 </div>
757 </fieldset></td>
758 </tr>
759 <tr valign="top">
760 <th scope="row"><?php _e("Responsiveness", 'add-to-any'); ?></th>
761 <td><fieldset>
762 <label>
763 <input id="A2A_SHARE_SAVE_floating_vertical_responsive" name="A2A_SHARE_SAVE_floating_vertical_responsive" type="checkbox"<?php
764 if ( ! isset( $options['floating_vertical_responsive'] ) || $options['floating_vertical_responsive'] != '-1' ) echo ' checked="checked"'; ?> value="1" />
765 Hide on mobile screens <input name="A2A_SHARE_SAVE_floating_vertical_responsive_max_width" type="number" value="<?php if ( isset( $options['floating_vertical_responsive_max_width'] ) ) echo esc_attr( $options['floating_vertical_responsive_max_width'] ); else echo '980'; ?>" class="small-text" /> pixels or narrower
766 </label>
767 <br>
768 <label>
769 <input id="A2A_SHARE_SAVE_floating_vertical_scroll_top" name="A2A_SHARE_SAVE_floating_vertical_scroll_top" type="checkbox"<?php
770 if ( ! empty( $options['floating_vertical_scroll_top'] ) && $options['floating_vertical_scroll_top'] == '1' ) echo ' checked="checked"'; ?> value="1" />
771 Hide until page is scrolled <input name="A2A_SHARE_SAVE_floating_vertical_scroll_top_pixels" type="number" value="<?php if ( isset( $options['floating_vertical_scroll_top_pixels'] ) ) echo esc_attr( $options['floating_vertical_scroll_top_pixels'] ); else echo '100'; ?>" class="small-text" /> pixels or more from the top
772 </label>
773 <br>
774 <label>
775 <input id="A2A_SHARE_SAVE_floating_vertical_scroll_bottom" name="A2A_SHARE_SAVE_floating_vertical_scroll_bottom" type="checkbox"<?php
776 if ( ! empty( $options['floating_vertical_scroll_bottom'] ) && $options['floating_vertical_scroll_bottom'] == '1' ) echo ' checked="checked"'; ?> value="1" />
777 Hide when page is scrolled <input name="A2A_SHARE_SAVE_floating_vertical_scroll_bottom_pixels" type="number" value="<?php if ( isset( $options['floating_vertical_scroll_bottom_pixels'] ) ) echo esc_attr( $options['floating_vertical_scroll_bottom_pixels'] ); else echo '100'; ?>" class="small-text" /> pixels or less from the bottom
778 </label>
779 </fieldset></td>
780 </tr>
781 <tr valign="top">
782 <th scope="row"><?php _e("Position", 'add-to-any'); ?></th>
783 <td><fieldset>
784 <label><input name="A2A_SHARE_SAVE_floating_vertical_position" type="number" value="<?php if ( isset( $options['floating_vertical_position'] ) ) echo esc_attr( $options['floating_vertical_position'] ); else echo '100'; ?>" class="small-text" /> pixels from top</label>
785 </fieldset></td>
786 </tr>
787 <tr valign="top">
788 <th scope="row"><?php _e("Offset", 'add-to-any'); ?></th>
789 <td><fieldset>
790 <label><input name="A2A_SHARE_SAVE_floating_vertical_offset" type="number" value="<?php if ( isset( $options['floating_vertical_offset'] ) ) echo esc_attr( $options['floating_vertical_offset'] ); else echo '0'; ?>" class="small-text" /> pixels from left <span id="addtoany_vertical_offset_text">or right</span></label>
791 </fieldset></td>
792 </tr>
793 <tr valign="top">
794 <th scope="row"><?php _e("Icon Size", 'add-to-any'); ?></th>
795 <td><fieldset>
796 <label><input name="A2A_SHARE_SAVE_floating_vertical_icon_size" type="number" max="300" min="10" maxlength="3" step="2" oninput="if(this.value.length > 3) this.value=this.value.slice(0, 3)" placeholder="32" value="<?php if ( isset( $options['floating_vertical_icon_size'] ) ) echo esc_attr( $options['floating_vertical_icon_size'] ); else echo '32'; ?>" class="small-text"> pixels</label>
797 </fieldset></td>
798 </tr>
799 <tr valign="top">
800 <th scope="row"><?php _e('Background', 'add-to-any'); ?></th>
801 <td><fieldset>
802 <label>
803 <select class="addtoany_icon_color" name="A2A_SHARE_SAVE_floating_vertical_bg">
804 <option value="transparent"<?php _a2a_selected_attr('transparent', 'floating_vertical_bg', $options); ?>>Transparent</option>
805 <option value="custom"<?php _a2a_selected_attr('custom', 'floating_vertical_bg', $options); ?>>Custom&#8230;</option>
806 </select>
807 </label>
808 <div class="color-field-container"><input name="A2A_SHARE_SAVE_floating_vertical_bg_color" class="color-field" type="text" value="<?php echo ! empty( $options['floating_vertical_bg_color'] ) ? esc_attr( $options['floating_vertical_bg_color'] ) : '#ffffff'; ?>" data-default-color="#ffffff"></div>
809 </fieldset></td>
810 </tr>
811 </table>
812
813 <h3><?php _e('Horizontal Buttons', 'add-to-any'); ?></h3>
814 <table class="form-table">
815 <tr valign="top">
816 <th scope="row"><?php _e("Placement", 'add-to-any'); ?></th>
817 <td><fieldset>
818 <label><input type="radio" name="A2A_SHARE_SAVE_floating_horizontal" value="left_docked"<?php if ( isset( $options['floating_horizontal'] ) && 'left_docked' == $options['floating_horizontal'] ) echo ' checked="checked"'; ?>> <?php _e('Left docked', 'add-to-any'); ?></label>
819 <br>
820 <label><input type="radio" name="A2A_SHARE_SAVE_floating_horizontal" value="right_docked"<?php if ( isset( $options['floating_horizontal'] ) && 'right_docked' == $options['floating_horizontal'] ) echo ' checked="checked"'; ?>> <?php _e('Right docked', 'add-to-any'); ?></label>
821 <br>
822 <label><input type="radio" name="A2A_SHARE_SAVE_floating_horizontal" value="center_docked"<?php if ( isset( $options['floating_horizontal'] ) && 'center_docked' == $options['floating_horizontal'] ) echo ' checked="checked"'; ?>> <?php _e('Center docked', 'add-to-any'); ?></label>
823 <br>
824 <label><input type="radio" name="A2A_SHARE_SAVE_floating_horizontal" value="none"<?php if ( ! isset( $options['floating_horizontal'] ) || 'none' == $options['floating_horizontal'] ) echo ' checked="checked"'; ?>> <?php _e('None', 'add-to-any'); ?></label>
825 </fieldset></td>
826 </tr>
827 <tr valign="top">
828 <th scope="row"><?php _e("Responsiveness", 'add-to-any'); ?></th>
829 <td><fieldset>
830 <label>
831 <input id="A2A_SHARE_SAVE_floating_horizontal_responsive" name="A2A_SHARE_SAVE_floating_horizontal_responsive" type="checkbox"<?php
832 if ( ! isset( $options['floating_horizontal_responsive'] ) || $options['floating_horizontal_responsive'] != '-1' ) echo ' checked="checked"'; ?> value="1" />
833 Hide on desktop screens <input name="A2A_SHARE_SAVE_floating_horizontal_responsive_min_width" type="number" value="<?php if ( isset( $options['floating_horizontal_responsive_min_width'] ) ) echo esc_attr( $options['floating_horizontal_responsive_min_width'] ); else echo '981'; ?>" class="small-text" /> pixels or wider
834 </label>
835 <br>
836 <label>
837 <input id="A2A_SHARE_SAVE_floating_horizontal_scroll_top" name="A2A_SHARE_SAVE_floating_horizontal_scroll_top" type="checkbox"<?php
838 if ( ! empty( $options['floating_horizontal_scroll_top'] ) && $options['floating_horizontal_scroll_top'] == '1' ) echo ' checked="checked"'; ?> value="1" />
839 Hide until page is scrolled <input name="A2A_SHARE_SAVE_floating_horizontal_scroll_top_pixels" type="number" value="<?php if ( isset( $options['floating_horizontal_scroll_top_pixels'] ) ) echo esc_attr( $options['floating_horizontal_scroll_top_pixels'] ); else echo '100'; ?>" class="small-text" /> pixels or more from the top
840 </label>
841 <br>
842 <label>
843 <input id="A2A_SHARE_SAVE_floating_horizontal_scroll_bottom" name="A2A_SHARE_SAVE_floating_horizontal_scroll_bottom" type="checkbox"<?php
844 if ( ! empty( $options['floating_horizontal_scroll_bottom'] ) && $options['floating_horizontal_scroll_bottom'] == '1' ) echo ' checked="checked"'; ?> value="1" />
845 Hide when page is scrolled <input name="A2A_SHARE_SAVE_floating_horizontal_scroll_bottom_pixels" type="number" value="<?php if ( isset( $options['floating_horizontal_scroll_bottom_pixels'] ) ) echo esc_attr( $options['floating_horizontal_scroll_bottom_pixels'] ); else echo '100'; ?>" class="small-text" /> pixels or less from the bottom
846 </label>
847 </fieldset></td>
848 </tr>
849 <tr valign="top">
850 <th scope="row"><?php _e("Position", 'add-to-any'); ?></th>
851 <td><fieldset>
852 <label><input name="A2A_SHARE_SAVE_floating_horizontal_position" type="number" value="<?php if ( isset( $options['floating_horizontal_position'] ) ) echo esc_attr( $options['floating_horizontal_position'] ); else echo '0'; ?>" class="small-text" /> pixels from left or right</label>
853 </fieldset></td>
854 </tr>
855 <tr valign="top">
856 <th scope="row"><?php _e("Offset", 'add-to-any'); ?></th>
857 <td><fieldset>
858 <label><input name="A2A_SHARE_SAVE_floating_horizontal_offset" type="number" value="<?php if ( isset( $options['floating_horizontal_offset'] ) ) echo esc_attr( $options['floating_horizontal_offset'] ); else echo '0'; ?>" class="small-text" /> pixels from bottom</label>
859 </fieldset></td>
860 </tr>
861 <tr valign="top">
862 <th scope="row"><?php _e("Icon Size", 'add-to-any'); ?></th>
863 <td><fieldset>
864 <label><input name="A2A_SHARE_SAVE_floating_horizontal_icon_size" type="number" max="300" min="10" maxlength="3" step="2" oninput="if(this.value.length > 3) this.value=this.value.slice(0, 3)" placeholder="32" value="<?php if ( isset( $options['floating_horizontal_icon_size'] ) ) echo esc_attr( $options['floating_horizontal_icon_size'] ); else echo '32'; ?>" class="small-text"> pixels</label>
865 </fieldset></td>
866 </tr>
867 <tr valign="top">
868 <th scope="row"><?php _e('Background', 'add-to-any'); ?></th>
869 <td><fieldset>
870 <label>
871 <select class="addtoany_icon_color" name="A2A_SHARE_SAVE_floating_horizontal_bg">
872 <option value="transparent"<?php _a2a_selected_attr('transparent', 'floating_horizontal_bg', $options); ?>>Transparent</option>
873 <option value="custom"<?php _a2a_selected_attr('custom', 'floating_horizontal_bg', $options); ?>>Custom&#8230;</option>
874 </select>
875 </label>
876 <div class="color-field-container"><input name="A2A_SHARE_SAVE_floating_horizontal_bg_color" class="color-field" type="text" value="<?php echo ! empty( $options['floating_horizontal_bg_color'] ) ? esc_attr( $options['floating_horizontal_bg_color'] ) : '#ffffff'; ?>" data-default-color="#ffffff"></div>
877 </fieldset></td>
878 </tr>
879 </table>
880
881 <?php endif; ?>
882
883 </table>
884
885 <p class="submit">
886 <input class="button-primary" type="submit" name="Submit" value="<?php _e('Save Changes', 'add-to-any' ) ?>" />
887 <input id="A2A_SHARE_SAVE_reset_options" type="submit" name="Reset" onclick="return confirm('<?php _e('Are you sure you want to delete all AddToAny options?', 'add-to-any' ) ?>')" value="<?php _e('Reset', 'add-to-any' ) ?>" />
888 </p>
889
890 </form>
891
892 <h2><?php _e('Like this plugin?','add-to-any'); ?></h2>
893 <p><?php _e('<a href="https://wordpress.org/support/plugin/add-to-any/reviews/#new-post" target="_blank">Give it a 5 star rating</a> on WordPress.org.','add-to-any'); ?></p>
894 <p><?php _e('<a href="https://www.addtoany.com/share#title=WordPress%20Share%20Plugin%20by%20AddToAny.com&amp;url=https%3A%2F%2Fwordpress.org%2Fplugins%2Fadd-to-any%2F">Share it</a> and follow <a href="https://www.addtoany.com/">AddToAny</a> on <a href="https://www.facebook.com/AddToAny" target="_blank">Facebook</a> &amp; <a href="https://twitter.com/AddToAny" target="_blank">Twitter</a>.','add-to-any'); ?></p>
895
896 <h2><?php _e('Need support?','add-to-any'); ?></h2>
897 <p><?php _e('See the <a href="https://wordpress.org/plugins/add-to-any/faq/">FAQs</a>.','add-to-any'); ?></p>
898 <p><?php _e('Search the <a href="https://wordpress.org/support/plugin/add-to-any">support forums</a>.','add-to-any'); ?></p>
899 </div>
900
901 <script src="https://static.addtoany.com/menu/page.js"></script>
902 <script>
903 jQuery(document).on( 'load', function() {
904 if ( ! window.a2a) jQuery('<div class="error"><p><strong>Something is preventing AddToAny from loading. Try disabling content blockers such as ad-blocking add-ons, or try another web browser.</strong></p></div>').insertBefore('.nav-tab-wrapper:eq(0)');
905 if ( window.a2a && a2a.svg_css ) a2a.svg_css();
906 });
907 </script>
908
909 <?php
910
911 }
912
913 // Admin page header
914 function A2A_SHARE_SAVE_admin_head() {
915 if ( isset( $_GET['page'] ) && $_GET['page'] == 'addtoany' ) {
916
917 $options = get_option( 'addtoany_options', array() );
918
919 ?>
920 <script>
921 jQuery(document).ready(function(){
922
923 // Add color picker
924 jQuery('.color-field').wpColorPicker();
925
926 function show_color_picker_for_custom(arg_1){
927 var $this = jQuery(this);
928 var $colorFieldParent = $this.parent().next('div').first();
929
930 if ('custom' === $this.val()) {
931 // If first argument is a number, indicating $.each() is the caller
932 if (typeof arg_1 === 'number') {
933 $colorFieldParent.fadeIn('fast');
934 } else {
935 $colorFieldParent.slideDown('fast');
936 }
937 } else {
938 $colorFieldParent.hide();
939 }
940 }
941
942 // Show color picker when "Custom" color is selected
943 jQuery('select.addtoany_icon_color').on('change', show_color_picker_for_custom).each(show_color_picker_for_custom);
944
945 // Toggle child options of 'Display in posts'
946 jQuery('#A2A_SHARE_SAVE_display_in_posts').on('change', function(e){
947 if (jQuery(this).is(':checked'))
948 jQuery('.A2A_SHARE_SAVE_child_of_display_in_posts').attr('checked', true).attr('disabled', false);
949 else
950 jQuery('.A2A_SHARE_SAVE_child_of_display_in_posts').attr('checked', false).attr('disabled', true);
951 });
952
953 // Update button position labels/values universally in Placement section
954 jQuery('select[name="A2A_SHARE_SAVE_position"]').on('change', function(e){
955 var $this = jQuery(this);
956 jQuery('select[name="A2A_SHARE_SAVE_position"]').not($this).val($this.val());
957
958 jQuery('.A2A_SHARE_SAVE_position').html($this.find('option:selected').html());
959 });
960
961 var entityMap = {
962 '&': '&amp;',
963 '<': '&lt;',
964 '>': '&gt;',
965 '"': '&quot;',
966 "'": '&#39;',
967 '/': '&#x2F;',
968 '`': '&#x60;',
969 '=': '&#x3D;'
970 };
971
972 function escapeHtml (string) {
973 return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
974 return entityMap[s];
975 });
976 }
977
978 var to_input = function(this_sortable){
979 // Clear any previous hidden inputs for storing chosen services
980 // and special service options
981 jQuery('input.addtoany_hidden_options').remove();
982
983 var services_array = jQuery(this_sortable).sortable('toArray'),
984 services_size = services_array.length;
985 if (services_size < 1) return;
986
987 for (var i=0, service_name, show_count_value, fb_verb_value; i < services_size; i++) {
988 if(services_array[i]!='') { // Exclude dummy icon
989 jQuery('#addtoany_admin_form').append('<input class="addtoany_hidden_options" name="A2A_SHARE_SAVE_active_services[]" type="hidden" value="'+escapeHtml(services_array[i])+'"/>');
990
991 // Special service options?
992 service_name = services_array[i].substr(7);
993 if (service_name == 'facebook_like' || service_name == 'pinterest_pin') {
994 show_count_value = (jQuery('#' + services_array[i] + '_show_count').is(':checked')) ? '1' : '-1' ;
995 jQuery('#addtoany_admin_form').append('<input class="addtoany_hidden_options" name="addtoany_' + service_name + '_show_count" type="hidden" value="' + show_count_value + '"/>');
996
997 if (service_name == 'facebook_like') {
998 fb_verb_value = (jQuery('#' + services_array[i] + '_verb').val() == 'recommend') ? 'recommend' : 'like';
999 jQuery('#addtoany_admin_form').append('<input class="addtoany_hidden_options" name="addtoany_' + service_name + '_verb" type="hidden" value="' + fb_verb_value + '"/>');
1000 }
1001 // AddToAny counters
1002 } else if ( jQuery.inArray( service_name, ['pinterest', 'reddit', 'tumblr'] ) > -1 ) {
1003 show_count_value = (jQuery('#' + services_array[i] + '_show_count').is(':checked')) ? '1' : '-1' ;
1004 jQuery('#addtoany_admin_form').append('<input class="addtoany_hidden_options" name="addtoany_' + service_name + '_show_count" type="hidden" value="' + show_count_value + '"/>');
1005 }
1006 }
1007 }
1008 };
1009
1010 jQuery('#addtoany_services_sortable').sortable({
1011 forcePlaceholderSize: true,
1012 items: 'li:not(#addtoany_show_services, .dummy)',
1013 placeholder: 'ui-sortable-placeholder',
1014 opacity: .6,
1015 tolerance: 'pointer',
1016 update: function(){to_input(this)}
1017 });
1018
1019 // Service click = move to sortable list
1020 var moveToSortableList = function(){
1021 var configurable_html = '',
1022 this_service = jQuery(this),
1023 this_service_name = this_service.attr('id').substr(7),
1024 this_service_is_special = this_service.hasClass('addtoany_special_service'),
1025 this_service_is_3p = this_service.hasClass('addtoany_3p_button'),
1026 checked = '',
1027 special_options_html = '';
1028
1029 if (jQuery('#addtoany_services_sortable li').not('.dummy').length == 0)
1030 jQuery('#addtoany_services_sortable').find('.dummy').hide();
1031
1032 // If special service that has special options
1033 if ( this_service_is_special && -1 === jQuery.inArray( this_service_name, ['twitter_tweet'] ) ) {
1034 // Common "Show count" for facebook, pinterest, pinterest_pin, etc.
1035 if (service_options[this_service_name] && service_options[this_service_name].show_count) {
1036 checked = ' checked="checked"';
1037 }
1038 special_options_html += '<label><input' + checked + ' id="' + this_service.attr('id') + '_show_count" name="' + this_service.attr('id') + '_show_count" type="checkbox" value="1"> Show count</label>';
1039
1040 if ('facebook_like' == this_service_name) {
1041 if (service_options[this_service_name] && service_options[this_service_name].verb)
1042 checked = ' selected="selected"';
1043 special_options_html += '<br><select id="' + this_service.attr('id') + '_verb" name="' + this_service.attr('id') + '_verb">'
1044 + '<option value="like">Like</option>'
1045 + '<option' + checked + ' value="recommend">Recommend</option>'
1046 + '</select>';
1047 }
1048
1049 if (special_options_html.length > 0) {
1050 configurable_html = '<span class="down_arrow"></span><br style="clear:both"/><div class="special_options">' + special_options_html + '</div>';
1051 }
1052 }
1053
1054 var new_service = this_service.toggleClass('addtoany_selected')
1055 .off('click', moveToSortableList)
1056 .on('click', moveToSelectableList)
1057 .clone();
1058
1059 new_service.data('a2a_32_icon_html', this_service.find('img').clone().attr('alt', this_service.attr('title')).wrap('<p>').parent().html() + configurable_html);
1060
1061 new_service.html( new_service.data('a2a_32_icon_html') )
1062 .click(function(){
1063 jQuery(this).not('.addtoany_special_service_options_selected').find('.special_options').slideDown('fast').parent().addClass('addtoany_special_service_options_selected');
1064 })
1065 .hide()
1066 .insertBefore('#addtoany_services_sortable .dummy')
1067 .fadeIn('fast');
1068
1069 this_service.attr( 'id', 'old_'+this_service.attr('id') );
1070 };
1071
1072 // Service click again = move back to selectable list
1073 var moveToSelectableList = function(){
1074 jQuery(this).toggleClass('addtoany_selected')
1075 .off('click', moveToSelectableList)
1076 .on('click', moveToSortableList);
1077
1078 jQuery( '#'+jQuery(this).attr('id').substr(4).replace(/\./, '\\.') )
1079 .hide('fast', function(){
1080 jQuery(this).remove();
1081 });
1082
1083 if( jQuery('#addtoany_services_sortable li').not('.dummy').length==1 )
1084 jQuery('#addtoany_services_sortable').find('.dummy').show();
1085
1086 jQuery(this).attr('id', jQuery(this).attr('id').substr(4));
1087 };
1088
1089 // Service click = move to sortable list
1090 jQuery('#addtoany_services_selectable li').on('click', moveToSortableList);
1091
1092 // Form submit = get sortable list
1093 jQuery('#addtoany_admin_form').submit(function(){to_input('#addtoany_services_sortable')});
1094
1095 // Auto-select active services
1096 <?php
1097 $admin_services_saved = isset( $_POST['A2A_SHARE_SAVE_active_services'] ) && isset( $_POST['Submit'] );
1098
1099 if ( $admin_services_saved ) {
1100 $active_services = isset( $_POST['A2A_SHARE_SAVE_active_services'] ) ? array_map( 'sanitize_text_field', $_POST['A2A_SHARE_SAVE_active_services'] ) : array();
1101 } elseif ( ! $admin_services_saved && isset( $options['active_services'] ) ) {
1102 $active_services = $options['active_services'];
1103 } else {
1104 // Use default services if options have not been set yet (and no services were just saved in the form)
1105 $active_services = array( 'facebook', 'twitter', 'email' );
1106 }
1107
1108 $active_services_for_js = array();
1109 $service_options_for_js = array();
1110 foreach ($active_services as $service) {
1111 if ( $admin_services_saved )
1112 $service = substr( $service, 7 ); // Remove a2a_wp_
1113 $active_services_for_js[] = $service;
1114
1115 // AddToAny counter enabled?
1116 if ( in_array( $service, array( 'pinterest', 'reddit', 'tumblr', ) ) ) {
1117 if ( isset( $_POST['addtoany_' . $service . '_show_count'] ) && $_POST['addtoany_' . $service . '_show_count'] == '1'
1118 || ! isset( $_POST['addtoany_' . $service . '_show_count'] )
1119 && isset( $options['special_' . $service . '_options'] )
1120 && isset( $options['special_' . $service . '_options']['show_count'] )
1121 && $options['special_' . $service . '_options']['show_count'] == '1'
1122 ) {
1123 $service_options_for_js[$service]['show_count'] = 1;
1124 }
1125 }
1126 }
1127 ?>
1128
1129 var services = <?php echo wp_json_encode( $active_services_for_js ); ?>;
1130
1131 <?php
1132 if ( isset( $_POST['addtoany_facebook_like_verb'] ) && $_POST['addtoany_facebook_like_verb'] == 'recommend'
1133 || ! isset( $_POST['addtoany_facebook_like_verb'] )
1134 && isset( $options['special_facebook_like_options'] ) && isset( $options['special_facebook_like_options']['verb'] )
1135 && $options['special_facebook_like_options']['verb'] == 'recommend'
1136 ) {
1137 $service_options_for_js['facebook_like']['verb'] = 'recommend';
1138 }
1139 if ( isset( $_POST['addtoany_facebook_like_show_count'] ) && $_POST['addtoany_facebook_like_show_count'] == '1'
1140 || ! isset( $_POST['addtoany_facebook_like_show_count'] )
1141 && isset( $options['special_facebook_like_options'] ) && isset( $options['special_facebook_like_options']['show_count'] )
1142 && $options['special_facebook_like_options']['show_count'] == '1'
1143 ){
1144 $service_options_for_js['facebook_like']['show_count'] = 1;
1145 }
1146 if ( isset( $_POST['addtoany_pinterest_pin_show_count'] ) && $_POST['addtoany_pinterest_pin_show_count'] == '1'
1147 || ! isset( $_POST['addtoany_pinterest_pin_show_count'] )
1148 && isset( $options['special_pinterest_pin_options'] ) && isset( $options['special_pinterest_pin_options']['show_count'] )
1149 && $options['special_pinterest_pin_options']['show_count'] == '1'
1150 ) {
1151 $service_options_for_js['pinterest_pin']['show_count'] = 1;
1152 }
1153 ?>
1154
1155 var service_options = <?php echo wp_json_encode( $service_options_for_js ); ?>;
1156
1157 jQuery.each(services, function(i, val) {
1158 try {
1159 jQuery('#a2a_wp_'+escapeHtml(val)).click();
1160 } catch(e) {
1161 if (console && console.warn)
1162 console.warn('Invalid CSS selector: ' + val);
1163 }
1164 });
1165
1166 // Add/Remove Services button
1167 jQuery('#addtoany_services_sortable .dummy:first').after('<li id="addtoany_show_services"><?php _e('Add/Remove Services', 'add-to-any'); ?> &#187;</li>');
1168 jQuery('#addtoany_show_services').click(function(e) {
1169 jQuery('#addtoany_services_selectable, #addtoany_services_info, #addtoany_services_tip').slideDown('fast');
1170 jQuery(this).fadeOut('fast');
1171 });
1172
1173 // Inserts an accessible 'show section/elements' button
1174 function addtoany_insert_show_button(index) {
1175 var section = jQuery(this);
1176 // If not already inserted
1177 if ( ! section.next('fieldset').has('.addtoany_show_more_button').length ) {
1178 section.attr('aria-expanded', 'false').attr('tabindex', '-1')
1179 .after('<fieldset><button class="addtoany_show_more_button button" type="button" aria-controls="' + section.attr('id') + '"><span class="dashicons dashicons-arrow-down"></span></button></fieldset>');
1180 }
1181 }
1182 // Hide each 'extra' element that does not contain a checked/selected input
1183 jQuery('.addtoany_extra_element:not(:has(input:checked))').hide().parents('fieldset')
1184 // Insert 'show' button into section
1185 .each(addtoany_insert_show_button);
1186 // Hide each 'extra' section if it is not .addtoany_show_extra,
1187 // does not contain visible .addtoany_extra_element elements,
1188 // and does not contain a textarea with a value
1189 jQuery('.addtoany_extra_section:not(.addtoany_show_extra, :has(.addtoany_extra_element:visible), :has(textarea:not(:empty)))').hide()
1190 // Insert 'show' button into each section
1191 .each(addtoany_insert_show_button);
1192 // Handle click on 'show section' button
1193 jQuery('.addtoany_extra_section').next('fieldset').find('.addtoany_show_more_button').click(function(e) {
1194 var button = jQuery(this);
1195 var section = button.parent().prev('fieldset');
1196 button.hide('fast');
1197 section.children('.addtoany_extra_element').slideDown('fast');
1198 section.slideDown('fast').attr('aria-expanded', 'true').focus();
1199 });
1200 // Add margin-top to 'show section' buttons if section is visible
1201 jQuery('.addtoany_extra_section:visible').next('fieldset').find('.addtoany_show_more_button').css('margin-top', '10px');
1202
1203 // Show/hide selector input for floating vertical "attached" placement
1204 var floating_vertical_selector = 'input[name="A2A_SHARE_SAVE_floating_vertical"]';
1205 var floating_vertical_offset = jQuery('[name="A2A_SHARE_SAVE_floating_vertical_offset"]');
1206 function floating_vertical_attached_selected() {
1207 return -1 !== jQuery.inArray( jQuery(floating_vertical_selector+':checked').val(), ['left_attached', 'right_attached'] ) ? true : false;
1208 }
1209 if ( floating_vertical_attached_selected() ) {
1210 jQuery('.addtoany_floating_vertical_attached_to').slideDown('fast');
1211 jQuery('#addtoany_vertical_offset_text').text('of content');
1212 }
1213 jQuery(floating_vertical_selector).on('change', function(e) {
1214 if ( floating_vertical_attached_selected() ) {
1215 jQuery('.addtoany_floating_vertical_attached_to').slideDown('fast');
1216 jQuery('#addtoany_vertical_offset_text').text('of content');
1217 var offset = floating_vertical_offset;
1218 window.__addtoany_vertical_offset = offset.val();
1219 if ( '0' == offset.val() ) {
1220 var icon_size = parseInt( jQuery('[name="A2A_SHARE_SAVE_floating_vertical_icon_size"]').val(), 10 );
1221 offset.val( '-' + icon_size * 2 );
1222 }
1223 } else {
1224 jQuery('.addtoany_floating_vertical_attached_to').slideUp('fast');
1225 jQuery('#addtoany_vertical_offset_text').text('or right');
1226 if (window.__addtoany_vertical_offset) {
1227 floating_vertical_offset.val( window.__addtoany_vertical_offset );
1228 delete window.__addtoany_vertical_offset;
1229 }
1230 }
1231 });
1232 });
1233 </script>
1234
1235 <style>
1236 .addtoany_floating_vertical_attached_to,
1237 .color-field-container,
1238 .CodeMirror-hints{display:none;}
1239
1240 .ui-sortable-placeholder{background-color:transparent;border:1px dashed #CCC !important;}
1241 .addtoany_admin_list{list-style:none;padding:0;margin:0;}
1242 .addtoany_admin_list li{border-radius:6px;}
1243
1244 #addtoany_services_selectable{clear:left;display:none;}
1245 #addtoany_services_selectable li{cursor:pointer;float:left;width:150px;font-size:12px;line-height:24px;margin:0;padding:6px;border:1px solid transparent;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
1246 #addtoany_services_selectable li:hover, #addtoany_services_selectable li.addtoany_selected{border:1px solid #CCC;background-color:#FFF;}
1247 #addtoany_services_selectable li.addtoany_selected:hover{border-color:#F00;}
1248 #addtoany_services_selectable li:active{border:1px solid #000;}
1249 #addtoany_services_selectable img{border-radius:4px;margin:0 6px;width:24px;height:24px;border:0;vertical-align:top;}
1250 #addtoany_services_selectable .addtoany_3p_button{padding:8px 6px 4px;}
1251 #addtoany_services_selectable .addtoany_3p_button img{border-radius:0;width:auto;height:20px;}
1252
1253 /* Work around jQuery UI 1.13.0 bug: https://github.com/jquery/jquery-ui/issues/1998 */
1254 #addtoany_services_sortable{display:flex;flex-flow:row wrap;align-items:flex-start;}
1255 #addtoany_services_sortable li, #addtoany_services_sortable li.dummy:hover{cursor:move;float:left;padding:14px 10px;border:1px solid transparent;}
1256 #addtoany_services_sortable li:hover{border:1px solid #CCC;background-color:#FFF;}
1257 #addtoany_services_sortable li.dummy, #addtoany_services_sortable li.dummy:hover{cursor:auto;background-color:transparent;}
1258 #addtoany_services_sortable img{width:32px;height:32px;border:0;border-radius:4px;vertical-align:middle;}
1259 #addtoany_services_sortable .addtoany_3p_button img{width:auto;height:20px;float:left;}
1260 #addtoany_services_sortable .addtoany_special_service {position: relative;}
1261 #addtoany_services_sortable .addtoany_special_service span.down_arrow{background:url(<?php echo admin_url( '/images/arrows.png' ); ?>) no-repeat 2px 9px;bottom: -6px;left: 50%;margin:0 0 0 -10px;position:absolute;height:29px;width:14px;}
1262 #addtoany_services_sortable .addtoany_special_service div.special_options{display:none;font-size:11px;margin-top:9px;}
1263 #addtoany_services_sortable .addtoany_special_service_options_selected{border:1px solid #CCC;background-color:#FFF;}
1264 #addtoany_services_sortable .addtoany_special_service_options_selected span.down_arrow{display:none;}
1265
1266 li#addtoany_show_services{border:1px solid #DFDFDF;background-color:#FFF;cursor:pointer;line-height:32px;margin-left:9px;}
1267 li#addtoany_show_services:hover{border:1px solid #CCC;}
1268 #addtoany_services_info, #addtoany_services_tip{clear:left;display:none;margin:12px;padding:10px 0;}
1269 #addtoany_services_tip{padding:20px 0 0;}
1270 #addtoany_services_tip img{border-radius:4px;background-color:#444;}
1271
1272 /* No outline during ARIA focus */
1273 .addtoany_extra_section {
1274 outline: 0;
1275 }
1276 /* Adjust position of arrow icon on 'show more' button */
1277 .addtoany_show_more_button .dashicons {
1278 position: relative;
1279 right: 1px;
1280 top: 2px;
1281 }
1282 @media screen and (max-width: 782px) {
1283 .addtoany_show_more_button .dashicons {
1284 top: 0px;
1285 }
1286 }
1287
1288 .a2a_kit_size_32.addtoany_override .a2a_svg,
1289 .a2a_kit_size_32.addtoany_override img {
1290 border-radius: 4px;
1291 display:inline-block;
1292 height: 32px;
1293 vertical-align:middle;
1294 width: 32px;
1295 }
1296 .a2a_kit_size_32.addtoany_override img {
1297 background-color: #0166FF;
1298 margin-left: 9px;
1299 }
1300
1301 #A2A_SHARE_SAVE_reset_options{color:red;margin-left: 15px;}
1302 </style>
1303 <?php
1304
1305 }
1306 }
1307
1308 add_filter( 'admin_head', 'A2A_SHARE_SAVE_admin_head' );
1309
1310 function addtoany_admin_scripts( $current_admin_page ) {
1311 if ( 'settings_page_addtoany' !== $current_admin_page ) {
1312 return;
1313 }
1314
1315 wp_enqueue_script( 'jquery-ui-sortable' );
1316 wp_enqueue_script( 'wp-color-picker' );
1317 wp_enqueue_style( 'wp-color-picker' );
1318
1319 // If current screen is the default tab and WordPress >= 4.9
1320 if ( empty( $_GET['action'] ) && function_exists( 'wp_enqueue_code_editor' ) ) {
1321 $readOnly_value = current_user_can( 'unfiltered_html' ) ? false : 'nocursor';
1322
1323 // Additional JavaScript editor.
1324 // Enqueue code editor and settings for manipulating JavaScript.
1325 $settings = wp_enqueue_code_editor( array(
1326 'type' => 'text/javascript',
1327 'jshint' => array(
1328 'globals' => array( 'a2a_config' => true ),
1329 'quotmark' => false,
1330 'undef' => false,
1331 'unused' => false,
1332 ),
1333 'codemirror' => array(
1334 'lineNumbers' => false,
1335 'readOnly' => $readOnly_value,
1336 ),
1337 ) );
1338
1339 // If user hasn't disabled CodeMirror.
1340 if ( false !== $settings ) {
1341 wp_add_inline_script(
1342 'code-editor',
1343 sprintf(
1344 'jQuery( function() { var wpCodeEditor = wp.codeEditor.initialize( "A2A_SHARE_SAVE_additional_js_variables", %s ); window.wpa2aCodeEditorJS = wpCodeEditor.codemirror; } );',
1345 wp_json_encode( $settings )
1346 )
1347 );
1348
1349 // Additional CSS editor.
1350 // Enqueue code editor and settings for manipulating CSS.
1351 $settings = wp_enqueue_code_editor( array(
1352 'type' => 'text/css',
1353 'codemirror' => array(
1354 'lineNumbers' => false,
1355 'readOnly' => $readOnly_value,
1356 ),
1357 ) );
1358
1359 wp_add_inline_script(
1360 'code-editor',
1361 sprintf(
1362 'jQuery( function() { var wpCodeEditor = wp.codeEditor.initialize( "A2A_SHARE_SAVE_additional_css", %s ); window.wpa2aCodeEditorCSS = wpCodeEditor.codemirror; } );',
1363 wp_json_encode( $settings )
1364 )
1365 );
1366 }
1367 }
1368 }
1369
1370 add_action( 'admin_enqueue_scripts', 'addtoany_admin_scripts' );