本文整理汇总了PHP中wpcf7_contact_form函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_contact_form函数的具体用法?PHP wpcf7_contact_form怎么用?PHP wpcf7_contact_form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_contact_form函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_template
/**
* Load selected template and translate.
*
* @uses wpcf7_load_textdomain
* @since 0.0.1
*/
function load_template()
{
// Check the nonce and if not valid, just die.
if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'cf7s')) {
die;
}
// Get translation if locale is set and exists in the Contact Form 7 l10n
if (isset($_POST['locale']) && !empty($_POST['locale']) && array_key_exists($_POST['locale'], wpcf7_l10n())) {
wpcf7_load_textdomain($_POST['locale']);
}
// Get translation based on post ID
if (isset($_POST['post']) && !empty($_POST['post'])) {
$wpcf7 = wpcf7_contact_form((int) $_POST['post']);
// current CF7 form
wpcf7_load_textdomain($wpcf7->locale);
}
// Load selected template file
$templates = $this->cf7s_get_template_list();
$template = $templates[$_POST['template']];
require_once $template['path'] . trailingslashit($template['dir']) . $template['index'];
exit;
}
示例2: wpcf7_get_contact_form_by_title
function wpcf7_get_contact_form_by_title($title)
{
$page = get_page_by_title($title, OBJECT, 'wpcf7_contact_form');
if ($page) {
return wpcf7_contact_form($page->ID);
}
return null;
}
示例3: wpcf7_admin_management_page
function wpcf7_admin_management_page()
{
$contact_forms = get_posts(array('numberposts' => -1, 'orderby' => 'ID', 'order' => 'ASC', 'post_type' => 'wpcf7_contact_form'));
$cf = null;
$unsaved = false;
if (!isset($_GET['contactform'])) {
$_GET['contactform'] = '';
}
if ('new' == $_GET['contactform'] && wpcf7_admin_has_edit_cap()) {
$unsaved = true;
$current = -1;
$cf = wpcf7_get_contact_form_default_pack(array('locale' => isset($_GET['locale']) ? $_GET['locale'] : ''));
} elseif ($cf = wpcf7_contact_form($_GET['contactform'])) {
$current = (int) $_GET['contactform'];
} else {
$first = reset($contact_forms);
// Returns first item
if ($first) {
$current = $first->ID;
$cf = wpcf7_contact_form($current);
}
}
require_once WPCF7_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
require_once WPCF7_PLUGIN_DIR . '/admin/edit.php';
}
示例4: wpcf7_file_display_warning_message
function wpcf7_file_display_warning_message()
{
if (empty($_GET['post']) || !($contact_form = wpcf7_contact_form($_GET['post']))) {
return;
}
$has_tags = (bool) $contact_form->form_scan_shortcode(array('type' => array('file', 'file*')));
if (!$has_tags) {
return;
}
$uploads_dir = wpcf7_upload_tmp_dir();
wpcf7_init_uploads();
if (!is_dir($uploads_dir) || !wp_is_writable($uploads_dir)) {
$message = sprintf(__('This contact form contains file uploading fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'wpcf7'), $uploads_dir);
echo '<div class="error"><p><strong>' . esc_html($message) . '</strong></p></div>';
}
}
示例5: wpcf7_admin_management_page
function wpcf7_admin_management_page()
{
$contact_forms = wpcf7_contact_forms();
$unsaved = false;
if (!isset($_GET['contactform'])) {
$_GET['contactform'] = '';
}
if ('new' == $_GET['contactform']) {
$unsaved = true;
$current = -1;
$cf = wpcf7_contact_form_default_pack(isset($_GET['locale']) ? $_GET['locale'] : '');
} elseif ($cf = wpcf7_contact_form($_GET['contactform'])) {
$current = (int) $_GET['contactform'];
} else {
$first = reset($contact_forms);
// Returns first item
$current = $first->id;
$cf = wpcf7_contact_form($current);
}
require_once WPCF7_PLUGIN_DIR . '/admin/edit.php';
}
示例6: wpcf7_captcha_display_warning_message
function wpcf7_captcha_display_warning_message()
{
if (empty($_GET['post']) || !($contact_form = wpcf7_contact_form($_GET['post']))) {
return;
}
$has_tags = (bool) $contact_form->form_scan_shortcode(array('type' => array('captchac')));
if (!$has_tags) {
return;
}
if (!class_exists('ReallySimpleCaptcha')) {
return;
}
$uploads_dir = wpcf7_captcha_tmp_dir();
wpcf7_init_captcha();
if (!is_dir($uploads_dir) || !wp_is_writable($uploads_dir)) {
$message = sprintf(__('This contact form contains CAPTCHA fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'wpcf7'), $uploads_dir);
echo '<div class="error"><p><strong>' . esc_html($message) . '</strong></p></div>';
}
if (!function_exists('imagecreatetruecolor') || !function_exists('imagettftext')) {
$message = __('This contact form contains CAPTCHA fields, but the necessary libraries (GD and FreeType) are not available on your server.', 'wpcf7');
echo '<div class="error"><p><strong>' . esc_html($message) . '</strong></p></div>';
}
}
示例7: wpcf7_load_contact_form_admin
function wpcf7_load_contact_form_admin()
{
global $plugin_page;
$action = wpcf7_current_action();
if ('save' == $action) {
$id = $_POST['post_ID'];
check_admin_referer('wpcf7-save-contact-form_' . $id);
if (!current_user_can('wpcf7_edit_contact_form', $id)) {
wp_die(__('You are not allowed to edit this item.', 'contact-form-7'));
}
if (!($contact_form = wpcf7_contact_form($id))) {
$contact_form = new WPCF7_ContactForm();
$contact_form->initial = true;
}
$contact_form->title = trim($_POST['wpcf7-title']);
$contact_form->locale = trim($_POST['wpcf7-locale']);
$form = trim($_POST['wpcf7-form']);
$mail = array('subject' => trim($_POST['wpcf7-mail-subject']), 'sender' => trim($_POST['wpcf7-mail-sender']), 'body' => trim($_POST['wpcf7-mail-body']), 'recipient' => trim($_POST['wpcf7-mail-recipient']), 'additional_headers' => trim($_POST['wpcf7-mail-additional-headers']), 'attachments' => trim($_POST['wpcf7-mail-attachments']), 'use_html' => isset($_POST['wpcf7-mail-use-html']) && 1 == $_POST['wpcf7-mail-use-html']);
$mail_2 = array('active' => isset($_POST['wpcf7-mail-2-active']) && 1 == $_POST['wpcf7-mail-2-active'], 'subject' => trim($_POST['wpcf7-mail-2-subject']), 'sender' => trim($_POST['wpcf7-mail-2-sender']), 'body' => trim($_POST['wpcf7-mail-2-body']), 'recipient' => trim($_POST['wpcf7-mail-2-recipient']), 'additional_headers' => trim($_POST['wpcf7-mail-2-additional-headers']), 'attachments' => trim($_POST['wpcf7-mail-2-attachments']), 'use_html' => isset($_POST['wpcf7-mail-2-use-html']) && 1 == $_POST['wpcf7-mail-2-use-html']);
$messages = isset($contact_form->messages) ? $contact_form->messages : array();
foreach (wpcf7_messages() as $key => $arr) {
$field_name = 'wpcf7-message-' . strtr($key, '_', '-');
if (isset($_POST[$field_name])) {
$messages[$key] = trim($_POST[$field_name]);
}
}
$additional_settings = trim($_POST['wpcf7-additional-settings']);
$props = apply_filters('wpcf7_contact_form_admin_posted_properties', compact('form', 'mail', 'mail_2', 'messages', 'additional_settings'));
foreach ((array) $props as $key => $prop) {
$contact_form->{$key} = $prop;
}
$query = array();
$query['message'] = $contact_form->initial ? 'created' : 'saved';
$contact_form->save();
$query['post'] = $contact_form->id;
$redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
wp_safe_redirect($redirect_to);
exit;
}
if ('copy' == $action) {
$id = empty($_POST['post_ID']) ? absint($_REQUEST['post']) : absint($_POST['post_ID']);
check_admin_referer('wpcf7-copy-contact-form_' . $id);
if (!current_user_can('wpcf7_edit_contact_form', $id)) {
wp_die(__('You are not allowed to edit this item.', 'contact-form-7'));
}
$query = array();
if ($contact_form = wpcf7_contact_form($id)) {
$new_contact_form = $contact_form->copy();
$new_contact_form->save();
$query['post'] = $new_contact_form->id;
$query['message'] = 'created';
}
$redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
wp_safe_redirect($redirect_to);
exit;
}
if ('delete' == $action) {
if (!empty($_POST['post_ID'])) {
check_admin_referer('wpcf7-delete-contact-form_' . $_POST['post_ID']);
} elseif (!is_array($_REQUEST['post'])) {
check_admin_referer('wpcf7-delete-contact-form_' . $_REQUEST['post']);
} else {
check_admin_referer('bulk-posts');
}
$posts = empty($_POST['post_ID']) ? (array) $_REQUEST['post'] : (array) $_POST['post_ID'];
$deleted = 0;
foreach ($posts as $post) {
$post = new WPCF7_ContactForm($post);
if (empty($post)) {
continue;
}
if (!current_user_can('wpcf7_delete_contact_form', $post->id)) {
wp_die(__('You are not allowed to delete this item.', 'contact-form-7'));
}
if (!$post->delete()) {
wp_die(__('Error in deleting.', 'contact-form-7'));
}
$deleted += 1;
}
$query = array();
if (!empty($deleted)) {
$query['message'] = 'deleted';
}
$redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
wp_safe_redirect($redirect_to);
exit;
}
$_GET['post'] = isset($_GET['post']) ? $_GET['post'] : '';
$post = null;
if ('wpcf7-new' == $plugin_page && isset($_GET['locale'])) {
$post = wpcf7_get_contact_form_default_pack(array('locale' => $_GET['locale']));
} elseif (!empty($_GET['post'])) {
$post = wpcf7_contact_form($_GET['post']);
}
if ($post && current_user_can('wpcf7_edit_contact_form', $post->id)) {
wpcf7_add_meta_boxes($post->id);
} else {
$current_screen = get_current_screen();
if (!class_exists('WPCF7_Contact_Form_List_Table')) {
require_once WPCF7_PLUGIN_DIR . '/admin/includes/class-contact-forms-list-table.php';
//.........这里部分代码省略.........
示例8: wpcf7_contact_form_tag_func
function wpcf7_contact_form_tag_func($atts, $content = null, $code = '')
{
global $wpcf7, $wpcf7_contact_form;
if (is_feed()) {
return '[contact-form-7]';
}
if ('contact-form-7' == $code) {
$atts = shortcode_atts(array('id' => 0, 'title' => ''), $atts);
$id = (int) $atts['id'];
$title = trim($atts['title']);
if (!($wpcf7_contact_form = wpcf7_contact_form($id))) {
$wpcf7_contact_form = wpcf7_get_contact_form_by_title($title);
}
} else {
if (is_string($atts)) {
$atts = explode(' ', $atts, 2);
}
$id = (int) array_shift($atts);
$wpcf7_contact_form = wpcf7_get_contact_form_by_old_id($id);
}
if (!$wpcf7_contact_form) {
return '[contact-form-7 404 "Not Found"]';
}
if ($wpcf7->processing_within) {
// Inside post content or text widget
$wpcf7->unit_count += 1;
$unit_count = $wpcf7->unit_count;
$processing_within = $wpcf7->processing_within;
} else {
// Inside template
if (!isset($wpcf7->global_unit_count)) {
$wpcf7->global_unit_count = 0;
}
$wpcf7->global_unit_count += 1;
$unit_count = 1;
$processing_within = 't' . $wpcf7->global_unit_count;
}
$unit_tag = 'wpcf7-f' . $wpcf7_contact_form->id . '-' . $processing_within . '-o' . $unit_count;
$wpcf7_contact_form->unit_tag = $unit_tag;
$form = $wpcf7_contact_form->form_html();
$wpcf7_contact_form = null;
return $form;
}
示例9: wpcf7_get_contact_form_by_old_id
function wpcf7_get_contact_form_by_old_id($old_id)
{
global $wpdb;
$q = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_old_cf7_unit_id'" . $wpdb->prepare(" AND meta_value = %d", $old_id);
if ($new_id = $wpdb->get_var($q)) {
return wpcf7_contact_form($new_id);
}
}
示例10: wpcf7_load_contact_form_admin
function wpcf7_load_contact_form_admin()
{
global $plugin_page;
$action = wpcf7_current_action();
if ('save' == $action) {
$id = $_POST['post_ID'];
check_admin_referer('wpcf7-save-contact-form_' . $id);
if (!current_user_can('wpcf7_edit_contact_form', $id)) {
wp_die(__('You are not allowed to edit this item.', 'contact-form-7'));
}
$id = wpcf7_save_contact_form($id);
$query = array('message' => -1 == $_POST['post_ID'] ? 'created' : 'saved', 'post' => $id, 'active-tab' => isset($_POST['active-tab']) ? (int) $_POST['active-tab'] : 0);
$redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
wp_safe_redirect($redirect_to);
exit;
}
if ('copy' == $action) {
$id = empty($_POST['post_ID']) ? absint($_REQUEST['post']) : absint($_POST['post_ID']);
check_admin_referer('wpcf7-copy-contact-form_' . $id);
if (!current_user_can('wpcf7_edit_contact_form', $id)) {
wp_die(__('You are not allowed to edit this item.', 'contact-form-7'));
}
$query = array();
if ($contact_form = wpcf7_contact_form($id)) {
$new_contact_form = $contact_form->copy();
$new_contact_form->save();
$query['post'] = $new_contact_form->id();
$query['message'] = 'created';
}
$redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
wp_safe_redirect($redirect_to);
exit;
}
if ('delete' == $action) {
if (!empty($_POST['post_ID'])) {
check_admin_referer('wpcf7-delete-contact-form_' . $_POST['post_ID']);
} elseif (!is_array($_REQUEST['post'])) {
check_admin_referer('wpcf7-delete-contact-form_' . $_REQUEST['post']);
} else {
check_admin_referer('bulk-posts');
}
$posts = empty($_POST['post_ID']) ? (array) $_REQUEST['post'] : (array) $_POST['post_ID'];
$deleted = 0;
foreach ($posts as $post) {
$post = WPCF7_ContactForm::get_instance($post);
if (empty($post)) {
continue;
}
if (!current_user_can('wpcf7_delete_contact_form', $post->id())) {
wp_die(__('You are not allowed to delete this item.', 'contact-form-7'));
}
if (!$post->delete()) {
wp_die(__('Error in deleting.', 'contact-form-7'));
}
$deleted += 1;
}
$query = array();
if (!empty($deleted)) {
$query['message'] = 'deleted';
}
$redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
wp_safe_redirect($redirect_to);
exit;
}
$_GET['post'] = isset($_GET['post']) ? $_GET['post'] : '';
$post = null;
if ('wpcf7-new' == $plugin_page && isset($_GET['locale'])) {
$post = WPCF7_ContactForm::get_template(array('locale' => $_GET['locale']));
} elseif (!empty($_GET['post'])) {
$post = WPCF7_ContactForm::get_instance($_GET['post']);
}
$current_screen = get_current_screen();
$help_tabs = new WPCF7_Help_Tabs($current_screen);
if ($post && current_user_can('wpcf7_edit_contact_form', $post->id())) {
$help_tabs->set_help_tabs('edit');
} else {
if ('wpcf7-new' == $plugin_page) {
$help_tabs->set_help_tabs('add_new');
} else {
$help_tabs->set_help_tabs('list');
if (!class_exists('WPCF7_Contact_Form_List_Table')) {
require_once WPCF7_PLUGIN_DIR . '/admin/includes/class-contact-forms-list-table.php';
}
add_filter('manage_' . $current_screen->id . '_columns', array('WPCF7_Contact_Form_List_Table', 'define_columns'));
add_screen_option('per_page', array('default' => 20, 'option' => 'cfseven_contact_forms_per_page'));
}
}
}
示例11: wpcf7_submit_nonajax
function wpcf7_submit_nonajax()
{
if (!isset($_POST['_wpcf7'])) {
return;
}
if ($contact_form = wpcf7_contact_form((int) $_POST['_wpcf7'])) {
$contact_form->submit();
}
}
示例12: wpcf7_contact_form_tag_func
function wpcf7_contact_form_tag_func($atts)
{
global $wpcf7_contact_form, $wpcf7_unit_count, $wpcf7_processing_within;
if (is_feed()) {
return '[contact-form]';
}
if (is_string($atts)) {
$atts = explode(' ', $atts, 2);
}
$atts = (array) $atts;
$id = (int) array_shift($atts);
if (!($wpcf7_contact_form = wpcf7_contact_form($id))) {
return '[contact-form 404 "Not Found"]';
}
$wpcf7_unit_count += 1;
$unit_tag = 'wpcf7-f' . $id . '-' . $wpcf7_processing_within . '-o' . $wpcf7_unit_count;
$wpcf7_contact_form->unit_tag = $unit_tag;
$form = $wpcf7_contact_form->form_html();
$wpcf7_contact_form = null;
return $form;
}
示例13: wpcf7_save_contact_form
function wpcf7_save_contact_form($post_id = -1)
{
if (-1 != $post_id) {
$contact_form = wpcf7_contact_form($post_id);
}
if (empty($contact_form)) {
$contact_form = WPCF7_ContactForm::get_template();
}
if (isset($_POST['post_title'])) {
$contact_form->set_title($_POST['post_title']);
}
if (isset($_POST['wpcf7-locale'])) {
$locale = trim($_POST['wpcf7-locale']);
if (wpcf7_is_valid_locale($locale)) {
$contact_form->locale = $locale;
}
}
$properties = $contact_form->get_properties();
if (isset($_POST['wpcf7-form'])) {
$properties['form'] = trim($_POST['wpcf7-form']);
}
$mail = $properties['mail'];
if (isset($_POST['wpcf7-mail-subject'])) {
$mail['subject'] = trim($_POST['wpcf7-mail-subject']);
}
if (isset($_POST['wpcf7-mail-sender'])) {
$mail['sender'] = trim($_POST['wpcf7-mail-sender']);
}
if (isset($_POST['wpcf7-mail-body'])) {
$mail['body'] = trim($_POST['wpcf7-mail-body']);
}
if (isset($_POST['wpcf7-mail-recipient'])) {
$mail['recipient'] = trim($_POST['wpcf7-mail-recipient']);
}
if (isset($_POST['wpcf7-mail-additional-headers'])) {
$mail['additional_headers'] = trim($_POST['wpcf7-mail-additional-headers']);
}
if (isset($_POST['wpcf7-mail-attachments'])) {
$mail['attachments'] = trim($_POST['wpcf7-mail-attachments']);
}
$mail['use_html'] = !empty($_POST['wpcf7-mail-use-html']);
$mail['exclude_blank'] = !empty($_POST['wpcf7-mail-exclude-blank']);
$properties['mail'] = $mail;
$mail_2 = $properties['mail_2'];
$mail_2['active'] = !empty($_POST['wpcf7-mail-2-active']);
if (isset($_POST['wpcf7-mail-2-subject'])) {
$mail_2['subject'] = trim($_POST['wpcf7-mail-2-subject']);
}
if (isset($_POST['wpcf7-mail-2-sender'])) {
$mail_2['sender'] = trim($_POST['wpcf7-mail-2-sender']);
}
if (isset($_POST['wpcf7-mail-2-body'])) {
$mail_2['body'] = trim($_POST['wpcf7-mail-2-body']);
}
if (isset($_POST['wpcf7-mail-2-recipient'])) {
$mail_2['recipient'] = trim($_POST['wpcf7-mail-2-recipient']);
}
if (isset($_POST['wpcf7-mail-2-additional-headers'])) {
$mail_2['additional_headers'] = trim($_POST['wpcf7-mail-2-additional-headers']);
}
if (isset($_POST['wpcf7-mail-2-attachments'])) {
$mail_2['attachments'] = trim($_POST['wpcf7-mail-2-attachments']);
}
$mail_2['use_html'] = !empty($_POST['wpcf7-mail-2-use-html']);
$mail_2['exclude_blank'] = !empty($_POST['wpcf7-mail-2-exclude-blank']);
$properties['mail_2'] = $mail_2;
foreach (wpcf7_messages() as $key => $arr) {
$field_name = 'wpcf7-message-' . strtr($key, '_', '-');
if (isset($_POST[$field_name])) {
$properties['messages'][$key] = trim($_POST[$field_name]);
}
}
if (isset($_POST['wpcf7-additional-settings'])) {
$properties['additional_settings'] = trim($_POST['wpcf7-additional-settings']);
}
$contact_form->set_properties($properties);
do_action('wpcf7_save_contact_form', $contact_form);
return $contact_form->save();
}
示例14: get_object_link
/**
* @param int $object_id
* @since 3.0
* @return string
*/
public function get_object_link($object_id)
{
// for backwards compatibility, not all CF7 sign-ups have an object id
if (empty($object_id)) {
return '';
}
// Return empty string if CF7 is no longer activated.
if (!function_exists('wpcf7_contact_form')) {
return '';
}
$form = wpcf7_contact_form($object_id);
if (!is_object($form)) {
return '';
}
return sprintf('<a href="%s">%s</a>', admin_url('admin.php?page=wpcf7&post=' . $object_id), $form->title());
}
示例15: wpcf7_admin_management_page
function wpcf7_admin_management_page()
{
global $wp_version;
switch ($_GET['message']) {
case 'created':
$updated_message = __("Contact form created.", 'wpcf7');
break;
case 'saved':
$updated_message = __("Contact form saved.", 'wpcf7');
break;
case 'deleted':
$updated_message = __("Contact form deleted.", 'wpcf7');
break;
case 'table_created':
$updated_message = __("Database table created.", 'wpcf7');
break;
case 'table_not_created':
$updated_message = __("Failed to create database table.", 'wpcf7');
break;
}
$contact_forms = wpcf7_contact_forms();
$id = $_POST['wpcf7-id'];
if ('new' == $_GET['contactform']) {
$unsaved = true;
$current = -1;
$cf = wpcf7_contact_form_default_pack();
} elseif ($cf = wpcf7_contact_form($_GET['contactform'])) {
$current = (int) $_GET['contactform'];
} else {
$first = reset($contact_forms);
// Returns first item
$current = $first->id;
$cf = wpcf7_contact_form($current);
}
require_once WPCF8_PLUGIN_DIR . '/admin/admin-panel.php';
}