本文整理汇总了PHP中wpcf7_script_is函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_script_is函数的具体用法?PHP wpcf7_script_is怎么用?PHP wpcf7_script_is使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_script_is函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf7_submit_shortcode_handler
function wpcf7_submit_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$options = (array) $tag['options'];
$values = (array) $tag['values'];
$atts = '';
$id_att = '';
$class_att = '';
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
}
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
$value = isset($values[0]) ? $values[0] : '';
if (empty($value)) {
$value = __('Send', 'wpcf7');
}
$html = '<input type="submit" value="' . esc_attr($value) . '"' . $atts . ' />';
if (wpcf7_script_is()) {
$html .= ' <img class="ajax-loader" style="visibility: hidden;" alt="ajax loader" src="' . wpcf7_plugin_url('images/ajax-loader.gif') . '" />';
}
return $html;
}
示例2: wpcf7_acceptance_shortcode_handler
function wpcf7_acceptance_shortcode_handler($tag)
{
global $wpcf7_contact_form;
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
if (empty($name)) {
return '';
}
$atts = '';
$id_att = '';
$class_att = '';
$tabindex_att = '';
$class_att .= ' wpcf7-acceptance';
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif ('invert' == $option) {
$class_att .= ' wpcf7-invert';
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
$default_on = (bool) preg_grep('/^default:on$/i', $options);
if (wpcf7_script_is()) {
$onclick = ' onclick="wpcf7ToggleSubmit(this.form);"';
} else {
$onclick = '';
}
$checked = $default_on ? ' checked="checked"' : '';
$html = '<input type="checkbox" name="' . $name . '" value="1"' . $atts . $onclick . $checked . ' />';
return $html;
}
示例3: wpcf7_submit_shortcode_handler
function wpcf7_submit_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$options = (array) $tag['options'];
$values = (array) $tag['values'];
$atts = '';
$id_att = '';
$class_att = '';
$tabindex_att = '';
$class_att .= ' wpcf7-submit';
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
$value = isset($values[0]) ? $values[0] : '';
if (empty($value)) {
$value = __('Send', 'wpcf7');
}
$html = '<input type="submit" value="' . esc_attr($value) . '"' . $atts . ' />';
if (wpcf7_script_is()) {
$src = apply_filters('wpcf7_ajax_loader', wpcf7_plugin_url('images/ajax-loader.gif'));
$html .= '<img class="ajax-loader" style="visibility: hidden;" alt="' . esc_attr(__('Sending ...', 'wpcf7')) . '" src="' . esc_url_raw($src) . '" />';
}
return $html;
}
示例4: wpcf7_text_shortcode_handler
function wpcf7_text_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
if (empty($name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($name);
$atts = $id_att = $size_att = $maxlength_att = '';
$tabindex_att = $title_att = '';
$class_att = wpcf7_form_controls_class($type, 'wpcf7-text');
if ('email' == $type || 'email*' == $type) {
$class_att .= ' wpcf7-validates-as-email';
}
if ($validation_error) {
$class_att .= ' wpcf7-not-valid';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('%^([0-9]*)[/x]([0-9]*)$%', $option, $matches)) {
$size_att = (int) $matches[1];
$maxlength_att = (int) $matches[2];
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
$value = (string) reset($values);
if (wpcf7_script_is() && preg_grep('%^watermark$%', $options)) {
$class_att .= ' wpcf7-use-title-as-watermark';
$title_att .= sprintf(' %s', $value);
$value = '';
} elseif (empty($value) && is_user_logged_in()) {
$user = wp_get_current_user();
$user_options = array('default:user_login' => 'user_login', 'default:user_email' => 'user_email', 'default:user_url' => 'user_url', 'default:user_first_name' => 'first_name', 'default:user_last_name' => 'last_name', 'default:user_nickname' => 'nickname', 'default:user_display_name' => 'display_name');
foreach ($user_options as $option => $prop) {
if (preg_grep('%^' . $option . '$%', $options)) {
$value = $user->{$prop};
break;
}
}
}
if (wpcf7_is_posted() && isset($_POST[$name])) {
$value = stripslashes_deep($_POST[$name]);
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
if ($size_att) {
$atts .= ' size="' . $size_att . '"';
} else {
$atts .= ' size="40"';
}
// default size
if ($maxlength_att) {
$atts .= ' maxlength="' . $maxlength_att . '"';
}
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
if ($title_att) {
$atts .= sprintf(' title="%s"', trim(esc_attr($title_att)));
}
$html = '<input type="text" name="' . $name . '" value="' . esc_attr($value) . '"' . $atts . ' />';
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . $validation_error . '</span>';
return $html;
}
示例5: wpcf7_head
function wpcf7_head()
{
// Cached?
if (wpcf7_script_is() && defined('WP_CACHE') && WP_CACHE) {
?>
<script type="text/javascript">
//<![CDATA[
var _wpcf7 = { cached: 1 };
//]]>
</script>
<?php
}
}
示例6: wpcf7_html5_fallback
function wpcf7_html5_fallback()
{
if (!wpcf7_support_html5_fallback()) {
return;
}
if (wpcf7_script_is()) {
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_script('jquery-ui-spinner');
}
if (wpcf7_style_is()) {
wp_enqueue_style('jquery-ui-smoothness', wpcf7_plugin_url('includes/js/jquery-ui/themes/smoothness/jquery-ui.min.css'), array(), '1.10.3', 'screen');
}
}
示例7: wpcf7_captcha_shortcode_handler
function wpcf7_captcha_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
if (empty($name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($name);
$atts = $id_att = $size_att = $maxlength_att = $tabindex_att = $title_att = '';
$class_att = wpcf7_form_controls_class($type);
if ('captchac' == $type) {
$class_att .= ' wpcf7-captcha-' . $name;
}
if ($validation_error && 'captchar' == $type) {
$class_att .= ' wpcf7-not-valid';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('%^([0-9]*)[/x]([0-9]*)$%', $option, $matches)) {
$size_att = (int) $matches[1];
$maxlength_att = (int) $matches[2];
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
// Value.
$value = '';
if ('captchar' == $type && !wpcf7_is_posted() && isset($values[0])) {
$value = $values[0];
if (wpcf7_script_is() && preg_grep('%^watermark$%', $options)) {
$class_att .= ' wpcf7-use-title-as-watermark';
$title_att .= sprintf(' %s', $value);
$value = '';
}
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
if ('captchac' == $type) {
if (!class_exists('ReallySimpleCaptcha')) {
return '<em>' . __('To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'wpcf7') . '</em>';
}
$op = array();
// Default
$op['img_size'] = array(72, 24);
$op['base'] = array(6, 18);
$op['font_size'] = 14;
$op['font_char_width'] = 15;
$op = array_merge($op, wpcf7_captchac_options($options));
if (!($filename = wpcf7_generate_captcha($op))) {
return '';
}
if (is_array($op['img_size'])) {
$atts .= ' width="' . $op['img_size'][0] . '" height="' . $op['img_size'][1] . '"';
}
$captcha_url = trailingslashit(wpcf7_captcha_tmp_url()) . $filename;
$html = '<img alt="captcha" src="' . $captcha_url . '"' . $atts . ' />';
$ref = substr($filename, 0, strrpos($filename, '.'));
$html = '<input type="hidden" name="_wpcf7_captcha_challenge_' . $name . '" value="' . $ref . '" />' . $html;
return $html;
} elseif ('captchar' == $type) {
if ($size_att) {
$atts .= ' size="' . $size_att . '"';
} else {
$atts .= ' size="40"';
}
// default size
if ($maxlength_att) {
$atts .= ' maxlength="' . $maxlength_att . '"';
}
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
if ('' !== $title_att) {
$atts .= sprintf(' title="%s"', trim(esc_attr($title_att)));
}
$html = '<input type="text" name="' . $name . '" value="' . esc_attr($value) . '"' . $atts . ' />';
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . $validation_error . '</span>';
return $html;
}
}
示例8: wpcf7_textarea_shortcode_handler
function wpcf7_textarea_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
$content = $tag['content'];
if (empty($name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($name);
$atts = '';
$id_att = '';
$class_att = '';
$cols_att = '';
$rows_att = '';
$tabindex_att = '';
$title_att = '';
$class_att = wpcf7_form_controls_class($type);
if ($validation_error) {
$class_att .= ' wpcf7-not-valid';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('%^([0-9]*)[x/]([0-9]*)$%', $option, $matches)) {
$cols_att = (int) $matches[1];
$rows_att = (int) $matches[2];
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
$value = (string) reset($values);
if (!empty($content)) {
$value = $content;
}
if (wpcf7_script_is() && preg_grep('%^watermark$%', $options)) {
$class_att .= ' wpcf7-use-title-as-watermark';
$title_att .= sprintf(' %s', $value);
$value = '';
}
if (wpcf7_is_posted() && isset($_POST[$name])) {
$value = stripslashes_deep($_POST[$name]);
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
if ($cols_att) {
$atts .= ' cols="' . $cols_att . '"';
} else {
$atts .= ' cols="40"';
}
// default size
if ($rows_att) {
$atts .= ' rows="' . $rows_att . '"';
} else {
$atts .= ' rows="10"';
}
// default size
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
if ($title_att) {
$atts .= sprintf(' title="%s"', trim(esc_attr($title_att)));
}
$html = '<textarea name="' . $name . '"' . $atts . '>' . esc_textarea($value) . '</textarea>';
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . $validation_error . '</span>';
return $html;
}
示例9: wpcf7_text_shortcode_handler
function wpcf7_text_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
if (empty($name)) {
return '';
}
$atts = '';
$id_att = '';
$class_att = '';
$size_att = '';
$maxlength_att = '';
$tabindex_att = '';
$title_att = '';
$class_att .= ' wpcf7-text';
if ('email' == $type || 'email*' == $type) {
$class_att .= ' wpcf7-validates-as-email';
}
if ('text*' == $type || 'email*' == $type) {
$class_att .= ' wpcf7-validates-as-required';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('%^([0-9]*)[/x]([0-9]*)$%', $option, $matches)) {
$size_att = (int) $matches[1];
$maxlength_att = (int) $matches[2];
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
$value = (string) reset($values);
if (wpcf7_script_is() && preg_grep('%^watermark$%', $options)) {
$class_att .= ' wpcf7-use-title-as-watermark';
$title_att .= sprintf(' %s', $value);
$value = '';
}
if (wpcf7_is_posted()) {
$value = stripslashes_deep($_POST[$name]);
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
if ($size_att) {
$atts .= ' size="' . $size_att . '"';
} else {
$atts .= ' size="40"';
}
// default size
if ($maxlength_att) {
$atts .= ' maxlength="' . $maxlength_att . '"';
}
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
if ($title_att) {
$atts .= sprintf(' title="%s"', trim(esc_attr($title_att)));
}
$html = '<input type="text" name="' . $name . '" value="' . esc_attr($value) . '"' . $atts . ' />';
$validation_error = wpcf7_get_validation_error($name);
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . $validation_error . '</span>';
return $html;
}
示例10: wpcf7_hidden_shortcode_handler
function wpcf7_hidden_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $raw_name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
if (empty($name)) {
return '';
}
$atts = '';
$id_att = '';
$class_att = '';
$size_att = '';
$maxlength_att = '';
$tabindex_att = '';
$title_att = '';
$class_att .= ' wpcf7-hidden';
if ('hidden*' == $type) {
$class_att .= ' wpcf7-validates-as-required';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
}
}
$value = (string) reset($values);
if (wpcf7_script_is() && $value && preg_grep('%^watermark$%', $options)) {
$class_att .= ' wpcf7-use-title-as-watermark';
$title_att .= sprintf(' %s', $value);
$value = '';
}
if (wpcf7_is_posted()) {
$value = stripslashes_deep($_POST[$name]);
}
if ($id_att) {
$id_att = trim($id_att);
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
// Add support for new CF7 format
if (preg_match('/hidden/ism', $name)) {
$name = isset($values[0]) ? $values[0] : $name;
}
$sanitized_name = strtolower(trim($name));
global $post;
if (is_object($post)) {
switch ($sanitized_name) {
case 'post_title':
case 'post-title':
$value = $post->post_title;
break;
case 'page_url':
case 'post_url':
$value = get_permalink($post->ID);
if (empty($value) && isset($post->guid)) {
$value = $post->guid;
}
$value = esc_url($value);
break;
case 'post_category':
$categories = get_the_category($post->ID);
$catnames = array();
// Get the category names
foreach ($categories as $cat) {
$catnames[] = $cat->cat_name;
}
$value = implode(', ', $catnames);
break;
case 'post_author_id':
$value = $post->post_author;
break;
case 'post_author':
$user = get_userdata($post->post_author);
$value = $user->display_name;
break;
default:
// You want post_modified? just use [hidden hidden-123 "post_modified"]
if (isset($post->{$name})) {
$value = $post->{$name};
}
break;
}
if (preg_match('/^custom_field\\-(.*?)$/ism', $sanitized_name)) {
$custom_field = preg_replace('/custom_field\\-(.*?)/ism', '$1', $name);
$value = get_post_meta($post->ID, $custom_field, false) ? get_post_meta($post->ID, $custom_field, false) : '';
}
}
// Process user stuff
if (preg_match('/user/ism', $sanitized_name) && is_user_logged_in()) {
global $current_user;
get_currentuserinfo();
switch ($sanitized_name) {
case 'user_name':
//.........这里部分代码省略.........
示例11: wpcf7_checkbox_shortcode_handler
function wpcf7_checkbox_shortcode_handler($tag)
{
global $wpcf7_contact_form;
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
$labels = (array) $tag['labels'];
if (empty($name)) {
return '';
}
$atts = '';
$id_att = '';
$class_att = '';
$tabindex_att = '';
$defaults = array();
$label_first = false;
$use_label_element = false;
if ('checkbox*' == $type) {
$class_att .= ' wpcf7-validates-as-required';
}
if ('checkbox' == $type || 'checkbox*' == $type) {
$class_att .= ' wpcf7-checkbox';
}
if ('radio' == $type) {
$class_att .= ' wpcf7-radio';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('/^default:([0-9_]+)$/', $option, $matches)) {
$defaults = explode('_', $matches[1]);
} elseif (preg_match('%^label[_-]?first$%', $option)) {
$label_first = true;
} elseif (preg_match('%^use[_-]?label[_-]?element$%', $option)) {
$use_label_element = true;
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
$multiple = preg_match('/^checkbox[*]?$/', $type) && !preg_grep('%^exclusive$%', $options);
$html = '';
if (preg_match('/^checkbox[*]?$/', $type) && !$multiple && wpcf7_script_is()) {
$onclick = ' onclick="wpcf7ExclusiveCheckbox(this);"';
} else {
$onclick = '';
}
$input_type = rtrim($type, '*');
$posted = is_a($wpcf7_contact_form, 'WPCF7_ContactForm') && $wpcf7_contact_form->is_posted();
foreach ($values as $key => $value) {
$checked = false;
if (in_array($key + 1, (array) $defaults)) {
$checked = true;
}
if ($posted) {
if ($multiple && in_array(esc_sql($value), (array) $_POST[$name])) {
$checked = true;
}
if (!$multiple && $_POST[$name] == esc_sql($value)) {
$checked = true;
}
}
$checked = $checked ? ' checked="checked"' : '';
if ('' !== $tabindex_att) {
$tabindex = sprintf(' tabindex="%d"', $tabindex_att);
$tabindex_att += 1;
} else {
$tabindex = '';
}
if (isset($labels[$key])) {
$label = $labels[$key];
} else {
$label = $value;
}
if ($label_first) {
// put label first, input last
$item = '<span class="wpcf7-list-item-label">' . esc_html($label) . '</span> ';
$item .= '<input type="' . $input_type . '" name="' . $name . ($multiple ? '[]' : '') . '" value="' . esc_attr($value) . '"' . $checked . $tabindex . $onclick . ' />';
} else {
$item = '<input type="' . $input_type . '" name="' . $name . ($multiple ? '[]' : '') . '" value="' . esc_attr($value) . '"' . $checked . $tabindex . $onclick . ' />';
$item .= ' <span class="wpcf7-list-item-label">' . esc_html($label) . '</span>';
}
if ($use_label_element) {
$item = '<label>' . $item . '</label>';
}
$item = '<span class="wpcf7-list-item">' . $item . '</span>';
$html .= $item;
}
$html = '<span' . $atts . '>' . $html . '</span>';
//.........这里部分代码省略.........