PluginProbe
PatternsWP – Gutenberg Block Patterns & Page Templates Library / trunk
PatternsWP – Gutenberg Block Patterns & Page Templates Library vtrunk
trunk 1.0.0 1.0.1 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
← All changes | patternswp.php +34 -6 1.0.5trunk View file →
@@ -4,9 +4,9 @@
4 4 * Plugin URI: https://thepatternswp.com
5 5 * Description: A growing library of ready-made block patterns can help you build websites faster in no time.
6 6 * Author: PatternsWP
7 7 * Author URI: https://thepatternswp.com
8 - * Version: 1.0.5
8 + * Version: 1.0.10
9 9 * License: GPL-2.0+
10 10 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11 11 * Text Domain: patternswp
12 12 * Domain Path: /languages
@@ -19,9 +19,9 @@
19 19
20 20 // Define plugin constants.
21 21 define('PWP_PLUGIN_DIR', plugin_dir_path(__FILE__));
22 22 define('PWP_PLUGIN_URL', plugin_dir_url(__FILE__));
23 -define('PWP_P_VERSION', '1.0.5');
23 +define('PWP_P_VERSION', '1.0.10');
24 24 define('PWP_PLUGIN_FILE', __FILE__);
25 25 define('PWP_ABSPATH', dirname(__FILE__) . '/');
26 26 define('PWP_VERSION', get_file_data(__FILE__, ['Version'])[0]);
27 27
@@ -51,9 +51,10 @@
51 51 $patternswp_api_section = new PatternsWP_API_Section();
52 52 $localize_data = [
53 53 'isLicenseActive' => $is_active,
54 54 'externalPatterns' => [],
55 - 'patternCategories' => $patternswp_api_section->get_patternswp_category_type()
55 + 'patternCategories' => $patternswp_api_section->get_patternswp_category_type(),
56 + 'patternsNonce' => wp_create_nonce('patternswp_nonce'),
56 57 ];
57 58
58 59 wp_localize_script('patternswp-editor-scripts', 'patternsWpData', $localize_data);
59 60
@@ -70,17 +71,44 @@
70 71 return file_exists($asset_path) ? require_once $asset_path : ['dependencies' => [], 'version' => PWP_VERSION];
71 72 }
72 73
73 74 // Plugin activation hook.
74 -register_activation_hook(__FILE__, function() {});
75 +register_activation_hook(__FILE__, 'patternswp_schedule_hourly_cron');
75 76
77 +function patternswp_schedule_hourly_cron() {
78 + if ( !wp_next_scheduled( 'patternswp_hourly_transient_load' ) ) {
79 + wp_schedule_event( time(), 'hourly', 'patternswp_hourly_transient_load' );
80 + }
81 +}
82 +
76 83 // Plugin deactivation hook.
77 -register_deactivation_hook(__FILE__, function() {});
84 +register_deactivation_hook(__FILE__, 'patternswp_remove_hourly_cron');
78 85
86 +function patternswp_remove_hourly_cron() {
87 + $timestamp = wp_next_scheduled( 'patternswp_hourly_transient_load' );
88 + if ( $timestamp ) {
89 + wp_unschedule_event( $timestamp, 'patternswp_hourly_transient_load' );
90 + }
91 +}
92 +
79 93 /**
80 94 * AJAX handler to fetch patterns.
81 95 */
82 96 function fetch_patterns_handler() {
97 +
98 + // Verify nonce
99 + if (!isset($_POST['nonce'])) {
100 + wp_send_json_error('Missing nonce');
101 + wp_die();
102 + }
103 +
104 + $nonce = sanitize_text_field(wp_unslash($_POST['nonce']));
105 +
106 + if (!wp_verify_nonce($nonce, 'patternswp_nonce')) {
107 + wp_send_json_error('Invalid nonce');
108 + wp_die();
109 + }
110 +
83 111 if (!isset($_POST['page']) || !isset($_POST['patternsPerPage'])) {
84 112 wp_send_json_error('Missing parameters');
85 113 wp_die();
86 114 }
@@ -142,5 +170,5 @@
142 170 $links[] = '<a href="https://wordpress.org/support/plugin/patternswp/reviews/?filter=5" target="_blank">Rate Us</a>';
143 171 }
144 172 return $links;
145 173 }
146 -add_filter('plugin_row_meta', 'patternswp_add_plugin_meta_links', 10, 2);
174 +add_filter('plugin_row_meta', 'patternswp_add_plugin_meta_links', 10, 2);