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


PHP mc4wp_get_form函数代码示例

本文整理汇总了PHP中mc4wp_get_form函数的典型用法代码示例。如果您正苦于以下问题:PHP mc4wp_get_form函数的具体用法?PHP mc4wp_get_form怎么用?PHP mc4wp_get_form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: output_form

 /**
  * @param int   $id
  * @param array $config
  * @param bool $echo
  *
  * @return string
  */
 public function output_form($id = 0, $config = array(), $echo = true)
 {
     try {
         $form = mc4wp_get_form($id);
     } catch (Exception $e) {
         if (current_user_can('manage_options')) {
             return sprintf('<strong>MailChimp for WordPress error:</strong> %s', $e->getMessage());
         }
         return '';
     }
     $this->count++;
     if (empty($config['element_id'])) {
         $config['element_id'] = 'mc4wp-form-' . $this->count;
     }
     $this->printed_forms[$form->ID] = $form;
     $this->printed_field_types += $form->get_field_types();
     $this->printed_field_types = array_unique($this->printed_field_types);
     $html = $form->get_html($config['element_id'], $config);
     /**
      * Runs just before a form element is outputted.
      *
      * @since 3.0
      *
      * @param MC4WP_Form $form
      */
     do_action('mc4wp_output_form', $form);
     if ($echo) {
         echo $html;
     }
     return $html;
 }
开发者ID:petersuhm,项目名称:mailchimp-for-wordpress,代码行数:38,代码来源:class-output-manager.php

示例2: listen

 /**
  * Listen for submitted forms
  *
  * @param $data
  * @return bool
  */
 public function listen(array $data)
 {
     if (!isset($data['_mc4wp_form_id'])) {
         return false;
     }
     /**
      * @var MC4WP_Request $request
      */
     $request = mc4wp('request');
     try {
         $form = mc4wp_get_form($request->params->get('_mc4wp_form_id'));
     } catch (Exception $e) {
         return false;
     }
     // where the magic happens
     $form->handle_request($request);
     $form->validate();
     // store submitted form
     $this->submitted_form = $form;
     // did form have errors?
     if (!$form->has_errors()) {
         // form was valid, do something
         $method = 'process_' . $form->get_action() . '_form';
         call_user_func(array($this, $method), $form);
     }
     $this->respond($form);
     return true;
 }
开发者ID:petersuhm,项目名称:mailchimp-for-wordpress,代码行数:34,代码来源:class-form-listener.php

示例3: listen

 /**
  * Listen for submitted forms
  *
  * @param MC4WP_Request $request
  * @return bool
  */
 public function listen(MC4WP_Request $request)
 {
     if (!$request->post->get('_mc4wp_form_id')) {
         return false;
     }
     try {
         $form = mc4wp_get_form($request->params->get('_mc4wp_form_id'));
     } catch (Exception $e) {
         return false;
     }
     // where the magic happens
     $form->handle_request($request);
     $form->validate();
     // store submitted form
     $this->submitted_form = $form;
     // did form have errors?
     if (!$form->has_errors()) {
         // form was valid, do something
         $method = 'process_' . $form->get_action() . '_form';
         call_user_func(array($this, $method), $form);
     } else {
         $this->get_log()->info(sprintf("Form %d > Submitted with errors: %s", $form->ID, join(', ', $form->errors)));
     }
     $this->respond($form);
     return true;
 }
开发者ID:aaronfrey,项目名称:PepperLillie-TAT,代码行数:32,代码来源:class-form-listener.php

示例4: __construct

 /**
  * @param int $form_id
  * @param int $preview_id
  *
  * @throws Exception
  */
 public function __construct($form_id, $preview_id = 0)
 {
     $this->form_id = $form_id;
     $this->preview_id = $preview_id;
     $this->is_preview = $preview_id > 0;
     if (!$this->is_preview) {
         $this->preview_id = $form_id;
     }
     $this->form = mc4wp_get_form($this->preview_id);
 }
开发者ID:spielhoelle,项目名称:amnesty,代码行数:16,代码来源:class-form-previewer.php

示例5: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array   $args     Widget arguments.
  * @param array   $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     // make sure template functions exist (for usage in avia layout builder)
     if (!function_exists('mc4wp_get_form')) {
         include_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions/template.php';
     }
     echo mc4wp_get_form(0);
     echo $args['after_widget'];
 }
开发者ID:sydneyDAD,项目名称:cardguys.com,代码行数:22,代码来源:class-widget.php

示例6: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array   $args     Widget arguments.
  * @param array   $options Saved values from database.
  */
 public function widget($args, $options)
 {
     $options = array_merge($this->default_options, $options);
     $options['title'] = apply_filters('widget_title', $options['title']);
     if (empty($options['form_id'])) {
         $options['form_id'] = get_option('mc4wp_default_form_id', 0);
     }
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $options['title'] . $args['after_title'];
     }
     echo mc4wp_get_form($options['form_id']);
     echo $args['after_widget'];
 }
开发者ID:hchouhan,项目名称:mailchimp-for-wordpress,代码行数:22,代码来源:Widget.php

示例7: __construct

 /**
  * @param int $form_id
  * @param bool $is_preview
  */
 public function __construct($form_id, $is_preview = false)
 {
     $this->form_id = $form_id;
     $this->is_preview = $is_preview;
     // get the preview form
     if ($is_preview) {
         $this->preview_form_id = $this->get_preview_id();
     }
     // if that failed, get the real form
     if (empty($this->preview_form_id)) {
         $this->preview_form_id = $this->form_id;
     }
     // get form instance
     $this->form = mc4wp_get_form($this->preview_form_id);
 }
开发者ID:nihrain,项目名称:accelerate,代码行数:19,代码来源:class-form-previewer.php

示例8: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array   $args     Widget arguments.
  * @param array   $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     $form_id = isset($instance['form_id']) ? $instance['form_id'] : get_option('mc4wp_default_form_id', 0);
     if (empty($form_id)) {
         if (current_user_can('manage_options')) {
             $form = 'Please select the sign-up form you\'d like to show here in the <a href="' . admin_url('widgets.php') . '">widget settings</a>.';
         } else {
             $form = '';
         }
     } else {
         $form = mc4wp_get_form($form_id);
     }
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     echo $form;
     echo $args['after_widget'];
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:28,代码来源:class-widget.php

示例9: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array   $args     Widget arguments.
  * @param array   $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     $title = isset($instance['title']) ? $instance['title'] : '';
     $title = apply_filters('widget_title', $title);
     // which form should we show?
     $form_id = isset($instance['form_id']) && !empty($instance['form_id']) ? $instance['form_id'] : get_option('mc4wp_default_form_id', false);
     if (false === $form_id) {
         if (current_user_can('manage_options')) {
             $form = sprintf(__('Please select the sign-up form you\'d like to show here in the <a href="%s">widget settings</a>.', 'mailchimp-for-wp'), admin_url('widgets.php'));
         } else {
             $form = '';
         }
     } else {
         $form = mc4wp_get_form($form_id);
     }
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     echo $form;
     echo $args['after_widget'];
 }
开发者ID:Ore4444,项目名称:old.backfeed.cc,代码行数:30,代码来源:class-widget.php

示例10: output_form

 /**
  * @param int   $id
  * @param array $config
  * @param bool $echo
  *
  * @return string
  */
 public function output_form($id = 0, $config = array(), $echo = true)
 {
     try {
         $form = mc4wp_get_form($id);
     } catch (Exception $e) {
         if (current_user_can('manage_options')) {
             return sprintf('<strong>MailChimp for WordPress error:</strong> %s', $e->getMessage());
         }
         return '';
     }
     $this->count++;
     // set a default element_id if none is given
     if (empty($config['element_id'])) {
         $config['element_id'] = 'mc4wp-form-' . $this->count;
     }
     $this->printed_forms[$form->ID] = $form;
     $this->printed_field_types += $form->get_field_types();
     $this->printed_field_types = array_unique($this->printed_field_types);
     // start new output buffer
     ob_start();
     /**
      * Runs just before a form element is outputted.
      *
      * @since 3.0
      *
      * @param MC4WP_Form $form
      */
     do_action('mc4wp_output_form', $form);
     // output the form (in output buffer)
     echo $form->get_html($config['element_id'], $config);
     // grab all contents in current output buffer & then clean it.
     $html = ob_get_clean();
     // echo content if necessary
     if ($echo) {
         echo $html;
     }
     return $html;
 }
开发者ID:dannyvankooten,项目名称:mailchimp-for-wordpress,代码行数:45,代码来源:class-output-manager.php

示例11: listen

 /**
  * Listen for submitted forms
  *
  * @param $data
  * @return bool
  */
 public function listen(array $data)
 {
     if (!isset($data['_mc4wp_form_id'])) {
         return false;
     }
     $request = mc4wp('request');
     try {
         $form = mc4wp_get_form($request->params->get('_mc4wp_form_id'));
     } catch (Exception $e) {
         return false;
     }
     // where the magic happens
     $form->handle_request($request);
     $this->submitted_form = $form;
     // is this form valid?
     if ($form->is_valid()) {
         // form was valid, do something
         $method = 'process_' . $form->get_action() . '_form';
         call_user_func(array($this, $method), $form);
     }
     $this->respond($form);
     return true;
 }
开发者ID:novichkovv,项目名称:prlab,代码行数:29,代码来源:class-form-listener.php

示例12: show_page

 /**
  * Show Styles Builder page
  */
 function show_page()
 {
     $forms = mc4wp_get_forms();
     $form_id = $forms[0]->ID;
     // get form to which styles should apply
     if (isset($_GET['form_id'])) {
         $form_id = absint($_GET['form_id']);
     }
     $form = mc4wp_get_form($form_id);
     // get css settings for this form (or 0)
     $builder = new MC4WP_Styles_Builder();
     $styles = $builder->get_form_styles($form_id);
     // create preview url
     $preview_url = add_query_arg(array('form_id' => $form_id, '_mc4wp_styles_builder_preview' => 1), home_url());
     require dirname(__FILE__) . '/../views/styles-builder.php';
 }
开发者ID:siggisdairy,项目名称:siggis-web,代码行数:19,代码来源:class-admin.php

示例13: show_edit_page

 /**
  * Show the "Edit Form" page
  *
  * @internal
  */
 public function show_edit_page()
 {
     $form_id = !empty($_GET['form_id']) ? (int) $_GET['form_id'] : 0;
     $lists = $this->mailchimp->get_lists();
     try {
         $form = mc4wp_get_form($form_id);
     } catch (Exception $e) {
         echo '<h2>' . __("Form not found.", 'mailchimp-for-wp') . '</h2>';
         echo '<p>' . $e->getMessage() . '</p>';
         echo '<p><a href="javascript:history.go(-1);"> &lsaquo; ' . __('Go back') . '</a></p>';
         return;
     }
     $opts = $form->settings;
     $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'fields';
     require dirname(__FILE__) . '/views/edit-form.php';
 }
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:21,代码来源:class-admin.php

示例14: mc4wp_form_get_response_html

/**
 * @since 2.3.8
 * @deprecated 3.0
 * @ignore
 * @use mc4wp_get_form
 *
 * @param int $form_id (optional)
 *
 * @return string
 */
function mc4wp_form_get_response_html($form_id = 0)
{
    try {
        $form = mc4wp_get_form($form_id);
    } catch (Exception $e) {
        return '';
    }
    return $form->get_response_html();
}
开发者ID:nihrain,项目名称:accelerate,代码行数:19,代码来源:functions.php

示例15: column_type

 /**
  * Outputs the text for the "type" column
  *
  * @param $item
  *
  * @return string|void
  */
 public function column_type($item)
 {
     if (isset($this->integrations[$item->type])) {
         $object_link = $this->integrations[$item->type]->get_object_link($item->related_object_ID);
         if (!empty($object_link)) {
             return $object_link;
         }
         return $this->integrations[$item->type]->name;
     }
     if ($item->type === 'mc4wp-form') {
         $form_id = $item->related_object_ID;
         try {
             $form = mc4wp_get_form($form_id);
             return '<a href="' . mc4wp_get_edit_form_url($form->ID) . '">' . $form->name . '</a>';
         } catch (Exception $e) {
             return __('Form', 'mailchimp-for-wp') . ' ' . $form_id . ' <em>(' . __('deleted', 'mailchimp-for-wp') . ')</em>';
         }
     } elseif ($item->type === 'mc4wp-top-bar') {
         return 'MailChimp Top Bar';
     }
     return $item->type;
 }
开发者ID:siggisdairy,项目名称:siggis-web,代码行数:29,代码来源:class-log-table.php


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