Wordpress - [FIX] function wpscf_my_shortcode_head()

Here you can ask or discuss anything else you want...

Wordpress - [FIX] function wpscf_my_shortcode_head()

New postby masterix21 » Mon Oct 07, 2013 6:31 pm

Hi friend,

i found a fix for your function wpscf_my_shortcode_head().

File: sexy-contact-form/includes/display-functions.php
Line: 12

Change from:
Code: Select all
if (is_array($matches) && $matches[2] == 'sexyform') {


to:
Code: Select all
if (is_array($matches) && isset($matches[2]) && $matches[2] == 'sexyform') {


This fix allow to prevent an error stops if the array $matches won't have three items.
masterix21
 
Posts: 12
Joined: Wed Oct 02, 2013 10:09 pm

Re: Wordpress - [FIX] function wpscf_my_shortcode_head()

New postby masterix21 » Mon Oct 07, 2013 8:05 pm

I found another problem when the page requested doesn't exist.

These are the changes that i applied to the file display-functions.php:

Code: Select all
function wpscf_my_shortcode_head(){
   global $posts;
   global $wpscf_token;
   
   if (!is_array($posts) || !isset($posts[0]))
      return;
   
   $pattern = get_shortcode_regex();
   preg_match('/(\[(sexyform) id="([0-9]+)"\])/s', $posts[0]->post_content, $matches);
   if (is_array($matches) && isset($matches[2]) && $matches[2] == 'sexyform') {
      $form_id = (int) $matches[3];
      wpscf_enqueue_front_scripts($form_id);
      
      //set token
      $wpscf_token = md5(time() * rand(1000,9999));
      $_SESSION['sexycontactform_token'] = $wpscf_token;
   }
}
masterix21
 
Posts: 12
Joined: Wed Oct 02, 2013 10:09 pm

Re: Wordpress - [FIX] function wpscf_my_shortcode_head()

New postby Simon » Tue Oct 08, 2013 2:47 pm

Thanks for your help to make Sexy Contact Form better.
User avatar
Simon
Site Admin
 
Posts: 1306
Joined: Wed Jul 13, 2011 8:53 pm


Return to Open discussion

Who is online

Users browsing this forum: No registered users and 3 guests