Commit 6da1cf23 authored by imac's avatar imac

[ADD]Contact : form

parent 229109e6
File deleted
......@@ -15,3 +15,4 @@ wp-content/plugins/hello.php
/readme.html
/sitemap.xml
/sitemap.xml.gz
*.DS_Store
\ No newline at end of file
This diff is collapsed.
/*
* Tabs
*/
#contact-form-editor-tabs {
padding: 9px 10px 0 15px;
}
#contact-form-editor-tabs li a span.dashicons {
padding: 6px 4px 4px 0;
}
/*
* Form Tab
*/
.tag-generator-panel {
text-align: right;
}
.tag-generator-panel .control-box > fieldset legend {
border: 1px solid #dfdfdf;
border-right: 4px solid #00a0d2;
}
.tag-generator-panel .insert-box input.tag {
float: right;
}
.tag-generator-panel .insert-box .submitbox input[type="button"] {
float: left;
}
/*
* Mail Tab
*/
.contact-form-editor-box-mail span.mailtag {
margin: 0 4px 0 0;
}
/*
* Welcome Panel
*/
.welcome-panel .welcome-panel-column,
.welcome-panel .welcome-panel-column:first-child {
padding: 0 0 0 2%;
}
/*
* Integration
*/
.card {
border-left: 1px solid #e5e5e5;
border-right: 4px solid #e5e5e5;
}
.card img.icon {
float: right;
margin: 8px -8px 8px 8px;
}
.card h2.title {
float: right;
}
.card .infobox {
float: left;
}
#titlediv .inside p.description {
margin: 8px 2px 0;
}
#titlediv .inside p.description label {
cursor: pointer;
}
span.shortcode {
display: block;
margin: 2px 0;
}
span.shortcode.old {
background: #777;
color: #fff;
}
span.shortcode > input {
background: inherit;
color: inherit;
font-size: 12px;
border: none;
box-shadow: none;
padding: 4px 8px;
margin: 0;
}
#submitpost input.copy {
margin-bottom: 10px;
}
#submitpost input.delete {
padding: 0;
margin: 0;
border: none;
cursor: pointer;
background: inherit;
color: #a00;
}
#submitpost input.delete:hover {
color: #f00;
}
#submitpost input.delete:focus {
outline: thin dotted;
}
.postbox-container .postbox h3 {
border-bottom: 1px solid transparent;
}
.keyboard-interaction {
visibility: hidden;
color: #23282d;
}
div.config-error, span.config-error, ul.config-error {
color: #444;
font-style: normal;
font-size: 13px;
}
div.config-error span.dashicons {
color: #82878c;
}
ul.config-error {
margin: 0;
}
ul.config-error li {
list-style: disc inside;
padding: 0 4px;
margin: 0;
}
ul.config-error li a.external {
font-style: normal;
font-weight: normal;
font-size: 18px;
vertical-align: middle;
}
[data-config-field][aria-invalid="true"] {
border-color: #d00;
}
/*
* Tabs
*/
#contact-form-editor-tabs {
border-bottom: 1px solid #aaa;
padding: 9px 15px 0 10px;
margin: 0;
}
#contact-form-editor-tabs li {
display: inline-block;
list-style: none;
border: 1px solid #ccc;
border-bottom: 1px solid #aaa;
padding: 0;
margin: 0 4px -1px;
background-color: #e4e4e4;
}
#contact-form-editor-tabs li:hover {
background-color: #fff;
}
#contact-form-editor-tabs li.ui-tabs-active,
#contact-form-editor-tabs li.ui-tabs-active:hover {
border-top: 1px solid #aaa;
border-right: 1px solid #aaa;
border-left: 1px solid #aaa;
border-bottom: 1px solid #f5f5f5;
background-color: #f5f5f5;
}
#contact-form-editor-tabs li a {
padding: 6px 10px;
font-size: 14px;
font-weight: normal;
line-height: 30px;
color: #333;
text-decoration: none;
}
#contact-form-editor-tabs li.ui-tabs-active a {
color: #000;
font-size: 14px;
font-weight: bold;
}
#contact-form-editor-tabs li a:hover {
color: #000;
}
#contact-form-editor-tabs li a span.dashicons {
font-style: normal;
padding: 6px 0 4px 4px;
color: #82878c;
}
#contact-form-editor-tabs li.ui-tabs-active a span.dashicons {
display: none;
}
#contact-form-editor .contact-form-editor-panel h2 {
font-size: 18px;
font-weight: 400;
line-height: 24px;
margin: 8px 0;
padding: 0;
}
#contact-form-editor .contact-form-editor-panel {
background-color: #f5f5f5;
border: 1px solid #aaa;
border-top: none;
padding: 16px;
}
#contact-form-editor .form-table th {
width: 100px;
}
#contact-form-editor .contact-form-editor-panel fieldset legend {
line-height: 1.5;
margin: .6em 0 .4em;
}
/*
* Form Tab
*/
#tag-generator-list a.button {
font-size: 12px;
height: 26px;
line-height: 24px;
margin: 2px;
padding: 0 8px 1px;
}
.tag-generator-panel {
position: relative;
height: 495px;
}
.tag-generator-panel .control-box {
padding: 0;
margin: 0;
height: 380px;
overflow: auto;
}
.tag-generator-panel .control-box > fieldset legend {
border: 1px solid #dfdfdf;
border-left: 4px solid #00a0d2;
background: #f7fcfe;
padding: 4px 12px;
margin: 4px 0;
line-height: 1.4em;
width: 95%;
}
.tag-generator-panel table {
width: 100%;
}
.tag-generator-panel table.form-table th {
width: 120px;
padding: 4px 10px 4px 0;
font-size: 13px;
}
.tag-generator-panel table.form-table td {
padding: 4px 10px;
font-size: 13px;
}
.tag-generator-panel .control-box input.oneline {
width: 200px;
}
.tag-generator-panel .control-box textarea.values {
width: 200px;
height: 6em;
}
.tag-generator-panel .control-box input[type="number"],
.tag-generator-panel .control-box input[type="date"] {
width: 88px;
}
.tag-generator-panel .control-box table caption {
text-align: left;
font-size: 110%;
font-weight: bold;
color: #777;
margin: 10px 0 5px;
}
.tag-generator-panel .control-box table.form-table td label {
line-height: 1.1em;
}
.tag-generator-panel .control-box table.form-table td label .description {
line-height: 1.4em;
}
.tag-generator-panel .insert-box {
position: absolute;
left: -15px;
right: -15px;
bottom: -15px;
width: 100%;
height: 84px;
margin: 0;
padding: 8px 16px;
background-color: #fcfcfc;
border-top: 1px solid #dfdfdf;
overflow: auto;
}
.tag-generator-panel .insert-box input.tag {
width: 480px;
float: left;
background-color: transparent;
box-shadow: none;
}
.tag-generator-panel .insert-box .submitbox {
padding: 2px 4px;
}
.tag-generator-panel .insert-box .submitbox input[type="button"] {
float: right;
}
.tag-generator-panel .insert-box .description label {
cursor: text;
}
/*
* Mail Tab
*/
.contact-form-editor-box-mail span.mailtag {
display: inline-block;
margin: 0 0 0 4px;
padding: 1px 2px;
cursor: pointer;
color: #000;
}
.contact-form-editor-box-mail span.mailtag.used {
color: #666;
}
/*
* Messages Tab
*/
#messages-panel p.description {
margin: 5px 0 10px;
}
/*
* List Table
*/
.fixed .column-title {
width: 38%;
}
.fixed .column-shortcode {
width: 38%;
}
.wp-list-table .config-error span.dashicons {
color: #82878c;
}
/*
* Welcome Panel
*/
.welcome-panel .welcome-panel-column,
.welcome-panel .welcome-panel-column:first-child {
width: 48%;
padding: 0 2% 0 0;
margin: 0 0 1em 0;
}
@media screen and (max-width: 870px) {
.welcome-panel .welcome-panel-column,
.welcome-panel .welcome-panel-column:first-child {
display: block;
float: none;
width: 100%;
}
}
.welcome-panel h3 {
font-size: 16px;
font-weight: 600;
line-height: 2.1em;
margin: 1em 0 1.2em;
}
.welcome-panel h3 .dashicons {
position: relative;
top: -2px;
display: inline-block;
width: 60px;
color: #575757;
font-size: 40px;
}
.welcome-panel p a {
font-weight: bold;
}
.welcome-panel-close {
z-index: 2;
}
/*
* Integration
*/
.card {
background: #fff none repeat scroll 0 0;
border: 1px solid #e5e5e5;
border-left: 4px solid #e5e5e5;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
margin-top: 20px;
max-width: 520px;
min-width: 255px;
padding: 0.7em 2em 1em;
position: relative;
}
.card.active {
border-color: #00a0d2;
}
.card img.icon {
float: left;
margin: 8px 8px 8px -8px;
}
.card h2.title {
float: left;
max-width: 240px;
font-size: 1.3em;
font-weight: 600;
}
.card .infobox {
float: right;
font-size: 13px;
color: #666;
margin: 2px 0 5px;
line-height: 1.5;
max-width: 240px;
}
.card .inside .form-table th {
padding: 15px 10px 15px 0;
width: 160px;
}
.card .inside .form-table td {
padding: 10px 10px;
}
<?php
// don't load directly
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
function wpcf7_admin_save_button( $post_id ) {
static $button = '';
if ( ! empty( $button ) ) {
echo $button;
return;
}
$nonce = wp_create_nonce( 'wpcf7-save-contact-form_' . $post_id );
$onclick = sprintf(
"this.form._wpnonce.value = '%s';"
. " this.form.action.value = 'save';"
. " return true;",
$nonce );
$button = sprintf(
'<input type="submit" class="button-primary" name="wpcf7-save" value="%1$s" onclick="%2$s" />',
esc_attr( __( 'Save', 'contact-form-7' ) ),
$onclick );
echo $button;
}
?><div class="wrap">
<h1 class="wp-heading-inline"><?php
if ( $post->initial() ) {
echo esc_html( __( 'Add New Contact Form', 'contact-form-7' ) );
} else {
echo esc_html( __( 'Edit Contact Form', 'contact-form-7' ) );
}
?></h1>
<?php
if ( ! $post->initial() && current_user_can( 'wpcf7_edit_contact_forms' ) ) {
echo sprintf( '<a href="%1$s" class="add-new-h2">%2$s</a>',
esc_url( menu_page_url( 'wpcf7-new', false ) ),
esc_html( __( 'Add New', 'contact-form-7' ) ) );
}
?>
<hr class="wp-header-end">
<?php do_action( 'wpcf7_admin_warnings' ); ?>
<?php do_action( 'wpcf7_admin_notices' ); ?>
<?php
if ( $post ) :
if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
$disabled = '';
} else {
$disabled = ' disabled="disabled"';
}
?>
<form method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post_id ), menu_page_url( 'wpcf7', false ) ) ); ?>" id="wpcf7-admin-form-element"<?php do_action( 'wpcf7_post_edit_form_tag' ); ?>>
<?php
if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
wp_nonce_field( 'wpcf7-save-contact-form_' . $post_id );
}
?>
<input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
<input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale() ); ?>" />
<input type="hidden" id="hiddenaction" name="action" value="save" />
<input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" />
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-2">
<div id="post-body-content">
<div id="titlediv">
<div id="titlewrap">
<label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html( __( 'Enter title here', 'contact-form-7' ) ); ?></label>
<?php
$posttitle_atts = array(
'type' => 'text',
'name' => 'post_title',
'size' => 30,
'value' => $post->initial() ? '' : $post->title(),
'id' => 'title',
'spellcheck' => 'true',
'autocomplete' => 'off',
'disabled' => current_user_can( 'wpcf7_edit_contact_form', $post_id )
? '' : 'disabled' );
echo sprintf( '<input %s />', wpcf7_format_atts( $posttitle_atts ) );
?>
</div><!-- #titlewrap -->
<div class="inside">
<?php
if ( ! $post->initial() ) :
?>
<p class="description">
<label for="wpcf7-shortcode"><?php echo esc_html( __( "Copy this shortcode and paste it into your post, page, or text widget content:", 'contact-form-7' ) ); ?></label>
<span class="shortcode wp-ui-highlight"><input type="text" id="wpcf7-shortcode" onfocus="this.select();" readonly="readonly" class="large-text code" value="<?php echo esc_attr( $post->shortcode() ); ?>" /></span>
</p>
<?php
if ( $old_shortcode = $post->shortcode( array( 'use_old_format' => true ) ) ) :
?>
<p class="description">
<label for="wpcf7-shortcode-old"><?php echo esc_html( __( "You can also use this old-style shortcode:", 'contact-form-7' ) ); ?></label>
<span class="shortcode old"><input type="text" id="wpcf7-shortcode-old" onfocus="this.select();" readonly="readonly" class="large-text code" value="<?php echo esc_attr( $old_shortcode ); ?>" /></span>
</p>
<?php
endif;
endif;
?>
</div>
</div><!-- #titlediv -->
</div><!-- #post-body-content -->
<div id="postbox-container-1" class="postbox-container">
<?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
<div id="submitdiv" class="postbox">
<h3><?php echo esc_html( __( 'Status', 'contact-form-7' ) ); ?></h3>
<div class="inside">
<div class="submitbox" id="submitpost">
<div id="minor-publishing-actions">
<div class="hidden">
<input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" />
</div>
<?php
if ( ! $post->initial() ) :
$copy_nonce = wp_create_nonce( 'wpcf7-copy-contact-form_' . $post_id );
?>
<input type="submit" name="wpcf7-copy" class="copy button" value="<?php echo esc_attr( __( 'Duplicate', 'contact-form-7' ) ); ?>" <?php echo "onclick=\"this.form._wpnonce.value = '$copy_nonce'; this.form.action.value = 'copy'; return true;\""; ?> />
<?php endif; ?>
</div><!-- #minor-publishing-actions -->
<div id="misc-publishing-actions">
<?php do_action( 'wpcf7_admin_misc_pub_section', $post_id ); ?>
</div><!-- #misc-publishing-actions -->
<div id="major-publishing-actions">
<?php
if ( ! $post->initial() ) :
$delete_nonce = wp_create_nonce( 'wpcf7-delete-contact-form_' . $post_id );
?>
<div id="delete-action">
<input type="submit" name="wpcf7-delete" class="delete submitdelete" value="<?php echo esc_attr( __( 'Delete', 'contact-form-7' ) ); ?>" <?php echo "onclick=\"if (confirm('" . esc_js( __( "You are about to delete this contact form.\n 'Cancel' to stop, 'OK' to delete.", 'contact-form-7' ) ) . "')) {this.form._wpnonce.value = '$delete_nonce'; this.form.action.value = 'delete'; return true;} return false;\""; ?> />
</div><!-- #delete-action -->
<?php endif; ?>
<div id="publishing-action">
<span class="spinner"></span>
<?php wpcf7_admin_save_button( $post_id ); ?>
</div>
<div class="clear"></div>
</div><!-- #major-publishing-actions -->
</div><!-- #submitpost -->
</div>
</div><!-- #submitdiv -->
<?php endif; ?>
<div id="informationdiv" class="postbox">
<h3><?php echo esc_html( __( 'Information', 'contact-form-7' ) ); ?></h3>
<div class="inside">
<ul>
<li><?php echo wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ); ?></li>
<li><?php echo wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ); ?></li>
<li><?php echo wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ); ?></li>
</ul>
</div>
</div><!-- #informationdiv -->
</div><!-- #postbox-container-1 -->
<div id="postbox-container-2" class="postbox-container">
<div id="contact-form-editor">
<div class="keyboard-interaction"><?php echo sprintf( esc_html( __( '%s keys switch panels', 'contact-form-7' ) ), '<span class="dashicons dashicons-leftright"></span>' ); ?></div>
<?php
$editor = new WPCF7_Editor( $post );
$panels = array();
if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
$panels = array(
'form-panel' => array(
'title' => __( 'Form', 'contact-form-7' ),
'callback' => 'wpcf7_editor_panel_form' ),
'mail-panel' => array(
'title' => __( 'Mail', 'contact-form-7' ),
'callback' => 'wpcf7_editor_panel_mail' ),
'messages-panel' => array(
'title' => __( 'Messages', 'contact-form-7' ),
'callback' => 'wpcf7_editor_panel_messages' ) );
$additional_settings = trim( $post->prop( 'additional_settings' ) );
$additional_settings = explode( "\n", $additional_settings );
$additional_settings = array_filter( $additional_settings );
$additional_settings = count( $additional_settings );
$panels['additional-settings-panel'] = array(
'title' => $additional_settings
? sprintf(
__( 'Additional Settings (%d)', 'contact-form-7' ),
$additional_settings )
: __( 'Additional Settings', 'contact-form-7' ),
'callback' => 'wpcf7_editor_panel_additional_settings' );
}
$panels = apply_filters( 'wpcf7_editor_panels', $panels );
foreach ( $panels as $id => $panel ) {
$editor->add_panel( $id, $panel['title'], $panel['callback'] );
}
$editor->display();
?>
</div><!-- #contact-form-editor -->
<?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
<p class="submit"><?php wpcf7_admin_save_button( $post_id ); ?></p>
<?php endif; ?>
</div><!-- #postbox-container-2 -->
</div><!-- #post-body -->
<br class="clear" />
</div><!-- #poststuff -->
</form>
<?php endif; ?>
</div><!-- .wrap -->
<?php
$tag_generator = WPCF7_TagGenerator::get_instance();
$tag_generator->print_panels( $post );
do_action( 'wpcf7_admin_footer', $post );
<?php
function wpcf7_current_action() {
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
return $_REQUEST['action'];
}
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
return $_REQUEST['action2'];
}
return false;
}
function wpcf7_admin_has_edit_cap() {
return current_user_can( 'wpcf7_edit_contact_forms' );
}
function wpcf7_add_tag_generator( $name, $title, $elm_id, $callback, $options = array() ) {
$tag_generator = WPCF7_TagGenerator::get_instance();
return $tag_generator->add( $name, $title, $callback, $options );
}
<?php
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class WPCF7_Contact_Form_List_Table extends WP_List_Table {
public static function define_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title', 'contact-form-7' ),
'shortcode' => __( 'Shortcode', 'contact-form-7' ),
'author' => __( 'Author', 'contact-form-7' ),
'date' => __( 'Date', 'contact-form-7' ),
);
return $columns;
}
function __construct() {
parent::__construct( array(
'singular' => 'post',
'plural' => 'posts',
'ajax' => false,
) );
}
function prepare_items() {
$current_screen = get_current_screen();
$per_page = $this->get_items_per_page( 'cfseven_contact_forms_per_page' );
$this->_column_headers = $this->get_column_info();
$args = array(
'posts_per_page' => $per_page,
'orderby' => 'title',
'order' => 'ASC',
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
);
if ( ! empty( $_REQUEST['s'] ) ) {
$args['s'] = $_REQUEST['s'];
}
if ( ! empty( $_REQUEST['orderby'] ) ) {
if ( 'title' == $_REQUEST['orderby'] ) {
$args['orderby'] = 'title';
} elseif ( 'author' == $_REQUEST['orderby'] ) {
$args['orderby'] = 'author';
} elseif ( 'date' == $_REQUEST['orderby'] ) {
$args['orderby'] = 'date';
}
}
if ( ! empty( $_REQUEST['order'] ) ) {
if ( 'asc' == strtolower( $_REQUEST['order'] ) ) {
$args['order'] = 'ASC';
} elseif ( 'desc' == strtolower( $_REQUEST['order'] ) ) {
$args['order'] = 'DESC';
}
}
$this->items = WPCF7_ContactForm::find( $args );
$total_items = WPCF7_ContactForm::count();
$total_pages = ceil( $total_items / $per_page );
$this->set_pagination_args( array(
'total_items' => $total_items,
'total_pages' => $total_pages,
'per_page' => $per_page,
) );
}
function get_columns() {
return get_column_headers( get_current_screen() );
}
function get_sortable_columns() {
$columns = array(
'title' => array( 'title', true ),
'author' => array( 'author', false ),
'date' => array( 'date', false ),
);
return $columns;
}
function get_bulk_actions() {
$actions = array(
'delete' => __( 'Delete', 'contact-form-7' ),
);
return $actions;
}
function column_default( $item, $column_name ) {
return '';
}
function column_cb( $item ) {
return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
$this->_args['singular'],
$item->id() );
}
function column_title( $item ) {
$url = admin_url( 'admin.php?page=wpcf7&post=' . absint( $item->id() ) );
$edit_link = add_query_arg( array( 'action' => 'edit' ), $url );
$output = sprintf(
'<a class="row-title" href="%1$s" title="%2$s">%3$s</a>',
esc_url( $edit_link ),
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;', 'contact-form-7' ),
$item->title() ) ),
esc_html( $item->title() )
);
$output = sprintf( '<strong>%s</strong>', $output );
if ( wpcf7_validate_configuration()
&& current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
$config_validator = new WPCF7_ConfigValidator( $item );
$config_validator->restore();
if ( $count_errors = $config_validator->count_errors() ) {
$error_notice = sprintf(
_n(
'%s configuration error detected',
'%s configuration errors detected',
$count_errors, 'contact-form-7' ),
number_format_i18n( $count_errors ) );
$output .= sprintf(
'<div class="config-error"><span class="dashicons dashicons-warning"></span> %s</div>',
$error_notice );
}
}
$actions = array(
'edit' => sprintf( '<a href="%1$s">%2$s</a>',
esc_url( $edit_link ),
esc_html( __( 'Edit', 'contact-form-7' ) ) ) );
if ( current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
$copy_link = wp_nonce_url(
add_query_arg( array( 'action' => 'copy' ), $url ),
'wpcf7-copy-contact-form_' . absint( $item->id() ) );
$actions = array_merge( $actions, array(
'copy' => sprintf( '<a href="%1$s">%2$s</a>',
esc_url( $copy_link ),
esc_html( __( 'Duplicate', 'contact-form-7' ) )
),
) );
}
$output .= $this->row_actions( $actions );
return $output;
}
function column_author( $item ) {
$post = get_post( $item->id() );
if ( ! $post ) {
return;
}
$author = get_userdata( $post->post_author );
if ( false === $author ) {
return;
}
return esc_html( $author->display_name );
}
function column_shortcode( $item ) {
$shortcodes = array( $item->shortcode() );
$output = '';
foreach ( $shortcodes as $shortcode ) {
$output .= "\n" . '<span class="shortcode"><input type="text"'
. ' onfocus="this.select();" readonly="readonly"'
. ' value="' . esc_attr( $shortcode ) . '"'
. ' class="large-text code" /></span>';
}
return trim( $output );
}
function column_date( $item ) {
$post = get_post( $item->id() );
if ( ! $post ) {
return;
}
$t_time = mysql2date( __( 'Y/m/d g:i:s A', 'contact-form-7' ),
$post->post_date, true );
$m_time = $post->post_date;
$time = mysql2date( 'G', $post->post_date )
- get_option( 'gmt_offset' ) * 3600;
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < 24*60*60 ) {
$h_time = sprintf(
__( '%s ago', 'contact-form-7' ), human_time_diff( $time ) );
} else {
$h_time = mysql2date( __( 'Y/m/d', 'contact-form-7' ), $m_time );
}
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
}
}
<?php
class WPCF7_Editor {
private $contact_form;
private $panels = array();
public function __construct( WPCF7_ContactForm $contact_form ) {
$this->contact_form = $contact_form;
}
public function add_panel( $id, $title, $callback ) {
if ( wpcf7_is_name( $id ) ) {
$this->panels[$id] = array(
'title' => $title,
'callback' => $callback,
);
}
}
public function display() {
if ( empty( $this->panels ) ) {
return;
}
echo '<ul id="contact-form-editor-tabs">';
foreach ( $this->panels as $id => $panel ) {
echo sprintf( '<li id="%1$s-tab"><a href="#%1$s">%2$s</a></li>',
esc_attr( $id ), esc_html( $panel['title'] ) );
}
echo '</ul>';
foreach ( $this->panels as $id => $panel ) {
echo sprintf( '<div class="contact-form-editor-panel" id="%1$s">',
esc_attr( $id ) );
if ( is_callable( $panel['callback'] ) ) {
$this->notice( $id, $panel );
call_user_func( $panel['callback'], $this->contact_form );
}
echo '</div>';
}
}
public function notice( $id, $panel ) {
echo '<div class="config-error"></div>';
}
}
function wpcf7_editor_panel_form( $post ) {
?>
<h2><?php echo esc_html( __( 'Form', 'contact-form-7' ) ); ?></h2>
<?php
$tag_generator = WPCF7_TagGenerator::get_instance();
$tag_generator->print_buttons();
?>
<textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="24" class="large-text code" data-config-field="form.body"><?php echo esc_textarea( $post->prop( 'form' ) ); ?></textarea>
<?php
}
function wpcf7_editor_panel_mail( $post ) {
wpcf7_editor_box_mail( $post );
echo '<br class="clear" />';
wpcf7_editor_box_mail( $post, array(
'id' => 'wpcf7-mail-2',
'name' => 'mail_2',
'title' => __( 'Mail (2)', 'contact-form-7' ),
'use' => __( 'Use Mail (2)', 'contact-form-7' ),
) );
}
function wpcf7_editor_box_mail( $post, $args = '' ) {
$args = wp_parse_args( $args, array(
'id' => 'wpcf7-mail',
'name' => 'mail',
'title' => __( 'Mail', 'contact-form-7' ),
'use' => null,
) );
$id = esc_attr( $args['id'] );
$mail = wp_parse_args( $post->prop( $args['name'] ), array(
'active' => false,
'recipient' => '',
'sender' => '',
'subject' => '',
'body' => '',
'additional_headers' => '',
'attachments' => '',
'use_html' => false,
'exclude_blank' => false,
) );
?>
<div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
<h2><?php echo esc_html( $args['title'] ); ?></h2>
<?php
if ( ! empty( $args['use'] ) ) :
?>
<label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>[active]" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
<p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
<?php
endif;
?>
<fieldset>
<legend><?php echo esc_html( __( "In the following fields, you can use these mail-tags:", 'contact-form-7' ) ); ?><br />
<?php $post->suggest_mail_tags( $args['name'] ); ?></legend>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
</th>
<td>
<input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>[recipient]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $args['name'] ) ); ?>" />
</td>
</tr>
<tr>
<th scope="row">
<label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
</th>
<td>
<input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>[sender]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $args['name'] ) ); ?>" />
</td>
</tr>
<tr>
<th scope="row">
<label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
</th>
<td>
<input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>[subject]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $args['name'] ) ); ?>" />
</td>
</tr>
<tr>
<th scope="row">
<label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
</th>
<td>
<textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>[additional_headers]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
</td>
</tr>
<tr>
<th scope="row">
<label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
</th>
<td>
<textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>[body]" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
<p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>[exclude_blank]" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
<p><label for="<?php echo $id; ?>-use-html"><input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id; ?>[use_html]" value="1"<?php echo ( $mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Use HTML content type', 'contact-form-7' ) ); ?></label></p>
</td>
</tr>
<tr>
<th scope="row">
<label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
</th>
<td>
<textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>[attachments]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
</td>
</tr>
</tbody>
</table>
</fieldset>
</div>
<?php
}
function wpcf7_editor_panel_messages( $post ) {
$messages = wpcf7_messages();
if ( isset( $messages['captcha_not_match'] )
&& ! wpcf7_use_really_simple_captcha() ) {
unset( $messages['captcha_not_match'] );
}
?>
<h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2>
<fieldset>
<legend><?php echo esc_html( __( 'Edit messages used in the following situations.', 'contact-form-7' ) ); ?></legend>
<?php
foreach ( $messages as $key => $arr ) {
$field_id = sprintf( 'wpcf7-message-%s', strtr( $key, '_', '-' ) );
$field_name = sprintf( 'wpcf7-messages[%s]', $key );
?>
<p class="description">
<label for="<?php echo $field_id; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
<input type="text" id="<?php echo $field_id; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" data-config-field="<?php echo sprintf( 'messages.%s', esc_attr( $key ) ); ?>" />
</label>
</p>
<?php
}
?>
</fieldset>
<?php
}
function wpcf7_editor_panel_additional_settings( $post ) {
$desc_link = wpcf7_link(
__( 'https://contactform7.com/additional-settings/', 'contact-form-7' ),
__( 'Additional Settings', 'contact-form-7' ) );
$description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' );
$description = sprintf( esc_html( $description ), $desc_link );
?>
<h2><?php echo esc_html( __( 'Additional Settings', 'contact-form-7' ) ); ?></h2>
<fieldset>
<legend><?php echo $description; ?></legend>
<textarea id="wpcf7-additional-settings" name="wpcf7-additional-settings" cols="100" rows="8" class="large-text" data-config-field="additional_settings.body"><?php echo esc_textarea( $post->prop( 'additional_settings' ) ); ?></textarea>
</fieldset>
<?php
}
<?php
class WPCF7_Help_Tabs {
private $screen;
public function __construct( WP_Screen $screen ) {
$this->screen = $screen;
}
public function set_help_tabs( $type ) {
switch ( $type ) {
case 'list':
$this->screen->add_help_tab( array(
'id' => 'list_overview',
'title' => __( 'Overview', 'contact-form-7' ),
'content' => $this->content( 'list_overview' ) ) );
$this->screen->add_help_tab( array(
'id' => 'list_available_actions',
'title' => __( 'Available Actions', 'contact-form-7' ),
'content' => $this->content( 'list_available_actions' ) ) );
$this->sidebar();
return;
case 'edit':
$this->screen->add_help_tab( array(
'id' => 'edit_overview',
'title' => __( 'Overview', 'contact-form-7' ),
'content' => $this->content( 'edit_overview' ) ) );
$this->screen->add_help_tab( array(
'id' => 'edit_form_tags',
'title' => __( 'Form-tags', 'contact-form-7' ),
'content' => $this->content( 'edit_form_tags' ) ) );
$this->screen->add_help_tab( array(
'id' => 'edit_mail_tags',
'title' => __( 'Mail-tags', 'contact-form-7' ),
'content' => $this->content( 'edit_mail_tags' ) ) );
$this->sidebar();
return;
case 'integration':
$this->screen->add_help_tab( array(
'id' => 'integration_overview',
'title' => __( 'Overview', 'contact-form-7' ),
'content' => $this->content( 'integration_overview' ) ) );
$this->sidebar();
return;
}
}
private function content( $name ) {
$content = array();
$content['list_overview'] = '<p>' . __( "On this screen, you can manage contact forms provided by Contact Form 7. You can manage an unlimited number of contact forms. Each contact form has a unique ID and Contact Form 7 shortcode ([contact-form-7 ...]). To insert a contact form into a post or a text widget, insert the shortcode into the target.", 'contact-form-7' ) . '</p>';
$content['list_available_actions'] = '<p>' . __( "Hovering over a row in the contact forms list will display action links that allow you to manage your contact form. You can perform the following actions:", 'contact-form-7' ) . '</p>';
$content['list_available_actions'] .= '<p>' . __( "<strong>Edit</strong> - Navigates to the editing screen for that contact form. You can also reach that screen by clicking on the contact form title.", 'contact-form-7' ) . '</p>';
$content['list_available_actions'] .= '<p>' . __( "<strong>Duplicate</strong> - Clones that contact form. A cloned contact form inherits all content from the original, but has a different ID.", 'contact-form-7' ) . '</p>';
$content['edit_overview'] = '<p>' . __( "On this screen, you can edit a contact form. A contact form is comprised of the following components:", 'contact-form-7' ) . '</p>';
$content['edit_overview'] .= '<p>' . __( "<strong>Title</strong> is the title of a contact form. This title is only used for labeling a contact form, and can be edited.", 'contact-form-7' ) . '</p>';
$content['edit_overview'] .= '<p>' . __( "<strong>Form</strong> is a content of HTML form. You can use arbitrary HTML, which is allowed inside a form element. You can also use Contact Form 7&#8217;s form-tags here.", 'contact-form-7' ) . '</p>';
$content['edit_overview'] .= '<p>' . __( "<strong>Mail</strong> manages a mail template (headers and message body) that this contact form will send when users submit it. You can use Contact Form 7&#8217;s mail-tags here.", 'contact-form-7' ) . '</p>';
$content['edit_overview'] .= '<p>' . __( "<strong>Mail (2)</strong> is an additional mail template that works similar to Mail. Mail (2) is different in that it is sent only when Mail has been sent successfully.", 'contact-form-7' ) . '</p>';
$content['edit_overview'] .= '<p>' . __( "In <strong>Messages</strong>, you can edit various types of messages used for this contact form. These messages are relatively short messages, like a validation error message you see when you leave a required field blank.", 'contact-form-7' ) . '</p>';
$content['edit_overview'] .= '<p>' . __( "<strong>Additional Settings</strong> provides a place where you can customize the behavior of this contact form by adding code snippets.", 'contact-form-7' ) . '</p>';
$content['edit_form_tags'] = '<p>' . __( "A form-tag is a short code enclosed in square brackets used in a form content. A form-tag generally represents an input field, and its components can be separated into four parts: type, name, options, and values. Contact Form 7 supports several types of form-tags including text fields, number fields, date fields, checkboxes, radio buttons, menus, file-uploading fields, CAPTCHAs, and quiz fields.", 'contact-form-7' ) . '</p>';
$content['edit_form_tags'] .= '<p>' . __( "While form-tags have a comparatively complex syntax, you don&#8217;t need to know the syntax to add form-tags because you can use the straightforward tag generator (<strong>Generate Tag</strong> button on this screen).", 'contact-form-7' ) . '</p>';
$content['edit_mail_tags'] = '<p>' . __( "A mail-tag is also a short code enclosed in square brackets that you can use in every Mail and Mail (2) field. A mail-tag represents a user input value through an input field of a corresponding form-tag.", 'contact-form-7' ) . '</p>';
$content['edit_mail_tags'] .= '<p>' . __( "There are also special mail-tags that have specific names, but don&#8217;t have corresponding form-tags. They are used to represent meta information of form submissions like the submitter&#8217;s IP address or the URL of the page.", 'contact-form-7' ) . '</p>';
$content['integration_overview'] = '<p>' . __( "On this screen, you can manage services that are available through Contact Form 7. Using API will allow you to collaborate with any services that are available.", 'contact-form-7' ) . '</p>';
$content['integration_overview'] .= '<p>' . __( "You may need to first sign up for an account with the service that you plan to use. When you do so, you would need to authorize Contact Form 7 to access the service with your account.", 'contact-form-7' ) . '</p>';
$content['integration_overview'] .= '<p>' . __( "Any information you provide will not be shared with service providers without your authorization.", 'contact-form-7' ) . '</p>';
if ( ! empty( $content[$name] ) ) {
return $content[$name];
}
}
public function sidebar() {
$content = '<p><strong>' . __( 'For more information:', 'contact-form-7' ) . '</strong></p>';
$content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ) . '</p>';
$content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ) . '</p>';
$content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ) . '</p>';
$this->screen->set_help_sidebar( $content );
}
}
<?php
class WPCF7_TagGenerator {
private static $instance;
private $panels = array();
private function __construct() {}
public static function get_instance() {
if ( empty( self::$instance ) ) {
self::$instance = new self;
}
return self::$instance;
}
public function add( $id, $title, $callback, $options = array() ) {
$id = trim( $id );
if ( '' === $id || ! wpcf7_is_name( $id ) ) {
return false;
}
$this->panels[$id] = array(
'title' => $title,
'content' => 'tag-generator-panel-' . $id,
'options' => $options,
'callback' => $callback,
);
return true;
}
public function print_buttons() {
echo '<span id="tag-generator-list">';
foreach ( (array) $this->panels as $panel ) {
echo sprintf(
'<a href="#TB_inline?width=900&height=500&inlineId=%1$s" class="thickbox button" title="%2$s">%3$s</a>',
esc_attr( $panel['content'] ),
esc_attr( sprintf(
__( 'Form-tag Generator: %s', 'contact-form-7' ),
$panel['title'] ) ),
esc_html( $panel['title'] ) );
}
echo '</span>';
}
public function print_panels( WPCF7_ContactForm $contact_form ) {
foreach ( (array) $this->panels as $id => $panel ) {
$callback = $panel['callback'];
$options = wp_parse_args( $panel['options'], array() );
$options = array_merge( $options, array(
'id' => $id,
'title' => $panel['title'],
'content' => $panel['content'],
) );
if ( is_callable( $callback ) ) {
echo sprintf( '<div id="%s" class="hidden">',
esc_attr( $options['content'] ) );
echo sprintf(
'<form action="" class="tag-generator-panel" data-id="%s">',
$options['id'] );
call_user_func( $callback, $contact_form, $options );
echo '</form></div>';
}
}
}
}
<?php
function wpcf7_welcome_panel() {
$classes = 'welcome-panel';
$vers = (array) get_user_meta( get_current_user_id(),
'wpcf7_hide_welcome_panel_on', true );
if ( wpcf7_version_grep( wpcf7_version( 'only_major=1' ), $vers ) ) {
$classes .= ' hidden';
}
?>
<div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
<?php wp_nonce_field( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
<a class="welcome-panel-close" href="<?php echo esc_url( menu_page_url( 'wpcf7', false ) ); ?>"><?php echo esc_html( __( 'Dismiss', 'contact-form-7' ) ); ?></a>
<div class="welcome-panel-content">
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<h3><span class="dashicons dashicons-shield"></span> <?php echo esc_html( __( "Getting spammed? You have protection.", 'contact-form-7' ) ); ?></h3>
<p><?php echo esc_html( __( "Spammers target everything; your contact forms aren&#8217;t an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ); ?></p>
<p><?php echo sprintf( esc_html( __( 'Contact Form 7 supports spam-filtering with %1$s. Intelligent %2$s blocks annoying spambots. Plus, using %3$s, you can block messages containing specified keywords or those sent from specified IP addresses.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Akismet', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/comment-blacklist/', 'contact-form-7' ), __( 'comment blacklist', 'contact-form-7' ) ) ); ?></p>
</div>
<div class="welcome-panel-column">
<h3><span class="dashicons dashicons-editor-help"></span> <?php echo esc_html( __( "Before you cry over spilt mail&#8230;", 'contact-form-7' ) ); ?></h3>
<p><?php echo esc_html( __( "Contact Form 7 doesn&#8217;t store submitted messages anywhere. Therefore, you may lose important messages forever if your mail server has issues or you make a mistake in mail configuration.", 'contact-form-7' ) ); ?></p>
<p><?php echo sprintf( esc_html( __( 'Install a message storage plugin before this happens to you. %s saves all messages through contact forms into the database. Flamingo is a free WordPress plugin created by the same author as Contact Form 7.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), __( 'Flamingo', 'contact-form-7' ) ) ); ?></p>
</div>
</div>
</div>
</div>
<?php
}
add_action( 'wp_ajax_wpcf7-update-welcome-panel', 'wpcf7_admin_ajax_welcome_panel' );
function wpcf7_admin_ajax_welcome_panel() {
check_ajax_referer( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce' );
$vers = get_user_meta( get_current_user_id(),
'wpcf7_hide_welcome_panel_on', true );
if ( empty( $vers ) || ! is_array( $vers ) ) {
$vers = array();
}
if ( empty( $_POST['visible'] ) ) {
$vers[] = wpcf7_version( 'only_major=1' );
}
$vers = array_unique( $vers );
update_user_meta( get_current_user_id(), 'wpcf7_hide_welcome_panel_on', $vers );
wp_die( 1 );
}
( function( $ ) {
'use strict';
if ( typeof wpcf7 === 'undefined' || wpcf7 === null ) {
return;
}
$( function() {
var welcomePanel = $( '#welcome-panel' );
var updateWelcomePanel;
updateWelcomePanel = function( visible ) {
$.post( ajaxurl, {
action: 'wpcf7-update-welcome-panel',
visible: visible,
welcomepanelnonce: $( '#welcomepanelnonce' ).val()
} );
};
$( 'a.welcome-panel-close', welcomePanel ).click( function( event ) {
event.preventDefault();
welcomePanel.addClass( 'hidden' );
updateWelcomePanel( 0 );
} );
$( '#contact-form-editor' ).tabs( {
active: wpcf7.activeTab,
activate: function( event, ui ) {
$( '#active-tab' ).val( ui.newTab.index() );
}
} );
$( '#contact-form-editor-tabs' ).focusin( function( event ) {
$( '#contact-form-editor .keyboard-interaction' ).css(
'visibility', 'visible' );
} ).focusout( function( event ) {
$( '#contact-form-editor .keyboard-interaction' ).css(
'visibility', 'hidden' );
} );
$( 'input:checkbox.toggle-form-table' ).click( function( event ) {
$( this ).wpcf7ToggleFormTable();
} ).wpcf7ToggleFormTable();
if ( '' == $( '#title' ).val() ) {
$( '#title' ).focus();
}
$.wpcf7TitleHint();
$( '.contact-form-editor-box-mail span.mailtag' ).click( function( event ) {
var range = document.createRange();
range.selectNodeContents( this );
window.getSelection().addRange( range );
} );
$.wpcf7UpdateConfigErrors();
$( '[data-config-field]' ).change( function() {
var postId = $( '#post_ID' ).val();
if ( ! postId || -1 == postId ) {
return;
}
var data = [];
$( this ).closest( 'form' ).find( '[data-config-field]' ).each( function() {
data.push( {
'name': $( this ).attr( 'name' ).replace( /^wpcf7-/, '' ).replace( /-/g, '_' ),
'value': $( this ).val()
});
});
data.push( { 'name': 'context', 'value': 'dry-run' } );
$.ajax( {
method: 'POST',
url: wpcf7.apiSettings.root +
'contact-form-7/v1/contact-forms/' + postId,
beforeSend: function( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', wpcf7.apiSettings.nonce );
},
data: data
} ).done( function( response ) {
wpcf7.configValidator.errors = response.config_errors;
$.wpcf7UpdateConfigErrors();
} );
} );
$( window ).on( 'beforeunload', function( event ) {
var changed = false;
$( '#wpcf7-admin-form-element :input[type!="hidden"]' ).each( function() {
if ( $( this ).is( ':checkbox, :radio' ) ) {
if ( this.defaultChecked != $( this ).is( ':checked' ) ) {
changed = true;
}
} else if ( $( this ).is( 'select' ) ) {
$( this ).find( 'option' ).each( function() {
if ( this.defaultSelected != $( this ).is( ':selected' ) ) {
changed = true;
}
});
} else {
if ( this.defaultValue != $( this ).val() ) {
changed = true;
}
}
} );
if ( changed ) {
event.returnValue = wpcf7.saveAlert;
return wpcf7.saveAlert;
}
} );
$( '#wpcf7-admin-form-element' ).submit( function() {
if ( 'copy' != this.action.value ) {
$( window ).off( 'beforeunload' );
}
if ( 'save' == this.action.value ) {
$( '#publishing-action .spinner' ).addClass( 'is-active' );
}
} );
} );
$.fn.wpcf7ToggleFormTable = function() {
return this.each( function() {
var formtable = $( this ).closest( '.contact-form-editor-box-mail' ).find( 'fieldset' );
if ( $( this ).is( ':checked' ) ) {
formtable.removeClass( 'hidden' );
} else {
formtable.addClass( 'hidden' );
}
} );
};
$.wpcf7UpdateConfigErrors = function() {
var errors = wpcf7.configValidator.errors;
var errorCount = {
total: 0,
};
$( '[data-config-field]' ).each( function() {
$( this ).removeAttr( 'aria-invalid' );
$( this ).next( 'ul.config-error' ).remove();
var section = $( this ).attr( 'data-config-field' );
if ( errors[ section ] ) {
var $list = $( '<ul></ul>' ).attr( {
'role': 'alert',
'class': 'config-error'
} );
$.each( errors[ section ], function( i, val ) {
var $li = $( '<li></li>' ).text( val.message );
if ( val.link ) {
var $link = $( '<a></a>' ).attr( {
'href': val.link,
'class': 'external dashicons dashicons-external'
} ).append( $( '<span></span>' ).attr( {
'class': 'screen-reader-text'
} ).text( wpcf7.configValidator.howToCorrect ) );
$li = $li.append( ' ' ).append( $link );
}
$li.appendTo( $list );
var tab = section
.replace( /^mail_\d+\./, 'mail.' ).replace( /\..*$/, '' );
if ( ! errorCount[tab] ) {
errorCount[tab] = 0;
}
errorCount[tab] += 1;
errorCount.total += 1;
} );
$( this ).after( $list ).attr( { 'aria-invalid': 'true' } );
}
} );
$( '#contact-form-editor-tabs > li' ).each( function() {
var $item = $( this );
$item.find( 'span.dashicons' ).remove();
var tab = $item.attr( 'id' ).replace( /-panel-tab$/, '' );
$.each( errors, function( key, val ) {
key = key.replace( /^mail_\d+\./, 'mail.' );
if ( key.replace( /\..*$/, '' ) == tab ) {
var $mark = $( '<span class="dashicons dashicons-warning"></span>' );
$item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
return false;
}
} );
var $tabPanelError = $( '#' + tab + '-panel > div.config-error:first' );
$tabPanelError.empty();
if ( errorCount[tab] ) {
$tabPanelError
.append( '<span class="dashicons dashicons-warning"></span> ' );
if ( 1 < errorCount[tab] ) {
var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
.replace( '%d', errorCount[tab] );
$tabPanelError.append( manyErrorsInTab );
} else {
$tabPanelError.append( wpcf7.configValidator.oneErrorInTab );
}
}
} );
$( '#misc-publishing-actions .misc-pub-section.config-error' )
.remove();
if ( errorCount.total ) {
var $warning = $( '<div></div>' )
.addClass( 'misc-pub-section config-error' )
.append( '<span class="dashicons dashicons-warning"></span> ' );
if ( 1 < errorCount.total ) {
$warning.append(
wpcf7.configValidator.manyErrors.replace( '%d', errorCount.total )
);
} else {
$warning.append( wpcf7.configValidator.oneError );
}
var $link = $( '<a></a>' ).attr( {
'href': wpcf7.configValidator.docUrl,
'class': 'external dashicons dashicons-external'
} ).append( $( '<span></span>' ).attr( {
'class': 'screen-reader-text'
} ).text( wpcf7.configValidator.howToCorrect ) );
$warning.append( ' ' ).append( $link );
$( '#misc-publishing-actions' ).append( $warning );
}
}
/**
* Copied from wptitlehint() in wp-admin/js/post.js
*/
$.wpcf7TitleHint = function() {
var title = $( '#title' );
var titleprompt = $( '#title-prompt-text' );
if ( '' == title.val() ) {
titleprompt.removeClass( 'screen-reader-text' );
}
titleprompt.click( function() {
$( this ).addClass( 'screen-reader-text' );
title.focus();
} );
title.blur( function() {
if ( '' == $(this).val() ) {
titleprompt.removeClass( 'screen-reader-text' );
}
} ).focus( function() {
titleprompt.addClass( 'screen-reader-text' );
} ).keydown( function( e ) {
titleprompt.addClass( 'screen-reader-text' );
$( this ).unbind( e );
} );
};
} )( jQuery );
( function( $ ) {
'use strict';
if ( typeof wpcf7 === 'undefined' || wpcf7 === null ) {
return;
}
wpcf7.taggen = {};
$( function() {
$( 'form.tag-generator-panel' ).each( function() {
wpcf7.taggen.update( $( this ) );
} );
} );
$( 'form.tag-generator-panel' ).submit( function() {
return false;
} );
$( 'form.tag-generator-panel .control-box :input' ).change( function() {
var $form = $( this ).closest( 'form.tag-generator-panel' );
wpcf7.taggen.normalize( $( this ) );
wpcf7.taggen.update( $form );
} );
$( 'input.insert-tag' ).click( function() {
var $form = $( this ).closest( 'form.tag-generator-panel' );
var tag = $form.find( 'input.tag' ).val();
wpcf7.taggen.insert( tag );
tb_remove(); // close thickbox
return false;
} );
wpcf7.taggen.update = function( $form ) {
var id = $form.attr( 'data-id' );
var name = '';
var name_fields = $form.find( 'input[name="name"]' );
if ( name_fields.length ) {
name = name_fields.val();
if ( '' === name ) {
name = id + '-' + Math.floor( Math.random() * 1000 );
name_fields.val( name );
}
}
if ( $.isFunction( wpcf7.taggen.update[ id ] ) ) {
return wpcf7.taggen.update[ id ].call( this, $form );
}
$form.find( 'input.tag' ).each( function() {
var tag_type = $( this ).attr( 'name' );
if ( $form.find( ':input[name="tagtype"]' ).length ) {
tag_type = $form.find( ':input[name="tagtype"]' ).val();
}
if ( $form.find( ':input[name="required"]' ).is( ':checked' ) ) {
tag_type += '*';
}
var components = wpcf7.taggen.compose( tag_type, $form );
$( this ).val( components );
} );
$form.find( 'span.mail-tag' ).text( '[' + name + ']' );
$form.find( 'input.mail-tag' ).each( function() {
$( this ).val( '[' + name + ']' );
} );
};
wpcf7.taggen.update.captcha = function( $form ) {
var captchac = wpcf7.taggen.compose( 'captchac', $form );
var captchar = wpcf7.taggen.compose( 'captchar', $form );
$form.find( 'input.tag' ).val( captchac + ' ' + captchar );
};
wpcf7.taggen.compose = function( tagType, $form ) {
var name = $form.find( 'input[name="name"]' ).val();
var scope = $form.find( '.scope.' + tagType );
if ( ! scope.length ) {
scope = $form;
}
var options = [];
scope.find( 'input.option' ).not( ':checkbox,:radio' ).each( function( i ) {
var val = $( this ).val();
if ( ! val ) {
return;
}
if ( $( this ).hasClass( 'filetype' ) ) {
val = val.split( /[,|\s]+/ ).join( '|' );
}
if ( $( this ).hasClass( 'color' ) ) {
val = '#' + val;
}
if ( 'class' == $( this ).attr( 'name' ) ) {
$.each( val.split( ' ' ), function( i, n ) {
options.push( 'class:' + n );
} );
} else {
options.push( $( this ).attr( 'name' ) + ':' + val );
}
} );
scope.find( 'input:checkbox.option' ).each( function( i ) {
if ( $( this ).is( ':checked' ) ) {
options.push( $( this ).attr( 'name' ) );
}
} );
scope.find( 'input:radio.option' ).each( function( i ) {
if ( $( this ).is( ':checked' ) && ! $( this ).hasClass( 'default' ) ) {
options.push( $( this ).attr( 'name' ) + ':' + $( this ).val() );
}
} );
if ( 'radio' == tagType ) {
options.push( 'default:1' );
}
options = ( options.length > 0 ) ? options.join( ' ' ) : '';
var value = '';
if ( scope.find( ':input[name="values"]' ).val() ) {
$.each(
scope.find( ':input[name="values"]' ).val().split( "\n" ),
function( i, n ) {
value += ' "' + n.replace( /["]/g, '&quot;' ) + '"';
}
);
}
var components = [];
$.each( [ tagType, name, options, value ], function( i, v ) {
v = $.trim( v );
if ( '' != v ) {
components.push( v );
}
} );
components = $.trim( components.join( ' ' ) );
return '[' + components + ']';
};
wpcf7.taggen.normalize = function( $input ) {
var val = $input.val();
if ( $input.is( 'input[name="name"]' ) ) {
val = val.replace( /[^0-9a-zA-Z:._-]/g, '' ).replace( /^[^a-zA-Z]+/, '' );
}
if ( $input.is( '.numeric' ) ) {
val = val.replace( /[^0-9.-]/g, '' );
}
if ( $input.is( '.idvalue' ) ) {
val = val.replace( /[^-0-9a-zA-Z_]/g, '' );
}
if ( $input.is( '.classvalue' ) ) {
val = $.map( val.split( ' ' ), function( n ) {
return n.replace( /[^-0-9a-zA-Z_]/g, '' );
} ).join( ' ' );
val = $.trim( val.replace( /\s+/g, ' ' ) );
}
if ( $input.is( '.color' ) ) {
val = val.replace( /[^0-9a-fA-F]/g, '' );
}
if ( $input.is( '.filesize' ) ) {
val = val.replace( /[^0-9kKmMbB]/g, '' );
}
if ( $input.is( '.filetype' ) ) {
val = val.replace( /[^0-9a-zA-Z.,|\s]/g, '' );
}
if ( $input.is( '.date' ) ) {
// 'yyyy-mm-dd' ISO 8601 format
if ( ! val.match( /^\d{4}-\d{2}-\d{2}$/ ) ) {
val = '';
}
}
if ( $input.is( ':input[name="values"]' ) ) {
val = $.trim( val );
}
$input.val( val );
if ( $input.is( ':checkbox.exclusive' ) ) {
wpcf7.taggen.exclusiveCheckbox( $input );
}
};
wpcf7.taggen.exclusiveCheckbox = function( $cb ) {
if ( $cb.is( ':checked' ) ) {
$cb.siblings( ':checkbox.exclusive' ).prop( 'checked', false );
}
};
wpcf7.taggen.insert = function( content ) {
$( 'textarea#wpcf7-form' ).each( function() {
this.focus();
if ( document.selection ) { // IE
var selection = document.selection.createRange();
selection.text = content;
} else if ( this.selectionEnd || 0 === this.selectionEnd ) {
var val = $( this ).val();
var end = this.selectionEnd;
$( this ).val( val.substring( 0, end ) +
content + val.substring( end, val.length ) );
this.selectionStart = end + content.length;
this.selectionEnd = end + content.length;
} else {
$( this ).val( $( this ).val() + content );
}
this.focus();
} );
};
} )( jQuery );
<?php
add_filter( 'map_meta_cap', 'wpcf7_map_meta_cap', 10, 4 );
function wpcf7_map_meta_cap( $caps, $cap, $user_id, $args ) {
$meta_caps = array(
'wpcf7_edit_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
'wpcf7_edit_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
'wpcf7_read_contact_forms' => WPCF7_ADMIN_READ_CAPABILITY,
'wpcf7_delete_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
'wpcf7_manage_integration' => 'manage_options',
);
$meta_caps = apply_filters( 'wpcf7_map_meta_cap', $meta_caps );
$caps = array_diff( $caps, array_keys( $meta_caps ) );
if ( isset( $meta_caps[$cap] ) ) {
$caps[] = $meta_caps[$cap];
}
return $caps;
}
<?php
function wpcf7_contact_form( $id ) {
return WPCF7_ContactForm::get_instance( $id );
}
function wpcf7_get_contact_form_by_old_id( $old_id ) {
global $wpdb;
$q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_old_cf7_unit_id'"
. $wpdb->prepare( " AND meta_value = %d", $old_id );
if ( $new_id = $wpdb->get_var( $q ) ) {
return wpcf7_contact_form( $new_id );
}
}
function wpcf7_get_contact_form_by_title( $title ) {
$page = get_page_by_title( $title, OBJECT, WPCF7_ContactForm::post_type );
if ( $page ) {
return wpcf7_contact_form( $page->ID );
}
return null;
}
function wpcf7_get_current_contact_form() {
if ( $current = WPCF7_ContactForm::get_current() ) {
return $current;
}
}
function wpcf7_is_posted() {
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
return false;
}
return $contact_form->is_posted();
}
function wpcf7_get_hangover( $name, $default = null ) {
if ( ! wpcf7_is_posted() ) {
return $default;
}
$submission = WPCF7_Submission::get_instance();
if ( ! $submission || $submission->is( 'mail_sent' ) ) {
return $default;
}
return isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : $default;
}
function wpcf7_get_validation_error( $name ) {
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
return '';
}
return $contact_form->validation_error( $name );
}
function wpcf7_get_message( $status ) {
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
return '';
}
return $contact_form->message( $status );
}
function wpcf7_form_controls_class( $type, $default = '' ) {
$type = trim( $type );
$default = array_filter( explode( ' ', $default ) );
$classes = array_merge( array( 'wpcf7-form-control' ), $default );
$typebase = rtrim( $type, '*' );
$required = ( '*' == substr( $type, -1 ) );
$classes[] = 'wpcf7-' . $typebase;
if ( $required ) {
$classes[] = 'wpcf7-validates-as-required';
}
$classes = array_unique( $classes );
return implode( ' ', $classes );
}
function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
if ( is_feed() ) {
return '[contact-form-7]';
}
if ( 'contact-form-7' == $code ) {
$atts = shortcode_atts(
array(
'id' => 0,
'title' => '',
'html_id' => '',
'html_name' => '',
'html_class' => '',
'output' => 'form',
),
$atts, 'wpcf7'
);
$id = (int) $atts['id'];
$title = trim( $atts['title'] );
if ( ! $contact_form = wpcf7_contact_form( $id ) ) {
$contact_form = wpcf7_get_contact_form_by_title( $title );
}
} else {
if ( is_string( $atts ) ) {
$atts = explode( ' ', $atts, 2 );
}
$id = (int) array_shift( $atts );
$contact_form = wpcf7_get_contact_form_by_old_id( $id );
}
if ( ! $contact_form ) {
return '[contact-form-7 404 "Not Found"]';
}
return $contact_form->form_html( $atts );
}
function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
$args = wp_parse_args( $args, array(
'id' => -1,
'title' => null,
'locale' => null,
'form' => null,
'mail' => null,
'mail_2' => null,
'messages' => null,
'additional_settings' => null,
) );
$args['id'] = (int) $args['id'];
if ( -1 == $args['id'] ) {
$contact_form = WPCF7_ContactForm::get_template();
} else {
$contact_form = wpcf7_contact_form( $args['id'] );
}
if ( empty( $contact_form ) ) {
return false;
}
if ( null !== $args['title'] ) {
$contact_form->set_title( $args['title'] );
}
if ( null !== $args['locale'] ) {
$contact_form->set_locale( $args['locale'] );
}
$properties = $contact_form->get_properties();
$properties['form'] = wpcf7_sanitize_form(
$args['form'], $properties['form'] );
$properties['mail'] = wpcf7_sanitize_mail(
$args['mail'], $properties['mail'] );
$properties['mail']['active'] = true;
$properties['mail_2'] = wpcf7_sanitize_mail(
$args['mail_2'], $properties['mail_2'] );
$properties['messages'] = wpcf7_sanitize_messages(
$args['messages'], $properties['messages'] );
$properties['additional_settings'] = wpcf7_sanitize_additional_settings(
$args['additional_settings'], $properties['additional_settings'] );
$contact_form->set_properties( $properties );
do_action( 'wpcf7_save_contact_form', $contact_form, $args, $context );
if ( 'save' == $context ) {
$contact_form->save();
}
return $contact_form;
}
function wpcf7_sanitize_form( $input, $default = '' ) {
if ( null === $input ) {
return $default;
}
$output = trim( $input );
return $output;
}
function wpcf7_sanitize_mail( $input, $defaults = array() ) {
$defaults = wp_parse_args( $defaults, array(
'active' => false,
'subject' => '',
'sender' => '',
'recipient' => '',
'body' => '',
'additional_headers' => '',
'attachments' => '',
'use_html' => false,
'exclude_blank' => false,
) );
$input = wp_parse_args( $input, $defaults );
$output = array();
$output['active'] = (bool) $input['active'];
$output['subject'] = trim( $input['subject'] );
$output['sender'] = trim( $input['sender'] );
$output['recipient'] = trim( $input['recipient'] );
$output['body'] = trim( $input['body'] );
$output['additional_headers'] = '';
$headers = str_replace( "\r\n", "\n", $input['additional_headers'] );
$headers = explode( "\n", $headers );
foreach ( $headers as $header ) {
$header = trim( $header );
if ( '' !== $header ) {
$output['additional_headers'] .= $header . "\n";
}
}
$output['additional_headers'] = trim( $output['additional_headers'] );
$output['attachments'] = trim( $input['attachments'] );
$output['use_html'] = (bool) $input['use_html'];
$output['exclude_blank'] = (bool) $input['exclude_blank'];
return $output;
}
function wpcf7_sanitize_messages( $input, $defaults = array() ) {
$output = array();
foreach ( wpcf7_messages() as $key => $val ) {
if ( isset( $input[$key] ) ) {
$output[$key] = trim( $input[$key] );
} elseif ( isset( $defaults[$key] ) ) {
$output[$key] = $defaults[$key];
}
}
return $output;
}
function wpcf7_sanitize_additional_settings( $input, $default = '' ) {
if ( null === $input ) {
return $default;
}
$output = trim( $input );
return $output;
}
<?php
class WPCF7_ContactFormTemplate {
public static function get_default( $prop = 'form' ) {
if ( 'form' == $prop ) {
$template = self::form();
} elseif ( 'mail' == $prop ) {
$template = self::mail();
} elseif ( 'mail_2' == $prop ) {
$template = self::mail_2();
} elseif ( 'messages' == $prop ) {
$template = self::messages();
} else {
$template = null;
}
return apply_filters( 'wpcf7_default_template', $template, $prop );
}
public static function form() {
$template = sprintf(
'
<label> %2$s %1$s
[text* your-name] </label>
<label> %3$s %1$s
[email* your-email] </label>
<label> %4$s
[text your-subject] </label>
<label> %5$s
[textarea your-message] </label>
[submit "%6$s"]',
__( '(required)', 'contact-form-7' ),
__( 'Your Name', 'contact-form-7' ),
__( 'Your Email', 'contact-form-7' ),
__( 'Subject', 'contact-form-7' ),
__( 'Your Message', 'contact-form-7' ),
__( 'Send', 'contact-form-7' ) );
return trim( $template );
}
public static function mail() {
$template = array(
'subject' => sprintf(
_x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
get_bloginfo( 'name' ), '[your-subject]' ),
'sender' => sprintf( '[your-name] <%s>', self::from_email() ),
'body' =>
sprintf( __( 'From: %s', 'contact-form-7' ),
'[your-name] <[your-email]>' ) . "\n"
. sprintf( __( 'Subject: %s', 'contact-form-7' ),
'[your-subject]' ) . "\n\n"
. __( 'Message Body:', 'contact-form-7' )
. "\n" . '[your-message]' . "\n\n"
. '-- ' . "\n"
. sprintf( __( 'This e-mail was sent from a contact form on %1$s (%2$s)',
'contact-form-7' ), get_bloginfo( 'name' ), get_bloginfo( 'url' ) ),
'recipient' => get_option( 'admin_email' ),
'additional_headers' => 'Reply-To: [your-email]',
'attachments' => '',
'use_html' => 0,
'exclude_blank' => 0,
);
return $template;
}
public static function mail_2() {
$template = array(
'active' => false,
'subject' => sprintf(
_x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
get_bloginfo( 'name' ), '[your-subject]' ),
'sender' => sprintf( '%s <%s>',
get_bloginfo( 'name' ), self::from_email() ),
'body' =>
__( 'Message Body:', 'contact-form-7' )
. "\n" . '[your-message]' . "\n\n"
. '-- ' . "\n"
. sprintf( __( 'This e-mail was sent from a contact form on %1$s (%2$s)',
'contact-form-7' ), get_bloginfo( 'name' ), get_bloginfo( 'url' ) ),
'recipient' => '[your-email]',
'additional_headers' => sprintf( 'Reply-To: %s',
get_option( 'admin_email' ) ),
'attachments' => '',
'use_html' => 0,
'exclude_blank' => 0,
);
return $template;
}
public static function from_email() {
$admin_email = get_option( 'admin_email' );
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
if ( wpcf7_is_localhost() ) {
return $admin_email;
}
if ( substr( $sitename, 0, 4 ) == 'www.' ) {
$sitename = substr( $sitename, 4 );
}
if ( strpbrk( $admin_email, '@' ) == '@' . $sitename ) {
return $admin_email;
}
return 'wordpress@' . $sitename;
}
public static function messages() {
$messages = array();
foreach ( wpcf7_messages() as $key => $arr ) {
$messages[$key] = $arr['default'];
}
return $messages;
}
}
function wpcf7_messages() {
$messages = array(
'mail_sent_ok' => array(
'description'
=> __( "Sender's message was sent successfully", 'contact-form-7' ),
'default'
=> __( "Thank you for your message. It has been sent.", 'contact-form-7' ),
),
'mail_sent_ng' => array(
'description'
=> __( "Sender's message failed to send", 'contact-form-7' ),
'default'
=> __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' ),
),
'validation_error' => array(
'description'
=> __( "Validation errors occurred", 'contact-form-7' ),
'default'
=> __( "One or more fields have an error. Please check and try again.", 'contact-form-7' ),
),
'spam' => array(
'description'
=> __( "Submission was referred to as spam", 'contact-form-7' ),
'default'
=> __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' ),
),
'accept_terms' => array(
'description'
=> __( "There are terms that the sender must accept", 'contact-form-7' ),
'default'
=> __( "You must accept the terms and conditions before sending your message.", 'contact-form-7' ),
),
'invalid_required' => array(
'description'
=> __( "There is a field that the sender must fill in", 'contact-form-7' ),
'default'
=> __( "The field is required.", 'contact-form-7' ),
),
'invalid_too_long' => array(
'description'
=> __( "There is a field with input that is longer than the maximum allowed length", 'contact-form-7' ),
'default'
=> __( "The field is too long.", 'contact-form-7' ),
),
'invalid_too_short' => array(
'description'
=> __( "There is a field with input that is shorter than the minimum allowed length", 'contact-form-7' ),
'default'
=> __( "The field is too short.", 'contact-form-7' ),
)
);
return apply_filters( 'wpcf7_messages', $messages );
}
This diff is collapsed.
<?php
add_action( 'wp_loaded', 'wpcf7_control_init' );
function wpcf7_control_init() {
if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )
&& 'XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH'] ) {
return;
}
if ( isset( $_POST['_wpcf7'] ) ) {
$contact_form = wpcf7_contact_form( (int) $_POST['_wpcf7'] );
if ( $contact_form ) {
$contact_form->submit();
}
}
}
add_filter( 'widget_text', 'wpcf7_widget_text_filter', 9 );
function wpcf7_widget_text_filter( $content ) {
$pattern = '/\[[\r\n\t ]*contact-form(-7)?[\r\n\t ].*?\]/';
if ( ! preg_match( $pattern, $content ) ) {
return $content;
}
$content = do_shortcode( $content );
return $content;
}
add_action( 'wp_enqueue_scripts', 'wpcf7_do_enqueue_scripts' );
function wpcf7_do_enqueue_scripts() {
if ( wpcf7_load_js() ) {
wpcf7_enqueue_scripts();
}
if ( wpcf7_load_css() ) {
wpcf7_enqueue_styles();
}
}
function wpcf7_enqueue_scripts() {
$in_footer = true;
if ( 'header' === wpcf7_load_js() ) {
$in_footer = false;
}
wp_enqueue_script( 'contact-form-7',
wpcf7_plugin_url( 'includes/js/scripts.js' ),
array( 'jquery' ), WPCF7_VERSION, $in_footer );
$wpcf7 = array(
'apiSettings' => array(
'root' => esc_url_raw( get_rest_url() ),
'namespace' => 'contact-form-7/v1',
),
'recaptcha' => array(
'messages' => array(
'empty' =>
__( 'Please verify that you are not a robot.', 'contact-form-7' ),
),
),
);
if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
$wpcf7['cached'] = 1;
}
if ( wpcf7_support_html5_fallback() ) {
$wpcf7['jqueryUi'] = 1;
}
wp_localize_script( 'contact-form-7', 'wpcf7', $wpcf7 );
do_action( 'wpcf7_enqueue_scripts' );
}
function wpcf7_script_is() {
return wp_script_is( 'contact-form-7' );
}
function wpcf7_enqueue_styles() {
wp_enqueue_style( 'contact-form-7',
wpcf7_plugin_url( 'includes/css/styles.css' ),
array(), WPCF7_VERSION, 'all' );
if ( wpcf7_is_rtl() ) {
wp_enqueue_style( 'contact-form-7-rtl',
wpcf7_plugin_url( 'includes/css/styles-rtl.css' ),
array(), WPCF7_VERSION, 'all' );
}
do_action( 'wpcf7_enqueue_styles' );
}
function wpcf7_style_is() {
return wp_style_is( 'contact-form-7' );
}
/* HTML5 Fallback */
add_action( 'wp_enqueue_scripts', 'wpcf7_html5_fallback', 20 );
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.11.4', 'screen' );
}
}
span.wpcf7-not-valid-tip {
direction: rtl;
}
.use-floating-validation-tip span.wpcf7-not-valid-tip {
left: auto;
right: 20%;
}
span.wpcf7-list-item {
margin: 0 1em 0 0;
}
div.wpcf7 {
margin: 0;
padding: 0;
}
div.wpcf7-response-output {
margin: 2em 0.5em 1em;
padding: 0.2em 1em;
}
div.wpcf7 .screen-reader-response {
position: absolute;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
width: 1px;
margin: 0;
padding: 0;
border: 0;
}
div.wpcf7-mail-sent-ok {
border: 2px solid #398f14;
}
div.wpcf7-mail-sent-ng {
border: 2px solid #ff0000;
}
div.wpcf7-spam-blocked {
border: 2px solid #ffa500;
}
div.wpcf7-validation-errors {
border: 2px solid #f7e700;
}
.wpcf7-form-control-wrap {
position: relative;
}
span.wpcf7-not-valid-tip {
color: #f00;
font-size: 1em;
font-weight: normal;
display: block;
}
.use-floating-validation-tip span.wpcf7-not-valid-tip {
position: absolute;
top: 20%;
left: 20%;
z-index: 100;
border: 1px solid #ff0000;
background: #fff;
padding: .2em .8em;
}
span.wpcf7-list-item {
display: inline-block;
margin: 0 0 0 1em;
}
span.wpcf7-list-item-label::before,
span.wpcf7-list-item-label::after {
content: " ";
}
.wpcf7-display-none {
display: none;
}
div.wpcf7 .ajax-loader {
visibility: hidden;
display: inline-block;
background-image: url('../../images/ajax-loader.gif');
width: 16px;
height: 16px;
border: none;
padding: 0;
margin: 0 0 0 4px;
vertical-align: middle;
}
div.wpcf7 .ajax-loader.is-active {
visibility: visible;
}
div.wpcf7 div.ajax-error {
display: none;
}
div.wpcf7 .placeheld {
color: #888;
}
div.wpcf7 .wpcf7-recaptcha iframe {
margin-bottom: 0;
}
div.wpcf7 input[type="file"] {
cursor: pointer;
}
div.wpcf7 input[type="file"]:disabled {
cursor: default;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
class WPCF7_Integration {
private static $instance;
private $services = array();
private $categories = array();
private function __construct() {}
public static function get_instance() {
if ( empty( self::$instance ) ) {
self::$instance = new self;
}
return self::$instance;
}
public function add_service( $name, WPCF7_Service $service ) {
$name = sanitize_key( $name );
if ( empty( $name ) || isset( $this->services[$name] ) ) {
return false;
}
$this->services[$name] = $service;
}
public function add_category( $name, $title ) {
$name = sanitize_key( $name );
if ( empty( $name ) || isset( $this->categories[$name] ) ) {
return false;
}
$this->categories[$name] = $title;
}
public function service_exists( $name = '' ) {
if ( '' == $name ) {
return (bool) count( $this->services );
} else {
return isset( $this->services[$name] );
}
}
public function get_service( $name ) {
if ( $this->service_exists( $name ) ) {
return $this->services[$name];
} else {
return false;
}
}
public function list_services( $args = '' ) {
$args = wp_parse_args( $args, array(
'include' => array(),
) );
$singular = false;
$services = (array) $this->services;
if ( ! empty( $args['include'] ) ) {
$services = array_intersect_key( $services,
array_flip( (array) $args['include'] ) );
if ( 1 == count( $services ) ) {
$singular = true;
}
}
if ( empty( $services ) ) {
return;
}
$action = wpcf7_current_action();
foreach ( $services as $name => $service ) {
$cats = array_intersect_key( $this->categories,
array_flip( $service->get_categories() ) );
?>
<div class="card<?php echo $service->is_active() ? ' active' : ''; ?>" id="<?php echo esc_attr( $name ); ?>">
<?php $service->icon(); ?>
<h2 class="title"><?php echo esc_html( $service->get_title() ); ?></h2>
<div class="infobox">
<?php echo esc_html( implode( ', ', $cats ) ); ?>
<br />
<?php $service->link(); ?>
</div>
<br class="clear" />
<div class="inside">
<?php
if ( $singular ) {
$service->display( $action );
} else {
$service->display();
}
?>
</div>
</div>
<?php
}
}
}
abstract class WPCF7_Service {
abstract public function get_title();
abstract public function is_active();
public function get_categories() {
return array();
}
public function icon() {
return '';
}
public function link() {
return '';
}
public function load( $action = '' ) {
}
public function display( $action = '' ) {
}
public function admin_notice( $message = '' ) {
}
}
This diff is collapsed.
<?php
function wpcf7_l10n() {
static $l10n = array();
if ( ! empty( $l10n ) ) {
return $l10n;
}
if ( ! is_admin() ) {
return $l10n;
}
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
$api = translations_api( 'plugins', array(
'slug' => 'contact-form-7',
'version' => WPCF7_VERSION,
) );
if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
return $l10n;
}
foreach ( (array) $api['translations'] as $translation ) {
if ( ! empty( $translation['language'] )
&& ! empty( $translation['english_name'] ) ) {
$l10n[$translation['language']] = $translation['english_name'];
}
}
return $l10n;
}
function wpcf7_is_valid_locale( $locale ) {
$pattern = '/^[a-z]{2,3}(?:_[a-zA-Z_]{2,})?$/';
return (bool) preg_match( $pattern, $locale );
}
function wpcf7_is_rtl( $locale = '' ) {
static $rtl_locales = array(
'ar' => 'Arabic',
'ary' => 'Moroccan Arabic',
'azb' => 'South Azerbaijani',
'fa_IR' => 'Persian',
'haz' => 'Hazaragi',
'he_IL' => 'Hebrew',
'ps' => 'Pashto',
'ug_CN' => 'Uighur',
);
if ( empty( $locale ) && function_exists( 'is_rtl' ) ) {
return is_rtl();
}
if ( empty( $locale ) ) {
$locale = get_locale();
}
return isset( $rtl_locales[$locale] );
}
function wpcf7_load_textdomain( $locale = null ) {
global $l10n;
$domain = 'contact-form-7';
if ( get_locale() == $locale ) {
$locale = null;
}
if ( empty( $locale ) ) {
if ( is_textdomain_loaded( $domain ) ) {
return true;
} else {
return load_plugin_textdomain( $domain, false, $domain . '/languages' );
}
} else {
$mo_orig = $l10n[$domain];
unload_textdomain( $domain );
$mofile = $domain . '-' . $locale . '.mo';
$path = WP_PLUGIN_DIR . '/' . $domain . '/languages';
if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) {
return $loaded;
} else {
$mofile = WP_LANG_DIR . '/plugins/' . $mofile;
return load_textdomain( $domain, $mofile );
}
$l10n[$domain] = $mo_orig;
}
return false;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Translations have moved to
https://translate.wordpress.org/projects/wp-plugins/contact-form-7
Thank you for your contribution.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,13 +5,10 @@ zone4: ['12' , '15' , '16' , '17' , '19' , '23' , '24' , '31' , '32' , '33' , '4
zone5: ['01' , '04' , '05' , '07' , '10' , '21' , '25' , '26' , '38' , '39' , '42' , '43' , '52' , '54' , '57' , '63' , '67' , '68' , '69' , '70' , '71' , '73' , '74' , '88' , '90' , 'CH'],
zone6: ['06' , '09' , '11' , '13' , '20' , '30' , '34' , '48' , '66' , '81' , '83' , '84' , '2A' , '2B' , 'ES']}
*/
var zones = jQuery.parseJSON(zones.listZones);
//console.log(zones);
var zones = jQuery.parseJSON(zonesL.listZones);
console.log(zones);
console.log(typeof zones);
function initMap(){
setTimeout(function(){
$('#map').addClass('eeeeeeeeee');
if(jQuery(document).find('#map').length){
svg = jQuery("#map").getSVG();
jQuery.map(zones, function(zoneDeps,zone){
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment