home
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
function wpcf7_current_action() {
|
||||
foreach ( array( 'action', 'action2' ) as $var ) {
|
||||
$action = wpcf7_superglobal_request( $var, null );
|
||||
|
||||
if ( isset( $action ) and -1 !== $action ) {
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
add_action(
|
||||
'wp_ajax_wpcf7-dashboard-widgets',
|
||||
'wpcf7_ajax_dashboard_widgets',
|
||||
10, 0
|
||||
);
|
||||
|
||||
/**
|
||||
* Ajax action to update the Contact Form 7 news in the Dashboard screen.
|
||||
*/
|
||||
function wpcf7_ajax_dashboard_widgets() {
|
||||
require_once WPCF7_PLUGIN_DIR . '/admin/includes/dashboard.php';
|
||||
|
||||
set_current_screen( 'toplevel_page_wpcf7-dashboard' );
|
||||
|
||||
if ( 'dashboard_primary' === wpcf7_superglobal_get( 'widget' ) ) {
|
||||
wpcf7_dashboard_cf7com_news();
|
||||
}
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
|
||||
add_action(
|
||||
'wp_ajax_wpcf7-sendinblue-contact-lists',
|
||||
'wpcf7_ajax_sendinblue_contact_lists',
|
||||
10, 0
|
||||
);
|
||||
|
||||
/**
|
||||
* Ajax action to update the contact lists in the Brevo editor panel.
|
||||
*/
|
||||
function wpcf7_ajax_sendinblue_contact_lists() {
|
||||
$contact_form = wpcf7_contact_form( wpcf7_superglobal_get( 'id' ) );
|
||||
|
||||
$prop = wp_parse_args(
|
||||
$contact_form ? $contact_form->prop( 'sendinblue' ) : array(),
|
||||
array(
|
||||
'enable_contact_list' => false,
|
||||
'contact_lists' => array(),
|
||||
'enable_transactional_email' => false,
|
||||
'email_template' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
wpcf7_sendinblue_editor_lists( $prop['contact_lists'] );
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
|
||||
add_action(
|
||||
'wp_ajax_wpcf7-sendinblue-email-template',
|
||||
'wpcf7_ajax_sendinblue_email_template',
|
||||
10, 0
|
||||
);
|
||||
|
||||
/**
|
||||
* Ajax action to update the email templates in the Brevo editor panel.
|
||||
*/
|
||||
function wpcf7_ajax_sendinblue_email_template() {
|
||||
$contact_form = wpcf7_contact_form( wpcf7_superglobal_get( 'id' ) );
|
||||
|
||||
$prop = wp_parse_args(
|
||||
$contact_form ? $contact_form->prop( 'sendinblue' ) : array(),
|
||||
array(
|
||||
'enable_contact_list' => false,
|
||||
'contact_lists' => array(),
|
||||
'enable_transactional_email' => false,
|
||||
'email_template' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
wpcf7_sendinblue_editor_templates( $prop['email_template'] );
|
||||
|
||||
wp_die();
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
wp_admin_notice(
|
||||
sprintf(
|
||||
'%1$s » %2$s',
|
||||
__( 'Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.', 'contact-form-7' ),
|
||||
wpcf7_link(
|
||||
add_query_arg(
|
||||
array( 'action' => 'validate' ),
|
||||
menu_page_url( 'wpcf7', false )
|
||||
),
|
||||
__( 'Validate Contact Form 7 Configuration', 'contact-form-7' )
|
||||
)
|
||||
),
|
||||
array( 'type' => 'warning' )
|
||||
);
|
||||
}
|
||||
|
||||
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' !== wpcf7_superglobal_server( 'REQUEST_METHOD' )
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
check_admin_referer( 'wpcf7-bulk-validate' );
|
||||
|
||||
if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
||||
wp_die( wp_kses_data( __( '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(
|
||||
/* translators: %s: number of contact forms */
|
||||
_n(
|
||||
'Validate %s contact form now',
|
||||
'Validate %s contact forms now',
|
||||
$count, 'contact-form-7'
|
||||
),
|
||||
number_format_i18n( $count )
|
||||
);
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter( array(
|
||||
'allowed_html' => array_merge( wpcf7_kses_allowed_html(), array(
|
||||
'form' => array(
|
||||
'action' => true,
|
||||
'method' => true,
|
||||
),
|
||||
) ),
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'div', array(
|
||||
'class' => 'wrap',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'h1' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Validate Configuration', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'h1' );
|
||||
|
||||
$formatter->append_start_tag( 'form', array(
|
||||
'method' => 'post',
|
||||
'action' => '',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->call_user_func( static function () {
|
||||
wp_nonce_field( 'wpcf7-bulk-validate' );
|
||||
} );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'action',
|
||||
'value' => 'validate',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'submit',
|
||||
'class' => 'button',
|
||||
'value' => $submit_text,
|
||||
) );
|
||||
|
||||
$formatter->end_tag( 'form' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
wpcf7_link(
|
||||
'https://contactform7.com/configuration-validator-faq/',
|
||||
__( 'FAQ about Configuration Validator', 'contact-form-7' )
|
||||
)
|
||||
);
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Form Tab
|
||||
*/
|
||||
.tag-generator-panel {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.tag-generator-dialog > .close-button {
|
||||
right: auto;
|
||||
left: 8px;
|
||||
}
|
||||
|
||||
form.tag-generator-panel[data-version="1"] {
|
||||
.control-box > fieldset > legend {
|
||||
border: 1px solid #dfdfdf;
|
||||
border-right: 4px solid #00a0d2;
|
||||
}
|
||||
|
||||
.insert-box input.tag {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.insert-box .submitbox input[type="button"] {
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Mail Tab
|
||||
*/
|
||||
.contact-form-editor-box-mail span.mailtag {
|
||||
margin: 0 4px 0 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dashboard
|
||||
*/
|
||||
#wpcf7_dashboard_right_now li a::before,
|
||||
#wpcf7_get_support li a::before {
|
||||
padding: 0 0 0 5px;
|
||||
}
|
||||
@@ -0,0 +1,566 @@
|
||||
#wpcf7-contact-form-editor a .dashicons {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap {
|
||||
margin-top: 1ex;
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap button.toggle-shortcode {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap button.toggle-shortcode::after {
|
||||
font: 1.2rem dashicons;
|
||||
content: "\f343" / "";
|
||||
padding-inline-start: 2px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap.hide-shortcode button.toggle-shortcode::after {
|
||||
content: "\f347" / "";
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap.hide-shortcode #wpcf7-shortcode-inside {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap p.description {
|
||||
margin: 8px 2px 0;
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap p.description label {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap span.shortcode {
|
||||
display: block;
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
#wpcf7-shortcode-wrap span.shortcode input {
|
||||
font-size: 12px;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
padding: 4px 8px;
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#submitpost button.copy {
|
||||
margin-bottom: 10px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#submitpost button.delete {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
background: inherit;
|
||||
color: #a00;
|
||||
}
|
||||
|
||||
#submitpost button.delete:hover {
|
||||
color: #dc3232; /* Red */
|
||||
}
|
||||
|
||||
#submitpost button.delete:focus {
|
||||
outline: thin dotted;
|
||||
}
|
||||
|
||||
.postbox-container .postbox h3 {
|
||||
border-bottom: 1px solid transparent;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#misc-publishing-actions .config-error {
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
[data-config-field][aria-invalid="true"] {
|
||||
border-color: #dc3232;
|
||||
}
|
||||
|
||||
#contact-form-editor-tabs .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: baseline;
|
||||
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 10px 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#contact-form-editor-tabs button {
|
||||
display: inline-block;
|
||||
border: 1px solid #ccc;
|
||||
border-bottom: 1px solid #aaa;
|
||||
padding: 6px 10px;
|
||||
margin: 0 4px -1px;
|
||||
color: #333;
|
||||
background-color: #e4e4e4;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
#contact-form-editor-tabs button[aria-selected="true"] {
|
||||
border-top: 1px solid #aaa;
|
||||
border-right: 1px solid #aaa;
|
||||
border-left: 1px solid #aaa;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
color: #000;
|
||||
background-color: #f5f5f5;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#contact-form-editor-tabs button:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#contact-form-editor .contact-form-editor-panel > div.config-error {
|
||||
margin-bottom: 1.4em;
|
||||
}
|
||||
|
||||
#contact-form-editor-tabs button[aria-selected="true"] .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: 0.6em 0 0.4em;
|
||||
}
|
||||
|
||||
/*
|
||||
* Form Tab
|
||||
*/
|
||||
#tag-generator-list button {
|
||||
font-size: 12px;
|
||||
height: 26px;
|
||||
line-height: 24px;
|
||||
margin: 2px;
|
||||
padding: 0 8px 1px;
|
||||
}
|
||||
|
||||
.tag-generator-dialog {
|
||||
padding: 12px;
|
||||
border: 1px solid #c3c4c7;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
|
||||
height: 720px;
|
||||
width: 720px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.tag-generator-dialog::backdrop {
|
||||
background: rgb(0 0 0 / 50%);
|
||||
}
|
||||
|
||||
.tag-generator-dialog > .close-button {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
}
|
||||
|
||||
form.tag-generator-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 720px;
|
||||
width: 720px;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
margin-block-end: 0;
|
||||
}
|
||||
|
||||
form.tag-generator-panel[data-version="2"] {
|
||||
&:invalid .mail-tag-tip {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.description-box {
|
||||
box-sizing: border-box;
|
||||
flex: none;
|
||||
margin-inline: -12px;
|
||||
padding-inline: 12px;
|
||||
border-bottom: 1px solid #dfdfdf;
|
||||
}
|
||||
|
||||
.control-box {
|
||||
box-sizing: border-box;
|
||||
flex: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px 0;
|
||||
min-height: 120px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.control-box > fieldset {
|
||||
margin-block: 8px;
|
||||
margin-inline-start: 10em;
|
||||
line-height: 2.25;
|
||||
}
|
||||
|
||||
.control-box > fieldset > legend {
|
||||
font-weight: bolder;
|
||||
margin-block: 8px;
|
||||
margin-inline-start: -10em;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.control-box input[type="text"] {
|
||||
width: 20rem;
|
||||
max-width: 88%;
|
||||
}
|
||||
|
||||
.control-box input[type="number"] {
|
||||
width: 8rem;
|
||||
max-width: 44%;
|
||||
}
|
||||
|
||||
.control-box textarea {
|
||||
height: 12ex;
|
||||
width: 20rem;
|
||||
max-width: 88%;
|
||||
}
|
||||
|
||||
.control-box select {
|
||||
width: 20rem;
|
||||
max-width: 88%;
|
||||
}
|
||||
|
||||
.control-box input:invalid,
|
||||
.control-box textarea:invalid {
|
||||
background-color: #ffe9de;
|
||||
}
|
||||
|
||||
.insert-box {
|
||||
box-sizing: border-box;
|
||||
flex: none;
|
||||
margin-block-end: -12px;
|
||||
margin-inline: -12px;
|
||||
padding-block: 24px 12px;
|
||||
padding-inline: 12px;
|
||||
background-color: #fcfcfc;
|
||||
border-top: 1px solid #dfdfdf;
|
||||
}
|
||||
|
||||
.insert-box .flex-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.insert-box .flex-container > [data-tag-part="tag"] {
|
||||
flex: auto;
|
||||
margin-inline-end: 8px;
|
||||
}
|
||||
|
||||
.insert-box .mail-tag-tip::before {
|
||||
font: 1.2rem dashicons;
|
||||
content: "\f348" / "";
|
||||
color: #646970;
|
||||
padding-inline-end: 4px;
|
||||
vertical-align: top;
|
||||
}
|
||||
}
|
||||
|
||||
form.tag-generator-panel[data-version="1"] {
|
||||
.control-box {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow: auto;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.form-table th {
|
||||
width: 120px;
|
||||
padding: 4px 10px 4px 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
table.form-table td {
|
||||
padding: 4px 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.control-box input.oneline {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.control-box input.large-text {
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
.control-box textarea.values {
|
||||
width: 200px;
|
||||
height: 6em;
|
||||
}
|
||||
|
||||
.control-box input[type="number"],
|
||||
.control-box input[type="date"] {
|
||||
width: 88px;
|
||||
}
|
||||
|
||||
.control-box table caption {
|
||||
text-align: left;
|
||||
font-size: 110%;
|
||||
font-weight: bold;
|
||||
color: #777;
|
||||
margin: 10px 0 5px;
|
||||
}
|
||||
|
||||
.control-box table.form-table td label {
|
||||
line-height: 1.1em;
|
||||
}
|
||||
|
||||
.control-box table.form-table td label .description {
|
||||
line-height: 1.4em;
|
||||
}
|
||||
|
||||
.insert-box {
|
||||
margin: 0 -15px -15px;
|
||||
padding: 8px 16px;
|
||||
background-color: #fcfcfc;
|
||||
border-top: 1px solid #dfdfdf;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.insert-box input.tag {
|
||||
width: 510px;
|
||||
float: left;
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.insert-box .submitbox {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.insert-box .submitbox input[type="button"] {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.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
|
||||
*/
|
||||
#sendinblue-panel table tr.inactive ~ tr {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#sendinblue-panel .dashicons {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#sendinblue-panel td p {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
/*
|
||||
* List Table
|
||||
*/
|
||||
#wpcf7-contact-form-list-table .column-title .tag {
|
||||
display: inline-block;
|
||||
margin: 4px 6px 4px 0;
|
||||
padding: 4px 6px;
|
||||
background-color: #eff2ff;
|
||||
color: #1e1e1e;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#wpcf7-contact-form-list-table .column-title .tag.warning {
|
||||
background-color: #fff2ef;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
#constant_contact.card.active {
|
||||
border-color: #dc3232;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dashboard
|
||||
*/
|
||||
#wpcf7_dashboard_right_now li a::before,
|
||||
#wpcf7_get_support li a::before {
|
||||
content: "\f109" / "";
|
||||
padding: 0 5px 0 0;
|
||||
color: #646970;
|
||||
font: normal 20px/1 dashicons;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
text-decoration: none !important;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#wpcf7_dashboard_right_now li.page-count a::before {
|
||||
content: "\f105" / "";
|
||||
}
|
||||
|
||||
#wpcf7_dashboard_right_now li.active-integration a::before {
|
||||
content: "\f137" / "";
|
||||
}
|
||||
|
||||
#wpcf7_dashboard_right_now li.flamingo a::before {
|
||||
content: "\f17d" / "";
|
||||
}
|
||||
|
||||
#wpcf7_get_support li.public a::before {
|
||||
content: "\f307" / "";
|
||||
}
|
||||
|
||||
#wpcf7_get_support li.private a::before {
|
||||
content: "\f468" / "";
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
|
||||
|
||||
/**
|
||||
* Defines the core widgets for the Contact Form 7 Dashboard.
|
||||
*/
|
||||
function wpcf7_dashboard_widgets() {
|
||||
return array(
|
||||
'wpcf7_dashboard_right_now' => array(
|
||||
'widget_name' => __( 'At a Glance', 'contact-form-7' ),
|
||||
),
|
||||
'wpcf7_dashboard_news' => array(
|
||||
'widget_name' => __( 'News', 'contact-form-7' ),
|
||||
),
|
||||
'wpcf7_get_support' => array(
|
||||
'widget_name' => __( 'Get Support', 'contact-form-7' ),
|
||||
'context' => 'side',
|
||||
),
|
||||
'wpcf7_spam_protection' => array(
|
||||
'widget_name' => __( 'Spam Protection', 'contact-form-7' ),
|
||||
'context' => 'side',
|
||||
),
|
||||
'wpcf7_save_messages' => array(
|
||||
'widget_name' => __( 'Save Messages', 'contact-form-7' ),
|
||||
'context' => 'side',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds dashboard widgets to the Contact Form 7 Dashboard screen.
|
||||
*/
|
||||
function wpcf7_dashboard_setup() {
|
||||
foreach ( wpcf7_dashboard_widgets() as $widget_id => $widget ) {
|
||||
wp_add_dashboard_widget(
|
||||
$widget_id,
|
||||
$widget['widget_name'] ?? '',
|
||||
$widget['callback'] ?? $widget_id,
|
||||
$widget['control_callback'] ?? null,
|
||||
$widget['callback_args'] ?? null,
|
||||
$widget['context'] ?? 'normal',
|
||||
$widget['priority'] ?? 'core'
|
||||
);
|
||||
}
|
||||
|
||||
do_action( 'wpcf7_dashboard_setup' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines the "At a Glance" dashboard widget content.
|
||||
*/
|
||||
function wpcf7_dashboard_right_now() {
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'ul' );
|
||||
|
||||
$formatter->append_start_tag( 'li', array(
|
||||
'class' => 'page-count',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'a', array(
|
||||
'href' => menu_page_url( 'wpcf7', false ),
|
||||
) );
|
||||
|
||||
WPCF7_ContactForm::find();
|
||||
$count = WPCF7_ContactForm::count();
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( sprintf(
|
||||
/* translators: %s: number of contact forms */
|
||||
_n(
|
||||
'%s Contact form',
|
||||
'%s Contact forms',
|
||||
$count,
|
||||
'contact-form-7'
|
||||
),
|
||||
number_format_i18n( $count )
|
||||
) )
|
||||
);
|
||||
|
||||
if ( current_user_can( 'wpcf7_manage_integration' ) ) {
|
||||
$integration = WPCF7_Integration::get_instance();
|
||||
|
||||
$services = array( 'sendinblue', 'turnstile', 'recaptcha', 'stripe' );
|
||||
|
||||
foreach ( $services as $service_name ) {
|
||||
if ( $integration->service_exists( $service_name ) ) {
|
||||
$service = $integration->get_service( $service_name );
|
||||
|
||||
if ( $service->is_active() ) {
|
||||
$formatter->append_start_tag( 'li', array(
|
||||
'class' => sprintf(
|
||||
'active-integration %s',
|
||||
$service_name
|
||||
),
|
||||
) );
|
||||
|
||||
$setup_page_link = add_query_arg(
|
||||
array(
|
||||
'service' => $service_name,
|
||||
'action' => 'setup',
|
||||
),
|
||||
menu_page_url( 'wpcf7-integration', false )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'a', array(
|
||||
'href' => $setup_page_link,
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
sprintf(
|
||||
/* translators: %s: service name */
|
||||
__( '<strong>%s</strong> integration is active', 'contact-form-7' ),
|
||||
$service->get_title()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined( 'FLAMINGO_VERSION' ) ) {
|
||||
$formatter->append_start_tag( 'li', array(
|
||||
'class' => 'flamingo',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'a', array(
|
||||
'href' => menu_page_url( 'flamingo_inbound', false ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
sprintf(
|
||||
/* translators: %s: Flamingo version */
|
||||
__( '<strong>Flamingo</strong> (version %s) is active', 'contact-form-7' ),
|
||||
FLAMINGO_VERSION
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$formatter->end_tag( 'ul' );
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( sprintf(
|
||||
/* translators: %s: Contact Form 7 version string */
|
||||
__( 'Contact Form 7 version %s is running.', 'contact-form-7' ),
|
||||
WPCF7_VERSION
|
||||
) )
|
||||
);
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines the "News" dashboard widget content.
|
||||
*/
|
||||
function wpcf7_dashboard_news() {
|
||||
echo '<div class="cf7com-news hide-if-no-js">';
|
||||
|
||||
wpcf7_dashboard_cf7com_news();
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the news feed from the contactform7.com site.
|
||||
*/
|
||||
function wpcf7_dashboard_cf7com_news() {
|
||||
wp_dashboard_cached_rss_widget(
|
||||
'wpcf7_dashboard_cf7com_news',
|
||||
'wp_dashboard_primary_output',
|
||||
array(
|
||||
'news' => array(
|
||||
'link' => 'https://contactform7.com/',
|
||||
'url' => 'https://contactform7.com/feed/',
|
||||
'title' => __( 'Contact Form 7 official site', 'contact-form-7' ),
|
||||
'items' => 6,
|
||||
'show_summary' => 0,
|
||||
'show_author' => 0,
|
||||
'show_date' => 1,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines the "Get Support" dashboard widget content.
|
||||
*/
|
||||
function wpcf7_get_support() {
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
__( 'Do you need help? These support channels are available:', 'contact-form-7' )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'ul' );
|
||||
|
||||
$formatter->append_start_tag( 'li', array(
|
||||
'class' => 'public',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'a', array(
|
||||
'href' => 'https://wordpress.org/support/plugin/contact-form-7/',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
__( 'Public support forum on WordPress.org', 'contact-form-7' )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'li', array(
|
||||
'class' => 'private',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'a', array(
|
||||
'href' => 'https://contactform7.com/custom-development/',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
__( 'Private support by Codeable experts', 'contact-form-7' )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'ul' );
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
sprintf(
|
||||
/* translators: 1: URL to the docs page, 2: URL to the FAQ page */
|
||||
__( 'Or, consult the <a href="%1$s">docs</a> and <a href="%2$s">FAQ</a>.', 'contact-form-7' ),
|
||||
'https://contactform7.com/docs/',
|
||||
'https://contactform7.com/faq/'
|
||||
)
|
||||
);
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines the "Spam Protection" dashboard widget content.
|
||||
*/
|
||||
function wpcf7_spam_protection() {
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
__( 'Spammers target everything. Your contact forms are not an exception.', 'contact-form-7' )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
sprintf(
|
||||
/* translators: 1: URL to the Turnstile doc page, 2: URL to the Akismet doc page */
|
||||
__( 'To provide effective protection, Contact Form 7 recommends using <a href="%1$s"><strong>Turnstile</strong></a> (good at blocking bots) and <a href="%2$s"><strong>Akismet</strong></a> (good at blocking human spammers) together.', 'contact-form-7' ),
|
||||
'https://contactform7.com/turnstile-integration/',
|
||||
'https://contactform7.com/spam-filtering-with-akismet/'
|
||||
)
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
sprintf(
|
||||
/* translators: %s: URL to the Disallowed list doc page */
|
||||
__( 'You can also block submissions that contain specific keywords or come from specific IP addresses (<a href="%s"><strong>Disallowed list</strong></a>).', 'contact-form-7' ),
|
||||
'https://contactform7.com/comment-blacklist/'
|
||||
)
|
||||
);
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines the "Save Messages" dashboard widget content.
|
||||
*/
|
||||
function wpcf7_save_messages() {
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
sprintf(
|
||||
/* translators: %s: URL to the Flamingo doc page */
|
||||
__( 'Contact Form 7 itself doesn’t have a feature to store submitted messages; therefore, there is always a risk of losing important messages. Contact Form 7 recommends installing a separate plugin called <a href="%s"><strong>Flamingo</strong></a>, which is dedicated to storing messages in the database.', 'contact-form-7' ),
|
||||
'https://contactform7.com/save-submitted-messages-with-flamingo/'
|
||||
)
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
sprintf(
|
||||
/* translators: %s: URL to the Brevo integration doc page */
|
||||
__( 'If you use contact forms for customer relationship management, consider activating the <a href="%s"><strong>Brevo</strong></a> integration. With the integration, Contact Form 7 can safely connect to the leading CRM platform in Europe, while protecting user privacy.', 'contact-form-7' ),
|
||||
'https://contactform7.com/sendinblue-integration/'
|
||||
)
|
||||
);
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
@@ -0,0 +1,559 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$active_panel_id = wpcf7_superglobal_get( 'active-tab' );
|
||||
|
||||
if ( ! array_key_exists( $active_panel_id, $this->panels ) ) {
|
||||
$active_panel_id = array_key_first( $this->panels );
|
||||
}
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'nav', array(
|
||||
'id' => 'contact-form-editor-tabs',
|
||||
'role' => 'tablist',
|
||||
'aria-label' => __( 'Contact form editor tabs', 'contact-form-7' ),
|
||||
'data-active-tab' => absint( array_search(
|
||||
$active_panel_id, array_keys( $this->panels ), true
|
||||
) ),
|
||||
) );
|
||||
|
||||
foreach ( $this->panels as $panel_id => $panel ) {
|
||||
$active = $panel_id === $active_panel_id;
|
||||
|
||||
$formatter->append_start_tag( 'button', array(
|
||||
'type' => 'button',
|
||||
'role' => 'tab',
|
||||
'aria-selected' => $active ? 'true' : 'false',
|
||||
'aria-controls' => $panel_id,
|
||||
'id' => sprintf( '%s-tab', $panel_id ),
|
||||
'tabindex' => $active ? '0' : '-1',
|
||||
'data-panel' => $panel_id,
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted( esc_html( $panel['title'] ) );
|
||||
}
|
||||
|
||||
$formatter->end_tag( 'nav' );
|
||||
|
||||
foreach ( $this->panels as $panel_id => $panel ) {
|
||||
$active = $panel_id === $active_panel_id;
|
||||
|
||||
$formatter->append_start_tag( 'section', array(
|
||||
'role' => 'tabpanel',
|
||||
'aria-labelledby' => sprintf( '%s-tab', $panel_id ),
|
||||
'id' => $panel_id,
|
||||
'class' => 'contact-form-editor-panel',
|
||||
'tabindex' => '0',
|
||||
'hidden' => ! $active,
|
||||
) );
|
||||
|
||||
if ( is_callable( $panel['callback'] ) ) {
|
||||
$formatter->call_user_func( $panel['callback'], $this->contact_form );
|
||||
}
|
||||
|
||||
$formatter->end_tag( 'section' );
|
||||
}
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
}
|
||||
|
||||
function wpcf7_editor_panel_form( $post ) {
|
||||
$description = sprintf(
|
||||
/* translators: %s: URL to support page about the form template */
|
||||
__( 'You can edit the form template here. For details, see <a href="%s">Editing form template</a>.', 'contact-form-7' ),
|
||||
'https://contactform7.com/editing-form-template/'
|
||||
);
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'h2' );
|
||||
$formatter->append_preformatted( esc_html( __( 'Form', 'contact-form-7' ) ) );
|
||||
$formatter->end_tag( 'h2' );
|
||||
|
||||
$formatter->append_start_tag( 'fieldset' );
|
||||
|
||||
$formatter->append_start_tag( 'legend' );
|
||||
$formatter->append_preformatted( $description );
|
||||
$formatter->end_tag( 'legend' );
|
||||
|
||||
$formatter->call_user_func( static function () {
|
||||
$tag_generator = WPCF7_TagGenerator::get_instance();
|
||||
$tag_generator->print_buttons();
|
||||
} );
|
||||
|
||||
$formatter->append_start_tag( 'textarea', array(
|
||||
'id' => 'wpcf7-form',
|
||||
'name' => 'wpcf7-form',
|
||||
'cols' => 100,
|
||||
'rows' => 24,
|
||||
'class' => 'large-text code',
|
||||
'data-config-field' => 'form.body',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted( esc_textarea( $post->prop( 'form' ) ) );
|
||||
|
||||
$formatter->end_tag( 'textarea' );
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
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, $options = '' ) {
|
||||
$options = wp_parse_args( $options, array(
|
||||
'id' => 'wpcf7-mail',
|
||||
'name' => 'mail',
|
||||
'title' => __( 'Mail', 'contact-form-7' ),
|
||||
'use' => null,
|
||||
) );
|
||||
|
||||
$id = esc_attr( $options['id'] );
|
||||
|
||||
$mail = wp_parse_args( $post->prop( $options['name'] ), array(
|
||||
'active' => false,
|
||||
'recipient' => '',
|
||||
'sender' => '',
|
||||
'subject' => '',
|
||||
'body' => '',
|
||||
'additional_headers' => '',
|
||||
'attachments' => '',
|
||||
'use_html' => false,
|
||||
'exclude_blank' => false,
|
||||
) );
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'div', array(
|
||||
'class' => 'contact-form-editor-box-mail',
|
||||
'id' => $id,
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'h2' );
|
||||
$formatter->append_preformatted( esc_html( $options['title'] ) );
|
||||
$formatter->end_tag( 'h2' );
|
||||
|
||||
if ( ! empty( $options['use'] ) ) {
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-active', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'checkbox',
|
||||
'id' => sprintf( '%s-active', $id ),
|
||||
'name' => sprintf( '%s[active]', $id ),
|
||||
'data-config-field' => '',
|
||||
'data-toggle' => sprintf( '%s-fieldset', $id ),
|
||||
'value' => '1',
|
||||
'checked' => $mail['active'],
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
$formatter->append_preformatted( esc_html( $options['use'] ) );
|
||||
$formatter->end_tag( 'label' );
|
||||
|
||||
$formatter->append_start_tag( 'p', array(
|
||||
'class' => 'description',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Mail (2) is an additional mail template often used as an autoresponder.', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'p' );
|
||||
}
|
||||
|
||||
$formatter->append_start_tag( 'fieldset', array(
|
||||
'id' => sprintf( '%s-fieldset', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'legend' );
|
||||
|
||||
$description = sprintf(
|
||||
/* translators: %s: URL to support page about the email template */
|
||||
__( 'You can edit the email template here. For details, see <a href="%s">Setting up mail</a>.', 'contact-form-7' ),
|
||||
'https://contactform7.com/setting-up-mail/'
|
||||
);
|
||||
|
||||
$formatter->append_preformatted( $description );
|
||||
|
||||
$formatter->append_start_tag( 'br' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'In the following fields, you can use these mail-tags:', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'br' );
|
||||
|
||||
$formatter->call_user_func( static function () use ( $post, $options ) {
|
||||
$post->suggest_mail_tags( $options['name'] );
|
||||
} );
|
||||
|
||||
$formatter->end_tag( 'legend' );
|
||||
|
||||
$formatter->append_start_tag( 'table', array(
|
||||
'class' => 'form-table',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'tbody' );
|
||||
|
||||
$formatter->append_start_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'th', array(
|
||||
'scope' => 'row',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-recipient', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'To', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'td' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'text',
|
||||
'id' => sprintf( '%s-recipient', $id ),
|
||||
'name' => sprintf( '%s[recipient]', $id ),
|
||||
'class' => 'large-text code',
|
||||
'size' => 70,
|
||||
'value' => $mail['recipient'],
|
||||
'data-config-field' => sprintf( '%s.recipient', $options['name'] ),
|
||||
) );
|
||||
|
||||
$formatter->end_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'th', array(
|
||||
'scope' => 'row',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-sender', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'From', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'td' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'text',
|
||||
'id' => sprintf( '%s-sender', $id ),
|
||||
'name' => sprintf( '%s[sender]', $id ),
|
||||
'class' => 'large-text code',
|
||||
'size' => 70,
|
||||
'value' => $mail['sender'],
|
||||
'data-config-field' => sprintf( '%s.sender', $options['name'] ),
|
||||
) );
|
||||
|
||||
$formatter->end_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'th', array(
|
||||
'scope' => 'row',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-subject', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Subject', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'td' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'text',
|
||||
'id' => sprintf( '%s-subject', $id ),
|
||||
'name' => sprintf( '%s[subject]', $id ),
|
||||
'class' => 'large-text code',
|
||||
'size' => 70,
|
||||
'value' => $mail['subject'],
|
||||
'data-config-field' => sprintf( '%s.subject', $options['name'] ),
|
||||
) );
|
||||
|
||||
$formatter->end_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'th', array(
|
||||
'scope' => 'row',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-additional-headers', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Additional headers', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'td' );
|
||||
|
||||
$formatter->append_start_tag( 'textarea', array(
|
||||
'id' => sprintf( '%s-additional-headers', $id ),
|
||||
'name' => sprintf( '%s[additional_headers]', $id ),
|
||||
'cols' => 100,
|
||||
'rows' => 4,
|
||||
'class' => 'large-text code',
|
||||
'data-config-field' => sprintf( '%s.additional_headers', $options['name'] ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_textarea( $mail['additional_headers'] )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'th', array(
|
||||
'scope' => 'row',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-body', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Message body', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'td' );
|
||||
|
||||
$formatter->append_start_tag( 'textarea', array(
|
||||
'id' => sprintf( '%s-body', $id ),
|
||||
'name' => sprintf( '%s[body]', $id ),
|
||||
'cols' => 100,
|
||||
'rows' => 18,
|
||||
'class' => 'large-text code',
|
||||
'data-config-field' => sprintf( '%s.body', $options['name'] ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_textarea( $mail['body'] )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'textarea' );
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-exclude-blank', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'checkbox',
|
||||
'id' => sprintf( '%s-exclude-blank', $id ),
|
||||
'name' => sprintf( '%s[exclude_blank]', $id ),
|
||||
'value' => '1',
|
||||
'checked' => $mail['exclude_blank'],
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Exclude a line from output if all of its mail-tags are blank', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'p' );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-use-html', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'checkbox',
|
||||
'id' => sprintf( '%s-use-html', $id ),
|
||||
'name' => sprintf( '%s[use_html]', $id ),
|
||||
'value' => '1',
|
||||
'checked' => $mail['use_html'],
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Use HTML content type', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'tr' );
|
||||
|
||||
$formatter->append_start_tag( 'th', array(
|
||||
'scope' => 'row',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( '%s-attachments', $id ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'File attachments', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'td' );
|
||||
|
||||
$formatter->append_start_tag( 'textarea', array(
|
||||
'id' => sprintf( '%s-attachments', $id ),
|
||||
'name' => sprintf( '%s[attachments]', $id ),
|
||||
'cols' => 100,
|
||||
'rows' => 4,
|
||||
'class' => 'large-text code',
|
||||
'data-config-field' => sprintf( '%s.attachments', $options['name'] ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_textarea( $mail['attachments'] )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'textarea' );
|
||||
$formatter->end_tag( 'tr' );
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
function wpcf7_editor_panel_messages( $post ) {
|
||||
$description = sprintf(
|
||||
/* translators: %s: URL to support page about the messages editor */
|
||||
__( 'You can edit messages used in various situations here. For details, see <a href="%s">Editing messages</a>.', 'contact-form-7' ),
|
||||
'https://contactform7.com/editing-messages/'
|
||||
);
|
||||
|
||||
$messages = wpcf7_messages();
|
||||
|
||||
if (
|
||||
isset( $messages['captcha_not_match'] ) and
|
||||
! wpcf7_use_really_simple_captcha()
|
||||
) {
|
||||
unset( $messages['captcha_not_match'] );
|
||||
}
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'h2' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Messages', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'h2' );
|
||||
|
||||
$formatter->append_start_tag( 'fieldset' );
|
||||
|
||||
$formatter->append_start_tag( 'legend' );
|
||||
$formatter->append_preformatted( $description );
|
||||
$formatter->end_tag( 'legend' );
|
||||
|
||||
foreach ( $messages as $key => $arr ) {
|
||||
$field_id = sprintf( 'wpcf7-message-%s', strtr( $key, '_', '-' ) );
|
||||
$field_name = sprintf( 'wpcf7-messages[%s]', $key );
|
||||
|
||||
$formatter->append_start_tag( 'p', array(
|
||||
'class' => 'description',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => $field_id,
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted( esc_html( $arr['description'] ) );
|
||||
$formatter->append_start_tag( 'br' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'text',
|
||||
'id' => $field_id,
|
||||
'name' => $field_name,
|
||||
'class' => 'large-text',
|
||||
'size' => 70,
|
||||
'value' => $post->message( $key, false ),
|
||||
'data-config-field' => sprintf( 'messages.%s', $key ),
|
||||
) );
|
||||
}
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
function wpcf7_editor_panel_additional_settings( $post ) {
|
||||
$description = sprintf(
|
||||
/* translators: %s: URL to support page about the additional settings editor */
|
||||
__( 'You can add customization code snippets here. For details, see <a href="%s">Additional settings</a>.', 'contact-form-7' ),
|
||||
'https://contactform7.com/additional-settings/'
|
||||
);
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'h2' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Additional Settings', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'h2' );
|
||||
|
||||
$formatter->append_start_tag( 'fieldset' );
|
||||
|
||||
$formatter->append_start_tag( 'legend' );
|
||||
$formatter->append_preformatted( $description );
|
||||
$formatter->end_tag( 'legend' );
|
||||
|
||||
$formatter->append_start_tag( 'textarea', array(
|
||||
'id' => 'wpcf7-additional-settings',
|
||||
'name' => 'wpcf7-additional-settings',
|
||||
'cols' => 100,
|
||||
'rows' => 24,
|
||||
'class' => 'large-text',
|
||||
'data-config-field' => 'additional_settings.body',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_textarea( $post->prop( 'additional_settings' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'textarea' );
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
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 your team has created with Contact Form 7. You can embed contact forms in post content or a block theme template by inserting a Contact Form 7 block. For use in the classic editor environment, traditional shortcodes are also provided.', '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’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’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’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/', __( 'Docs', 'contact-form-7' ) ) . '</p>';
|
||||
$content .= '<p>' . wpcf7_link( 'https://contactform7.com/faq/', __( 'FAQ', 'contact-form-7' ) ) . '</p>';
|
||||
$content .= '<p>' . wpcf7_link( 'https://contactform7.com/support/', __( 'Support', 'contact-form-7' ) ) . '</p>';
|
||||
|
||||
$this->screen->set_help_sidebar( $content );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'dependencies' => array(
|
||||
'wp-api-fetch',
|
||||
'wp-i18n',
|
||||
'wp-url',
|
||||
),
|
||||
'version' => WPCF7_VERSION,
|
||||
);
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'WP_List_Table' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
||||
}
|
||||
|
||||
class WPCF7_List_Table extends WP_List_Table {
|
||||
|
||||
private static $instance;
|
||||
|
||||
public static function get_instance() {
|
||||
self::$instance ??= new self();
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private function __construct() {
|
||||
parent::__construct( array(
|
||||
'singular' => 'post',
|
||||
'plural' => 'posts',
|
||||
'ajax' => false,
|
||||
) );
|
||||
}
|
||||
|
||||
public function prepare_items() {
|
||||
$current_orderby = wpcf7_superglobal_get( 'orderby' );
|
||||
$current_order = wpcf7_superglobal_get( 'order' );
|
||||
|
||||
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
||||
|
||||
foreach ( array_keys( $columns ) as $column_key ) {
|
||||
if ( isset( $sortable[$column_key] ) ) {
|
||||
$orderby = $sortable[$column_key][0] ?? '';
|
||||
$initial_order = $sortable[$column_key][4] ?? '';
|
||||
|
||||
if ( '' === $current_orderby and $initial_order ) {
|
||||
$current_orderby = $orderby;
|
||||
$current_order = $initial_order;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$per_page = $this->get_items_per_page( 'wpcf7_contact_forms_per_page' );
|
||||
|
||||
$args = array(
|
||||
'posts_per_page' => $per_page,
|
||||
'orderby' => $current_orderby,
|
||||
'order' => $current_order,
|
||||
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
|
||||
's' => wpcf7_superglobal_get( 's' ),
|
||||
);
|
||||
|
||||
$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 array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'contact-form-7' ),
|
||||
'author' => __( 'Author', 'contact-form-7' ),
|
||||
'date' => __( 'Date', 'contact-form-7' ),
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_sortable_columns() {
|
||||
return array(
|
||||
'title' => array(
|
||||
'title',
|
||||
false,
|
||||
__( 'Title', 'contact-form-7' ),
|
||||
__( 'Table ordered by Title.', 'contact-form-7' ),
|
||||
'asc',
|
||||
),
|
||||
'author' => array(
|
||||
'author',
|
||||
false,
|
||||
__( 'Author', 'contact-form-7' ),
|
||||
__( 'Table ordered by Author.', 'contact-form-7' ),
|
||||
),
|
||||
'date' => array(
|
||||
'date',
|
||||
true,
|
||||
__( 'Date', 'contact-form-7' ),
|
||||
__( 'Table ordered by Date.', 'contact-form-7' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_bulk_actions() {
|
||||
$post_type_obj = get_post_type_object( WPCF7_ContactForm::post_type );
|
||||
|
||||
if ( current_user_can( $post_type_obj->cap->edit_posts ) ) {
|
||||
return array(
|
||||
'delete' => __( 'Delete', 'contact-form-7' ),
|
||||
);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
public function column_default( $item, $column_name ) {
|
||||
do_action( 'wpcf7_manage_custom_column', $column_name, $item->id() );
|
||||
}
|
||||
|
||||
public function column_cb( $item ) {
|
||||
$post_type_obj = get_post_type_object( WPCF7_ContactForm::post_type );
|
||||
$show = current_user_can( $post_type_obj->cap->edit_post, $item->id() );
|
||||
|
||||
if ( ! $show ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'id' => sprintf( 'cb-select-%d', $item->id() ),
|
||||
'type' => 'checkbox',
|
||||
'name' => sprintf( '%s[]', $this->_args['singular'] ),
|
||||
'value' => $item->id(),
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'label', array(
|
||||
'for' => sprintf( 'cb-select-%d', $item->id() ),
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'span', array(
|
||||
'class' => 'screen-reader-text',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( sprintf(
|
||||
/* translators: %s: contact form title */
|
||||
__( 'Select %s', 'contact-form-7' ),
|
||||
$item->title()
|
||||
) )
|
||||
);
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
public function column_title( $item ) {
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'strong' );
|
||||
|
||||
$edit_link = add_query_arg(
|
||||
array(
|
||||
'post' => absint( $item->id() ),
|
||||
'action' => 'edit',
|
||||
),
|
||||
menu_page_url( 'wpcf7', false )
|
||||
);
|
||||
|
||||
$formatter->append_start_tag( 'a', array(
|
||||
'class' => 'row-title',
|
||||
'href' => esc_url( $edit_link ),
|
||||
'aria-label' => sprintf(
|
||||
/* translators: %s: title of contact form */
|
||||
__( 'Edit “%s”', 'contact-form-7' ),
|
||||
$item->title()
|
||||
),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted( esc_html( $item->title() ) );
|
||||
|
||||
$formatter->end_tag( 'strong' );
|
||||
|
||||
$post_type_obj = get_post_type_object( WPCF7_ContactForm::post_type );
|
||||
|
||||
if ( $item->is_true( 'subscribers_only' ) ) {
|
||||
$formatter->append_start_tag( 'span', array(
|
||||
'class' => 'tag info',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'subscribers only', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'span' );
|
||||
}
|
||||
|
||||
if ( $item->is_true( 'demo_mode' ) ) {
|
||||
$formatter->append_start_tag( 'span', array(
|
||||
'class' => 'tag info',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'demo mode', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'span' );
|
||||
}
|
||||
|
||||
if ( $item->is_true( 'skip_mail' ) ) {
|
||||
$formatter->append_start_tag( 'span', array(
|
||||
'class' => 'tag info',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'skip mail', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'span' );
|
||||
}
|
||||
|
||||
if ( $item->is_true( 'do_not_store' ) ) {
|
||||
$formatter->append_start_tag( 'span', array(
|
||||
'class' => 'tag info',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'do not store', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'span' );
|
||||
}
|
||||
|
||||
if (
|
||||
wpcf7_validate_configuration() and
|
||||
current_user_can( $post_type_obj->cap->edit_post, $item->id() )
|
||||
) {
|
||||
$config_validator = new WPCF7_ConfigValidator( $item );
|
||||
$config_validator->restore();
|
||||
|
||||
if ( $count_errors = $config_validator->count_errors() ) {
|
||||
$formatter->append_start_tag( 'span', array(
|
||||
'class' => 'tag warning',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'has config errors', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'span' );
|
||||
}
|
||||
}
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
echo esc_html( $author->display_name );
|
||||
}
|
||||
|
||||
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' ) )
|
||||
);
|
||||
|
||||
echo $t_time;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,627 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* The base class for form-tag generators management.
|
||||
*/
|
||||
class WPCF7_TagGenerator {
|
||||
|
||||
private static $instance;
|
||||
|
||||
private $panels = array();
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of this class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
self::$instance ??= new self();
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a form-tag generator instance.
|
||||
*/
|
||||
public function add( $id, $title, $callback, $options = '' ) {
|
||||
$id = trim( $id );
|
||||
|
||||
if (
|
||||
'' === $id or
|
||||
! wpcf7_is_name( $id ) or
|
||||
! is_callable( $callback )
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$options = wp_parse_args( $options, array(
|
||||
'version' => '1',
|
||||
) );
|
||||
|
||||
$this->panels[$id] = array(
|
||||
'title' => $title,
|
||||
'content' => 'tag-generator-panel-' . $id,
|
||||
'options' => $options,
|
||||
'callback' => $callback,
|
||||
);
|
||||
|
||||
if ( version_compare( $options['version'], '2', '<' ) ) {
|
||||
$message = sprintf(
|
||||
/* translators: 1: version, 2: tag generator title */
|
||||
__( 'Use of tag generator instances older than version 2 is deprecated. Version %1$s instance (%2$s) detected.', 'contact-form-7' ),
|
||||
$options['version'],
|
||||
$title
|
||||
);
|
||||
|
||||
wp_trigger_error( __METHOD__, $message, E_USER_DEPRECATED );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renders form-tag generator calling buttons.
|
||||
*/
|
||||
public function print_buttons() {
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'span', array(
|
||||
'id' => 'tag-generator-list',
|
||||
'class' => 'hide-if-no-js',
|
||||
) );
|
||||
|
||||
foreach ( (array) $this->panels as $panel ) {
|
||||
$formatter->append_start_tag( 'button', array(
|
||||
'type' => 'button',
|
||||
'data-taggen' => 'open-dialog',
|
||||
'data-target' => $panel['content'],
|
||||
'title' => sprintf(
|
||||
/* translators: %s: title of form-tag */
|
||||
__( 'Form-tag Generator: %s', 'contact-form-7' ),
|
||||
$panel['title']
|
||||
),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted( esc_html( $panel['title'] ) );
|
||||
}
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renders form-tag generator dialog panels (hidden until called).
|
||||
*/
|
||||
public function print_panels( WPCF7_ContactForm $contact_form ) {
|
||||
$formatter = new WPCF7_HTMLFormatter( array(
|
||||
'allowed_html' => array_merge( wpcf7_kses_allowed_html(), array(
|
||||
'dialog' => array(
|
||||
'id' => true,
|
||||
'class' => true,
|
||||
),
|
||||
'form' => array(
|
||||
'method' => true,
|
||||
'class' => true,
|
||||
'data-*' => true,
|
||||
),
|
||||
) ),
|
||||
) );
|
||||
|
||||
foreach ( (array) $this->panels as $id => $panel ) {
|
||||
$callback = $panel['callback'];
|
||||
|
||||
$options = array_merge( $panel['options'], array(
|
||||
'id' => $id,
|
||||
'title' => $panel['title'],
|
||||
'content' => $panel['content'],
|
||||
) );
|
||||
|
||||
if ( is_callable( $callback ) ) {
|
||||
$formatter->append_start_tag( 'dialog', array(
|
||||
'id' => $options['content'],
|
||||
'class' => 'tag-generator-dialog',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'button', array(
|
||||
'class' => 'close-button',
|
||||
'title' => __( 'Close this dialog box', 'contact-form-7' ),
|
||||
'data-taggen' => 'close-dialog',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Close', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'button' );
|
||||
|
||||
$formatter->append_start_tag( 'form', array(
|
||||
'method' => 'dialog',
|
||||
'class' => 'tag-generator-panel',
|
||||
'data-id' => $options['id'],
|
||||
'data-version' => $options['version'],
|
||||
) );
|
||||
|
||||
$formatter->call_user_func( $callback, $contact_form, $options );
|
||||
|
||||
$formatter->close_all_tags();
|
||||
}
|
||||
}
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class helps to implement a form-tag generator content.
|
||||
*/
|
||||
class WPCF7_TagGeneratorGenerator {
|
||||
|
||||
private $key = '';
|
||||
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public function __construct( $key ) {
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a unique reference ID.
|
||||
*/
|
||||
public function ref( $suffix = '' ) {
|
||||
$ref = sprintf( '%s-%s', $this->key, $suffix );
|
||||
$ref = strtolower( $ref );
|
||||
$ref = preg_replace( '/[^0-9a-z-]/', '', $ref );
|
||||
$ref = preg_replace( '/[-]+/', '-', $ref );
|
||||
$ref = trim( $ref, '-' );
|
||||
return $ref;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls one of the template methods.
|
||||
*/
|
||||
public function print( $part, $options = '' ) {
|
||||
if ( is_callable( array( $this, $part ) ) ) {
|
||||
call_user_func( array( $this, $part ), $options );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for field type field.
|
||||
*/
|
||||
private function field_type( $options = '' ) {
|
||||
$options = wp_parse_args( $options, array(
|
||||
'with_required' => false,
|
||||
'with_optional' => false,
|
||||
'select_options' => array(),
|
||||
) );
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'fieldset' );
|
||||
|
||||
$formatter->append_start_tag( 'legend', array(
|
||||
'id' => $this->ref( 'type-legend' ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Field type', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'legend' );
|
||||
|
||||
$formatter->append_start_tag( 'select', array(
|
||||
'data-tag-part' => 'basetype',
|
||||
'aria-labelledby' => $this->ref( 'type-legend' ),
|
||||
) );
|
||||
|
||||
foreach ( (array) $options['select_options'] as $basetype => $title ) {
|
||||
$formatter->append_start_tag( 'option', array(
|
||||
'value' => $basetype,
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted( esc_html( $title ) );
|
||||
}
|
||||
|
||||
$formatter->end_tag( 'select' );
|
||||
|
||||
if ( $options['with_required'] ) {
|
||||
$formatter->append_start_tag( 'br' );
|
||||
$formatter->append_start_tag( 'label' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'checkbox',
|
||||
'data-tag-part' => 'type-suffix',
|
||||
'value' => '*',
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'This is a required field.', 'contact-form-7' ) )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $options['with_optional'] ) {
|
||||
$formatter->append_start_tag( 'br' );
|
||||
$formatter->append_start_tag( 'label' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'checkbox',
|
||||
'data-tag-part' => 'option',
|
||||
'data-tag-option' => 'optional',
|
||||
'checked' => true,
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'This checkbox is optional.', 'contact-form-7' ) )
|
||||
);
|
||||
}
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for field name field.
|
||||
*/
|
||||
private function field_name( $options = '' ) {
|
||||
$options = wp_parse_args( $options, array(
|
||||
'ask_if' => '',
|
||||
) );
|
||||
|
||||
?>
|
||||
<fieldset>
|
||||
<legend id="<?php echo esc_attr( $this->ref( 'name-legend' ) ); ?>"><?php
|
||||
echo esc_html( __( 'Field name', 'contact-form-7' ) );
|
||||
?></legend>
|
||||
<input type="text" data-tag-part="name" pattern="[A-Za-z][A-Za-z0-9_\-]*" aria-labelledby="<?php echo esc_attr( $this->ref( 'name-legend' ) ); ?>" />
|
||||
|
||||
<?php
|
||||
$tag_option = $label = '';
|
||||
|
||||
if ( 'author_name' === $options['ask_if'] ) {
|
||||
$tag_option = 'autocomplete:name';
|
||||
|
||||
if ( wpcf7_akismet_is_available() ) {
|
||||
$tag_option .= ' akismet:author';
|
||||
}
|
||||
|
||||
$label = __( "This field expects the submitter name.", 'contact-form-7' );
|
||||
} elseif ( 'author_email' === $options['ask_if'] ) {
|
||||
$tag_option = 'autocomplete:email';
|
||||
|
||||
if ( wpcf7_akismet_is_available() ) {
|
||||
$tag_option .= ' akismet:author_email';
|
||||
}
|
||||
|
||||
$label = __( "This field expects the submitter email.", 'contact-form-7' );
|
||||
} elseif ( 'author_url' === $options['ask_if'] ) {
|
||||
$tag_option = 'autocomplete:url';
|
||||
|
||||
if ( wpcf7_akismet_is_available() ) {
|
||||
$tag_option .= ' akismet:author_url';
|
||||
}
|
||||
|
||||
$label = __( "This field expects the submitter URL.", 'contact-form-7' );
|
||||
} elseif ( 'author_tel' === $options['ask_if'] ) {
|
||||
$tag_option = 'autocomplete:tel';
|
||||
$label = __( "This field expects the submitter telephone number.", 'contact-form-7' );
|
||||
}
|
||||
|
||||
if ( $tag_option ) {
|
||||
?>
|
||||
<br />
|
||||
<label>
|
||||
<input type="checkbox" data-tag-part="option" data-tag-option="<?php echo esc_attr( $tag_option ); ?>" />
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for ID attribute option field.
|
||||
*/
|
||||
private function id_attr( $options = '' ) {
|
||||
?>
|
||||
<fieldset>
|
||||
<legend id="<?php echo esc_attr( $this->ref( 'id-legend' ) ); ?>"><?php
|
||||
echo esc_html( __( 'ID attribute', 'contact-form-7' ) );
|
||||
?></legend>
|
||||
<input type="text" data-tag-part="option" data-tag-option="id:" pattern="[A-Za-z][A-Za-z0-9_\-]*" aria-labelledby="<?php echo esc_attr( $this->ref( 'id-legend' ) ); ?>" />
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for class attribute option field.
|
||||
*/
|
||||
private function class_attr( $options = '' ) {
|
||||
?>
|
||||
<fieldset>
|
||||
<legend id="<?php echo esc_attr( $this->ref( 'class-legend' ) ); ?>"><?php
|
||||
echo esc_html( __( 'Class attribute', 'contact-form-7' ) );
|
||||
?></legend>
|
||||
<input type="text" data-tag-part="option" data-tag-option="class:" pattern="[A-Za-z0-9_\-\s]*" aria-labelledby="<?php echo esc_attr( $this->ref( 'class-legend' ) ); ?>" />
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for min/max options.
|
||||
*/
|
||||
private function min_max( $options = '' ) {
|
||||
$options = wp_parse_args( $options, array(
|
||||
'type' => 'number',
|
||||
'title' => __( 'Length', 'contact-form-7' ),
|
||||
'min_option' => 'minlength:',
|
||||
'max_option' => 'maxlength:',
|
||||
'accept_minus' => false,
|
||||
) );
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'fieldset' );
|
||||
|
||||
$formatter->append_start_tag( 'legend' );
|
||||
$formatter->append_preformatted( esc_html( $options['title'] ) );
|
||||
$formatter->end_tag( 'legend' );
|
||||
|
||||
$formatter->append_start_tag( 'label' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Min', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => $options['type'],
|
||||
'data-tag-part' => 'option',
|
||||
'data-tag-option' => $options['min_option'],
|
||||
'min' => $options['accept_minus'] ? null : 0,
|
||||
) );
|
||||
|
||||
$formatter->end_tag( 'label' );
|
||||
|
||||
$formatter->append_preformatted( ' ⇔ ' );
|
||||
|
||||
$formatter->append_start_tag( 'label' );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Max', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => $options['type'],
|
||||
'data-tag-part' => 'option',
|
||||
'data-tag-option' => $options['max_option'],
|
||||
'min' => $options['accept_minus'] ? null : 0,
|
||||
) );
|
||||
|
||||
$formatter->end_tag( 'label' );
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for default value field.
|
||||
*/
|
||||
private function default_value( $options = '' ) {
|
||||
$options = wp_parse_args( $options, array(
|
||||
'type' => 'text',
|
||||
'title' => __( 'Default value', 'contact-form-7' ),
|
||||
'with_placeholder' => false,
|
||||
'use_content' => false,
|
||||
) );
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'fieldset' );
|
||||
|
||||
$formatter->append_start_tag( 'legend', array(
|
||||
'id' => $this->ref( 'value-legend' ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted( esc_html( $options['title'] ) );
|
||||
|
||||
$formatter->end_tag( 'legend' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => $options['type'],
|
||||
'data-tag-part' => $options['use_content'] ? 'content' : 'value',
|
||||
'aria-labelledby' => $this->ref( 'value-legend' ),
|
||||
) );
|
||||
|
||||
if ( $options['with_placeholder'] ) {
|
||||
$formatter->append_start_tag( 'br' );
|
||||
$formatter->append_start_tag( 'label' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'checkbox',
|
||||
'data-tag-part' => 'option',
|
||||
'data-tag-option' => 'placeholder',
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Use this text as the placeholder.', 'contact-form-7' ) )
|
||||
);
|
||||
}
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for selectable values useful for checkboxes or a menu.
|
||||
*/
|
||||
private function selectable_values( $options = '' ) {
|
||||
$options = wp_parse_args( $options, array(
|
||||
'first_as_label' => false,
|
||||
'use_label_element' => false,
|
||||
) );
|
||||
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'fieldset' );
|
||||
|
||||
$formatter->append_start_tag( 'legend', array(
|
||||
'id' => $this->ref( 'selectable-values-legend' ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Selectable values', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'legend' );
|
||||
|
||||
$formatter->append_start_tag( 'span', array(
|
||||
'id' => $this->ref( 'selectable-values-description' ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'One item per line.', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'span' );
|
||||
|
||||
$formatter->append_start_tag( 'br' );
|
||||
|
||||
$formatter->append_start_tag( 'textarea', array(
|
||||
'required' => true,
|
||||
'data-tag-part' => 'value',
|
||||
'aria-labelledby' => $this->ref( 'selectable-values-legend' ),
|
||||
'aria-describedby' => $this->ref( 'selectable-values-description' ),
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( "Option 1\nOption 2\nOption 3", 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'textarea' );
|
||||
|
||||
if ( $options['first_as_label'] ) {
|
||||
$formatter->append_start_tag( 'br' );
|
||||
$formatter->append_start_tag( 'label' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'checkbox',
|
||||
'checked' => 'checked' === $options['first_as_label'],
|
||||
'data-tag-part' => 'option',
|
||||
'data-tag-option' => 'first_as_label',
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Use the first item as a label.', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'label' );
|
||||
}
|
||||
|
||||
if ( $options['use_label_element'] ) {
|
||||
$formatter->append_start_tag( 'br' );
|
||||
$formatter->append_start_tag( 'label' );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'checkbox',
|
||||
'checked' => 'checked' === $options['use_label_element'],
|
||||
'data-tag-part' => 'option',
|
||||
'data-tag-option' => 'use_label_element',
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Wrap each item with a label element.', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'label' );
|
||||
}
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for insert-box content including the result form-tag.
|
||||
*/
|
||||
private function insert_box_content( $options = '' ) {
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'div', array(
|
||||
'class' => 'flex-container',
|
||||
) );
|
||||
|
||||
$formatter->append_start_tag( 'input', array(
|
||||
'type' => 'text',
|
||||
'class' => 'code selectable',
|
||||
'readonly' => true,
|
||||
'data-tag-part' => 'tag',
|
||||
'aria-label' => __( 'The form-tag to be inserted into the form template', 'contact-form-7' ),
|
||||
) );
|
||||
|
||||
$formatter->append_whitespace();
|
||||
|
||||
$formatter->append_start_tag( 'button', array(
|
||||
'type' => 'button',
|
||||
'class' => 'button button-primary',
|
||||
'data-taggen' => 'insert-tag',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted(
|
||||
esc_html( __( 'Insert Tag', 'contact-form-7' ) )
|
||||
);
|
||||
|
||||
$formatter->end_tag( 'button' );
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template method for a tip message about mail-tag.
|
||||
*/
|
||||
private function mail_tag_tip( $options = '' ) {
|
||||
$formatter = new WPCF7_HTMLFormatter();
|
||||
|
||||
$formatter->append_start_tag( 'p', array(
|
||||
'class' => 'mail-tag-tip',
|
||||
) );
|
||||
|
||||
$formatter->append_preformatted( sprintf(
|
||||
/* translators: %s: mail-tag corresponding to the form-tag */
|
||||
esc_html( __( 'To use the user input in the email, insert the corresponding mail-tag %s into the email template.', 'contact-form-7' ) ),
|
||||
'<strong data-tag-part="mail-tag"></strong>'
|
||||
) );
|
||||
|
||||
$formatter->print();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user