function icl_wpcf7_display_warning_message(&$contact_form) { if (!$contact_form) { return; } $has_icl_tags = (bool) $contact_form->form_scan_shortcode(array('type' => array('icl'))); if (!$has_icl_tags) { $messages = (array) $contact_form->messages; $shortcode_manager = new WPCF7_ShortcodeManager(); $shortcode_manager->add_shortcode('icl', create_function('$tag', 'return null;'), true); foreach ($messages as $message) { if ($shortcode_manager->scan_shortcode($message)) { $has_icl_tags = true; break; } } } if (!$has_icl_tags) { return; } $message = __("This contact form contains [icl] tags, but they are obsolete and no longer functioning on this version of Contact Form 7. <a href=\"http://contactform7.com/2009/12/25/contact-form-in-your-language/#Creating_contact_form_in_different_languages\" target=\"_blank\">There is a simpler way for creating contact forms of other languages</a> and you are recommended to use it.", 'wpcf7'); echo '<div class="error"><p><strong>' . $message . '</strong></p></div>'; }
function icl_wpcf7_collect_strings(&$contact_form) { $scanned = $contact_form->form_scan_shortcode(); foreach ($scanned as $tag) { if (!is_array($tag)) { continue; } $type = $tag['type']; $name = $tag['name']; $options = (array) $tag['options']; $raw_values = (array) $tag['raw_values']; $content = $tag['content']; $icl_option = array(); foreach ($options as $option) { if ('icl' == $option) { $icl_option = array('icl', null); break; } elseif (preg_match('/^icl:(.+)$/', $option, $matches)) { $icl_option = array('icl', $matches[1]); break; } } if (!('icl' == $type || $icl_option)) { continue; } $str_id = $icl_option[1] ? $icl_option[1] : $name; if (!empty($content)) { $string_name = icl_wpcf7_string_name($content, $str_id); icl_wpcf7_register_string($string_name, $content); } elseif (!empty($raw_values)) { foreach ($raw_values as $key => $value) { $value = trim($value); $string_name = icl_wpcf7_string_name($value, $str_id, $key); icl_wpcf7_register_string($string_name, $value); } } } /* From messages */ $messages = (array) $contact_form->messages; $shortcode_manager = new WPCF7_ShortcodeManager(); $shortcode_manager->add_shortcode('icl', create_function('$tag', 'return null;'), true); foreach ($messages as $message) { $tags = $shortcode_manager->scan_shortcode($message); foreach ($tags as $tag) { $name = $tag['name']; $values = (array) $tag['values']; $content = trim($tag['content']); if (!empty($content)) { $string_name = icl_wpcf7_string_name($content, $name); icl_wpcf7_register_string($string_name, $content); } else { foreach ($values as $key => $value) { $value = trim($value); $string_name = icl_wpcf7_string_name($value, $name, $key); icl_wpcf7_register_string($string_name, $value); } } } } }