wpcf7_add_shortcode deprecated since CF7 v4.6. Causes PHP notice
-
[13-Sep-2017 09:56:09 UTC] PHP Notice: wpcf7_add_shortcode is deprecated since Contact Form 7 version 4.6! Use wpcf7_add_form_tag instead. in /wp-content/plugins/contact-form-7/includes/functions.php on line 355
With the help of Query Monitor I tracked it to the add_shortcode_wpcaptcha() function in hctpc-contact-form-integration.php
I copied the code from Contact Form 7 Honeypot (https://www.ads-software.com/plugins/contact-form-7-honeypot/). That plugin calls the wpcf7_add_form_tag() function if it is available.
Here is a patch:
https://pastebin.com/LvVGP8iu— hctpc-contact-form-integration.orig.php 2017-09-13 08:53:03.000000000 +0100
+++ hctpc-contact-form-integration.php 2017-09-13 11:07:25.286147500 +0100
@@ -21,7 +21,12 @@
*/
add_action( ‘wpcf7_init’, ‘add_shortcode_wpcaptcha’ );
function add_shortcode_wpcaptcha() {
– wpcf7_add_shortcode( ‘wpcaptcha’, ‘captcha_shortcode’, true );
+ // Test if new 4.6+ functions exists
+ if (function_exists(‘wpcf7_add_form_tag’)) {
+ wpcf7_add_form_tag( ‘wpcaptcha’, ‘captcha_shortcode’, true );
+ } else {
+ wpcf7_add_shortcode( ‘wpcaptcha’, ‘captcha_shortcode’, true );
+ }
}
- The topic ‘wpcf7_add_shortcode deprecated since CF7 v4.6. Causes PHP notice’ is closed to new replies.