c06ef486 by Jeff Balicki

plugin

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent fd9f65e0
Showing 817 changed files with 4916 additions and 0 deletions
/*
* Tabs
*/
#contact-form-editor-tabs {
padding: 9px 10px 0 15px;
}
/*
* 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
*/
.wpcf7-welcome-panel .welcome-panel-close {
left: 10px;
right: auto;
padding: 10px 21px 10px 15px;
}
.wpcf7-welcome-panel .welcome-panel-close::before {
right: 0;
left: auto;
}
.wpcf7-welcome-panel .welcome-panel-content {
margin-right: 13px;
}
.wpcf7-welcome-panel .welcome-panel-column {
float: right;
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 {
font-size: 12px;
border: none;
box-shadow: none;
padding: 4px 8px;
margin: 0;
}
#wpcf7-contact-form-list-table span.shortcode input,
#wpcf7-contact-form-editor span.shortcode input {
background: transparent;
}
#wpcf7-contact-form-list-table span.shortcode input {
color: #444;
}
#wpcf7-contact-form-editor span.shortcode input {
color: #fff;
}
#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: #dc3232; /* Red */
}
#submitpost input.delete:focus {
outline: thin dotted;
}
.postbox-container .postbox h3 {
border-bottom: 1px solid transparent;
}
.keyboard-interaction {
visibility: hidden;
color: #23282d; /* Dark Gray 800 */
}
div.config-error, span.config-error, ul.config-error {
color: #444;
font-style: normal;
font-size: 13px;
}
ul.config-error {
margin: 2px 0;
}
ul.config-error li {
list-style: none;
padding: 2px 2px;
margin: 0;
}
[data-config-field][aria-invalid="true"] {
border-color: #dc3232;
}
#contact-form-editor-tabs li a .icon-in-circle,
#contact-form-editor .config-error .icon-in-circle,
.wp-list-table .config-error .icon-in-circle,
.icon-in-circle {
display: inline-block;
vertical-align: text-top;
margin: 1px 6px 0;
padding: 0 5px;
min-width: 7px;
height: 17px;
border-radius: 11px;
background-color: #ca4a1f;
color: #fff;
font-size: 12px;
font-weight: bold;
line-height: 17px;
text-align: center;
z-index: 26;
}
/*
* 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 .contact-form-editor-panel > div.config-error {
margin-bottom: 1.4em;
}
#contact-form-editor-tabs li.ui-tabs-active a .icon-in-circle {
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 {
height: 495px;
display: flex;
flex-direction: column;
}
.tag-generator-panel .control-box {
padding: 0;
margin: 0;
overflow: auto;
flex-grow: 1;
}
.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: 100%;
box-sizing: border-box;
}
.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 input.large-text {
width: 400px;
}
.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 {
margin: 0 -15px -15px;
padding: 8px 16px;
background-color: #fcfcfc;
border-top: 1px solid #dfdfdf;
overflow: auto;
}
.tag-generator-panel .insert-box input.tag {
width: 510px;
float: left;
background-color: transparent;
box-shadow: none;
}
.tag-generator-panel .insert-box .submitbox {
padding: 0;
}
.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;
}
.contact-form-editor-box-mail span.mailtag.unused {
font-weight: bold;
}
/*
* Messages Tab
*/
#messages-panel p.description {
margin: 5px 0 10px;
}
/*
* Tabs for integration modules
*/
#ctct-panel table tr.inactive ~ tr,
#sendinblue-panel table tr.inactive ~ tr {
display: none;
}
#ctct-panel .dashicons,
#sendinblue-panel .dashicons {
text-decoration: none;
}
#ctct-panel td p,
#sendinblue-panel td p {
margin-top: 12px;
}
/*
* List Table
*/
.fixed .column-title {
width: 38%;
}
.fixed .column-shortcode {
width: 38%;
}
/*
* Welcome Panel
*/
.wpcf7-welcome-panel {
position: relative;
overflow: auto;
margin: 16px 0;
padding: 23px 10px 0;
border: 1px solid #c3c4c7;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
background: #fff;
font-size: 13px;
line-height: 1.7;
}
.wpcf7-welcome-panel h3 {
font-size: 16px;
font-weight: 600;
line-height: 2.1em;
margin: 1em 0 1.2em;
}
.wpcf7-welcome-panel h3 .dashicons {
position: relative;
top: -2px;
display: inline-block;
width: 60px;
color: #575757;
font-size: 40px;
}
.wpcf7-welcome-panel p {
color: #646970;
}
.wpcf7-welcome-panel p a {
font-weight: bold;
}
.wpcf7-welcome-panel .welcome-panel-close {
position: absolute;
z-index: 2;
top: 10px;
right: 10px;
padding: 10px 15px 10px 21px;
font-size: 13px;
line-height: 1.23076923; /* Chrome rounding, needs to be 16px equivalent */
text-decoration: none;
}
.wpcf7-welcome-panel .welcome-panel-close::before {
background: 0 0;
color: #787c82;
content: "\f153";
display: block;
font: normal 16px/20px dashicons;
speak: never;
height: 20px;
text-align: center;
width: 20px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
position: absolute;
top: 8px;
left: 0;
transition: all .1s ease-in-out;
}
.wpcf7-welcome-panel .welcome-panel-content {
display: block;
margin-left: 13px;
max-width: 1500px;
min-height: auto;
}
.wpcf7-welcome-panel .welcome-panel-column-container {
clear: both;
position: relative;
}
.wpcf7-welcome-panel .welcome-panel-column {
display: block;
width: 48%;
min-width: 200px;
float: left;
padding: 0 2% 0 0;
margin: 0 0 1em 0;
}
@media screen and (max-width: 870px) {
.wpcf7-welcome-panel .welcome-panel-column {
display: block;
float: none;
width: 100%;
}
}
.wpcf7-welcome-panel .welcome-panel-column p {
margin-top: 7px;
color: #3c434a;
}
/*
* 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: 1em;
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;
}
.card .checkboxes li {
margin: 0;
}
<?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" id="wpcf7-contact-form-editor">
<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()
and current_user_can( 'wpcf7_edit_contact_forms' ) ) {
echo wpcf7_link(
menu_page_url( 'wpcf7-new', false ),
__( 'Add New', 'contact-form-7' ),
array( 'class' => 'page-title-action' )
);
}
?>
<hr class="wp-header-end">
<?php
do_action( 'wpcf7_admin_warnings',
$post->initial() ? 'wpcf7-new' : 'wpcf7',
wpcf7_current_action(),
$post
);
do_action( 'wpcf7_admin_notices',
$post->initial() ? 'wpcf7-new' : 'wpcf7',
wpcf7_current_action(),
$post
);
?>
<?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 ),
);
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( __( "Do you need help?", 'contact-form-7' ) ); ?></h3>
<div class="inside">
<p><?php echo esc_html( __( "Here are some available options to help solve your problems.", 'contact-form-7' ) ); ?></p>
<ol>
<li><?php echo sprintf(
/* translators: 1: FAQ, 2: Docs ("FAQ & Docs") */
__( '%1$s and %2$s', 'contact-form-7' ),
wpcf7_link(
__( 'https://contactform7.com/faq/', 'contact-form-7' ),
__( 'FAQ', 'contact-form-7' )
),
wpcf7_link(
__( 'https://contactform7.com/docs/', 'contact-form-7' ),
__( 'docs', 'contact-form-7' )
)
); ?></li>
<li><?php echo wpcf7_link(
__( 'https://wordpress.org/support/plugin/contact-form-7/', 'contact-form-7' ),
__( 'Support forums', 'contact-form-7' )
); ?></li>
<li><?php echo wpcf7_link(
__( 'https://contactform7.com/custom-development/', 'contact-form-7' ),
__( 'Professional services', 'contact-form-7' )
); ?></li>
</ol>
</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(
/* translators: 1: ◀ ▶ dashicon, 2: screen reader text for the dashicon */
esc_html( __( '%1$s %2$s keys switch panels', 'contact-form-7' ) ),
'<span class="dashicons dashicons-leftright" aria-hidden="true"></span>',
sprintf(
'<span class="screen-reader-text">%s</span>',
/* translators: screen reader text */
esc_html( __( '(left and right arrow)', 'contact-form-7' ) )
)
);
?></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 = $post->prop( 'additional_settings' );
if ( ! is_scalar( $additional_settings ) ) {
$additional_settings = '';
}
$additional_settings = trim( $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(
/* translators: %d: number of additional settings */
__( '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'] ) and -1 != $_REQUEST['action'] ) {
return $_REQUEST['action'];
}
if ( isset( $_REQUEST['action2'] ) and -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;
}
public function __construct() {
parent::__construct( array(
'singular' => 'post',
'plural' => 'posts',
'ajax' => false,
) );
}
public function prepare_items() {
$current_screen = get_current_screen();
$per_page = $this->get_items_per_page( 'wpcf7_contact_forms_per_page' );
$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,
) );
}
public function get_columns() {
return get_column_headers( get_current_screen() );
}
protected function get_sortable_columns() {
$columns = array(
'title' => array( 'title', true ),
'author' => array( 'author', false ),
'date' => array( 'date', false ),
);
return $columns;
}
protected function get_bulk_actions() {
$actions = array(
'delete' => __( 'Delete', 'contact-form-7' ),
);
return $actions;
}
protected function column_default( $item, $column_name ) {
return '';
}
public function column_cb( $item ) {
return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
$this->_args['singular'],
$item->id()
);
}
public function column_title( $item ) {
$edit_link = add_query_arg(
array(
'post' => absint( $item->id() ),
'action' => 'edit',
),
menu_page_url( 'wpcf7', false )
);
$output = sprintf(
'<a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a>',
esc_url( $edit_link ),
esc_attr( sprintf(
/* translators: %s: title of contact form */
__( 'Edit &#8220;%s&#8221;', 'contact-form-7' ),
$item->title()
) ),
esc_html( $item->title() )
);
$output = sprintf( '<strong>%s</strong>', $output );
if ( wpcf7_validate_configuration()
and 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(
/* translators: %s: number of errors detected */
'%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="icon-in-circle" aria-hidden="true">!</span> %s</div>',
$error_notice
);
}
}
return $output;
}
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $column_name !== $primary ) {
return '';
}
$edit_link = add_query_arg(
array(
'post' => absint( $item->id() ),
'action' => 'edit',
),
menu_page_url( 'wpcf7', false )
);
$actions = array(
'edit' => wpcf7_link( $edit_link, __( 'Edit', 'contact-form-7' ) ),
);
if ( current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
$copy_link = add_query_arg(
array(
'post' => absint( $item->id() ),
'action' => 'copy',
),
menu_page_url( 'wpcf7', false )
);
$copy_link = wp_nonce_url(
$copy_link,
'wpcf7-copy-contact-form_' . absint( $item->id() )
);
$actions = array_merge( $actions, array(
'copy' => wpcf7_link( $copy_link, __( 'Duplicate', 'contact-form-7' ) ),
) );
}
return $this->row_actions( $actions );
}
public 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 );
}
public 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 );
}
public function column_date( $item ) {
$datetime = get_post_datetime( $item->id() );
if ( false === $datetime ) {
return '';
}
$t_time = sprintf(
/* translators: 1: date, 2: time */
__( '%1$s at %2$s', 'contact-form-7' ),
/* translators: date format, see https://www.php.net/date */
$datetime->format( __( 'Y/m/d', 'contact-form-7' ) ),
/* translators: time format, see https://www.php.net/date */
$datetime->format( __( 'g:i a', 'contact-form-7' ) )
);
return $t_time;
}
}
<?php
add_action( 'wpcf7_admin_menu', 'wpcf7_admin_init_bulk_cv', 10, 0 );
function wpcf7_admin_init_bulk_cv() {
if ( ! wpcf7_validate_configuration()
or ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
return;
}
$result = WPCF7::get_option( 'bulk_validate' );
$last_important_update = WPCF7_ConfigValidator::last_important_update;
if ( ! empty( $result['version'] )
and version_compare( $last_important_update, $result['version'], '<=' ) ) {
return;
}
add_filter( 'wpcf7_admin_menu_change_notice',
'wpcf7_admin_menu_change_notice_bulk_cv',
10, 1
);
add_action( 'wpcf7_admin_warnings',
'wpcf7_admin_warnings_bulk_cv',
5, 3
);
}
function wpcf7_admin_menu_change_notice_bulk_cv( $counts ) {
$counts['wpcf7'] += 1;
return $counts;
}
function wpcf7_admin_warnings_bulk_cv( $page, $action, $object ) {
if ( 'wpcf7' === $page and 'validate' === $action ) {
return;
}
$link = wpcf7_link(
add_query_arg(
array( 'action' => 'validate' ),
menu_page_url( 'wpcf7', false )
),
__( 'Validate Contact Form 7 Configuration', 'contact-form-7' )
);
$message = __( "Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7' );
echo sprintf(
'<div class="notice notice-warning"><p>%1$s &raquo; %2$s</p></div>',
esc_html( $message ),
$link
);
}
add_action( 'wpcf7_admin_load', 'wpcf7_load_bulk_validate_page', 10, 2 );
function wpcf7_load_bulk_validate_page( $page, $action ) {
if ( 'wpcf7' != $page
or 'validate' != $action
or ! wpcf7_validate_configuration()
or 'POST' != $_SERVER['REQUEST_METHOD'] ) {
return;
}
check_admin_referer( 'wpcf7-bulk-validate' );
if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
wp_die( __( "You are not allowed to validate configuration.", 'contact-form-7' ) );
}
$contact_forms = WPCF7_ContactForm::find();
$result = array(
'timestamp' => time(),
'version' => WPCF7_VERSION,
'count_valid' => 0,
'count_invalid' => 0,
);
foreach ( $contact_forms as $contact_form ) {
$config_validator = new WPCF7_ConfigValidator( $contact_form );
$config_validator->validate();
$config_validator->save();
if ( $config_validator->is_valid() ) {
$result['count_valid'] += 1;
} else {
$result['count_invalid'] += 1;
}
}
WPCF7::update_option( 'bulk_validate', $result );
$redirect_to = add_query_arg(
array(
'message' => 'validated',
),
menu_page_url( 'wpcf7', false )
);
wp_safe_redirect( $redirect_to );
exit();
}
function wpcf7_admin_bulk_validate_page() {
$contact_forms = WPCF7_ContactForm::find();
$count = WPCF7_ContactForm::count();
$submit_text = sprintf(
_n(
/* translators: %s: number of contact forms */
"Validate %s contact form now",
"Validate %s contact forms now",
$count, 'contact-form-7'
),
number_format_i18n( $count )
);
?>
<div class="wrap">
<h1><?php echo esc_html( __( 'Validate Configuration', 'contact-form-7' ) ); ?></h1>
<form method="post" action="">
<input type="hidden" name="action" value="validate" />
<?php wp_nonce_field( 'wpcf7-bulk-validate' ); ?>
<p><input type="submit" class="button" value="<?php echo esc_attr( $submit_text ); ?>" /></p>
</form>
<?php
echo wpcf7_link(
__( 'https://contactform7.com/configuration-validator-faq/', 'contact-form-7' ),
__( 'FAQ about Configuration Validator', 'contact-form-7' )
);
?>
</div>
<?php
}
<?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( $panel_id, $title, $callback ) {
if ( wpcf7_is_name( $panel_id ) ) {
$this->panels[$panel_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 $panel_id => $panel ) {
echo sprintf(
'<li id="%1$s-tab"><a href="#%1$s">%2$s</a></li>',
esc_attr( $panel_id ),
esc_html( $panel['title'] )
);
}
echo '</ul>';
foreach ( $this->panels as $panel_id => $panel ) {
echo sprintf(
'<div class="contact-form-editor-panel" id="%1$s">',
esc_attr( $panel_id )
);
if ( is_callable( $panel['callback'] ) ) {
$this->notice( $panel_id, $panel );
call_user_func( $panel['callback'], $this->contact_form );
}
echo '</div>';
}
}
public function notice( $panel_id, $panel ) {
echo '<div class="config-error"></div>';
}
}
function wpcf7_editor_panel_form( $post ) {
$desc_link = wpcf7_link(
__( 'https://contactform7.com/editing-form-template/', 'contact-form-7' ),
__( 'Editing form template', 'contact-form-7' ) );
$description = __( "You can edit the form template here. For details, see %s.", 'contact-form-7' );
$description = sprintf( esc_html( $description ), $desc_link );
?>
<h2><?php echo esc_html( __( 'Form', 'contact-form-7' ) ); ?></h2>
<fieldset>
<legend><?php echo $description; ?></legend>
<?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>
</fieldset>
<?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
$desc_link = wpcf7_link(
__( 'https://contactform7.com/setting-up-mail/', 'contact-form-7' ),
__( 'Setting up mail', 'contact-form-7' ) );
$description = __( "You can edit the mail template here. For details, see %s.", 'contact-form-7' );
$description = sprintf( esc_html( $description ), $desc_link );
echo $description;
echo '<br />';
echo esc_html( __( "In the following fields, you can use these mail-tags:",
'contact-form-7' ) );
echo '<br />';
$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 ) {
$desc_link = wpcf7_link(
__( 'https://contactform7.com/editing-messages/', 'contact-form-7' ),
__( 'Editing messages', 'contact-form-7' ) );
$description = __( "You can edit messages used in various situations here. For details, see %s.", 'contact-form-7' );
$description = sprintf( esc_html( $description ), $desc_link );
$messages = wpcf7_messages();
if ( isset( $messages['captcha_not_match'] )
and ! wpcf7_use_really_simple_captcha() ) {
unset( $messages['captcha_not_match'] );
}
?>
<h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2>
<fieldset>
<legend><?php echo $description; ?></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( $screen_type ) {
switch ( $screen_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 do not 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 do not 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
or ! 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(
/* translators: %s: title of form-tag like 'email' or 'checkboxes' */
__( '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
abstract class WPCF7_WelcomePanelColumn {
abstract protected function icon();
abstract protected function title();
abstract protected function content();
public function print_content() {
$icon = sprintf(
'<span class="dashicons dashicons-%s" aria-hidden="true"></span>',
esc_attr( $this->icon() )
);
$title = sprintf(
'<h3>%1$s %2$s</h3>',
$icon,
$this->title()
);
$content = $this->content();
if ( is_array( $content ) ) {
$content = implode( "\n\n", $content );
}
$content = wp_kses_post( $content );
$content = wptexturize( $content );
$content = convert_chars( $content );
$content = wpautop( $content );
echo "\n";
echo '<div class="welcome-panel-column">';
echo $title;
echo $content;
echo '</div>';
}
}
class WPCF7_WelcomePanelColumn_AntiSpam extends WPCF7_WelcomePanelColumn {
protected function icon() {
return 'shield';
}
protected function title() {
return esc_html(
__( "Getting spammed? You have protection.", 'contact-form-7' )
);
}
protected function content() {
return array(
esc_html( __( "Spammers target everything; your contact forms are not an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ),
sprintf(
/* translators: links labeled 1: 'Akismet', 2: 'reCAPTCHA', 3: 'disallowed list' */
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' ),
__( 'disallowed list', 'contact-form-7' )
)
),
);
}
}
class WPCF7_WelcomePanelColumn_Donation extends WPCF7_WelcomePanelColumn {
protected function icon() {
return 'megaphone';
}
protected function title() {
return esc_html(
__( "Contact Form 7 needs your support.", 'contact-form-7' )
);
}
protected function content() {
return array(
esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you.", 'contact-form-7' ) ),
sprintf(
/* translators: %s: link labeled 'making a donation' */
esc_html( __( 'If you enjoy using Contact Form 7 and find it useful, please consider %s.', 'contact-form-7' ) ),
wpcf7_link(
__( 'https://contactform7.com/donate/', 'contact-form-7' ),
__( 'making a donation', 'contact-form-7' )
)
),
esc_html( __( "Your donation will help encourage and support the plugin&#8217;s continued development and better user support.", 'contact-form-7' ) ),
);
}
}
class WPCF7_WelcomePanelColumn_Flamingo extends WPCF7_WelcomePanelColumn {
protected function icon() {
return 'editor-help';
}
protected function title() {
return esc_html(
__( "Before you cry over spilt mail&#8230;", 'contact-form-7' )
);
}
protected function content() {
return array(
esc_html( __( "Contact Form 7 does not 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' ) ),
sprintf(
/* translators: %s: link labeled 'Flamingo' */
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' )
)
),
);
}
}
class WPCF7_WelcomePanelColumn_Integration extends WPCF7_WelcomePanelColumn {
protected function icon() {
return 'superhero-alt';
}
protected function title() {
return esc_html(
__( "You have strong allies to back you up.", 'contact-form-7' )
);
}
protected function content() {
return array(
sprintf(
/* translators: 1: link labeled 'Brevo', 2: link labeled 'Constant Contact' */
esc_html( __( 'Your contact forms will become more powerful and versatile by integrating them with external APIs. With CRM and email marketing services, you can build your own contact lists (%1$s and %2$s).', 'contact-form-7' ) ),
wpcf7_link(
__( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ),
__( 'Brevo', 'contact-form-7' )
),
wpcf7_link(
__( 'https://contactform7.com/constant-contact-integration/', 'contact-form-7' ),
__( 'Constant Contact', 'contact-form-7' )
)
),
sprintf(
/* translators: 1: link labeled 'reCAPTCHA', 2: link labeled 'Stripe' */
esc_html( __( 'With help from cloud-based machine learning, anti-spam services will protect your forms (%1$s). Even payment services are natively supported (%2$s).', 'contact-form-7' ) ),
wpcf7_link(
__( 'https://contactform7.com/recaptcha/', 'contact-form-7' ),
__( 'reCAPTCHA', 'contact-form-7' )
),
wpcf7_link(
__( 'https://contactform7.com/stripe-integration/', 'contact-form-7' ),
__( 'Stripe', 'contact-form-7' )
)
),
);
}
}
function wpcf7_welcome_panel() {
$columns = array();
$flamingo_is_active = defined( 'FLAMINGO_VERSION' );
$sendinblue_is_active = false;
if ( class_exists( 'WPCF7_Sendinblue' )
and $sendinblue = WPCF7_Sendinblue::get_instance() ) {
$sendinblue_is_active = $sendinblue->is_active();
}
if ( $flamingo_is_active and $sendinblue_is_active ) {
$columns[] = new WPCF7_WelcomePanelColumn_AntiSpam();
$columns[] = new WPCF7_WelcomePanelColumn_Donation();
} elseif ( $flamingo_is_active ) {
$columns[] = new WPCF7_WelcomePanelColumn_Integration();
$columns[] = new WPCF7_WelcomePanelColumn_AntiSpam();
} elseif ( $sendinblue_is_active ) {
$columns[] = new WPCF7_WelcomePanelColumn_Flamingo();
$columns[] = new WPCF7_WelcomePanelColumn_AntiSpam();
} else {
$columns[] = new WPCF7_WelcomePanelColumn_Flamingo();
$columns[] = new WPCF7_WelcomePanelColumn_Integration();
}
$classes = 'wpcf7-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="wpcf7-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">
<?php
foreach ( $columns as $column ) {
$column->print_content();
}
?>
</div>
</div>
</div>
<?php
}
add_action(
'wp_ajax_wpcf7-update-welcome-panel',
'wpcf7_admin_ajax_welcome_panel',
10, 0
);
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 ) or ! is_array( $vers ) ) {
$vers = array();
}
if ( empty( $_POST['visible'] ) ) {
$vers[] = wpcf7_version( 'only_major=1' );
} else {
$vers = array_diff( $vers, array( 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 );
}
add_filter(
'screen_settings',
'wpcf7_welcome_panel_screen_settings',
10, 2
);
function wpcf7_welcome_panel_screen_settings( $screen_settings, $screen ) {
if ( 'toplevel_page_wpcf7' !== $screen->id ) {
return $screen_settings;
}
$vers = (array) get_user_meta( get_current_user_id(),
'wpcf7_hide_welcome_panel_on', true
);
$checkbox_id = 'wpcf7-welcome-panel-show';
$checked = ! in_array( wpcf7_version( 'only_major=1' ), $vers );
$checkbox = sprintf(
'<input %s />',
wpcf7_format_atts( array(
'id' => $checkbox_id,
'type' => 'checkbox',
'checked' => $checked,
) )
);
$screen_settings .= sprintf( '
<fieldset class="wpcf7-welcome-panel-options">
<legend>%1$s</legend>
<label for="%2$s">%3$s %4$s</label>
</fieldset>',
esc_html( __( 'Welcome panel', 'contact-form-7' ) ),
esc_attr( $checkbox_id ),
$checkbox,
esc_html( __( 'Show welcome panel', 'contact-form-7' ) )
);
return $screen_settings;
}
( function( $ ) {
'use strict';
if ( typeof wpcf7 === 'undefined' || wpcf7 === null ) {
return;
}
$( function() {
var welcomePanel = $( '#wpcf7-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 );
$( '#wpcf7-welcome-panel-show' ).prop( 'checked', false );
} );
$( '#wpcf7-welcome-panel-show' ).click( function( event ) {
if ( this.checked ) {
welcomePanel.removeClass( 'hidden' );
updateWelcomePanel( 1 );
} else {
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' );
} );
wpcf7.toggleMail2( 'input:checkbox.toggle-form-table' );
$( 'input:checkbox.toggle-form-table' ).click( function( event ) {
wpcf7.toggleMail2( this );
} );
if ( '' === $( '#title' ).val() ) {
$( '#title' ).focus();
}
wpcf7.titleHint();
$( '.contact-form-editor-box-mail span.mailtag' ).click( function( event ) {
var range = document.createRange();
range.selectNodeContents( this );
window.getSelection().addRange( range );
} );
wpcf7.updateConfigErrors();
$( '[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.getRoute( '/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;
wpcf7.updateConfigErrors();
} );
} );
$( 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' );
}
} );
$( '#wpcf7-ctct-enable-contact-list, #wpcf7-sendinblue-enable-contact-list, #wpcf7-sendinblue-enable-transactional-email' ).on( 'change', function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'tr' ).removeClass( 'inactive' );
} else {
$( this ).closest( 'tr' ).addClass( 'inactive' );
}
} );
} );
wpcf7.toggleMail2 = function( checkbox ) {
var $checkbox = $( checkbox );
var $fieldset = $( 'fieldset',
$checkbox.closest( '.contact-form-editor-box-mail' ) );
if ( $checkbox.is( ':checked' ) ) {
$fieldset.removeClass( 'hidden' );
} else {
$fieldset.addClass( 'hidden' );
}
};
wpcf7.updateConfigErrors = 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' );
$( this ).attr( 'aria-describedby', 'wpcf7-config-error-for-' + section );
if ( errors[ section ] ) {
var $list = $( '<ul></ul>' ).attr( {
'id': 'wpcf7-config-error-for-' + section,
'class': 'config-error'
} );
$.each( errors[ section ], function( i, val ) {
var $li = $( '<li></li>' ).append(
wpcf7.iconInCircle( '!' )
).append(
$( '<span class="screen-reader-text"></span>' ).text( wpcf7.configValidator.iconAlt )
).append( ' ' );
if ( val.link ) {
$li.append(
$( '<a></a>' ).attr( 'href', val.link ).text( val.message )
);
} else {
$li.text( val.message );
}
$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( '.icon-in-circle' ).remove();
var tab = $item.attr( 'id' ).replace( /-panel-tab$/, '' );
$.each( errors, function( key, val ) {
key = key.replace( /^mail_\d+\./, 'mail.' );
if ( key.replace( /\..*$/, '' ) == tab.replace( '-', '_' ) ) {
var $mark = wpcf7.iconInCircle( '!' );
$item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
return false;
}
} );
var $tabPanelError = $( '#' + tab + '-panel > div.config-error:first' );
$tabPanelError.empty();
if ( errorCount[ tab.replace( '-', '_' ) ] ) {
$tabPanelError.append( wpcf7.iconInCircle( '!' ) );
if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) {
var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
.replace( '%d', errorCount[ tab.replace( '-', '_' ) ] );
$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( wpcf7.iconInCircle( '!' ) );
if ( 1 < errorCount.total ) {
$warning.append(
wpcf7.configValidator.manyErrors.replace( '%d', errorCount.total )
);
} else {
$warning.append( wpcf7.configValidator.oneError );
}
$warning.append( '<br />' ).append(
$( '<a></a>' )
.attr( 'href', wpcf7.configValidator.docUrl )
.text( wpcf7.configValidator.howToCorrect )
);
$( '#misc-publishing-actions' ).append( $warning );
}
};
/**
* Copied from wptitlehint() in wp-admin/js/post.js
*/
wpcf7.titleHint = 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 );
} );
};
wpcf7.iconInCircle = function( icon ) {
var $span = $( '<span class="icon-in-circle" aria-hidden="true"></span>' );
return $span.text( icon );
};
wpcf7.apiSettings.getRoute = function( path ) {
var url = wpcf7.apiSettings.root;
url = url.replace(
wpcf7.apiSettings.namespace,
wpcf7.apiSettings.namespace + path );
return url;
};
} )( 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( ' ' ) );
components = '[' + components + ']';
var content = scope.find( ':input[name="content"]' ).val();
content = $.trim( content );
if ( content ) {
components += ' ' + content + ' [/' + tagType + ']';
}
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 );
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 242.5 239.46"><defs><style>.cls-1,.cls-6{fill:none;}.cls-2{clip-path:url(#clip-path);}.cls-3{fill:#33c6f4;}.cls-4{fill:#1b447e;}.cls-5{fill:#fff;}.cls-6{stroke:#221e1f;stroke-miterlimit:10;stroke-width:7.16px;}</style><clipPath id="clip-path" transform="translate(1.72)"><circle class="cls-1" cx="119.73" cy="119.73" r="116.15"/></clipPath></defs><g id="Layer_2" data-name="Layer 2"><g id="Layer_1" data-name="Layer 1"><g class="cls-2"><circle class="cls-3" cx="121.45" cy="119.73" r="116.15"/><path class="cls-4" d="M239.32,167.79c-53.41-24-108.37-91.46-113-94.55s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11S36.94,237.79,122,237.79C208.48,237.79,239.32,167.79,239.32,167.79Z" transform="translate(1.72)"/><path class="cls-5" d="M67.48,116.58s15.48-7,12.38,4.65-15.48,28.64-11.61,29.41S83,140.58,86.06,142.12s5.42.78,3.87,6.2-3.1,9.29,0,9.29,5.42-7,9.29-13.94,10.06-3.87,12.38-1.55,9.29,15.49,14.71,13.94,8.51-8.52,6.19-24,1.55-20.12,1.55-20.12,4.64-2.32,13.16,8.51,24,27.09,26.31,26.32-10.83-17.8-7.74-19.35,15.48,2.32,21.68,7.74c0,0,2.12,8.87,2.12.36L126.31,73.24,115.47,74l-10.06.77S80.64,111.94,67.48,116.58Z" transform="translate(1.72)"/><path class="cls-6" d="M239.32,170.11c-53.41-24-108.37-93.78-113-96.87s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11" transform="translate(1.72)"/></g><circle class="cls-6" cx="121.45" cy="119.73" r="116.15"/></g></g></svg>
<?php
add_action(
'init',
'wpcf7_init_block_editor_assets',
10, 0
);
function wpcf7_init_block_editor_assets() {
$assets = array();
$asset_file = wpcf7_plugin_path(
'includes/block-editor/index.asset.php'
);
if ( file_exists( $asset_file ) ) {
$assets = include( $asset_file );
}
$assets = wp_parse_args( $assets, array(
'dependencies' => array(
'wp-api-fetch',
'wp-block-editor',
'wp-blocks',
'wp-components',
'wp-element',
'wp-i18n',
'wp-url',
),
'version' => WPCF7_VERSION,
) );
wp_register_script(
'contact-form-7-block-editor',
wpcf7_plugin_url( 'includes/block-editor/index.js' ),
$assets['dependencies'],
$assets['version']
);
wp_set_script_translations(
'contact-form-7-block-editor',
'contact-form-7'
);
register_block_type(
wpcf7_plugin_path( 'includes/block-editor' ),
array(
'editor_script' => 'contact-form-7-block-editor',
)
);
}
add_action(
'enqueue_block_editor_assets',
'wpcf7_enqueue_block_editor_assets',
10, 0
);
function wpcf7_enqueue_block_editor_assets() {
$contact_forms = array_map(
static function ( $contact_form ) {
return array(
'id' => $contact_form->id(),
'slug' => $contact_form->name(),
'title' => $contact_form->title(),
'locale' => $contact_form->locale(),
);
},
WPCF7_ContactForm::find( array(
'posts_per_page' => 20,
'orderby' => 'modified',
'order' => 'DESC',
) )
);
wp_add_inline_script(
'contact-form-7-block-editor',
sprintf(
'window.wpcf7 = {contactForms:%s};',
json_encode( $contact_forms )
),
'before'
);
}
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "contact-form-7/contact-form-selector",
"title": "Contact Form 7",
"category": "widgets",
"description": "Insert a contact form you have created with Contact Form 7.",
"keywords": [ "form" ],
"textdomain": "contact-form-7",
"attributes": {
"id": {
"type": "integer"
},
"title": {
"type": "string"
},
"htmlId": {
"type": "string"
},
"htmlName": {
"type": "string"
},
"htmlTitle": {
"type": "string"
},
"htmlClass": {
"type": "string"
},
"output": {
"enum": [ "form", "raw_form" ],
"default": "form"
}
},
"editorScript": "file:./index.js"
}
<?php
return array(
'dependencies' => array(
'wp-api-fetch',
'wp-block-editor',
'wp-blocks',
'wp-components',
'wp-element',
'wp-i18n',
'wp-url',
),
'version' => WPCF7_VERSION,
);
(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var a in l)e.o(l,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:l[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,l=window.wp.i18n,a=window.wp.blocks,r=window.wp.blockEditor,o=(0,t.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 242.5 239.46"},(0,t.createElement)("defs",null,(0,t.createElement)("clipPath",{id:"clip-path",transform:"translate(1.72)"},(0,t.createElement)("circle",{className:"cls-1",cx:"119.73",cy:"119.73",r:"116.15",fill:"none"}))),(0,t.createElement)("g",{id:"Layer_2","data-name":"Layer 2"},(0,t.createElement)("g",{id:"Layer_1","data-name":"Layer 1"},(0,t.createElement)("g",{className:"cls-2",clipPath:"url(#clip-path)"},(0,t.createElement)("circle",{className:"cls-3",cx:"121.45",cy:"119.73",r:"116.15",fill:"#33c6f4"}),(0,t.createElement)("path",{className:"cls-4",d:"M239.32,167.79c-53.41-24-108.37-91.46-113-94.55s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11S36.94,237.79,122,237.79C208.48,237.79,239.32,167.79,239.32,167.79Z",transform:"translate(1.72)",fill:"#1b447e"}),(0,t.createElement)("path",{className:"cls-5",d:"M67.48,116.58s15.48-7,12.38,4.65-15.48,28.64-11.61,29.41S83,140.58,86.06,142.12s5.42.78,3.87,6.2-3.1,9.29,0,9.29,5.42-7,9.29-13.94,10.06-3.87,12.38-1.55,9.29,15.49,14.71,13.94,8.51-8.52,6.19-24,1.55-20.12,1.55-20.12,4.64-2.32,13.16,8.51,24,27.09,26.31,26.32-10.83-17.8-7.74-19.35,15.48,2.32,21.68,7.74c0,0,2.12,8.87,2.12.36L126.31,73.24,115.47,74l-10.06.77S80.64,111.94,67.48,116.58Z",transform:"translate(1.72)",fill:"#fff"}),(0,t.createElement)("path",{className:"cls-6",d:"M239.32,170.11c-53.41-24-108.37-93.78-113-96.87s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11",transform:"translate(1.72)",fill:"none",stroke:"#221e1f",strokeMiterlimit:"10",strokeWidth:"8px"})),(0,t.createElement)("circle",{className:"cls-6",cx:"121.45",cy:"119.73",r:"116.15",fill:"none",stroke:"#1b447e",strokeMiterlimit:"10",strokeWidth:"8px"})))),n=window.wp.components,c=window.wp.apiFetch;var s=e.n(c);const m=window.wp.url,i=e=>{let t="[contact-form-7]";return e.id&&(t=t.replace(/\]$/,` id="${e.id}"]`)),e.title&&(t=t.replace(/\]$/,` title="${e.title}"]`)),e.htmlId&&(t=t.replace(/\]$/,` html_id="${e.htmlId}"]`)),e.htmlName&&(t=t.replace(/\]$/,` html_name="${e.htmlName}"]`)),e.htmlTitle&&(t=t.replace(/\]$/,` html_title="${e.htmlTitle}"]`)),e.htmlClass&&(t=t.replace(/\]$/,` html_class="${e.htmlClass}"]`)),"raw_form"===e.output&&(t=t.replace(/\]$/,` output="${e.output}"]`)),t},d=e=>{const t=ajaxurl.replace(/\/admin-ajax\.php$/,"/admin.php");return(0,m.addQueryArgs)(t,{page:"wpcf7",post:e.id,action:"edit"})},p={from:[{type:"shortcode",tag:"contact-form-7",attributes:{id:{type:"integer",shortcode:e=>{let{named:{id:t}}=e;return parseInt(t)}},title:{type:"string",shortcode:e=>{let{named:{title:t}}=e;return t}}}}],to:[{type:"block",blocks:["core/shortcode"],transform:e=>{const t=i(e);return(0,a.createBlock)("core/shortcode",{text:t})}}]};var h;window.wpcf7=null!==(h=window.wpcf7)&&void 0!==h?h:{contactForms:[]},(0,a.registerBlockType)("contact-form-7/contact-form-selector",{icon:o,transforms:p,edit:function(e){let{attributes:a,setAttributes:o}=e;const c=e=>e.reduce(((e,t)=>e.set(t.id,t)),new Map),[i,p]=(0,t.useState)((()=>{var e;return c(null!==(e=window.wpcf7.contactForms)&&void 0!==e?e:[])}));return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(r.InspectorControls,null,a.id&&(0,t.createElement)(n.PanelBody,{title:a.title},(0,t.createElement)(n.ExternalLink,{href:d(a)},(0,l.__)("Edit this contact form","contact-form-7"))),a.id&&(0,t.createElement)(n.PanelBody,{title:(0,l.__)("Form attributes","contact-form-7"),initialOpen:!1},(0,t.createElement)(n.TextControl,{label:(0,l.__)("ID","contact-form-7"),value:a.htmlId,onChange:e=>o({htmlId:e}),help:(0,l.__)("Used for the id attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Name","contact-form-7"),value:a.htmlName,onChange:e=>o({htmlName:e}),help:(0,l.__)("Used for the name attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Title","contact-form-7"),value:a.htmlTitle,onChange:e=>o({htmlTitle:e}),help:(0,l.__)("Used for the aria-label attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Class","contact-form-7"),value:a.htmlClass,onChange:e=>o({htmlClass:e}),help:(0,l.__)("Used for the class attribute value of the form element.","contact-form-7")}))),(0,t.createElement)("div",(0,r.useBlockProps)({className:"components-placeholder",style:{marginTop:"28px",marginBottom:"28px"}}),(0,t.createElement)(n.ComboboxControl,{label:(0,l.__)("Select a contact form:","contact-form-7"),options:(e=>{const t=[];for(const[l,a]of e)t.push({value:l,label:a.title});return t})(i),value:a.id,onChange:e=>{var t;return o({id:parseInt(e),title:null===(t=i.get(parseInt(e)))||void 0===t?void 0:t.title})},onFilterValueChange:e=>{(async e=>s()({path:(0,m.addQueryArgs)("/contact-form-7/v1/contact-forms",{posts_per_page:20,orderby:"modified",order:"DESC",...e})}).then((e=>e)))({search:e}).then((e=>{p(c(e))}))}})))},save:e=>{let{attributes:l}=e;const a=i(l);return(0,t.createElement)("div",r.useBlockProps.save(),a)}})})();
\ No newline at end of file
<?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_form' => WPCF7_ADMIN_READ_CAPABILITY,
'wpcf7_read_contact_forms' => WPCF7_ADMIN_READ_CAPABILITY,
'wpcf7_delete_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
'wpcf7_delete_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
'wpcf7_manage_integration' => 'manage_options',
'wpcf7_submit' => 'read',
);
$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
/**
* Contact form helper functions
*/
/**
* Wrapper function of WPCF7_ContactForm::get_instance().
*
* @param WPCF7_ContactForm|WP_Post|int $post Object or post ID.
* @return WPCF7_ContactForm|null Contact form object. Null if unset.
*/
function wpcf7_contact_form( $post ) {
return WPCF7_ContactForm::get_instance( $post );
}
/**
* Searches for a contact form by an old unit ID.
*
* @param int $old_id Old unit ID.
* @return WPCF7_ContactForm Contact form object.
*/
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 );
}
}
/**
* Searches for a contact form by title.
*
* @param string $title Title of contact form.
* @return WPCF7_ContactForm|null Contact form object if found, null otherwise.
*/
function wpcf7_get_contact_form_by_title( $title ) {
if ( ! is_string( $title ) or '' === $title ) {
return null;
}
$contact_forms = WPCF7_ContactForm::find( array(
'title' => $title,
'posts_per_page' => 1,
) );
if ( $contact_forms ) {
return wpcf7_contact_form( reset( $contact_forms ) );
}
}
/**
* Wrapper function of WPCF7_ContactForm::get_current().
*
* @return WPCF7_ContactForm Contact form object.
*/
function wpcf7_get_current_contact_form() {
if ( $current = WPCF7_ContactForm::get_current() ) {
return $current;
}
}
/**
* Returns true if it is in the state that a non-Ajax submission is accepted.
*/
function wpcf7_is_posted() {
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
return false;
}
return $contact_form->is_posted();
}
/**
* Retrieves the user input value through a non-Ajax submission.
*
* @param string $name Name of form control.
* @param string $default_value Optional default value.
* @return string The user input value through the form-control.
*/
function wpcf7_get_hangover( $name, $default_value = null ) {
if ( ! wpcf7_is_posted() ) {
return $default_value;
}
$submission = WPCF7_Submission::get_instance();
if ( ! $submission
or $submission->is( 'mail_sent' ) ) {
return $default_value;
}
return isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : $default_value;
}
/**
* Retrieves an HTML snippet of validation error on the given form control.
*
* @param string $name Name of form control.
* @return string Validation error message in a form of HTML snippet.
*/
function wpcf7_get_validation_error( $name ) {
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
return '';
}
return $contact_form->validation_error( $name );
}
/**
* Returns a reference key to a validation error message.
*
* @param string $name Name of form control.
* @param string $unit_tag Optional. Unit tag of the contact form.
* @return string Reference key code.
*/
function wpcf7_get_validation_error_reference( $name, $unit_tag = '' ) {
if ( '' === $unit_tag ) {
$contact_form = wpcf7_get_current_contact_form();
if ( $contact_form and $contact_form->validation_error( $name ) ) {
$unit_tag = $contact_form->unit_tag();
} else {
return null;
}
}
return preg_replace( '/[^0-9a-z_-]+/i', '',
sprintf(
'%1$s-ve-%2$s',
$unit_tag,
$name
)
);
}
/**
* Retrieves a message for the given status.
*/
function wpcf7_get_message( $status ) {
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
return '';
}
return $contact_form->message( $status );
}
/**
* Returns a class names list for a form-tag of the specified type.
*
* @param string $type Form-tag type.
* @param string $default_classes Optional default classes.
* @return string Whitespace-separated list of class names.
*/
function wpcf7_form_controls_class( $type, $default_classes = '' ) {
$type = trim( $type );
$default_classes = array_filter( explode( ' ', $default_classes ) );
$classes = array_merge( array( 'wpcf7-form-control' ), $default_classes );
$typebase = rtrim( $type, '*' );
$required = ( '*' == substr( $type, -1 ) );
$classes[] = 'wpcf7-' . $typebase;
if ( $required ) {
$classes[] = 'wpcf7-validates-as-required';
}
$classes = array_unique( $classes );
return implode( ' ', $classes );
}
/**
* Callback function for the contact-form-7 shortcode.
*/
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_title' => '',
'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 sprintf(
'<p class="wpcf7-contact-form-not-found"><strong>%1$s</strong> %2$s</p>',
esc_html( __( 'Error:', 'contact-form-7' ) ),
esc_html( __( "Contact form not found.", 'contact-form-7' ) )
);
}
$callback = static function ( $contact_form, $atts ) {
return $contact_form->form_html( $atts );
};
return wpcf7_switch_locale(
$contact_form->locale(),
$callback,
$contact_form, $atts
);
}
/**
* Saves the contact form data.
*/
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 = wp_unslash( $args );
$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 = array();
if ( null !== $args['form'] ) {
$properties['form'] = wpcf7_sanitize_form( $args['form'] );
}
if ( null !== $args['mail'] ) {
$properties['mail'] = wpcf7_sanitize_mail( $args['mail'] );
$properties['mail']['active'] = true;
}
if ( null !== $args['mail_2'] ) {
$properties['mail_2'] = wpcf7_sanitize_mail( $args['mail_2'] );
}
if ( null !== $args['messages'] ) {
$properties['messages'] = wpcf7_sanitize_messages( $args['messages'] );
}
if ( null !== $args['additional_settings'] ) {
$properties['additional_settings'] = wpcf7_sanitize_additional_settings(
$args['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;
}
/**
* Sanitizes the form property data.
*/
function wpcf7_sanitize_form( $input, $default_template = '' ) {
if ( null === $input ) {
return $default_template;
}
$output = trim( $input );
if ( ! current_user_can( 'unfiltered_html' ) ) {
$output = wpcf7_kses( $output, 'form' );
}
return $output;
}
/**
* Sanitizes the mail property data.
*/
function wpcf7_sanitize_mail( $input, $defaults = array() ) {
$input = wp_parse_args( $input, 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'] );
if ( ! current_user_can( 'unfiltered_html' ) ) {
$output['body'] = wpcf7_kses( $output['body'], 'mail' );
}
$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;
}
/**
* Sanitizes the messages property data.
*/
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;
}
/**
* Sanitizes the additional settings property data.
*/
function wpcf7_sanitize_additional_settings( $input, $default_template = '' ) {
if ( null === $input ) {
return $default_template;
}
$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
[text* your-name autocomplete:name] </label>
<label> %3$s
[email* your-email autocomplete:email] </label>
<label> %4$s
[text* your-subject] </label>
<label> %5$s %1$s
[textarea your-message] </label>
[submit "%6$s"]',
__( '(optional)', 'contact-form-7' ),
__( 'Your name', 'contact-form-7' ),
__( 'Your email', 'contact-form-7' ),
__( 'Subject', 'contact-form-7' ),
__( 'Your message', 'contact-form-7' ),
__( 'Submit', 'contact-form-7' )
);
return trim( $template );
}
public static function mail() {
$template = array(
'subject' => sprintf(
/* translators: 1: blog name, 2: [your-subject] */
_x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
'[_site_title]',
'[your-subject]'
),
'sender' => sprintf(
'%s <%s>',
'[_site_title]',
self::from_email()
),
'body' =>
sprintf(
/* translators: %s: [your-name] [your-email] */
__( 'From: %s', 'contact-form-7' ),
'[your-name] [your-email]'
) . "\n"
. sprintf(
/* translators: %s: [your-subject] */
__( 'Subject: %s', 'contact-form-7' ),
'[your-subject]'
) . "\n\n"
. __( 'Message Body:', 'contact-form-7' )
. "\n" . '[your-message]' . "\n\n"
. '-- ' . "\n"
. sprintf(
/* translators: 1: blog name, 2: blog URL */
__( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
'[_site_title]',
'[_site_url]'
),
'recipient' => '[_site_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(
/* translators: 1: blog name, 2: [your-subject] */
_x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
'[_site_title]',
'[your-subject]'
),
'sender' => sprintf(
'%s <%s>',
'[_site_title]',
self::from_email()
),
'body' =>
__( 'Message Body:', 'contact-form-7' )
. "\n" . '[your-message]' . "\n\n"
. '-- ' . "\n"
. sprintf(
/* translators: 1: blog name, 2: blog URL */
__( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
'[_site_title]',
'[_site_url]'
),
'recipient' => '[your-email]',
'additional_headers' => sprintf(
'Reply-To: %s',
'[_site_admin_email]'
),
'attachments' => '',
'use_html' => 0,
'exclude_blank' => 0,
);
return $template;
}
public static function from_email() {
$admin_email = get_option( 'admin_email' );
if ( wpcf7_is_localhost() ) {
return $admin_email;
}
$sitename = wp_parse_url( network_home_url(), PHP_URL_HOST );
$sitename = strtolower( $sitename );
if ( 'www.' === substr( $sitename, 0, 4 ) ) {
$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'
=> __( "Please fill out this field.", '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'
=> __( "This field has a too long input.", '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'
=> __( "This field has a too short input.", 'contact-form-7' ),
),
);
return apply_filters( 'wpcf7_messages', $messages );
}
<?php
/**
* Controller for front-end requests, scripts, and styles
*/
add_action(
'parse_request',
'wpcf7_control_init',
20, 0
);
/**
* Handles a submission in non-Ajax mode.
*/
function wpcf7_control_init() {
if ( WPCF7_Submission::is_restful() ) {
return;
}
if ( isset( $_POST['_wpcf7'] ) ) {
$contact_form = wpcf7_contact_form( (int) $_POST['_wpcf7'] );
if ( $contact_form ) {
$contact_form->submit();
}
}
}
/**
* Registers main scripts and styles.
*/
add_action(
'wp_enqueue_scripts',
static function () {
$assets = array();
$asset_file = wpcf7_plugin_path( 'includes/js/index.asset.php' );
if ( file_exists( $asset_file ) ) {
$assets = include( $asset_file );
}
$assets = wp_parse_args( $assets, array(
'dependencies' => array(),
'version' => WPCF7_VERSION,
) );
wp_register_script(
'contact-form-7',
wpcf7_plugin_url( 'includes/js/index.js' ),
array_merge(
$assets['dependencies'],
array( 'swv' )
),
$assets['version'],
true
);
wp_register_script(
'contact-form-7-html5-fallback',
wpcf7_plugin_url( 'includes/js/html5-fallback.js' ),
array( 'jquery-ui-datepicker' ),
WPCF7_VERSION,
true
);
if ( wpcf7_load_js() ) {
wpcf7_enqueue_scripts();
}
wp_register_style(
'contact-form-7',
wpcf7_plugin_url( 'includes/css/styles.css' ),
array(),
WPCF7_VERSION,
'all'
);
wp_register_style(
'contact-form-7-rtl',
wpcf7_plugin_url( 'includes/css/styles-rtl.css' ),
array( 'contact-form-7' ),
WPCF7_VERSION,
'all'
);
wp_register_style(
'jquery-ui-smoothness',
wpcf7_plugin_url(
'includes/js/jquery-ui/themes/smoothness/jquery-ui.min.css'
),
array(),
'1.12.1',
'screen'
);
if ( wpcf7_load_css() ) {
wpcf7_enqueue_styles();
}
},
10, 0
);
/**
* Enqueues scripts.
*/
function wpcf7_enqueue_scripts() {
wp_enqueue_script( 'contact-form-7' );
$wpcf7 = array(
'api' => array(
'root' => sanitize_url( get_rest_url() ),
'namespace' => 'contact-form-7/v1',
),
);
if ( defined( 'WP_CACHE' ) and WP_CACHE ) {
$wpcf7['cached'] = 1;
}
wp_localize_script( 'contact-form-7', 'wpcf7', $wpcf7 );
do_action( 'wpcf7_enqueue_scripts' );
}
/**
* Returns true if the main script is enqueued.
*/
function wpcf7_script_is() {
return wp_script_is( 'contact-form-7' );
}
/**
* Enqueues styles.
*/
function wpcf7_enqueue_styles() {
wp_enqueue_style( 'contact-form-7' );
if ( wpcf7_is_rtl() ) {
wp_enqueue_style( 'contact-form-7-rtl' );
}
do_action( 'wpcf7_enqueue_styles' );
}
/**
* Returns true if the main stylesheet is enqueued.
*/
function wpcf7_style_is() {
return wp_style_is( 'contact-form-7' );
}
add_action(
'wp_enqueue_scripts',
'wpcf7_html5_fallback',
20, 0
);
/**
* Enqueues scripts and styles for the HTML5 fallback.
*/
function wpcf7_html5_fallback() {
if ( ! wpcf7_support_html5_fallback() ) {
return;
}
if ( wpcf7_script_is() ) {
wp_enqueue_script( 'contact-form-7-html5-fallback' );
}
if ( wpcf7_style_is() ) {
wp_enqueue_style( 'jquery-ui-smoothness' );
}
}
.wpcf7-not-valid-tip {
direction: rtl;
}
.use-floating-validation-tip .wpcf7-not-valid-tip {
right: 1em;
}
.wpcf7-list-item {
margin: 0 1em 0 0;
}
.wpcf7 .screen-reader-response {
position: absolute;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
clip-path: inset(50%);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
border: 0;
word-wrap: normal !important;
}
.wpcf7 form .wpcf7-response-output {
margin: 2em 0.5em 1em;
padding: 0.2em 1em;
border: 2px solid #00a0d2; /* Blue */
}
.wpcf7 form.init .wpcf7-response-output,
.wpcf7 form.resetting .wpcf7-response-output,
.wpcf7 form.submitting .wpcf7-response-output {
display: none;
}
.wpcf7 form.sent .wpcf7-response-output {
border-color: #46b450; /* Green */
}
.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output {
border-color: #dc3232; /* Red */
}
.wpcf7 form.spam .wpcf7-response-output {
border-color: #f56e28; /* Orange */
}
.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.payment-required .wpcf7-response-output {
border-color: #ffb900; /* Yellow */
}
.wpcf7-form-control-wrap {
position: relative;
}
.wpcf7-not-valid-tip {
color: #dc3232; /* Red */
font-size: 1em;
font-weight: normal;
display: block;
}
.use-floating-validation-tip .wpcf7-not-valid-tip {
position: relative;
top: -2ex;
left: 1em;
z-index: 100;
border: 1px solid #dc3232;
background: #fff;
padding: .2em .8em;
width: 24em;
}
.wpcf7-list-item {
display: inline-block;
margin: 0 0 0 1em;
}
.wpcf7-list-item-label::before,
.wpcf7-list-item-label::after {
content: " ";
}
.wpcf7-spinner {
visibility: hidden;
display: inline-block;
background-color: #23282d; /* Dark Gray 800 */
opacity: 0.75;
width: 24px;
height: 24px;
border: none;
border-radius: 100%;
padding: 0;
margin: 0 24px;
position: relative;
}
form.submitting .wpcf7-spinner {
visibility: visible;
}
.wpcf7-spinner::before {
content: '';
position: absolute;
background-color: #fbfbfc; /* Light Gray 100 */
top: 4px;
left: 4px;
width: 6px;
height: 6px;
border: none;
border-radius: 100%;
transform-origin: 8px 8px;
animation-name: spin;
animation-duration: 1000ms;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
@media (prefers-reduced-motion: reduce) {
.wpcf7-spinner::before {
animation-name: blink;
animation-duration: 2000ms;
}
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes blink {
from {
opacity: 0;
}
50% {
opacity: 1;
}
to {
opacity: 0;
}
}
.wpcf7 input[type="file"] {
cursor: pointer;
}
.wpcf7 input[type="file"]:disabled {
cursor: default;
}
.wpcf7 .wpcf7-submit:disabled {
cursor: not-allowed;
}
.wpcf7 input[type="url"],
.wpcf7 input[type="email"],
.wpcf7 input[type="tel"] {
direction: ltr;
}
.wpcf7-reflection > output {
display: list-item;
list-style: none;
}
.wpcf7-reflection > output[hidden] {
display: none;
}
<?php
/**
* Integration API
*
* @link https://contactform7.com/integration-with-external-apis/
*/
class WPCF7_Integration {
private static $instance;
private $services = array();
private $categories = array();
private function __construct() {}
/**
* Returns initially supported service categories.
*
* @return array Service categories.
*/
public static function get_builtin_categories() {
return array(
'spam_protection' => __( 'Spam protection', 'contact-form-7' ),
'email_marketing' => __( 'Email marketing', 'contact-form-7' ),
'payments' => __( 'Payments', 'contact-form-7' ),
);
}
/**
* Returns the singleton instance of this class.
*
* @return WPCF7_Integration The instance.
*/
public static function get_instance() {
if ( empty( self::$instance ) ) {
self::$instance = new self;
self::$instance->categories = self::get_builtin_categories();
}
return self::$instance;
}
/**
* Adds a service to the services list.
*/
public function add_service( $name, WPCF7_Service $service ) {
$name = sanitize_key( $name );
if ( empty( $name )
or isset( $this->services[$name] ) ) {
return false;
}
$this->services[$name] = $service;
}
/**
* Adds a service category to the categories list.
*/
public function add_category( $name, $title ) {
$name = sanitize_key( $name );
if ( empty( $name )
or isset( $this->categories[$name] ) ) {
return false;
}
$this->categories[$name] = $title;
}
/**
* Returns true if a service with the name exists in the services list.
*
* @param string $name The name of service to search.
*/
public function service_exists( $name = '' ) {
if ( '' == $name ) {
return (bool) count( $this->services );
} else {
return isset( $this->services[$name] );
}
}
/**
* Returns a service object with the name.
*
* @param string $name The name of service.
* @return WPCF7_Service|bool The service object if it exists,
* false otherwise.
*/
public function get_service( $name ) {
if ( $this->service_exists( $name ) ) {
return $this->services[$name];
} else {
return false;
}
}
/**
* Prints services list.
*/
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 ) ); ?>
</div>
<br class="clear" />
<div class="inside">
<?php
if ( $singular ) {
$service->display( $action );
} else {
$service->display();
}
?>
</div>
</div>
<?php
}
}
}
/**
* Abstract class for services.
*
* Only instances of this class's subclasses are allowed to be
* listed on the Integration page.
*/
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 = '' ) {
}
}
/**
* Class for services that use OAuth.
*
* While this is not an abstract class, subclassing this class for
* your aim is advised.
*/
class WPCF7_Service_OAuth2 extends WPCF7_Service {
protected $client_id = '';
protected $client_secret = '';
protected $access_token = '';
protected $refresh_token = '';
protected $authorization_endpoint = 'https://example.com/authorization';
protected $token_endpoint = 'https://example.com/token';
public function get_title() {
return '';
}
public function is_active() {
return ! empty( $this->refresh_token );
}
protected function save_data() {
}
protected function reset_data() {
}
protected function get_redirect_uri() {
return admin_url();
}
protected function menu_page_url( $args = '' ) {
return menu_page_url( 'wpcf7-integration', false );
}
public function load( $action = '' ) {
if ( 'auth_redirect' == $action ) {
$code = isset( $_GET['code'] ) ? $_GET['code'] : '';
if ( $code ) {
$this->request_token( $code );
}
if ( ! empty( $this->access_token ) ) {
$message = 'success';
} else {
$message = 'failed';
}
wp_safe_redirect( $this->menu_page_url(
array(
'action' => 'setup',
'message' => $message,
)
) );
exit();
}
}
protected function authorize( $scope = '' ) {
$endpoint = add_query_arg(
array(
'response_type' => 'code',
'client_id' => $this->client_id,
'redirect_uri' => urlencode( $this->get_redirect_uri() ),
'scope' => $scope,
),
$this->authorization_endpoint
);
if ( wp_redirect( sanitize_url( $endpoint ) ) ) {
exit();
}
}
protected function get_http_authorization_header( $scheme = 'basic' ) {
$scheme = strtolower( trim( $scheme ) );
switch ( $scheme ) {
case 'bearer':
return sprintf( 'Bearer %s', $this->access_token );
case 'basic':
default:
return sprintf( 'Basic %s',
base64_encode( $this->client_id . ':' . $this->client_secret )
);
}
}
protected function request_token( $authorization_code ) {
$endpoint = add_query_arg(
array(
'code' => $authorization_code,
'redirect_uri' => urlencode( $this->get_redirect_uri() ),
'grant_type' => 'authorization_code',
),
$this->token_endpoint
);
$request = array(
'headers' => array(
'Authorization' => $this->get_http_authorization_header( 'basic' ),
),
);
$response = wp_remote_post( sanitize_url( $endpoint ), $request );
$response_code = (int) wp_remote_retrieve_response_code( $response );
$response_body = wp_remote_retrieve_body( $response );
$response_body = json_decode( $response_body, true );
if ( WP_DEBUG and 400 <= $response_code ) {
$this->log( $endpoint, $request, $response );
}
if ( 401 == $response_code ) { // Unauthorized
$this->access_token = null;
$this->refresh_token = null;
} else {
if ( isset( $response_body['access_token'] ) ) {
$this->access_token = $response_body['access_token'];
} else {
$this->access_token = null;
}
if ( isset( $response_body['refresh_token'] ) ) {
$this->refresh_token = $response_body['refresh_token'];
} else {
$this->refresh_token = null;
}
}
$this->save_data();
return $response;
}
protected function refresh_token() {
$endpoint = add_query_arg(
array(
'refresh_token' => $this->refresh_token,
'grant_type' => 'refresh_token',
),
$this->token_endpoint
);
$request = array(
'headers' => array(
'Authorization' => $this->get_http_authorization_header( 'basic' ),
),
);
$response = wp_remote_post( sanitize_url( $endpoint ), $request );
$response_code = (int) wp_remote_retrieve_response_code( $response );
$response_body = wp_remote_retrieve_body( $response );
$response_body = json_decode( $response_body, true );
if ( WP_DEBUG and 400 <= $response_code ) {
$this->log( $endpoint, $request, $response );
}
if ( 401 == $response_code ) { // Unauthorized
$this->access_token = null;
$this->refresh_token = null;
} else {
if ( isset( $response_body['access_token'] ) ) {
$this->access_token = $response_body['access_token'];
} else {
$this->access_token = null;
}
if ( isset( $response_body['refresh_token'] ) ) {
$this->refresh_token = $response_body['refresh_token'];
}
}
$this->save_data();
return $response;
}
protected function remote_request( $url, $request = array() ) {
static $refreshed = false;
$request = wp_parse_args( $request, array() );
$request['headers'] = array_merge(
$request['headers'],
array(
'Authorization' => $this->get_http_authorization_header( 'bearer' ),
)
);
$response = wp_remote_request( sanitize_url( $url ), $request );
if ( 401 === wp_remote_retrieve_response_code( $response )
and ! $refreshed ) {
$this->refresh_token();
$refreshed = true;
$response = $this->remote_request( $url, $request );
}
return $response;
}
protected function log( $url, $request, $response ) {
wpcf7_log_remote_request( $url, $request, $response );
}
}
( function( $ ) {
$( function() {
var supportHtml5 = ( function() {
var features = {};
var input = document.createElement( 'input' );
var inputTypes = [ 'date' ];
$.each( inputTypes, function( index, value ) {
input.setAttribute( 'type', value );
features[ value ] = input.type !== 'text';
} );
return features;
} )();
if ( ! supportHtml5.date ) {
$( 'input.wpcf7-date[type="date"]' ).each( function() {
$( this ).datepicker( {
dateFormat: 'yy-mm-dd',
minDate: new Date( $( this ).attr( 'min' ) ),
maxDate: new Date( $( this ).attr( 'max' ) )
} );
} );
}
} );
} )( jQuery );
<?php
return array(
'dependencies' => array(),
'version' => WPCF7_VERSION,
);
<?php
/**
* Retrieves an associative array of languages to which
* this plugin is translated.
*
* @return array Array of languages.
*/
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 )
or empty( $api['translations'] ) ) {
return $l10n;
}
foreach ( (array) $api['translations'] as $translation ) {
if ( ! empty( $translation['language'] )
and ! empty( $translation['english_name'] ) ) {
$l10n[$translation['language']] = $translation['english_name'];
}
}
return $l10n;
}
/**
* Returns true if the given locale code looks valid.
*
* @param string $locale Locale code.
*/
function wpcf7_is_valid_locale( $locale ) {
if ( ! is_string( $locale ) ) {
return false;
}
$pattern = '/^[a-z]{2,3}(?:_[a-zA-Z_]{2,})?$/';
return (bool) preg_match( $pattern, $locale );
}
/**
* Returns true if the given locale is an RTL language.
*/
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 )
and function_exists( 'is_rtl' ) ) {
return is_rtl();
}
if ( empty( $locale ) ) {
$locale = determine_locale();
}
return isset( $rtl_locales[$locale] );
}
/**
* Loads a translation file into the plugin's text domain.
*
* @param string $locale Locale code.
* @return bool True on success, false on failure.
*/
function wpcf7_load_textdomain( $locale = '' ) {
$mofile = path_join(
WP_LANG_DIR . '/plugins/',
sprintf( '%s-%s.mo', WPCF7_TEXT_DOMAIN, $locale )
);
return load_textdomain( WPCF7_TEXT_DOMAIN, $mofile, $locale );
}
/**
* Unloads translations for the plugin's text domain.
*
* @param bool $reloadable Whether the text domain can be loaded
* just-in-time again.
* @return bool True on success, false on failure.
*/
function wpcf7_unload_textdomain( $reloadable = false ) {
return unload_textdomain( WPCF7_TEXT_DOMAIN, $reloadable );
}
/**
* Switches translation locale, calls the callback, then switches back
* to the original locale.
*
* @param string $locale Locale code.
* @param callable $callback The callable to be called.
* @param mixed $args Parameters to be passed to the callback.
* @return mixed The return value of the callback.
*/
function wpcf7_switch_locale( $locale, callable $callback, ...$args ) {
static $available_locales = null;
if ( ! isset( $available_locales ) ) {
$available_locales = array_merge(
array( 'en_US' ),
get_available_languages()
);
}
$previous_locale = determine_locale();
$do_switch_locale = (
$locale !== $previous_locale &&
in_array( $locale, $available_locales, true ) &&
in_array( $previous_locale, $available_locales, true )
);
if ( $do_switch_locale ) {
wpcf7_unload_textdomain();
switch_to_locale( $locale );
wpcf7_load_textdomain( $locale );
}
$result = call_user_func( $callback, ...$args );
if ( $do_switch_locale ) {
wpcf7_unload_textdomain( true );
restore_previous_locale();
wpcf7_load_textdomain( $previous_locale );
}
return $result;
}
<?php
/**
* Pipe-related classes.
*
* @link https://contactform7.com/selectable-recipient-with-pipes/
*/
/**
* Class representing a pair of pipe.
*/
class WPCF7_Pipe {
public $before = '';
public $after = '';
public function __construct( $text ) {
$text = (string) $text;
$pipe_pos = strpos( $text, '|' );
if ( false === $pipe_pos ) {
$this->before = $this->after = trim( $text );
} else {
$this->before = trim( substr( $text, 0, $pipe_pos ) );
$this->after = trim( substr( $text, $pipe_pos + 1 ) );
}
}
}
/**
* Class representing a list of pipes.
*/
class WPCF7_Pipes {
private $pipes = array();
public function __construct( array $texts ) {
foreach ( $texts as $text ) {
$this->add_pipe( $text );
}
}
private function add_pipe( $text ) {
$pipe = new WPCF7_Pipe( $text );
$this->pipes[] = $pipe;
}
public function do_pipe( $input ) {
$input_canonical = wpcf7_canonicalize( $input, array(
'strto' => 'as-is',
) );
foreach ( $this->pipes as $pipe ) {
$before_canonical = wpcf7_canonicalize( $pipe->before, array(
'strto' => 'as-is',
) );
if ( $input_canonical === $before_canonical ) {
return $pipe->after;
}
}
return $input;
}
public function collect_befores() {
$befores = array();
foreach ( $this->pipes as $pipe ) {
$befores[] = $pipe->before;
}
return $befores;
}
public function collect_afters() {
$afters = array();
foreach ( $this->pipes as $pipe ) {
$afters[] = $pipe->after;
}
return $afters;
}
public function zero() {
return empty( $this->pipes );
}
public function random_pipe() {
if ( $this->zero() ) {
return null;
}
return $this->pipes[array_rand( $this->pipes )];
}
public function to_array() {
return array_map(
static function ( WPCF7_Pipe $pipe ) {
return array(
$pipe->before,
$pipe->after,
);
},
$this->pipes
);
}
}
<?php
/**
* Handy trait provides methods to handle dynamic properties.
*/
trait WPCF7_PocketHolder {
protected $pocket = array();
public function pull( $key ) {
if ( isset( $this->pocket[$key] ) ) {
return $this->pocket[$key];
}
}
public function push( $key, $value ) {
$this->pocket[$key] = $value;
}
}
<?php
/**
* All the functions and classes in this file are deprecated.
* You should not use them. The functions and classes will be
* removed in a later version.
*/
function wpcf7_add_shortcode( $tag, $callback, $has_name = false ) {
wpcf7_deprecated_function( __FUNCTION__, '4.6', 'wpcf7_add_form_tag' );
return wpcf7_add_form_tag( $tag, $callback, $has_name );
}
function wpcf7_remove_shortcode( $tag ) {
wpcf7_deprecated_function( __FUNCTION__, '4.6', 'wpcf7_remove_form_tag' );
return wpcf7_remove_form_tag( $tag );
}
function wpcf7_do_shortcode( $content ) {
wpcf7_deprecated_function( __FUNCTION__, '4.6',
'wpcf7_replace_all_form_tags' );
return wpcf7_replace_all_form_tags( $content );
}
function wpcf7_scan_shortcode( $cond = null ) {
wpcf7_deprecated_function( __FUNCTION__, '4.6', 'wpcf7_scan_form_tags' );
return wpcf7_scan_form_tags( $cond );
}
class WPCF7_ShortcodeManager {
private static $form_tags_manager;
private function __construct() {}
public static function get_instance() {
wpcf7_deprecated_function( __METHOD__, '4.6',
'WPCF7_FormTagsManager::get_instance' );
self::$form_tags_manager = WPCF7_FormTagsManager::get_instance();
return new self;
}
public function get_scanned_tags() {
wpcf7_deprecated_function( __METHOD__, '4.6',
'WPCF7_FormTagsManager::get_scanned_tags' );
return self::$form_tags_manager->get_scanned_tags();
}
public function add_shortcode( $tag, $callback, $has_name = false ) {
wpcf7_deprecated_function( __METHOD__, '4.6',
'WPCF7_FormTagsManager::add' );
return self::$form_tags_manager->add( $tag, $callback, $has_name );
}
public function remove_shortcode( $tag ) {
wpcf7_deprecated_function( __METHOD__, '4.6',
'WPCF7_FormTagsManager::remove' );
return self::$form_tags_manager->remove( $tag );
}
public function normalize_shortcode( $content ) {
wpcf7_deprecated_function( __METHOD__, '4.6',
'WPCF7_FormTagsManager::normalize' );
return self::$form_tags_manager->normalize( $content );
}
public function do_shortcode( $content, $exec = true ) {
wpcf7_deprecated_function( __METHOD__, '4.6',
'WPCF7_FormTagsManager::replace_all' );
if ( $exec ) {
return self::$form_tags_manager->replace_all( $content );
} else {
return self::$form_tags_manager->scan( $content );
}
}
public function scan_shortcode( $content ) {
wpcf7_deprecated_function( __METHOD__, '4.6',
'WPCF7_FormTagsManager::scan' );
return self::$form_tags_manager->scan( $content );
}
}
class WPCF7_Shortcode extends WPCF7_FormTag {
public function __construct( $tag ) {
wpcf7_deprecated_function( 'WPCF7_Shortcode', '4.6', 'WPCF7_FormTag' );
parent::__construct( $tag );
}
}
<?php
/**
** Special Mail Tags
** https://contactform7.com/special-mail-tags/
**/
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_special_mail_tag', 10, 4 );
/**
* Returns output string of a special mail-tag.
*
* @param string $output The string to be output.
* @param string $name The tag name of the special mail-tag.
* @param bool $html Whether the mail-tag is used in an HTML content.
* @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
* @return string Output of the given special mail-tag.
*/
function wpcf7_special_mail_tag( $output, $name, $html, $mail_tag = null ) {
if ( ! $mail_tag instanceof WPCF7_MailTag ) {
wpcf7_doing_it_wrong(
sprintf( '%s()', __FUNCTION__ ),
__( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
'5.2.2'
);
}
$name = preg_replace( '/^wpcf7\./', '_', $name ); // for back-compat
$submission = WPCF7_Submission::get_instance();
if ( ! $submission ) {
return $output;
}
if ( '_remote_ip' == $name ) {
if ( $remote_ip = $submission->get_meta( 'remote_ip' ) ) {
return $remote_ip;
} else {
return '';
}
}
if ( '_user_agent' == $name ) {
if ( $user_agent = $submission->get_meta( 'user_agent' ) ) {
return $html ? esc_html( $user_agent ) : $user_agent;
} else {
return '';
}
}
if ( '_url' == $name ) {
if ( $url = $submission->get_meta( 'url' ) ) {
return $url;
} else {
return '';
}
}
if ( '_date' == $name
or '_time' == $name ) {
if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
if ( '_date' == $name ) {
return wp_date( get_option( 'date_format' ), $timestamp );
}
if ( '_time' == $name ) {
return wp_date( get_option( 'time_format' ), $timestamp );
}
}
return '';
}
if ( '_invalid_fields' == $name ) {
return count( $submission->get_invalid_fields() );
}
return $output;
}
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_post_related_smt', 10, 4 );
/**
* Returns output string of a special mail-tag.
*
* @param string $output The string to be output.
* @param string $name The tag name of the special mail-tag.
* @param bool $html Whether the mail-tag is used in an HTML content.
* @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
* @return string Output of the given special mail-tag.
*/
function wpcf7_post_related_smt( $output, $name, $html, $mail_tag = null ) {
if ( ! $mail_tag instanceof WPCF7_MailTag ) {
wpcf7_doing_it_wrong(
sprintf( '%s()', __FUNCTION__ ),
__( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
'5.2.2'
);
}
if ( '_post_' != substr( $name, 0, 6 ) ) {
return $output;
}
$submission = WPCF7_Submission::get_instance();
if ( ! $submission ) {
return $output;
}
$post_id = (int) $submission->get_meta( 'container_post_id' );
if ( ! $post_id
or ! $post = get_post( $post_id ) ) {
return '';
}
if ( '_post_id' == $name ) {
return (string) $post->ID;
}
if ( '_post_name' == $name ) {
return $post->post_name;
}
if ( '_post_title' == $name ) {
return $html ? esc_html( $post->post_title ) : $post->post_title;
}
if ( '_post_url' == $name ) {
return get_permalink( $post->ID );
}
$user = new WP_User( $post->post_author );
if ( '_post_author' == $name ) {
return $user->display_name;
}
if ( '_post_author_email' == $name ) {
return $user->user_email;
}
return $output;
}
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_site_related_smt', 10, 4 );
/**
* Returns output string of a special mail-tag.
*
* @param string $output The string to be output.
* @param string $name The tag name of the special mail-tag.
* @param bool $html Whether the mail-tag is used in an HTML content.
* @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
* @return string Output of the given special mail-tag.
*/
function wpcf7_site_related_smt( $output, $name, $html, $mail_tag = null ) {
if ( ! $mail_tag instanceof WPCF7_MailTag ) {
wpcf7_doing_it_wrong(
sprintf( '%s()', __FUNCTION__ ),
__( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
'5.2.2'
);
}
$filter = $html ? 'display' : 'raw';
if ( '_site_title' == $name ) {
$output = get_bloginfo( 'name', $filter );
if ( ! $html ) {
$output = wp_specialchars_decode( $output, ENT_QUOTES );
}
return $output;
}
if ( '_site_description' == $name ) {
$output = get_bloginfo( 'description', $filter );
if ( ! $html ) {
$output = wp_specialchars_decode( $output, ENT_QUOTES );
}
return $output;
}
if ( '_site_url' == $name ) {
return get_bloginfo( 'url', $filter );
}
if ( '_site_admin_email' == $name ) {
return get_bloginfo( 'admin_email', $filter );
}
return $output;
}
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_user_related_smt', 10, 4 );
/**
* Returns output string of a special mail-tag.
*
* @param string $output The string to be output.
* @param string $name The tag name of the special mail-tag.
* @param bool $html Whether the mail-tag is used in an HTML content.
* @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
* @return string Output of the given special mail-tag.
*/
function wpcf7_user_related_smt( $output, $name, $html, $mail_tag = null ) {
if ( ! $mail_tag instanceof WPCF7_MailTag ) {
wpcf7_doing_it_wrong(
sprintf( '%s()', __FUNCTION__ ),
__( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
'5.2.2'
);
}
if ( '_user_' != substr( $name, 0, 6 )
or '_user_agent' == $name ) {
return $output;
}
$submission = WPCF7_Submission::get_instance();
if ( ! $submission ) {
return $output;
}
$user_id = (int) $submission->get_meta( 'current_user_id' );
if ( ! $user_id ) {
return '';
}
$primary_props = array( 'user_login', 'user_email', 'user_url' );
$opt = ltrim( $name, '_' );
$opt = in_array( $opt, $primary_props ) ? $opt : substr( $opt, 5 );
$user = new WP_User( $user_id );
if ( $user->has_prop( $opt ) ) {
return $user->get( $opt );
}
return '';
}
<?php
return array(
'dependencies' => array(),
'version' => WPCF7_VERSION,
);
<?php
class WPCF7_SWV_DateRule extends WPCF7_SWV_Rule {
const rule_name = 'date';
public function matches( $context ) {
if ( false === parent::matches( $context ) ) {
return false;
}
if ( empty( $context['text'] ) ) {
return false;
}
return true;
}
public function validate( $context ) {
$field = $this->get_property( 'field' );
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
$input = wpcf7_array_flatten( $input );
$input = wpcf7_exclude_blank( $input );
foreach ( $input as $i ) {
if ( ! wpcf7_is_date( $i ) ) {
return new WP_Error( 'wpcf7_invalid_date',
$this->get_property( 'error' )
);
}
}
return true;
}
public function to_array() {
return array( 'rule' => self::rule_name ) + (array) $this->properties;
}
}
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.