PluginProbe
Zotpress / 7.4
Zotpress v7.4
7.4.4 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0 2.1 2.2 2.3 2.4 2.5 2.5.1 2.5.2 2.6 2.6.1 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1 All 138 releases
zotpress / zotpress.php

zotpress.php in Zotpress 7.4, at zotpress.php

551 lines 22.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4
5 Plugin Name: Zotpress
6 Plugin URI: http://katieseaborn.com/plugins
7 Description: Bringing Zotero and scholarly blogging to your WordPress website.
8 Author: Katie Seaborn
9 Version: 7.4
10 Author URI: http://katieseaborn.com
11 Text Domain: zotpress
12 Domain Path: /languages/
13 License: Apache2.0
14
15 */
16
17 /*
18
19 Copyright 2025 Katie Seaborn
20
21 Licensed under the Apache License, Version 2.0 (the "License");
22 you may not use this file except in compliance with the License.
23 You may obtain a copy of the License at
24
25 http://www.apache.org/licenses/LICENSE-2.0
26
27 Unless required by applicable law or agreed to in writing, software
28 distributed under the License is distributed on an "AS IS" BASIS,
29 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 See the License for the specific language governing permissions and
31 limitations under the License.
32
33 */
34
35
36 // DESIGN ---------------------------------------------------------------------------------------
37 /*
38
39 For requests:
40
41 - Check the database for cached items with PHP:
42 - If using the cache, indicate with `used_cache` class
43 - If no cache, switch to JS and save to cache
44 - Format with JS
45 - Check for updates with JS
46 - Format again with JS
47
48 To-do:
49 * Zotero-API-Key` rather than `key=`.
50 * qmode=titleCreatorYear&q=2000,2001 -> v3 doesn't work
51 * multiple itemtype
52 * fix "dateAdded"
53
54 */
55 // DESIGN ---------------------------------------------------------------------------------------
56
57
58
59 // DIRECT ACESS ---------------------------------------------------------------------------------
60
61 // Thanks to Jörg Mechnich (jmechnich@github)
62
63 if ( ! defined( 'ABSPATH' ) ) {
64
65 exit; // Don't access directly.
66 };
67
68 // DIRECT ACESS ---------------------------------------------------------------------------------
69
70
71
72 // GLOBAL VARS ----------------------------------------------------------------------------------
73
74 define('ZOTPRESS_PLUGIN_FILE', __FILE__ );
75 define('ZOTPRESS_PLUGIN_URL', plugin_dir_url( ZOTPRESS_PLUGIN_FILE ));
76 define('ZOTPRESS_PLUGIN_DIR', dirname( __FILE__ ));
77 define('ZOTPRESS_VERSION', '7.4' );
78
79 // NOTE: Remember to set to TRUE after dev and before version release
80 define('ZOTPRESS_LIVEMODE', true );
81
82 $GLOBALS['zp_is_shortcode_displayed'] = false;
83 $GLOBALS['zp_shortcode_instances'] = array();
84
85 // 5.2.6: NOTE: Only change if the db needs updating
86 $GLOBALS['Zotpress_update_db_by_version'] = '7.1.4';
87
88 // GLOBAL VARS ----------------------------------------------------------------------------------
89
90
91
92 // LOCALIZATION ----------------------------------------------------------------------------------
93
94 // TODO: Apply localization to the entire plugin.
95 // TODO: Don't forget JS files, which have a special procedure.
96
97 function Zotpress_load_plugin_textdomain() {
98 load_plugin_textdomain( 'zotpress', false, basename( dirname( __FILE__ ) ) . '/languages/' );
99 }
100 add_action( 'plugins_loaded', 'Zotpress_load_plugin_textdomain' );
101
102 // LOCALIZATION ----------------------------------------------------------------------------------
103
104
105
106 // INSTALL -----------------------------------------------------------------------------------------
107
108 include( dirname(__FILE__) . '/lib/admin/admin.install.php' );
109
110 // INSTALL -----------------------------------------------------------------------------------------
111
112
113
114 // ADMIN -------------------------------------------------------------------------------------------
115
116 include( dirname(__FILE__) . '/lib/admin/admin.php' );
117
118 add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'zotpress_add_plugin_page_settings_link');
119 function zotpress_add_plugin_page_settings_link( $links ) {
120 $links[] = '<a href="' .
121 admin_url( 'admin.php?page=Zotpress' ) .
122 '">' . esc_html__('Explore','zotpress') . '</a>';
123 return $links;
124 }
125
126 // END ADMIN --------------------------------------------------------------------------------------
127
128
129
130 // SHORTCODE -------------------------------------------------------------------------------------
131
132 include( dirname(__FILE__) . '/lib/shortcode/shortcode.php' );
133 include( dirname(__FILE__) . '/lib/shortcode/shortcode.intext.php' );
134 include( dirname(__FILE__) . '/lib/shortcode/shortcode.intextbib.php' );
135 include( dirname(__FILE__) . '/lib/shortcode/shortcode.lib.php' );
136
137 // SHORTCODE -------------------------------------------------------------------------------------
138
139
140
141 // WIDGET & METABOX -----------------------------------------------------------------------------
142
143 include( dirname(__FILE__) . '/lib/widget/widget.sidebar.php' );
144 include( dirname(__FILE__) . '/lib/widget/widget.php' );
145
146 function Zotpress_format_script_register()
147 {
148 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
149
150 wp_register_script(
151 'zotpress.gutenberg'.$minify.'.js',
152 ZOTPRESS_PLUGIN_URL . 'js/zotpress.gutenberg'.$minify.'.js',
153 array( 'wp-rich-text', 'wp-element', 'wp-editor', 'jquery' ),
154 '7.4',
155 true
156 );
157 }
158 add_action( 'init', 'Zotpress_format_script_register' );
159
160 function Zotpress_format_enqueue_assets_editor()
161 {
162 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
163
164 wp_enqueue_script( 'jquery' );
165 wp_enqueue_script( 'zotpress.gutenberg'.$minify.'.js' );
166 wp_localize_script(
167 'zotpress.gutenberg'.$minify.'.js',
168 'zpTranslate',
169 array(
170 'txt_insertsc' => esc_html__('Insert Shortcode','zotpress'),
171 'txt_generatesc' => esc_html__('Generate Shortcode','zotpress')
172 )
173 );
174 }
175 add_action( 'enqueue_block_editor_assets', 'Zotpress_format_enqueue_assets_editor' );
176
177 // WIDGET & METABOX -----------------------------------------------------------------------------
178
179
180
181 // REGISTER ACTIONS -----------------------------------------------------------------------------
182
183 /**
184 * Admin scripts and styles
185 */
186 function Zotpress_admin_scripts_css($hook)
187 {
188 // Turn on/off minified versions if testing/live
189 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
190
191 if ( isset($_GET['page']) && ($_GET['page'] == 'Zotpress') )
192 {
193 wp_enqueue_script( 'jquery' );
194 wp_enqueue_media();
195 wp_enqueue_script( 'jquery.dotimeout.min.js', ZOTPRESS_PLUGIN_URL . 'js/jquery.dotimeout.min.js', array( 'jquery' ), '7.4', true );
196
197 if ( !in_array( $hook, array('post.php', 'post-new.php') ) )
198 {
199 wp_enqueue_script( 'jquery.livequery.min.js', ZOTPRESS_PLUGIN_URL . 'js/jquery.livequery.min.js', array( 'jquery' ), '7.4', true );
200 }
201
202 if ( isset($_GET['help']) && ($_GET['help'] == 'true') )
203 {
204 wp_enqueue_script( 'jquery-ui-core' );
205 wp_enqueue_script( 'jquery-ui-tabs' );
206 wp_enqueue_style( 'zotpress.help'.$minify.'.css', ZOTPRESS_PLUGIN_URL . 'css/zotpress.help'.$minify.'.css', array(), '7.4' );
207 wp_enqueue_script( 'zotpress.help.min.js', ZOTPRESS_PLUGIN_URL . 'js/zotpress.help.min.js', array( 'jquery' ), '7.4', true );
208 }
209
210 wp_enqueue_style( 'zotpress.shortcode'.$minify.'.css', ZOTPRESS_PLUGIN_URL . 'css/zotpress.shortcode'.$minify.'.css', array(), '7.4' );
211 wp_enqueue_style( 'zotpress.admin'.$minify.'.css', ZOTPRESS_PLUGIN_URL . 'css/zotpress.admin'.$minify.'.css', array(), '7.4' );
212 }
213 }
214 add_action( 'admin_enqueue_scripts', 'Zotpress_admin_scripts_css' );
215
216
217 function Zotpress_enqueue_admin_ajax( $hook )
218 {
219 // Turn on/off minified versions if testing/live
220 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
221
222 if ( stripos( $hook, "zotpress" ) !== false )
223 {
224 wp_enqueue_script( 'zotpress.admin'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.admin'.$minify.'.js', array( 'jquery','media-upload','thickbox' ), '7.4', true );
225 wp_localize_script(
226 'zotpress.admin'.$minify.'.js',
227 'zpAccountsAJAX',
228 array(
229 'ajaxurl' => admin_url( 'admin-ajax.php' ),
230 'zpAccountsAJAX_nonce' => wp_create_nonce( 'zpAccountsAJAX_nonce_val' ),
231 'action' => 'zpAccountsViaAJAX',
232 'txt_success' => esc_html__('Success','zotpress'),
233 'txt_chooseimg' => esc_html__('Choose Image','zotpress'),
234 'txt_accvalid' => esc_html__('Your Zotero account has been validated.','zotpress'),
235 'txt_sureremove' => esc_html__('Are you sure you want to remove this account?','zotpress'),
236 'txt_surecache' => esc_html__('Are you sure you want to clear the cache for this account?','zotpress'),
237 'txt_cachecleared' => esc_html__('Cache cleared!','zotpress'),
238 'txt_oops' => esc_html__('Oops!','zotpress'),
239 'txt_changeimg' => esc_html__( 'Change Image', 'zotpress' ),
240 'txt_setimg' => esc_html__( 'Set Image', 'zotpress' ),
241 'txt_removeimg' => esc_html__( 'Remove Image', 'zotpress' ),
242 'txt_surereset' => esc_html__('Are you sure you want to reset Zotpress? This cannot be undone.','zotpress'),
243 'txt_default' => esc_html__('Default','zotpress')
244 )
245 );
246 } // Zotpress pages only
247
248 wp_enqueue_script( 'zotpress.admin.notices'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.admin.notices'.$minify.'.js', array( 'jquery' ), '7.4', true );
249 wp_localize_script(
250 'zotpress.admin.notices'.$minify.'.js',
251 'zpNoticesAJAX',
252 array(
253 'ajaxurl' => admin_url( 'admin-ajax.php' ),
254 'zpNoticesAJAX_nonce' => wp_create_nonce( 'zpNoticesAJAX_nonce_val' ),
255 'action' => 'zpNoticesViaAJAX'
256 )
257 );
258 }
259 add_action( 'admin_enqueue_scripts', 'Zotpress_enqueue_admin_ajax' );
260
261
262 /**
263 * Add Zotpress to admin menu
264 */
265 function Zotpress_admin_menu()
266 {
267 add_menu_page( "Zotpress", "Zotpress", "edit_posts", "Zotpress", "Zotpress_options", ZOTPRESS_PLUGIN_URL."images/icon-menu.svg" );
268 add_submenu_page( "Zotpress", "Zotpress", esc_html__('Browse','zotpress'), "edit_posts", "Zotpress" );
269 add_submenu_page( "Zotpress", "Accounts", esc_html__('Accounts','zotpress'), "edit_posts", "admin.php?page=Zotpress&accounts=true" );
270 add_submenu_page( "Zotpress", "Options", esc_html__('Options','zotpress'), "edit_posts", "admin.php?page=Zotpress&options=true" );
271 add_submenu_page( "Zotpress", "Help", esc_html__('Help','zotpress'), "edit_posts", "admin.php?page=Zotpress&help=true" );
272 }
273 add_action( 'admin_menu', 'Zotpress_admin_menu' );
274
275 function Zotpress_admin_menu_submenu($parent_file)
276 {
277 global $submenu_file;
278
279 if ( isset($_GET['accounts']) || isset($_GET['selective']) || isset($_GET['import']) ) $submenu_file = 'admin.php?page=Zotpress&accounts=true';
280 if ( isset($_GET['options']) ) $submenu_file = 'admin.php?page=Zotpress&options=true';
281 if ( isset($_GET['help']) ) $submenu_file = 'admin.php?page=Zotpress&help=true';
282
283 return $parent_file;
284 }
285 add_filter('parent_file', 'Zotpress_admin_menu_submenu');
286
287
288 /**
289 * Add shortcode styles to user's theme
290 * Note that this always displays: There's no way to conditionally include it,
291 * because the existence of shortcodes is checked after CSS is included.
292 */
293 function Zotpress_theme_includes()
294 {
295 // Turn on/off minified versions if testing/live
296 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
297
298 wp_register_style('zotpress.shortcode'.$minify.'.css', ZOTPRESS_PLUGIN_URL . 'css/zotpress.shortcode'.$minify.'.css', array(), '7.4' );
299 wp_enqueue_style('zotpress.shortcode'.$minify.'.css', ZOTPRESS_PLUGIN_URL . 'css/zotpress.shortcode'.$minify.'.css', array(), '7.4' );
300 }
301 add_action('wp_print_styles', 'Zotpress_theme_includes');
302
303
304 /**
305 * Change HTTP request timeout
306 * Changed in 7.3.7
307 */
308 // function Zotpress_change_timeout($time): int { return 60; /* second */ }
309 function Zotpress_change_timeout($time) { return 60; /* second */ }
310 add_filter('http_request_timeout', 'Zotpress_change_timeout');
311
312
313
314 // Enqueue jQuery in theme if it isn't already enqueued
315 // Thanks to WordPress user "eceleste"
316 function Zotpress_enqueue_scripts()
317 {
318 if ( ! isset( $GLOBALS['wp_scripts']->registered[ "jquery" ] ) )
319 wp_enqueue_script("jquery");
320 }
321 add_action( 'wp_enqueue_scripts' , 'Zotpress_enqueue_scripts' );
322
323 // Add shortcodes and sidebar widget
324 add_shortcode( 'zotpress', 'Zotpress_func' );
325 add_shortcode( 'zotpressInText', 'Zotpress_zotpressInText' );
326 add_shortcode( 'zotpressInTextBib', 'Zotpress_zotpressInTextBib' );
327 add_shortcode( 'zotpressLib', 'Zotpress_zotpressLib' );
328 add_action( 'widgets_init', 'ZotpressSidebarWidgetInit' );
329
330 // Conditionally serve shortcode scripts
331 function Zotpress_theme_conditional_scripts_footer()
332 {
333 // Turn on/off minified versions if testing/live
334 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
335
336 if ( $GLOBALS['zp_is_shortcode_displayed'] === true )
337 {
338 if ( ! is_admin() ) wp_enqueue_script('jquery');
339 wp_register_script('jquery.livequery.min.js', ZOTPRESS_PLUGIN_URL . 'js/jquery.livequery.min.js', array('jquery'), '7.4', true );
340 wp_enqueue_script('jquery.livequery.min.js');
341
342 wp_enqueue_script("jquery-effects-core");
343 wp_enqueue_script("jquery-effects-highlight");
344
345 wp_enqueue_script( 'zotpress.default'.$minify.'.js', ZOTPRESS_PLUGIN_URL . 'js/zotpress.default'.$minify.'.js', array( 'jquery' ), '7.4', true );
346 }
347 }
348 add_action('wp_footer', 'Zotpress_theme_conditional_scripts_footer');
349
350
351 function Zotpress_enqueue_shortcode_bib()
352 {
353 // Turn on/off minified versions if testing/live
354 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
355
356 wp_register_script( 'zotpress.shortcode.bib'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.shortcode.bib'.$minify.'.js', array( 'jquery' ), '7.4', true );
357 wp_localize_script(
358 'zotpress.shortcode.bib'.$minify.'.js',
359 'zpShortcodeAJAX',
360 array(
361 'ajaxurl' => admin_url( 'admin-ajax.php' ),
362 'zpShortcode_nonce' => wp_create_nonce( 'zpShortcode_nonce_val' ),
363 'action' => 'zpRetrieveViaShortcode',
364 'txt_removeimg' => esc_html__('Remove Image', 'zotpress'),
365 'txt_zperror' => esc_html__('There was a Zotpress error:', 'zotpress'),
366 'txt_noitemsfound' => esc_html__( 'No items found.', 'zotpress' )
367 )
368 );
369 }
370 add_action( 'wp_enqueue_scripts', 'Zotpress_enqueue_shortcode_bib' );
371
372
373 function Zotpress_enqueue_dl()
374 {
375 // Turn on/off minified versions if testing/live
376 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
377
378 wp_register_script( 'zotpress.dl'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.dl'.$minify.'.js', array( 'jquery' ), '7.4', true );
379 wp_enqueue_script( 'zotpress.dl'.$minify.'.js' );
380 wp_localize_script(
381 'zotpress.dl'.$minify.'.js',
382 'zpDLAJAX',
383 array(
384 'ajaxurl' => admin_url( 'admin-ajax.php' ),
385 'zpDL_nonce' => wp_create_nonce( 'zpDL_nonce_val' ),
386 'action' => 'zpDLViaAJAX'
387 )
388 );
389 }
390 add_action( 'wp_enqueue_scripts', 'Zotpress_enqueue_dl' );
391
392
393 function Zotpress_enqueue_cite()
394 {
395 // Turn on/off minified versions if testing/live
396 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
397
398 wp_register_script( 'zotpress.cite'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.cite'.$minify.'.js', array( 'jquery' ), '7.4', true );
399 wp_enqueue_script( 'zotpress.cite'.$minify.'.js' );
400 wp_localize_script(
401 'zotpress.cite'.$minify.'.js',
402 'zpCiteAJAX',
403 array(
404 'ajaxurl' => admin_url( 'admin-ajax.php' ),
405 'zpCite_nonce' => wp_create_nonce( 'zpCite_nonce_val' ),
406 'action' => 'zpCiteViaAJAX'
407 )
408 );
409 }
410 add_action( 'wp_enqueue_scripts', 'Zotpress_enqueue_cite' );
411
412
413 function Zotpress_enqueue_shortcode_intext()
414 {
415 // Turn on/off minified versions if testing/live
416 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
417
418 wp_register_script( 'zotpress.shortcode.intext'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.shortcode.intext'.$minify.'.js', array( 'jquery' ), '7.4', true );
419 wp_localize_script(
420 'zotpress.shortcode.intext'.$minify.'.js',
421 'zpShortcodeAJAX',
422 array(
423 'ajaxurl' => admin_url( 'admin-ajax.php' ),
424 'zpShortcode_nonce' => wp_create_nonce( 'zpShortcode_nonce_val' ),
425 'action' => 'zpRetrieveViaShortcode',
426 'txt_zperror' => esc_html__('There was a Zotpress error:', 'zotpress'),
427 'txt_noitemsfound' => esc_html__( 'No items found.', 'zotpress' )
428 )
429 );
430 }
431 add_action( 'wp_enqueue_scripts', 'Zotpress_enqueue_shortcode_intext' );
432
433
434 function Zotpress_enqueue_lib_dropdown()
435 {
436 // Turn on/off minified versions if testing/live
437 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
438
439 wp_register_script( 'zotpress.lib'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.lib'.$minify.'.js', array( 'jquery' ), '7.4', true );
440 wp_register_script( 'zotpress.lib.dropdown'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.lib.dropdown'.$minify.'.js', array( 'jquery' ), '7.4', true );
441 wp_localize_script(
442 'zotpress.lib.dropdown'.$minify.'.js',
443 'zpShortcodeAJAX',
444 array(
445 'ajaxurl' => admin_url( 'admin-ajax.php' ),
446 'zpShortcode_nonce' => wp_create_nonce( 'zpShortcode_nonce_val' ),
447 'action' => 'zpRetrieveViaShortcode',
448 'txt_loading' => esc_html__( 'Loading', 'zotpress' ),
449 'txt_items' => esc_html__( 'items', 'zotpress' ),
450 'txt_subcoll' => esc_html__( 'subcollections', 'zotpress' ),
451 'txt_changeimg' => esc_html__( 'Change Image', 'zotpress' ),
452 'txt_setimg' => esc_html__( 'Set Image', 'zotpress' ),
453 'txt_itemkey' => esc_html__( 'Item Key', 'zotpress' ),
454 'txt_nocitations' => esc_html__( 'There are no citations to display.', 'zotpress' ),
455 'txt_toplevel' => esc_html__( 'Top Level', 'zotpress' ),
456 'txt_nocollsel' => esc_html__( 'No Collection Selected', 'zotpress' ),
457 'txt_backtotop' => esc_html__( 'Back', 'zotpress' ),
458 'txt_unsettag' => esc_html__( 'Unset Tag', 'zotpress' ),
459 'txt_notagsel' => esc_html__( 'No Tag Selected', 'zotpress' ),
460 'txt_notags' => esc_html__( 'No tags to display', 'zotpress' )
461 )
462 );
463 }
464 add_action( 'wp_enqueue_scripts', 'Zotpress_enqueue_lib_dropdown' );
465 add_action( 'admin_enqueue_scripts', 'Zotpress_enqueue_lib_dropdown' );
466
467
468 function Zotpress_enqueue_lib_searchbar()
469 {
470 // Turn on/off minified versions if testing/live
471 $minify = ''; if ( ZOTPRESS_LIVEMODE ) $minify = '.min';
472
473 wp_register_script( 'zotpress.lib'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.lib'.$minify.'.js', array( 'jquery' ), '7.4', true );
474 wp_register_script( 'zotpress.lib.searchbar'.$minify.'.js', plugin_dir_url( __FILE__ ) . 'js/zotpress.lib.searchbar'.$minify.'.js', array( 'jquery' ), '7.4', true );
475 wp_localize_script(
476 'zotpress.lib.searchbar'.$minify.'.js',
477 'zpShortcodeAJAX',
478 array(
479 'ajaxurl' => admin_url( 'admin-ajax.php' ),
480 'zpShortcode_nonce' => wp_create_nonce( 'zpShortcode_nonce_val' ),
481 'action' => 'zpRetrieveViaShortcode',
482 'txt_typetosearch' => esc_html__('Type to search','zotpress')
483 )
484 );
485 }
486 add_action( 'wp_enqueue_scripts', 'Zotpress_enqueue_lib_searchbar' );
487 add_action( 'admin_enqueue_scripts', 'Zotpress_enqueue_lib_searchbar' );
488
489 // REGISTER ACTIONS --------------------------------------------------------------------------------
490
491
492 // SECURITY ----------------------------------------------------------------------------------------
493
494 function Zotpress_nonce_life() {
495 return 24 * HOUR_IN_SECONDS;
496 }
497 add_filter( 'nonce_life', 'Zotpress_nonce_life' );
498
499 // SECURITY ----------------------------------------------------------------------------------------
500
501
502 // ZOTPRESS NOTIFICATIONS ------------------------------------------------------------------------
503
504 if ( in_array( ZOTPRESS_VERSION, array( "6.2.1", "6.2.2", "7.1.1", "7.1.2", "7.1.3", "7.1.4", "7.3.13", "7.3.14" ) ) )
505 {
506 // function Zotpress_plugin_update_message( $data, $response ) {
507 function Zotpress_plugin_update_message() {
508 // printf(
509 echo '<span style="display:block;font-weight:bold;margin:0.7em 0;"><span class="dashicons dashicons-warning" style="margin-right:6px;"></span>';
510 // echo sprintf(
511 // wp_kses(
512 /* translators: s: Zotero Groups URL */
513 // '<span style="display:block;font-weight:bold;margin:0.7em 0;"><span class="dashicons dashicons-warning" style="margin-right:6px;"></span>%s</span>',
514 // esc_html__( 'Be sure to clear the Zotpress cache for each account after updating!', 'zotpress' )
515 // );
516 esc_html_e( 'Be sure to clear the Zotpress cache for each account after updating!', 'zotpress' );
517 echo '</span>';
518 echo "\n\n";
519 }
520 add_action( 'in_plugin_update_message-zotpress/zotpress.php', 'Zotpress_plugin_update_message', 10, 2 );
521 }
522
523 if ( in_array( ZOTPRESS_VERSION, array( "6.2.1", "6.2.2", "7.1.4", "7.3.13", "7.3.14" ) ) )
524 {
525 if ( zotpress_get_total_accounts() > 0
526 && ! get_option( 'Zotpress_update_notice_dismissed' ) )
527 add_action( 'admin_notices', 'Zotpress_update_notice' );
528
529 function Zotpress_update_notice()
530 {
531 ?>
532 <div class="notice update-nag Zotpress_update_notice is-dismissible" >
533 <p><?php esc_html_e( '<strong>Warning:</strong> Due to major updates in this version of Zotpress, you may need to clear the cache of each synced Zotero account.', 'zotpress' ); ?></p>
534 <p>&raquo; <a href="admin.php?page=Zotpress&accounts=true"><?php esc_html_e( 'Accounts', 'zotpress' ); ?></a></p>
535 </div>
536 <?php
537 }
538
539 function Zotpress_dismiss_update_notice()
540 {
541 if ( ! get_option( 'Zotpress_update_notice_dismissed' )
542 || get_option( 'Zotpress_update_notice_dismissed' ) == 0 )
543 update_option( 'Zotpress_update_notice_dismissed', 1 );
544 }
545 add_action( 'wp_ajax_zpNoticesViaAJAX', 'Zotpress_dismiss_update_notice' );
546 }
547
548 // ZOTPRESS NOTIFICATIONS ------------------------------------------------------------------------
549
550
551 ?>