From 5524f7cd5a8f24c5c597f2c2672ab5bbcbca436a Mon Sep 17 00:00:00 2001 From: Zack Katz Date: Wed, 1 Feb 2017 15:06:37 -0700 Subject: [PATCH 01/15] Fix deprecated function Closes https://wordpress.org/support/topic/throws-error-with-cf7-4-6/ Closes https://wordpress.org/support/topic/notice-wpcf7_shortcode-errors/ --- hidden.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hidden.php b/hidden.php index b5b26fa..9cf7943 100644 --- a/hidden.php +++ b/hidden.php @@ -40,7 +40,11 @@ function contact_form_7_hidden_fields_textdomain() { function contact_form_7_hidden_fields() { global $pagenow; if( class_exists('WPCF7_Shortcode') ) { - wpcf7_add_shortcode( array( 'hidden', 'hidden*' ), 'wpcf7_hidden_shortcode_handler', true ); + if ( function_exists( 'wpcf7_add_form_tag' ) ) { + wpcf7_add_form_tag( array( 'hidden', 'hidden*' ), 'wpcf7_hidden_shortcode_handler', true ); + } else { + wpcf7_add_shortcode( array( 'hidden', 'hidden*' ), 'wpcf7_hidden_shortcode_handler', true ); + } } else { if($pagenow != 'plugins.php') { return; } add_action('admin_notices', 'cfhiddenfieldserror'); From f9c46709ff4dab56e983365521a8c1c22759787b Mon Sep 17 00:00:00 2001 From: Zack Katz Date: Wed, 1 Feb 2017 15:54:01 -0700 Subject: [PATCH 02/15] Convert remote message to inline --- functions.php | 75 ++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/functions.php b/functions.php index 7bdb4c2..5a80b24 100644 --- a/functions.php +++ b/functions.php @@ -15,46 +15,49 @@ function contact_form_7_modules_promo_message() { } if($pagenow == 'admin.php' && isset($_REQUEST['page']) && $_REQUEST['page'] == 'wpcf7' && ($message !== 3 || isset($_REQUEST['show']) && $_REQUEST['show'] == 'cf7_modules_promo_message')) { - $message = contact_form_7_modules_get_remote_message(); - - $message = str_replace('{hidelink}', add_query_arg('hide', 'cf7_modules_promo_message'), $message); - $message = str_replace('{showlink}', add_query_arg('show', 'cf7_modules_promo_message'), $message); - $message = str_replace('{adminurl}', admin_url(), $message); - $message = str_replace('{siteurl}', site_url(), $message); - - echo $message; + echo contact_form_7_modules_get_message(); } } -function contact_form_7_modules_get_remote_message() { - - // The ad is stored locally for 30 days as a transient. See if it exists. - $cache = function_exists('get_site_transient') ? get_site_transient('contact_form_7_modules_remote_ad') : get_transient('contact_form_7_modules_remote_ad'); - - // If it exists, use that (so we save some request time), unless ?cache is set. - if(!empty($cache) && !isset($_REQUEST['cache'])) { return $cache; } - - // Get the advertisement remotely. An encrypted site identifier, the language of the site, and the version of the cf7 plugin will be sent to katz.co - $response = wp_remote_post('http://katz.co/ads/', array('timeout' => 45,'body' => array('siteid' => sha1(site_url()), 'language' => get_bloginfo('language'), 'plugin' => 'cf7_modules', 'version' => WPCF7_VERSION))); - - // If it was a successful request, process it. - if(!is_wp_error($response) && !empty($response)) { - - // Basically, remove