Version Description
2020-01-14 =
FIX: Improve getting list of all CF7 shortcode tags in CF7 form content
Download this release
Release Info
Developer | buzztone |
Plugin | Contact Form 7 Skins |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.2.1
- includes/cf7-connect.php +107 -18
- index.php +2 -2
- readme.txt +5 -1
includes/cf7-connect.php
CHANGED
@@ -20,7 +20,11 @@ class CF7_Skins_CF7_Connect {
|
|
20 |
function __construct() {
|
21 |
add_filter( 'wpcf7_form_class_attr', array( &$this, 'form_classes' ) );
|
22 |
add_action( 'wpcf7_contact_form', array( &$this, 'cf7_form' ), 1 );
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -29,7 +33,9 @@ class CF7_Skins_CF7_Connect {
|
|
29 |
* Back compat for CF7 3.9
|
30 |
* @see http://contactform7.com/2014/07/02/contact-form-7-39-beta/
|
31 |
*
|
32 |
-
* @param
|
|
|
|
|
33 |
*
|
34 |
* @since 0.1.0
|
35 |
*/
|
@@ -46,7 +52,9 @@ class CF7_Skins_CF7_Connect {
|
|
46 |
*
|
47 |
* Back compat for CF7 3.9
|
48 |
*
|
49 |
-
* @param
|
|
|
|
|
50 |
*
|
51 |
* @since 0.1.0
|
52 |
*/
|
@@ -64,7 +72,7 @@ class CF7_Skins_CF7_Connect {
|
|
64 |
* Check if CF7 default stylesheet is still registered
|
65 |
* as is used by other CF7 Skins plugins.
|
66 |
*
|
67 |
-
* @return $deps
|
68 |
*
|
69 |
* @since 1.1.1
|
70 |
*/
|
@@ -84,7 +92,7 @@ class CF7_Skins_CF7_Connect {
|
|
84 |
* Check if CF7 default script is still registered
|
85 |
* as is used by other CF7 Skins plugins.
|
86 |
*
|
87 |
-
* @return $deps
|
88 |
*
|
89 |
* @since 1.2.2
|
90 |
*/
|
@@ -119,7 +127,7 @@ class CF7_Skins_CF7_Connect {
|
|
119 |
*
|
120 |
* @do_action 'cf7skins_enqueue_styles'
|
121 |
*
|
122 |
-
* @param
|
123 |
*
|
124 |
* @since 1.1.0
|
125 |
*/
|
@@ -137,7 +145,7 @@ class CF7_Skins_CF7_Connect {
|
|
137 |
*
|
138 |
* @action 'cf7skins_enqueue_styles'
|
139 |
*
|
140 |
-
* @param
|
141 |
*
|
142 |
* @since 1.1.0
|
143 |
*/
|
@@ -150,7 +158,7 @@ class CF7_Skins_CF7_Connect {
|
|
150 |
$this->stylesheet_dependencies(), CF7SKINS_VERSION, 'all' );
|
151 |
}
|
152 |
}
|
153 |
-
|
154 |
/**
|
155 |
* Add CF7 Skins classes to the CF7 HTML form class.
|
156 |
*
|
@@ -163,17 +171,17 @@ class CF7_Skins_CF7_Connect {
|
|
163 |
*
|
164 |
* @filter 'cf7skins_form_classes' - allows other CF7 Skins plugins to add their style classes
|
165 |
*
|
166 |
-
* @param
|
167 |
* @previous form_class_attr()
|
168 |
*
|
169 |
-
* @return modified class
|
170 |
*
|
171 |
* @since 0.1.0
|
172 |
*/
|
173 |
function form_classes( $class ) {
|
174 |
|
175 |
// Get the current CF7 form ID
|
176 |
-
$cf7 = wpcf7_get_current_contact_form();
|
177 |
$form_id = $this->get_form_id( $cf7 );
|
178 |
|
179 |
// Get current CF7 form template and style from post meta
|
@@ -201,10 +209,11 @@ class CF7_Skins_CF7_Connect {
|
|
201 |
* @uses WPCF7_ContactForm->form - before CF7 3.9
|
202 |
* @file wp-content\plugins\contact-form-7\includes\contact-form.php
|
203 |
*
|
204 |
-
* @param
|
|
|
205 |
* @previous contact_form()
|
206 |
*
|
207 |
-
* @return
|
208 |
*
|
209 |
* @since 0.1.0
|
210 |
*/
|
@@ -242,9 +251,9 @@ class CF7_Skins_CF7_Connect {
|
|
242 |
/**
|
243 |
* Modify current CF7 form content.
|
244 |
*
|
245 |
-
* @param
|
246 |
*
|
247 |
-
* @return
|
248 |
*
|
249 |
* @since 0.1.0
|
250 |
*/
|
@@ -262,7 +271,9 @@ class CF7_Skins_CF7_Connect {
|
|
262 |
* e.g. <li>Name [text* cf7s-name]</li> changed to
|
263 |
* <li><label for="cf7s-name">Name <em class="cf7s-reqd">*</em></label> [text* cf7s-name]</li>
|
264 |
*
|
265 |
-
* @param
|
|
|
|
|
266 |
*
|
267 |
* @since 1.1.1
|
268 |
*/
|
@@ -329,7 +340,9 @@ class CF7_Skins_CF7_Connect {
|
|
329 |
*
|
330 |
* @link https://bitbucket.org/cf7skins/cf7skins-dev-cf7skins/issues/28/wpcf7_shortcode-deprecated
|
331 |
*
|
332 |
-
* @param
|
|
|
|
|
333 |
*
|
334 |
* @since 1.2.1
|
335 |
*/
|
@@ -337,13 +350,89 @@ class CF7_Skins_CF7_Connect {
|
|
337 |
|
338 |
if ( version_compare( WPCF7_VERSION, '4.6', '<' ) ) { // before CF7 4.6
|
339 |
$manager = WPCF7_ShortcodeManager::get_instance();
|
340 |
-
return $manager->scan_shortcode( $form );
|
341 |
|
342 |
} else { // CF7 4.6 or greater
|
343 |
$manager = WPCF7_FormTagsManager::get_instance();
|
344 |
return $manager->scan( $form );
|
345 |
}
|
346 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
} // end class
|
348 |
|
349 |
/**
|
20 |
function __construct() {
|
21 |
add_filter( 'wpcf7_form_class_attr', array( &$this, 'form_classes' ) );
|
22 |
add_action( 'wpcf7_contact_form', array( &$this, 'cf7_form' ), 1 );
|
23 |
+
|
24 |
+
// Priority should be not empty or default to have them in the right order.
|
25 |
+
// Default is 10, we use 9 to allow other styles (registered wihtout setting priority/default)
|
26 |
+
// enqueued after this style, or before such as framework styles, default styling, etc.
|
27 |
+
add_action( 'cf7skins_enqueue_styles', array( $this, 'enqueue_skins_style' ), 9, 1 );
|
28 |
}
|
29 |
|
30 |
/**
|
33 |
* Back compat for CF7 3.9
|
34 |
* @see http://contactform7.com/2014/07/02/contact-form-7-39-beta/
|
35 |
*
|
36 |
+
* @param {Object} $cf7 Contact Form 7 object
|
37 |
+
*
|
38 |
+
* @return contact form id
|
39 |
*
|
40 |
* @since 0.1.0
|
41 |
*/
|
52 |
*
|
53 |
* Back compat for CF7 3.9
|
54 |
*
|
55 |
+
* @param {Object} $cf7 Contact Form 7 object
|
56 |
+
*
|
57 |
+
* @return {HTML} contact form
|
58 |
*
|
59 |
* @since 0.1.0
|
60 |
*/
|
72 |
* Check if CF7 default stylesheet is still registered
|
73 |
* as is used by other CF7 Skins plugins.
|
74 |
*
|
75 |
+
* @return {Array} $deps array of style dependencies
|
76 |
*
|
77 |
* @since 1.1.1
|
78 |
*/
|
92 |
* Check if CF7 default script is still registered
|
93 |
* as is used by other CF7 Skins plugins.
|
94 |
*
|
95 |
+
* @return {Array} $deps array of script dependencies
|
96 |
*
|
97 |
* @since 1.2.2
|
98 |
*/
|
127 |
*
|
128 |
* @do_action 'cf7skins_enqueue_styles'
|
129 |
*
|
130 |
+
* @param {String} $style CF7 Skins style slug name applied to current CF7 form
|
131 |
*
|
132 |
* @since 1.1.0
|
133 |
*/
|
145 |
*
|
146 |
* @action 'cf7skins_enqueue_styles'
|
147 |
*
|
148 |
+
* @param {String} $style CF7 Skins style slug name applied to current CF7 form
|
149 |
*
|
150 |
* @since 1.1.0
|
151 |
*/
|
158 |
$this->stylesheet_dependencies(), CF7SKINS_VERSION, 'all' );
|
159 |
}
|
160 |
}
|
161 |
+
|
162 |
/**
|
163 |
* Add CF7 Skins classes to the CF7 HTML form class.
|
164 |
*
|
171 |
*
|
172 |
* @filter 'cf7skins_form_classes' - allows other CF7 Skins plugins to add their style classes
|
173 |
*
|
174 |
+
* @param {String} $class CF7 HTML form class
|
175 |
* @previous form_class_attr()
|
176 |
*
|
177 |
+
* @return {String} $class modified CF7 HTML form class
|
178 |
*
|
179 |
* @since 0.1.0
|
180 |
*/
|
181 |
function form_classes( $class ) {
|
182 |
|
183 |
// Get the current CF7 form ID
|
184 |
+
$cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
|
185 |
$form_id = $this->get_form_id( $cf7 );
|
186 |
|
187 |
// Get current CF7 form template and style from post meta
|
209 |
* @uses WPCF7_ContactForm->form - before CF7 3.9
|
210 |
* @file wp-content\plugins\contact-form-7\includes\contact-form.php
|
211 |
*
|
212 |
+
* @param {Object} $cf7 Contact Form 7 object
|
213 |
+
*
|
214 |
* @previous contact_form()
|
215 |
*
|
216 |
+
* @return {Object} $cf7 Modified Contact Form 7 object
|
217 |
*
|
218 |
* @since 0.1.0
|
219 |
*/
|
251 |
/**
|
252 |
* Modify current CF7 form content.
|
253 |
*
|
254 |
+
* @param {HTML} $form Current CF7 form content
|
255 |
*
|
256 |
+
* @return {HTML} $form Modified CF7 form content
|
257 |
*
|
258 |
* @since 0.1.0
|
259 |
*/
|
271 |
* e.g. <li>Name [text* cf7s-name]</li> changed to
|
272 |
* <li><label for="cf7s-name">Name <em class="cf7s-reqd">*</em></label> [text* cf7s-name]</li>
|
273 |
*
|
274 |
+
* @param {HTML} $form Current CF7 form content
|
275 |
+
*
|
276 |
+
* @return {HTML} contact form with additional element attributes( id, class, etc)
|
277 |
*
|
278 |
* @since 1.1.1
|
279 |
*/
|
340 |
*
|
341 |
* @link https://bitbucket.org/cf7skins/cf7skins-dev-cf7skins/issues/28/wpcf7_shortcode-deprecated
|
342 |
*
|
343 |
+
* @param {HTML} $form Current CF7 form content
|
344 |
+
*
|
345 |
+
* @return {Object} CF7 shortcode object
|
346 |
*
|
347 |
* @since 1.2.1
|
348 |
*/
|
350 |
|
351 |
if ( version_compare( WPCF7_VERSION, '4.6', '<' ) ) { // before CF7 4.6
|
352 |
$manager = WPCF7_ShortcodeManager::get_instance();
|
353 |
+
return $manager->scan_shortcode( $form );
|
354 |
|
355 |
} else { // CF7 4.6 or greater
|
356 |
$manager = WPCF7_FormTagsManager::get_instance();
|
357 |
return $manager->scan( $form );
|
358 |
}
|
359 |
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Get lists that contains shortcode tag in CF7 form content.
|
363 |
+
* Shortcode tags outside a list <li/> will be excluded.
|
364 |
+
*
|
365 |
+
* @param {HTML/String} $form Current CF7 form content
|
366 |
+
*
|
367 |
+
* @return {Array} $lists array of <li></li>s
|
368 |
+
*
|
369 |
+
* @since 2.1.5
|
370 |
+
*/
|
371 |
+
public static function get_lists( $form ) {
|
372 |
+
|
373 |
+
$lists = array(); // handle list contains shortcode
|
374 |
+
|
375 |
+
// Get all current shortcode
|
376 |
+
$scanned = self::scan_shortcode( $form );
|
377 |
+
|
378 |
+
foreach( $scanned as $tag ) {
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Backward compatibility for CF7 4.6
|
382 |
+
* @since 1.2.1
|
383 |
+
*/
|
384 |
+
if ( version_compare( WPCF7_VERSION, '4.6', '<' ) ) { // before CF7 4.6
|
385 |
+
$tag = new WPCF7_Shortcode( $tag );
|
386 |
+
}
|
387 |
+
else { // CF7 4.6 or greater
|
388 |
+
$tag = new WPCF7_FormTag( $tag );
|
389 |
+
}
|
390 |
+
|
391 |
+
$types[] = $tag->type; // add shortcode for further text searching
|
392 |
+
}
|
393 |
+
|
394 |
+
libxml_use_internal_errors( true ); // handle error
|
395 |
+
$dom = new DOMDocument( '1.0', 'utf-8' );
|
396 |
+
$dom->loadHTML( "<?xml encoding='UTF-8' ?>". $form );
|
397 |
+
libxml_use_internal_errors( false ); // handle error
|
398 |
+
|
399 |
+
// Get all lists, including nested list
|
400 |
+
$get_lists = $dom->getElementsByTagName('li');
|
401 |
+
|
402 |
+
if ( $get_lists->length ) { // only if list exists
|
403 |
+
|
404 |
+
foreach( $get_lists as $list ) { // loop for each
|
405 |
+
|
406 |
+
$shortcode_exist = false;
|
407 |
+
|
408 |
+
foreach ( $list->childNodes as $node ) { // loop each child nodes
|
409 |
+
|
410 |
+
$content = trim( $node->textContent ); // remove spaces from plain text
|
411 |
+
|
412 |
+
// If is a text node and not empty (trim spaces/tabs)
|
413 |
+
// https://www.php.net/manual/en/dom.constants.php#constant.xml-text-node
|
414 |
+
if ( $node->nodeType === XML_TEXT_NODE && ! empty( $content ) ) {
|
415 |
+
|
416 |
+
// Loop for each type to find if the content contains shortcode
|
417 |
+
foreach( $types as $type ) {
|
418 |
+
$shortcode_type = "[{$type} "; // bracket+type+required+space, i.e. '[select* '
|
419 |
+
|
420 |
+
// Shortcode exists in content, set current node
|
421 |
+
if ( strpos( $content, $shortcode_type ) !== false ) {
|
422 |
+
$shortcode_exist = true;
|
423 |
+
}
|
424 |
+
}
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
if ( !! $shortcode_exist ) {
|
429 |
+
$lists[] = $dom->saveXML( $list );
|
430 |
+
}
|
431 |
+
}
|
432 |
+
}
|
433 |
+
|
434 |
+
return $lists;
|
435 |
+
}
|
436 |
} // end class
|
437 |
|
438 |
/**
|
index.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Contact Form 7 Skins
|
4 |
* Plugin URI: http://cf7skins.com
|
5 |
* Description: Adds drag & drop Visual Editor with Templates & Styles to Contact Form 7. Requires Contact Form 7.
|
6 |
-
* Version: 2.2
|
7 |
* Author: Neil Murray
|
8 |
* Author URI: http://cf7skins.com
|
9 |
* License: GPL-2.0+
|
@@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
30 |
*
|
31 |
* @since 0.1.0
|
32 |
*/
|
33 |
-
define( 'CF7SKINS_VERSION', '2.2' );
|
34 |
define( 'CF7SKINS_OPTIONS', 'cf7skins' ); // Database option names
|
35 |
define( 'CF7SKINS_TEXTDOMAIN', 'contact-form-7-skins' );
|
36 |
define( 'CF7SKINS_FEATURE_FILTER', false ); // @since 0.4.0
|
3 |
* Plugin Name: Contact Form 7 Skins
|
4 |
* Plugin URI: http://cf7skins.com
|
5 |
* Description: Adds drag & drop Visual Editor with Templates & Styles to Contact Form 7. Requires Contact Form 7.
|
6 |
+
* Version: 2.2.1
|
7 |
* Author: Neil Murray
|
8 |
* Author URI: http://cf7skins.com
|
9 |
* License: GPL-2.0+
|
30 |
*
|
31 |
* @since 0.1.0
|
32 |
*/
|
33 |
+
define( 'CF7SKINS_VERSION', '2.2.1' );
|
34 |
define( 'CF7SKINS_OPTIONS', 'cf7skins' ); // Database option names
|
35 |
define( 'CF7SKINS_TEXTDOMAIN', 'contact-form-7-skins' );
|
36 |
define( 'CF7SKINS_FEATURE_FILTER', false ); // @since 0.4.0
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: contact form 7, contact form 7 editor, contact form 7 addon, contact form
|
|
4 |
Requires at least: 4.3
|
5 |
Tested up to: 5.3
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 2.2
|
8 |
Author URI: https://cf7skins.com
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -122,6 +122,10 @@ Absolutely not. You can create and manage Contact Form 7 forms without any codin
|
|
122 |
|
123 |
== Changelog ==
|
124 |
|
|
|
|
|
|
|
|
|
125 |
= 2.2 - 2020-01-07 =
|
126 |
|
127 |
* FEATURE: Add Styles
|
4 |
Requires at least: 4.3
|
5 |
Tested up to: 5.3
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 2.2.1
|
8 |
Author URI: https://cf7skins.com
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
122 |
|
123 |
== Changelog ==
|
124 |
|
125 |
+
= 2.2.1 - 2020-01-14 =
|
126 |
+
|
127 |
+
* FIX: Improve getting list of all CF7 shortcode tags in CF7 form content
|
128 |
+
|
129 |
= 2.2 - 2020-01-07 =
|
130 |
|
131 |
* FEATURE: Add Styles
|