PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.9
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.9
2.7.9 2.7.8 2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 All 30 releases
← All changes | insert_php.php +57 -27 2.7.4 → 2.7.9 View file →
@@ -3,9 +3,9 @@
3 3 * Plugin Name: Woody Code Snippets
4 4 * Plugin URI: https://woodysnippet.com/
5 5 * Description: Executes PHP code, uses conditional logic to insert ads, text, media content and external service's code. Ensures no content duplication.
6 6 * Author: Themeisle
7 - * Version: 2.7.4
7 + * Version: 2.7.9
8 8 * WordPress Available: yes
9 9 * Requires License: no
10 10 * Text Domain: insert-php
11 11 * Domain Path: /languages/
@@ -40,9 +40,9 @@
40 40
41 41 // Set the constant that the plugin is activated.
42 42 define( 'WINP_PLUGIN_ACTIVE', true );
43 43
44 -define( 'WINP_PLUGIN_VERSION', '2.7.4' );
44 +define( 'WINP_PLUGIN_VERSION', '2.7.9' );
45 45
46 46 // Root directory of the plugin.
47 47 define( 'WINP_PLUGIN_DIR', __DIR__ );
48 48
@@ -88,38 +88,40 @@
88 88 }
89 89 );
90 90
91 91 // START: Related to premium version compatibility check for below 1.3.
92 -add_action(
93 - 'plugins_loaded',
94 - function () {
95 - $premium_plugin_file = 'woody-ad-snippets-premium/woody-ad-snippets-premium.php';
96 - $premium_plugin_path = WP_PLUGIN_DIR . '/' . $premium_plugin_file;
92 +/**
93 + * Deactivates Premium versions below 1.3.0, which are not compatible with this version.
94 + */
95 +function winp_deactivate_incompatible_premium(): void {
96 + $premium_plugin_file = 'woody-ad-snippets-premium/woody-ad-snippets-premium.php';
97 + $premium_plugin_path = WP_PLUGIN_DIR . '/' . $premium_plugin_file;
97 98
98 - if ( ! file_exists( $premium_plugin_path ) ) {
99 - return;
100 - }
99 + if ( ! file_exists( $premium_plugin_path ) ) {
100 + return;
101 + }
101 102
102 - if ( ! function_exists( 'is_plugin_active' ) ) {
103 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
104 - }
103 + if ( ! function_exists( 'is_plugin_active' ) ) {
104 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
105 + }
105 106
106 - if ( ! is_plugin_active( $premium_plugin_file ) ) {
107 - return;
108 - }
107 + if ( ! is_plugin_active( $premium_plugin_file ) ) {
108 + return;
109 + }
109 110
110 - if ( ! function_exists( 'get_plugin_data' ) ) {
111 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
112 - }
113 - $premium_data = get_plugin_data( $premium_plugin_path );
111 + if ( ! function_exists( 'get_plugin_data' ) ) {
112 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
113 + }
114 + $premium_data = get_plugin_data( $premium_plugin_path );
114 115
115 - if ( version_compare( $premium_data['Version'], '1.3.0', '<' ) ) {
116 - deactivate_plugins( $premium_plugin_file );
117 - set_transient( 'winp_premium_version_incompatible', true, WEEK_IN_SECONDS );
118 - }
119 - },
120 - 5
121 -);
116 + if ( version_compare( $premium_data['Version'], '1.3.0', '<' ) ) {
117 + deactivate_plugins( $premium_plugin_file );
118 + // Still hooked this request; it calls WINP_Plugin::app() before init.
119 + remove_action( 'plugins_loaded', 'wasp_premium_load', 20 );
120 + set_transient( 'winp_premium_version_incompatible', true, WEEK_IN_SECONDS );
121 + }
122 +}
123 +add_action( 'plugins_loaded', 'winp_deactivate_incompatible_premium', 5 );
122 124
123 125 add_action(
124 126 'admin_init',
125 127 function () {
@@ -167,8 +169,10 @@
167 169
168 170 require_once WINP_PLUGIN_DIR . '/includes/class.insertion.locations.php';
169 171 require_once WINP_PLUGIN_DIR . '/includes/class.http.php';
170 172 require_once WINP_PLUGIN_DIR . '/includes/class.helpers.php';
173 +require_once WINP_PLUGIN_DIR . '/includes/class.code-validator.php';
174 +require_once WINP_PLUGIN_DIR . '/includes/class.error-handler.php';
171 175 require_once WINP_PLUGIN_DIR . '/includes/class.plugin.php';
172 176
173 177 if ( file_exists( WINP_PLUGIN_DIR . '/vendor/autoload.php' ) ) {
174 178 require_once WINP_PLUGIN_DIR . '/vendor/autoload.php';
@@ -242,8 +246,33 @@
242 246 ];
243 247 }
244 248
245 249 /**
250 + * AI Connect metadata.
251 + *
252 + * Only the read abilities are listed: the abilities that save or activate
253 + * snippets run code, so the site owner switches those on deliberately.
254 + *
255 + * @return array<string, mixed>
256 + */
257 +function winp_sdk_ai_connect() {
258 + return [
259 + 'name' => 'Woody Code Snippets',
260 + 'notice_cases' => [
261 + __( 'find where a script is inserted', 'insert-php' ),
262 + __( 'review the code of a snippet', 'insert-php' ),
263 + __( 'audit your active snippets', 'insert-php' ),
264 + ],
265 + 'prompts' => [
266 + __( 'Find which Woody Code Snippets load gtag and where they are inserted.', 'insert-php' ),
267 + __( 'Show me the code of my header scripts snippet and explain what it does.', 'insert-php' ),
268 + __( 'Which of my snippets run PHP on every page?', 'insert-php' ),
269 + ],
270 + 'ability_prefix' => 'woody',
271 + ];
272 +}
273 +
274 +/**
246 275 * Register compatibility using SDK.
247 276 *
248 277 * @param array<string, array<string, string>> $compatibilities All compatibilities.
249 278 *
@@ -259,8 +288,9 @@
259 288 }
260 289
261 290 add_filter( 'themeisle_sdk_products', 'winp_sdk_register_products' );
262 291 add_filter( WINP_PLUGIN_NAMESPACE . '_about_us_metadata', 'winp_sdk_about_page' );
292 +add_filter( WINP_PLUGIN_NAMESPACE . '_ai_connect_metadata', 'winp_sdk_ai_connect' );
263 293 add_filter( 'themeisle_sdk_compatibilities/' . basename( WINP_PLUGIN_DIR ), 'winp_sdk_register_compatibility' );
264 294
265 295 // Register activation/deactivation hooks.
266 296 register_activation_hook(