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


PHP gf_do_action函数代码示例

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


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

示例1: update_form_meta

 public static function update_form_meta($form_id, $form_meta, $meta_name = 'display_meta')
 {
     global $wpdb;
     $form_meta = gf_apply_filters('gform_form_update_meta', $form_id, $form_meta, $form_id, $meta_name);
     $meta_table_name = self::get_meta_table_name();
     $form_meta = json_encode($form_meta);
     if (intval($wpdb->get_var($wpdb->prepare("SELECT count(0) FROM {$meta_table_name} WHERE form_id=%d", $form_id))) > 0) {
         $result = $wpdb->query($wpdb->prepare("UPDATE {$meta_table_name} SET {$meta_name}=%s WHERE form_id=%d", $form_meta, $form_id));
     } else {
         $result = $wpdb->query($wpdb->prepare("INSERT INTO {$meta_table_name}(form_id, {$meta_name}) VALUES(%d, %s)", $form_id, $form_meta));
     }
     self::$_current_forms[$form_id] = null;
     gf_do_action('gform_post_update_form_meta', $form_id, $form_meta, $form_id, $meta_name);
     return $result;
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:15,代码来源:forms_model.php

示例2: lead_detail_page


//.........这里部分代码省略.........
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
            return;
        }
        RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
        switch (RGForms::post('action')) {
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                $original_entry = $lead;
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                /**
                 * Fires after the Entry is updated from the entry detail page.
                 *
                 * @param array $form The form object for the entry.
                 * @param integer $lead['id'] The entry ID.
                 * @param array $original_entry The entry object before being updated.
                 */
                gf_do_action(array('gform_after_update_entry', $form['id']), $form, $lead['id'], $original_entry);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
                //emailing notes if configured
                if (rgpost('gentry_email_notes_to')) {
                    GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
                    $email_to = $_POST['gentry_email_notes_to'];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST['gentry_email_subject']);
                    $body = stripslashes($_POST['new_note']);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
                    $is_success = wp_mail($email_to, $email_subject, $body, $headers);
                    $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
                    if (!is_wp_error($is_success) && $is_success) {
                        GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
                    } else {
                        GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
                    }
                    if (has_filter('phpmailer_init')) {
                        GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
                    }
                    /**
                     * Fires after a note is attached to an entry and sent as an email
                     *
                     * @param string $result The Error message or success message when the entry note is sent
                     * @param string $email_to The email address to send the entry note to
开发者ID:slavic18,项目名称:cats,代码行数:67,代码来源:entry_detail.php

示例3: register_form_init_scripts

 /**
  * Enqueue and retrieve all inline scripts that should be executed when the form is rendered.
  * Use add_init_script() function to enqueue scripts.
  *
  * @param array $form
  * @param array $field_values
  * @param bool  $is_ajax
  */
 private static function register_form_init_scripts($form, $field_values = array(), $is_ajax = false)
 {
     if (rgars($form, 'save/enabled')) {
         $save_script = "jQuery('#gform_save_{$form['id']}').val('');";
         self::add_init_script($form['id'], 'save', self::ON_PAGE_RENDER, $save_script);
     }
     // adding conditional logic script if conditional logic is configured for this form.
     // get_conditional_logic also adds the chosen script for the enhanced dropdown option.
     // if this form does not have conditional logic, add chosen script separately
     if (self::has_conditional_logic($form)) {
         self::add_init_script($form['id'], 'number_formats', self::ON_PAGE_RENDER, self::get_number_formats_script($form));
         self::add_init_script($form['id'], 'conditional_logic', self::ON_PAGE_RENDER, self::get_conditional_logic($form, $field_values));
     }
     //adding currency config if there are any product fields in the form
     if (self::has_price_field($form)) {
         self::add_init_script($form['id'], 'pricing', self::ON_PAGE_RENDER, self::get_pricing_init_script($form));
     }
     if (self::has_password_strength($form)) {
         $password_script = self::get_password_strength_init_script($form);
         self::add_init_script($form['id'], 'password', self::ON_PAGE_RENDER, $password_script);
     }
     if (self::has_enhanced_dropdown($form)) {
         $chosen_script = self::get_chosen_init_script($form);
         self::add_init_script($form['id'], 'chosen', self::ON_PAGE_RENDER, $chosen_script);
         self::add_init_script($form['id'], 'chosen', self::ON_CONDITIONAL_LOGIC, $chosen_script);
     }
     if (self::has_character_counter($form)) {
         self::add_init_script($form['id'], 'character_counter', self::ON_PAGE_RENDER, self::get_counter_init_script($form));
     }
     if (self::has_input_mask($form)) {
         self::add_init_script($form['id'], 'input_mask', self::ON_PAGE_RENDER, self::get_input_mask_init_script($form));
     }
     if (self::has_calculation_field($form)) {
         self::add_init_script($form['id'], 'number_formats', self::ON_PAGE_RENDER, self::get_number_formats_script($form));
         self::add_init_script($form['id'], 'calculation', self::ON_PAGE_RENDER, self::get_calculations_init_script($form));
     }
     if (self::has_currency_format_number_field($form)) {
         self::add_init_script($form['id'], 'currency_format', self::ON_PAGE_RENDER, self::get_currency_format_init_script($form));
     }
     if (self::has_currency_copy_values_option($form)) {
         self::add_init_script($form['id'], 'copy_values', self::ON_PAGE_RENDER, self::get_copy_values_init_script($form));
     }
     if (self::has_placeholder($form)) {
         self::add_init_script($form['id'], 'placeholders', self::ON_PAGE_RENDER, self::get_placeholders_init_script($form));
     }
     if (isset($form['fields']) && is_array($form['fields'])) {
         foreach ($form['fields'] as $field) {
             /* @var GF_Field $field */
             if (is_subclass_of($field, 'GF_Field')) {
                 $field->register_form_init_scripts($form);
             }
         }
     }
     /**
      * Fires when inline Gravity Forms scripts are enqueued
      *
      * Used to enqueue additional inline scripts
      *
      * @param array  $form       The Form object
      * @param string $field_vale The current value of the selected field
      * @param bool   $is_ajax    Returns true if using AJAX.  Otherwise, false
      */
     gf_do_action(array('gform_register_init_scripts', $form['id']), $form, $field_values, $is_ajax);
 }
开发者ID:timk85,项目名称:DIT,代码行数:72,代码来源:form_display.php

示例4: update_entry


//.........这里部分代码省略.........
     $ip = isset($entry['ip']) ? $entry['ip'] : GFFormsModel::get_ip();
     $source_url = isset($entry['source_url']) ? $entry['source_url'] : GFFormsModel::get_current_page_url();
     $user_agent = isset($entry['user_agent']) ? $entry['user_agent'] : 'API';
     $currency = isset($entry['currency']) ? $entry['currency'] : GFCommon::get_currency();
     $payment_status = isset($entry['payment_status']) ? sprintf("'%s'", esc_sql($entry['payment_status'])) : 'NULL';
     $payment_date = strtotime(rgar($entry, 'payment_date')) ? "'" . gmdate('Y-m-d H:i:s', strtotime("{$entry['payment_date']}")) . "'" : 'NULL';
     $payment_amount = isset($entry['payment_amount']) ? (double) $entry['payment_amount'] : 'NULL';
     $payment_method = isset($entry['payment_method']) ? $entry['payment_method'] : '';
     $transaction_id = isset($entry['transaction_id']) ? sprintf("'%s'", esc_sql($entry['transaction_id'])) : 'NULL';
     $is_fulfilled = isset($entry['is_fulfilled']) ? intval($entry['is_fulfilled']) : 'NULL';
     $status = isset($entry['status']) ? $entry['status'] : 'active';
     global $current_user;
     $user_id = isset($entry['created_by']) ? absint($entry['created_by']) : '';
     if (empty($user_id)) {
         $user_id = $current_user && $current_user->ID ? absint($current_user->ID) : 'NULL';
     }
     $transaction_type = isset($entry['transaction_type']) ? intval($entry['transaction_type']) : 'NULL';
     $lead_table = GFFormsModel::get_lead_table_name();
     $sql = $wpdb->prepare("\n                UPDATE {$lead_table}\n                SET\n                form_id = %d,\n                post_id = {$post_id},\n                date_created = {$date_created},\n                is_starred = %d,\n                is_read = %d,\n                ip = %s,\n                source_url = %s,\n                user_agent = %s,\n                currency = %s,\n                payment_status = {$payment_status},\n                payment_date = {$payment_date},\n                payment_amount = {$payment_amount},\n                transaction_id = {$transaction_id},\n                is_fulfilled = {$is_fulfilled},\n                created_by = {$user_id},\n                transaction_type = {$transaction_type},\n                status = %s,\n                payment_method = %s\n                WHERE\n                id = %d\n                ", $form_id, $is_starred, $is_read, $ip, $source_url, $user_agent, $currency, $status, $payment_method, $entry_id);
     $result = $wpdb->query($sql);
     if (false === $result) {
         return new WP_Error('update_entry_properties_failed', __('There was a problem while updating the entry properties', 'gravityforms'), $wpdb->last_error);
     }
     // only save field values for fields that currently exist in the form. The rest in $entry will be ignored. The rest in $current_entry will get deleted.
     $lead_detail_table = GFFormsModel::get_lead_details_table_name();
     $current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $entry_id));
     $form = GFFormsModel::get_form_meta($form_id);
     $form = gf_apply_filters(array('gform_form_pre_update_entry', $form_id), $form, $entry, $entry_id);
     foreach ($form['fields'] as $field) {
         /* @var GF_Field $field */
         $type = GFFormsModel::get_input_type($field);
         if (in_array($type, array('html', 'page', 'section'))) {
             continue;
         }
         $inputs = $field->get_entry_inputs();
         if (is_array($inputs)) {
             foreach ($field->inputs as $input) {
                 $input_id = (string) $input['id'];
                 if (isset($entry[$input_id])) {
                     if ($entry[$input_id] != $current_entry[$input_id]) {
                         $lead_detail_id = GFFormsModel::get_lead_detail_id($current_fields, $input_id);
                         $result = GFFormsModel::update_lead_field_value($form, $entry, $field, $lead_detail_id, $input_id, $entry[$input_id]);
                         if (false === $result) {
                             return new WP_Error('update_input_value_failed', __('There was a problem while updating one of the input values for the entry', 'gravityforms'), $wpdb->last_error);
                         }
                     }
                     unset($current_entry[$input_id]);
                 }
             }
         } else {
             $field_id = $field->id;
             $field_value = isset($entry[(string) $field_id]) ? $entry[(string) $field_id] : '';
             if ($field_value != $current_entry[$field_id]) {
                 $lead_detail_id = GFFormsModel::get_lead_detail_id($current_fields, $field_id);
                 $result = GFFormsModel::update_lead_field_value($form, $entry, $field, $lead_detail_id, $field_id, $field_value);
                 if (false === $result) {
                     return new WP_Error('update_field_values_failed', __('There was a problem while updating the field values', 'gravityforms'), $wpdb->last_error);
                 }
             }
             unset($current_entry[$field_id]);
         }
     }
     // save the entry meta values - only for the entry meta currently available for the form, ignore the rest
     $entry_meta = GFFormsModel::get_entry_meta($form_id);
     if (is_array($entry_meta)) {
         foreach (array_keys($entry_meta) as $key) {
             if (isset($entry[$key])) {
                 if ($entry[$key] != $current_entry[$key]) {
                     gform_update_meta($entry_id, $key, $entry[$key]);
                 }
                 unset($current_entry[$key]);
             }
         }
     }
     // now delete remaining values from the old entry
     if (is_array($entry_meta)) {
         foreach (array_keys($entry_meta) as $meta_key) {
             if (isset($current_entry[$meta_key])) {
                 gform_delete_meta($entry_id, $meta_key);
                 unset($current_entry[$meta_key]);
             }
         }
     }
     foreach ($current_entry as $k => $v) {
         $lead_detail_id = GFFormsModel::get_lead_detail_id($current_fields, $k);
         $field = GFFormsModel::get_field($form, $k);
         $result = GFFormsModel::update_lead_field_value($form, $entry, $field, $lead_detail_id, $k, '');
         if (false === $result) {
             return new WP_Error('update_field_values_failed', __('There was a problem while updating the field values', 'gravityforms'), $wpdb->last_error);
         }
     }
     /**
      * Fires after the Entry is updated.
      *
      * @param array $lead The entry object after being updated.
      * @param array $original_entry The entry object before being updated.
      */
     gf_do_action(array('gform_post_update_entry', $form_id), $entry, $original_entry);
     return true;
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:101,代码来源:api.php

示例5: add_feed_error

 public function add_feed_error($error_message, $feed, $entry, $form)
 {
     /* Log debug error before we prepend the error name. */
     $backtrace = debug_backtrace();
     $method = $backtrace[1]['class'] . '::' . $backtrace[1]['function'];
     $this->log_error($method . '(): ' . $error_message);
     /* Prepend feed name to the error message. */
     $feed_name = rgars($feed, 'meta/feed_name') ? rgars($feed, 'meta/feed_name') : rgars($feed, 'meta/feedName');
     $error_message = $feed_name . ': ' . $error_message;
     /* Add error note to the entry. */
     $this->add_note($entry['id'], $error_message, 'error');
     /* Get Add-On slug */
     $slug = str_replace('gravityforms', '', $this->_slug);
     /* Process any error actions. */
     gf_do_action(array("gform_{$slug}_error", $form['id']), $feed, $entry, $form);
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:16,代码来源:class-gf-feed-addon.php

示例6: upload


//.........这里部分代码省略.........
         $valid_uploaded_filename = GFCommon::check_type_and_ext($_FILES['file'], $uploaded_filename);
         if (is_wp_error($valid_uploaded_filename)) {
             self::die_error($valid_uploaded_filename->get_error_code(), $valid_uploaded_filename->get_error_message());
         }
         $valid_file_name = GFCommon::check_type_and_ext($_FILES['file'], $file_name);
         if (is_wp_error($valid_uploaded_filename)) {
             self::die_error($valid_file_name->get_error_code(), $valid_file_name->get_error_message());
         }
     }
     $tmp_file_name = $form_unique_id . '_input_' . $field_id . '_' . $file_name;
     $tmp_file_name = sanitize_file_name($tmp_file_name);
     $file_path = $target_dir . $tmp_file_name;
     $cleanup_target_dir = true;
     // Remove old files
     $max_file_age = 5 * 3600;
     // Temp file age in seconds
     // Remove old temp files
     if ($cleanup_target_dir) {
         if (is_dir($target_dir) && ($dir = opendir($target_dir))) {
             while (($file = readdir($dir)) !== false) {
                 $tmp_file_path = $target_dir . $file;
                 // Remove temp file if it is older than the max age and is not the current file
                 if (preg_match('/\\.part$/', $file) && filemtime($tmp_file_path) < time() - $max_file_age && $tmp_file_path != "{$file_path}.part") {
                     GFCommon::log_debug('GFAsyncUpload::upload(): Deleting file: ' . $tmp_file_path);
                     @unlink($tmp_file_path);
                 }
             }
             closedir($dir);
         } else {
             GFCommon::log_debug('GFAsyncUpload::upload(): Failed to open temp directory: ' . $target_dir);
             self::die_error(100, __('Failed to open temp directory.', 'gravityforms'));
         }
     }
     if (isset($_SERVER['HTTP_CONTENT_TYPE'])) {
         $contentType = $_SERVER['HTTP_CONTENT_TYPE'];
     }
     if (isset($_SERVER['CONTENT_TYPE'])) {
         $contentType = $_SERVER['CONTENT_TYPE'];
     }
     $chunk = isset($_REQUEST['chunk']) ? intval($_REQUEST['chunk']) : 0;
     $chunks = isset($_REQUEST['chunks']) ? intval($_REQUEST['chunks']) : 0;
     // Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
     if (strpos($contentType, 'multipart') !== false) {
         if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
             // Open temp file
             $out = @fopen("{$file_path}.part", $chunk == 0 ? 'wb' : 'ab');
             if ($out) {
                 // Read binary input stream and append it to temp file
                 $in = @fopen($_FILES['file']['tmp_name'], 'rb');
                 if ($in) {
                     while ($buff = fread($in, 4096)) {
                         fwrite($out, $buff);
                     }
                 } else {
                     self::die_error(101, __('Failed to open input stream.', 'gravityforms'));
                 }
                 @fclose($in);
                 @fclose($out);
                 @unlink($_FILES['file']['tmp_name']);
             } else {
                 self::die_error(102, __('Failed to open output stream.', 'gravityforms'));
             }
         } else {
             self::die_error(103, __('Failed to move uploaded file.', 'gravityforms'));
         }
     } else {
         // Open temp file
         $out = @fopen("{$file_path}.part", $chunk == 0 ? 'wb' : 'ab');
         if ($out) {
             // Read binary input stream and append it to temp file
             $in = @fopen('php://input', 'rb');
             if ($in) {
                 while ($buff = fread($in, 4096)) {
                     fwrite($out, $buff);
                 }
             } else {
                 self::die_error(101, __('Failed to open input stream.', 'gravityforms'));
             }
             @fclose($in);
             @fclose($out);
         } else {
             self::die_error(102, __('Failed to open output stream.', 'gravityforms'));
         }
     }
     // Check if file has been uploaded
     if (!$chunks || $chunk == $chunks - 1) {
         // Strip the temp .part suffix off
         rename("{$file_path}.part", $file_path);
     }
     if (file_exists($file_path)) {
         GFFormsModel::set_permissions($file_path);
     } else {
         self::die_error(105, __('Upload unsuccessful', 'gravityforms') . ' ' . $uploaded_filename);
     }
     $output = array('status' => 'ok', 'data' => array('temp_filename' => $tmp_file_name, 'uploaded_filename' => str_replace("\\'", "'", urldecode($uploaded_filename))));
     $output = json_encode($output);
     GFCommon::log_debug(sprintf('GFAsyncUpload::upload(): File upload complete. temp_filename: %s  uploaded_filename: %s ', $tmp_file_name, $uploaded_filename));
     gf_do_action('gform_post_multifile_upload', $form['id'], $form, $field, $uploaded_filename, $tmp_file_name, $file_path);
     die($output);
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:101,代码来源:upload.php

示例7: create_post


//.........这里部分代码省略.........
                             if (!rgblank($item)) {
                                 add_post_meta($post_id, $meta_name, $item);
                             }
                         }
                     }
                     break;
                 case 'multiselect':
                 case 'checkbox':
                     $value = explode(',', $value);
                     if (is_array($value)) {
                         foreach ($value as $item) {
                             if (!rgblank($item)) {
                                 // add post meta and replace HTML symbol in $item with real comma
                                 add_post_meta($post_id, $meta_name, str_replace('&#44;', ',', $item));
                             }
                         }
                     }
                     break;
                 case 'date':
                     $value = GFCommon::date_display($value, rgar($custom_field, 'dateFormat'));
                     if (!rgblank($value)) {
                         add_post_meta($post_id, $meta_name, $value);
                     }
                     break;
                 default:
                     if (!rgblank($value)) {
                         add_post_meta($post_id, $meta_name, $value);
                     }
                     break;
             }
             $meta_index++;
         }
     }
     $has_content_field = sizeof(self::get_fields_by_type($form, array('post_content'))) > 0;
     $has_title_field = sizeof(self::get_fields_by_type($form, array('post_title'))) > 0;
     $post = false;
     //if a post field was configured with a content or title template, process template
     if (rgar($form, 'postContentTemplateEnabled') && $has_content_field || rgar($form, 'postTitleTemplateEnabled') && $has_title_field) {
         GFCommon::log_debug('GFFormsModel::create_post(): Processing template.');
         $post = get_post($post_id);
         if (rgar($form, 'postContentTemplateEnabled') && $has_content_field) {
             //replacing post image variables
             $post_content = GFCommon::replace_variables_post_image($form['postContentTemplate'], $post_images, $lead);
             //replacing all other variables
             $post_content = GFCommon::replace_variables($post_content, $form, $lead, false, false, false);
             //updating post content
             $post->post_content = $post_content;
         }
         if (rgar($form, 'postTitleTemplateEnabled') && $has_title_field) {
             //replacing post image variables
             $post_title = GFCommon::replace_variables_post_image($form['postTitleTemplate'], $post_images, $lead);
             //replacing all other variables
             $post_title = GFCommon::replace_variables($post_title, $form, $lead, false, false, false);
             // replace conditional shortcodes
             $post_title = do_shortcode($post_title);
             //updating post
             $post->post_title = $post_title;
             $post->post_name = $post_title;
         }
     }
     // update post status back to original status (if not draft)
     if ($post_status != 'draft') {
         $post = is_object($post) ? $post : get_post($post_id);
         $post->post_status = $post_status;
     }
     // if post has been modified since creation, save updates
     if (is_object($post)) {
         GFCommon::log_debug('GFFormsModel::create_post(): Updating post.');
         wp_update_post($post);
     }
     //adding post format
     if (current_theme_supports('post-formats') && rgar($form, 'postFormat')) {
         $formats = get_theme_support('post-formats');
         $post_format = rgar($form, 'postFormat');
         if (is_array($formats)) {
             $formats = $formats[0];
             if (in_array($post_format, $formats)) {
                 set_post_format($post_id, $post_format);
             } else {
                 if ('0' == $post_format) {
                     set_post_format($post_id, false);
                 }
             }
         }
     }
     //update post_id field if a post was created
     $lead['post_id'] = $post_id;
     GFCommon::log_debug('GFFormsModel::create_post(): Updating entry with post id.');
     self::update_lead_property($lead['id'], 'post_id', $post_id);
     /**
      * Fires after a post, from a form with post fields, is created
      *
      * @param int $form['id'] The ID of the form where the new post was created
      * @param int $post_id The new Post ID created after submission
      * @param array $lead The Lead Object
      * @param array $form The Form Object for the form used to create the post
      */
     gf_do_action('gform_after_create_post', $form['id'], $post_id, $lead, $form);
     return $post_id;
 }
开发者ID:plusplusminus,项目名称:athol,代码行数:101,代码来源:forms_model.php

示例8: notification_edit_page


//.........这里部分代码省略.........
             * @since 1.9.16
             *
             * @param bool $is_valid      True if it is valid.  False otherwise.
             * @param array $notification The Notification Object
             * @param array $form         The Form Object
             */
            $is_valid = gf_apply_filters(array('gform_notification_validation', $form_id), $is_valid, $notification, $form);
            if ($is_valid) {
                //input valid, updating...
                //emptying notification email if it is supposed to be disabled
                if ($_POST['gform_notification_to_type'] == 'routing') {
                    $notification['to'] = '';
                } else {
                    $notification['routing'] = null;
                }
                // trim values
                $notification = GFFormsModel::trim_conditional_logic_values_from_element($notification, $form);
                $form['notifications'][$notification_id] = $notification;
                RGFormsModel::save_form_notifications($form_id, $form['notifications']);
            }
        }
        if ($is_update && $is_valid) {
            $url = remove_query_arg('nid');
            GFCommon::add_message(sprintf(esc_html__('Notification saved successfully. %sBack to notifications.%s', 'gravityforms'), '<a href="' . esc_url($url) . '">', '</a>'));
            /**
             * Fires an action after a notification has been saved
             *
             * @since 1.9.16
             *
             * @param array $notification        The Notification Object
             * @param array $form                The Form Object
             * @param bool  $is_new_notification True if this is a new notification.  False otherwise.
             */
            gf_do_action(array('gform_post_notification_save', $form_id), $notification, $form, $is_new_notification);
        } else {
            if ($is_update && !$is_valid) {
                GFCommon::add_error_message(esc_html__('Notification could not be updated. Please enter all required information below.', 'gravityforms'));
            }
        }
        // moved page header loading here so the admin messages can be set upon saving and available for the header to print out
        GFFormSettings::page_header(esc_html__('Notifications', 'gravityforms'));
        $notification_ui_settings = self::get_notification_ui_settings($notification, $is_valid);
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        ?>
		<link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin<?php 
        echo $min;
        ?>
.css?ver=<?php 
        echo GFCommon::$version;
        ?>
" />

		<script type="text/javascript">

		var gform_has_unsaved_changes = false;
		jQuery(document).ready(function () {

			jQuery("#entry_form input, #entry_form textarea, #entry_form select").change(function () {
				gform_has_unsaved_changes = true;
			});

			window.onbeforeunload = function () {
				if (gform_has_unsaved_changes) {
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:67,代码来源:notification.php

示例9: lead_detail_page

    public static function lead_detail_page()
    {
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $requested_form_id = absint($_GET['id']);
        if (empty($requested_form_id)) {
            return;
        }
        $lead = self::get_current_entry();
        if (is_wp_error($lead) || !$lead) {
            esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
            return;
        }
        $lead_id = $lead['id'];
        $form = self::get_current_form();
        $form_id = absint($form['id']);
        $total_count = self::get_total_count();
        $position = rgget('pos') ? rgget('pos') : 0;
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < self::$_total_count - 1 ? $position + 1 : false;
        $filter = rgget('filter');
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
        switch (RGForms::post('action')) {
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                $original_entry = $lead;
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                /**
                 * Fires after the Entry is updated from the entry detail page.
                 *
                 * @param array   $form           The form object for the entry.
                 * @param integer $lead['id']     The entry ID.
                 * @param array   $original_entry The entry object before being updated.
                 */
                gf_do_action(array('gform_after_update_entry', $form['id']), $form, $lead['id'], $original_entry);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                self::set_current_entry($lead);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
                //emailing notes if configured
                if (rgpost('gentry_email_notes_to')) {
                    GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
                    $email_to = $_POST['gentry_email_notes_to'];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST['gentry_email_subject']);
                    $body = stripslashes($_POST['new_note']);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
                    $is_success = wp_mail($email_to, $email_subject, $body, $headers);
                    $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
                    if (!is_wp_error($is_success) && $is_success) {
                        GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
                    } else {
                        GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
                    }
                    if (has_filter('phpmailer_init')) {
                        GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
                    }
                    /**
                     * Fires after a note is attached to an entry and sent as an email
                     *
                     * @param string $result        The Error message or success message when the entry note is sent
                     * @param string $email_to      The email address to send the entry note to
                     * @param string $email_from    The email address from which the email is sent from
                     * @param string $email_subject The subject of the email that is sent
                     * @param mixed  $body          The Full body of the email containing the message after the note is sent
                     * @param array  $form          The current form object
                     * @param array  $lead          The Current lead object
                     */
                    do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead);
                }
                break;
            case 'add_quick_note':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note']));
                break;
            case 'bulk':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
//.........这里部分代码省略.........
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:101,代码来源:entry_detail.php

示例10: register_form_init_scripts

 /**
  * Enqueue and retrieve all inline scripts that should be executed when the form is rendered.
  * Use add_init_script() function to enqueue scripts.
  *
  * @param array $form
  * @param array $field_values
  * @param bool  $is_ajax
  */
 private static function register_form_init_scripts($form, $field_values = array(), $is_ajax = false)
 {
     // adding conditional logic script if conditional logic is configured for this form.
     // get_conditional_logic also adds the chosen script for the enhanced dropdown option.
     // if this form does not have conditional logic, add chosen script separately
     if (self::has_conditional_logic($form)) {
         self::add_init_script($form['id'], 'number_formats', self::ON_PAGE_RENDER, self::get_number_formats_script($form));
         self::add_init_script($form['id'], 'conditional_logic', self::ON_PAGE_RENDER, self::get_conditional_logic($form, $field_values));
     }
     //adding currency config if there are any product fields in the form
     if (self::has_price_field($form)) {
         self::add_init_script($form['id'], 'pricing', self::ON_PAGE_RENDER, self::get_pricing_init_script($form));
     }
     if (self::has_password_strength($form)) {
         $password_script = self::get_password_strength_init_script($form);
         self::add_init_script($form['id'], 'password', self::ON_PAGE_RENDER, $password_script);
     }
     if (self::has_enhanced_dropdown($form)) {
         $chosen_script = self::get_chosen_init_script($form);
         self::add_init_script($form['id'], 'chosen', self::ON_PAGE_RENDER, $chosen_script);
         self::add_init_script($form['id'], 'chosen', self::ON_CONDITIONAL_LOGIC, $chosen_script);
     }
     if (self::has_character_counter($form)) {
         self::add_init_script($form['id'], 'character_counter', self::ON_PAGE_RENDER, self::get_counter_init_script($form));
     }
     if (self::has_input_mask($form)) {
         self::add_init_script($form['id'], 'input_mask', self::ON_PAGE_RENDER, self::get_input_mask_init_script($form));
     }
     if (self::has_calculation_field($form)) {
         self::add_init_script($form['id'], 'number_formats', self::ON_PAGE_RENDER, self::get_number_formats_script($form));
         self::add_init_script($form['id'], 'calculation', self::ON_PAGE_RENDER, self::get_calculations_init_script($form));
     }
     if (self::has_currency_format_number_field($form)) {
         self::add_init_script($form['id'], 'currency_format', self::ON_PAGE_RENDER, self::get_currency_format_init_script($form));
     }
     if (self::has_currency_copy_values_option($form)) {
         self::add_init_script($form['id'], 'copy_values', self::ON_PAGE_RENDER, self::get_copy_values_init_script($form));
     }
     if (self::has_placeholder($form)) {
         self::add_init_script($form['id'], 'placeholders', self::ON_PAGE_RENDER, self::get_placeholders_init_script($form));
     }
     if (isset($form['fields']) && is_array($form['fields'])) {
         foreach ($form['fields'] as $field) {
             /* @var GF_Field $field */
             if (is_subclass_of($field, 'GF_Field')) {
                 $field->register_form_init_scripts($form);
             }
         }
     }
     gf_do_action('gform_register_init_scripts', $form['id'], $form, $field_values, $is_ajax);
 }
开发者ID:mariakhair,项目名称:bootstrap,代码行数:59,代码来源:form_display.php


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