本文整理汇总了PHP中WPCF7_ContactForm::get_template方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF7_ContactForm::get_template方法的具体用法?PHP WPCF7_ContactForm::get_template怎么用?PHP WPCF7_ContactForm::get_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPCF7_ContactForm
的用法示例。
在下文中一共展示了WPCF7_ContactForm::get_template方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf7_install
function wpcf7_install()
{
if ($opt = get_option('wpcf7')) {
return;
}
wpcf7_load_textdomain();
wpcf7_register_post_types();
wpcf7_upgrade();
if (get_posts(array('post_type' => 'wpcf7_contact_form'))) {
return;
}
$contact_form = WPCF7_ContactForm::get_template(array('title' => sprintf(__('Contact form %d', 'contact-form-7'), 1)));
$contact_form->save();
}
示例2: wpcf7_admin_add_new_page
function wpcf7_admin_add_new_page()
{
$post = wpcf7_get_current_contact_form();
if (!$post) {
$post = WPCF7_ContactForm::get_template();
}
$post_id = -1;
require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
}
示例3: wpcf7_install
function wpcf7_install()
{
if ($opt = get_option('wpcf7')) {
return;
}
wpcf7_load_textdomain();
wpcf7_register_post_types();
wpcf7_upgrade();
if (get_posts(array('post_type' => 'wpcf7_contact_form'))) {
return;
}
$contact_form = WPCF7_ContactForm::get_template(array('title' => sprintf(__('Contact form %d', 'contact-form-7'), 1)));
$contact_form->save();
WPCF7::update_option('bulk_validate', array('timestamp' => current_time('timestamp'), 'version' => WPCF7_VERSION, 'count_valid' => 1, 'count_invalid' => 0));
}
示例4: 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'));
}
}
}
示例5: 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();
}