当前位置: 首页>>代码示例>>PHP>>正文


PHP WPCF7_ContactForm::get_instance方法代码示例

本文整理汇总了PHP中WPCF7_ContactForm::get_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF7_ContactForm::get_instance方法的具体用法?PHP WPCF7_ContactForm::get_instance怎么用?PHP WPCF7_ContactForm::get_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WPCF7_ContactForm的用法示例。


在下文中一共展示了WPCF7_ContactForm::get_instance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cf7bs_get_form_property

function cf7bs_get_form_property($property, $form_id = 0)
{
    global $current_form_id, $current_form_properties;
    $current_form = $original_form = null;
    if (!$form_id) {
        $form_id = cf7bs_get_current_form_id();
        if (!$form_id) {
            return false;
        }
        $current_form = WPCF7_ContactForm::get_current();
    } else {
        $current_form = WPCF7_ContactForm::get_instance($form_id);
        $original_form = WPCF7_ContactForm::get_current();
        if (is_a($current_form, 'WPCF7_ContactForm') && is_callable(array($current_form, 'id')) && is_a($original_form, 'WPCF7_ContactForm') && is_callable(array($original_form, 'id'))) {
            if ($original_form->id() === $current_form->id()) {
                $original_form = null;
            }
        }
    }
    if ($current_form_id != $form_id) {
        $current_form_id = $form_id;
        $properties = cf7bs_get_default_form_properties();
        if (is_a($current_form, 'WPCF7_ContactForm') && is_callable(array($current_form, 'additional_setting'))) {
            foreach ($properties as $key => &$value) {
                $setting = $current_form->additional_setting($key);
                if (isset($setting[0])) {
                    $value = $setting[0];
                }
            }
            unset($key);
            unset($value);
        }
        $current_form_properties = apply_filters('cf7bs_form_' . $form_id . '_properties', $properties);
    }
    if (null !== $original_form) {
        if (is_a($original_form, 'WPCF7_ContactForm') && is_callable(array($original_form, 'id'))) {
            WPCF7_ContactForm::get_instance($original_form->id());
        }
    }
    if (isset($current_form_properties[$property])) {
        return $current_form_properties[$property];
    }
    return false;
}
开发者ID:aaronfrey,项目名称:PepperLillie-KSG,代码行数:44,代码来源:bootstrap-for-contact-form-7.php

示例2: wpcf7_contact_form

function wpcf7_contact_form($id)
{
    return WPCF7_ContactForm::get_instance($id);
}
开发者ID:estrategasdigitales,项目名称:dictobas,代码行数:4,代码来源:contact-form.php

示例3: __construct

 /**
  * Constructor for class
  *
  * @since 1.0.0
  */
 public function __construct()
 {
     // add admin page
     add_action('admin_menu', array($this, 'add_settings_pages'), 25);
     // save config
     add_action('wp_ajax_frmwks_save_config', array($this, 'save_config'));
     // exporter
     add_action('init', array($this, 'check_exporter'));
     // get forms list
     add_filter('formworks_get_forms', array($this, 'get_forms'));
     add_action('wp_ajax_frmwks_module_data', array($this, 'module_data_loader'));
     if (current_user_can('manage_options')) {
         add_action('wp_ajax_frmwks_rebuild_database', array($this, 'rebuild_database'));
         //add_action( 'wp_ajax_frmwks_reset_form_stats', array( $this, 'reset_form_stats') );
     }
     // create new
     add_action('wp_ajax_frmwks_create_formworks', array($this, 'create_new_formworks'));
     // delete
     add_action('wp_ajax_frmwks_delete_formworks', array($this, 'delete_formworks'));
     add_filter('formworks_stats_field_name', function ($field, $form_prefix, $form_id) {
         switch ($form_prefix) {
             case 'caldera':
                 if (false !== strpos($field, '[')) {
                     $field = strtok($field, '[');
                 }
                 // is CF
                 $form = \Caldera_Forms::get_form($form_id);
                 if (empty($form)) {
                     continue;
                 }
                 if (!empty($form['fields'][$field]['label'])) {
                     $field = $form['fields'][$field]['label'];
                 }
                 break;
             case 'gform':
                 //get gravity form
                 if (!class_exists('RGFormsModel')) {
                     continue;
                 }
                 $form_info = \RGFormsModel::get_form($form_id);
                 break;
             case 'ninja':
                 //get ninja form
                 if (!function_exists('Ninja_Forms')) {
                     continue;
                 }
                 $form_name = Ninja_Forms()->form($form_id)->get_setting('form_title');
                 $form_id = $form_id;
                 break;
             case 'cf7':
                 //get contact form 7
                 if (!class_exists('WPCF7_ContactForm')) {
                     continue;
                 }
                 $cf7form = \WPCF7_ContactForm::get_instance($form_id);
                 $form_name = $cf7form->title();
                 $form_id = $cf7form->id();
                 break;
             case 'frmid':
                 if (!class_exists('FrmForm')) {
                     continue;
                 }
                 $field_id = (int) strtok(str_replace('item_meta[', '', $field), ']');
                 $form_field = \FrmField::getOne($field_id);
                 $field = $form_field->name;
                 if (!empty($form_field->description) && $form_field->description != $form_field->name) {
                     $field .= ':' . $form_field->description;
                 }
                 break;
             case 'jp':
                 $form_post = get_post($form_id);
                 if (empty($form_post)) {
                     continue;
                 }
                 $field = ucwords(str_replace('g' . $form_id . '-', '', $field));
                 break;
             default:
                 //no idea what this is or the form plugin was disabled.
                 break;
         }
         return $field;
     }, 10, 3);
 }
开发者ID:CalderaWP,项目名称:formworks,代码行数:88,代码来源:settings.php

示例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'));
        }
    }
}
开发者ID:ArtistryandFunction,项目名称:contact-form-7,代码行数:88,代码来源:admin.php


注:本文中的WPCF7_ContactForm::get_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。