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


PHP GFCache类代码示例

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


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

示例1: setUp

 /** Activate the plugin, mock all the things */
 public function setUp()
 {
     parent::setUp();
     /* Activate GravityForms */
     require_once WP_PLUGIN_DIR . '/gravityforms/gravityforms.php';
     require_once WP_PLUGIN_DIR . '/gravityforms/export.php';
     /* Something happened in newer versions, and we can't get the lead cache to initialize
     			properly, we need to do this manually */
     global $_gform_lead_meta;
     if ($_gform_lead_meta === null) {
         $_gform_lead_meta = array();
     }
     GFForms::setup();
     GFCache::flush();
     /* Import some ready-made forms */
     $this->assertEquals(GFExport::import_file(dirname(__FILE__) . '/forms.xml'), 2);
     /* Add a faster turnaround schedule */
     add_filter('cron_schedules', function ($s) {
         $s['minute'] = array('interval' => 60, 'display' => 'Minutely');
         return $s;
     });
     /* Get an instance of our plugin */
     $this->digest = new GFDigestNotifications();
 }
开发者ID:acesmf,项目名称:Gravity-Forms-Digest-Bulk-Reports,代码行数:25,代码来源:main.php

示例2: field_value

 /**
  * Given an entry and a form field id, calculate the entry value for that field.
  *
  * @access public
  * @param array $entry
  * @param integer $field
  * @return null|string
  */
 public static function field_value($entry, $field_settings, $format = 'html')
 {
     if (empty($entry['form_id']) || empty($field_settings['id'])) {
         return NULL;
     }
     $gravityview_view = GravityView_View::getInstance();
     if (class_exists('GFCache')) {
         /**
          * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run.
          *
          * The reason is that the cache was checking against a field value stored in a transient every time `GFFormsModel::get_lead_field_value()` is called.
          *
          * What we're doing here is telling the GFCache that it's already checked the transient and the value is false, forcing it to just use the non-cached data, which is actually faster.
          *
          * @hack
          * @since  1.3
          * @param  string $cache_key Field Value transient key used by Gravity Forms
          * @param mixed false Setting the value of the cache to false so that it's not used by Gravity Forms' GFFormsModel::get_lead_field_value() method
          * @param boolean false Tell Gravity Forms not to store this as a transient
          * @param  int 0 Time to store the value. 0 is maximum amount of time possible.
          */
         GFCache::set("GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0);
     }
     $field_id = $field_settings['id'];
     $form = $gravityview_view->getForm();
     $field = gravityview_get_field($form, $field_id);
     $field_type = RGFormsModel::get_input_type($field);
     if ($field_type) {
         $field_type = $field['type'];
         $value = RGFormsModel::get_lead_field_value($entry, $field);
     } else {
         // For non-integer field types (`id`, `date_created`, etc.)
         $field_type = $field_id;
         $field['type'] = $field_id;
         $value = isset($entry[$field_type]) ? $entry[$field_type] : NULL;
     }
     // Prevent any PHP warnings that may be generated
     ob_start();
     $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format);
     if ($errors = ob_get_clean()) {
         do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors);
     }
     $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form);
     // prevent the use of merge_tags for non-admin fields
     if (!empty($field['adminOnly'])) {
         $display_value = self::replace_variables($display_value, $form, $entry);
     }
     // Check whether the field exists in /includes/fields/{$field_type}.php
     // This can be overridden by user template files.
     $field_exists = $gravityview_view->locate_template("fields/{$field_type}.php");
     // Set the field data to be available in the templates
     $gravityview_view->setCurrentField(array('form' => $form, 'field_id' => $field_id, 'field' => $field, 'field_settings' => $field_settings, 'value' => $value, 'display_value' => $display_value, 'format' => $format, 'entry' => $entry, 'field_type' => $field_type));
     if ($field_exists) {
         do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_exists));
         ob_start();
         load_template($field_exists, false);
         $output = ob_get_clean();
     } else {
         // Backup; the field template doesn't exist.
         $output = $display_value;
     }
     $field_settings = $gravityview_view->getCurrentField('field_settings');
     /**
      * Link to the single entry by wrapping the output in an anchor tag
      *
      * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example.
      *
      */
     if (!empty($field_settings['show_as_link'])) {
         $output = self::entry_link_html($entry, $output, array(), $field_settings);
     }
     /**
      * @filter `gravityview_field_entry_value_{$field_type}` Modify the field value output for a field type. Example: `gravityview_field_entry_value_number`
      * @since 1.6
      * @param string $output HTML value output
      * @param array  $entry The GF entry array
      * @param  array $field_settings Settings for the particular GV field
      */
     $output = apply_filters('gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField());
     /**
      * @filter `gravityview_field_entry_value` Modify the field value output for all field types
      * @param string $output HTML value output
      * @param array  $entry The GF entry array
      * @param  array $field_settings Settings for the particular GV field
      * @param array $field_data  {@since 1.6}
      */
     $output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField());
     return $output;
 }
开发者ID:roarmoser,项目名称:gv1,代码行数:97,代码来源:class-api.php

示例3: deactivation_hook

 /**
  * Performs Gravity Forms deactivation tasks.
  * @access public
  * @static
  * @see GFCache
  */
 public static function deactivation_hook()
 {
     GFCache::flush(true);
     delete_option('gravityforms_rewrite_rules_flushed');
     flush_rewrite_rules();
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:12,代码来源:gravityforms.php

示例4: get_payment_feed

 public function get_payment_feed($entry, $form = false)
 {
     $submission_feed = GFCache::get('payment_feed');
     if (!$submission_feed) {
         if ($entry['id']) {
             $feeds = $this->get_feeds_by_entry($entry['id']);
             $submission_feed = $this->get_feed($feeds[0]);
         } else {
             if ($form) {
                 // getting all active feeds
                 $feeds = $this->get_feeds($form['id']);
                 foreach ($feeds as $feed) {
                     if ($this->is_feed_condition_met($feed, $form, $entry)) {
                         $submission_feed = $feed;
                         break;
                     }
                 }
             }
         }
         // if called without $form, there is assumption that cache has already been set; let's avoid issues where the cache has not been set and form was not provided
         // so that the cache will only be set when an $entry and $form object are provided
         if ($entry && $form) {
             GFCache::set('payment_feed', $submission_feed);
         }
     }
     return $submission_feed;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:27,代码来源:class-gf-payment-addon.php

示例5: is_locked

 public function is_locked($object_id)
 {
     if (!($user_id = GFCache::get(self::PREFIX_EDIT_LOCK . $this->_object_type . '_' . $object_id))) {
         return false;
     }
     if ($user_id != get_current_user_id()) {
         return true;
     }
     return false;
 }
开发者ID:Nguyenkain,项目名称:strida.vn,代码行数:10,代码来源:class-gf-locking.php

示例6: flush

 public static function flush($flush_persistent = false)
 {
     global $wpdb;
     self::$_cache = array();
     if (false === $flush_persistent) {
         return true;
     }
     if (is_multisite()) {
         $sql = "\r\n                 DELETE FROM {$wpdb->sitemeta}\r\n                 WHERE meta_key LIKE '_site_transient_timeout_GFCache_%' OR\r\n                 meta_key LIKE '_site_transient_GFCache_%'\r\n                ";
     } else {
         $sql = "\r\n                 DELETE FROM {$wpdb->options}\r\n                 WHERE option_name LIKE '_transient_timeout_GFCache_%' OR\r\n                 option_name LIKE '_transient_GFCache_%'\r\n                ";
     }
     $rows_deleted = $wpdb->query($sql);
     $success = $rows_deleted !== false ? true : false;
     return $success;
 }
开发者ID:ascarius,项目名称:wordpress-bootstrap,代码行数:16,代码来源:common.php

示例7: inbox_page

        public function inbox_page($args = array())
        {
            $defaults = array('display_empty_fields' => true, 'check_permissions' => true, 'show_header' => true, 'timeline' => true);
            $args = array_merge($defaults, $args);
            if (rgget('view') == 'entry') {
                $entry_id = absint(rgget('lid'));
                $entry = GFAPI::get_entry($entry_id);
                if (is_wp_error($entry)) {
                    esc_html_e('Oops! We could not locate your entry.', 'gravityflow');
                    return;
                }
                $form_id = $entry['form_id'];
                $form = GFAPI::get_form($form_id);
                require_once $this->get_base_path() . '/includes/pages/class-entry-detail.php';
                $step = $this->get_current_step($form, $entry);
                if ($step) {
                    $token = $this->decode_access_token();
                    if (isset($token['scopes']['action'])) {
                        if ($token['scopes']['action'] === 'cancel_workflow') {
                            $entry_id = rgars($token, 'scopes/entry_id');
                            if (empty($entry_id) || $entry_id != $entry['id']) {
                                esc_html_e('Error: incorrect entry.', 'gravityflow');
                                return;
                            }
                            $api = new Gravity_Flow_API($form_id);
                            $result = $api->cancel_workflow($entry);
                            if ($result) {
                                esc_html_e('Workflow Cancelled', 'gravityflow');
                            }
                            return;
                        }
                        $feedback = $step->maybe_process_token_action($token['scopes']['action'], $token, $form, $entry);
                        if (empty($feedback)) {
                            esc_html_e('Error: This URL is no longer valid.', 'gravityflow');
                            return;
                        }
                        if (is_wp_error($feedback)) {
                            echo $feedback->get_error_message();
                            return;
                        }
                        $this->process_workflow($form, $entry_id);
                        echo $feedback;
                        return;
                    }
                }
                $feedback = $this->maybe_process_admin_action($form, $entry);
                if (empty($feedback) && $step) {
                    $feedback = $step->maybe_process_status_update($form, $entry);
                    if ($feedback && !is_wp_error($feedback)) {
                        $this->process_workflow($form, $entry_id);
                    }
                }
                if (is_wp_error($feedback)) {
                    $error_data = $feedback->get_error_data();
                    if (!empty($error_data['form'])) {
                        $form = $error_data['form'];
                    }
                    ?>
					<div class="notice error is-dismissible gravityflow_validation_error" style="padding:6px;">
						<?php 
                    esc_html_e($feedback->get_error_message());
                    ?>
					</div>
					<?php 
                } elseif ($feedback) {
                    GFCache::flush();
                    $entry = GFAPI::get_entry($entry_id);
                    // refresh entry
                    ?>
					<div class="updated notice notice-success is-dismissible" style="padding:6px;">
						<?php 
                    esc_html_e($feedback);
                    ?>
					</div>
					<?php 
                    $next_step = $this->get_current_step($form, $entry);
                    $current_user_assignee_key = $this->get_current_user_assignee_key();
                    if ($next_step && $next_step->is_assignee($current_user_assignee_key) || $args['check_permissions'] == false || $this->current_user_can_any('gravityflow_view_all')) {
                        $step = $next_step;
                    } else {
                        $args['display_instructions'] = false;
                    }
                    $args['check_permissions'] = false;
                }
                Gravity_Flow_Entry_Detail::entry_detail($form, $entry, $step, $args);
                return;
            } else {
                ?>
				<div class="wrap gf_entry_wrap gravityflow_workflow_wrap gravityflow_workflow_detail">
					<?php 
                if ($args['show_header']) {
                    ?>
						<h2 class="gf_admin_page_title">
							<img width="45" height="22" src="<?php 
                    echo $this->get_base_url();
                    ?>
/images/gravityflow-icon-blue-grad.svg" style="margin-right:5px;"/>
							<span><?php 
                    esc_html_e('Workflow Inbox', 'gravityflow');
                    ?>
//.........这里部分代码省略.........
开发者ID:jakejackson1,项目名称:gravityflow,代码行数:101,代码来源:class-gravity-flow.php

示例8: set_current_lead

 /**
  * Set RGFormsModel::$lead for use in hooks where $lead is not explicitly passed.
  *
  * @param mixed $lead
  */
 public static function set_current_lead($lead)
 {
     GFCache::flush();
     self::$_current_lead = $lead;
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:10,代码来源:forms_model.php

示例9: deactivation_hook

 public static function deactivation_hook()
 {
     /**
      * This code was added on Jan. 13, 2016.
      *
      * @author Wes
      */
     add_action('update_option_active_plugins', array('GFForms', 'aria_deactivate_plugins'));
     do_action('update_option_active_plugins');
     // gravity forms source code..
     GFCache::flush(true);
 }
开发者ID:wesleykepke,项目名称:ARIA,代码行数:12,代码来源:gravityforms.php

示例10: gpoll_get_results

 /**
  * Returns the results in an array of HTML formatted data.
  *
  * @param int $formid The form ID.
  * @param string $display_field
  * @param string $style
  * @param bool $show_percentages
  * @param bool $show_counts
  * @param array $lead
  *
  * @return array
  */
 public function gpoll_get_results($formid, $display_field = '0', $style = 'green', $show_percentages = true, $show_counts = true, $lead = array())
 {
     $gpoll_output = array();
     $gpoll_data = array();
     // each bar will receive this HTML formatting
     $bar_html = "<div class='gpoll_wrapper {$style}'><div class='gpoll_ratio_box'><div class='gpoll_ratio_label'>%s</div></div><div class='gpoll_bar'>";
     $bar_html .= "<span class='gpoll_bar_juice' data-origwidth='%s' style='width: %s%%'><span class='gpoll_bar_count'>%s</span></span></div></div>";
     // if data is cached then pull the data out of the cache
     if (false === ($gpoll_data = GFCache::get('gpoll_data_' . $formid))) {
         // cache has timed out so get the data again and cache it again
         $gpoll_data = $this->update_cache($formid);
     }
     // build HTML output
     $gpoll_output['summary'] = "<div class='gpoll_container'>";
     $field_counter = 0;
     // loop through polls data field by field
     foreach ($gpoll_data['fields'] as $field) {
         $fieldid = $field['field_id'];
         // only build html for the field(s) specified in the parameter. 0 = all fields
         if (is_array($display_field)) {
             if (false === in_array($fieldid, $display_field)) {
                 continue;
             }
         } elseif ($display_field != '0' && $fieldid != $display_field) {
             continue;
         }
         // build 2 sections: summary and individual fields
         $field_number = $field_counter + 1;
         $gpoll_output['summary'] .= "<div class='gpoll_field'>";
         $gpoll_output['summary'] .= "<div class='gpoll_field_label_container'>";
         $gpoll_output['summary'] .= "<div class='gpoll_field_label'>";
         $gpoll_output['summary'] .= $field['field_label'] . '</div></div>';
         // the individual fields HTML was used in the past but not used now.
         // it was used to display results 'inline' with the form (i.e. form input then the bar below)
         // I've left it because it may be useful either to designers or for a future use
         $gpoll_output['fields'][$field_counter]['field_id'] = $field['field_id'];
         $gpoll_output['fields'][$field_counter]['type'] = $field['type'];
         $selected_values = array();
         // if the lead object is passed then prepare to highlight the selected choices
         if (!empty($lead)) {
             $form_meta = RGFormsModel::get_form_meta($formid);
             // collect all the responses in the lead for this field
             $selected_values = $this->get_selected_values($form_meta, $fieldid, $lead);
             //collect all the choices that are currently possible in the field
             $possible_choices = $this->get_possible_choices($form_meta, $fieldid);
             $form_meta_field = RGFormsModel::get_field($form_meta, $fieldid);
             // if the 'other' option is selected for this field
             // add the psuedo-value 'gpoll_other' if responses are found that are not in the list of possible choices
             if ($form_meta_field->enableOtherChoice) {
                 foreach ($selected_values as $selected_value) {
                     if (!in_array($selected_value, $possible_choices)) {
                         array_push($selected_values, 'gpoll_other');
                     }
                 }
             }
         }
         // loop through all the inputs in this field (poll data field not form object field) and build the HTML for the bar
         $input_counter = 0;
         foreach ($field['inputs'] as $input) {
             //highlight the selected value by adding a class to the label
             $selected_class = '';
             if (in_array(rgar($input, 'value'), $selected_values)) {
                 $selected_class .= ' gpoll_value_selected';
             }
             //build the bar and add it to the summary
             $gpoll_output['summary'] .= sprintf("<div class='gpoll_choice_label%s'>%s</div>", $selected_class, rgar($input, 'label'));
             $ratio = rgar($input, 'ratio');
             $count = $show_counts === true ? rgar($input, 'total_entries') : '';
             $percentage_label = $show_percentages === true ? $ratio . '%' : '';
             $input_html = sprintf($bar_html, $percentage_label, $ratio, $ratio, $count);
             $gpoll_output['summary'] .= $input_html;
             //add the bar HTML to the fields array ready to output alongside the summary
             $input_data = array('input_id' => rgar($input, 'input_id'), 'label' => rgar($input, 'label'), 'total_entries' => $input['total_entries'], 'ratio' => $input['ratio'], 'bar_html' => $input_html);
             $gpoll_output['fields'][$field_counter]['inputs'][$input_counter] = $input_data;
             $input_counter += 1;
         }
         $gpoll_output['summary'] .= '</div>';
         $field_counter += 1;
     }
     $gpoll_output['summary'] .= '</div>';
     return $gpoll_output;
 }
开发者ID:GravityPDF,项目名称:gravityformspolls,代码行数:94,代码来源:class-gf-polls.php

示例11: get_payment_feed

 public function get_payment_feed($entry, $form)
 {
     $submission_feed = GFCache::get("payment_feed");
     if (!$submission_feed) {
         if (!empty($entry["id"])) {
             $feeds = $this->get_processed_feeds($entry["id"]);
             $submission_feed = $this->get_feed($feeds[0]);
         } else {
             // getting all active feeds
             $feeds = $this->get_feeds($form['id']);
             foreach ($feeds as $feed) {
                 if ($this->is_feed_condition_met($feed, $form, $entry)) {
                     $submission_feed = $feed;
                     break;
                 }
             }
         }
         GFCache::set("payment_feed", $submission_feed);
     }
     return $submission_feed;
 }
开发者ID:danaiser,项目名称:hollandLawns,代码行数:21,代码来源:class-gf-payment-addon.php

示例12: maybe_process_status_update

 public function maybe_process_status_update($form, $entry)
 {
     $feedback = false;
     $form_id = $form['id'];
     if (isset($_POST['gforms_save_entry']) && check_admin_referer('gforms_save_entry', 'gforms_save_entry')) {
         $new_status = rgpost('gravityflow_status');
         if (!in_array($new_status, array('in_progress', 'complete'))) {
             return false;
         }
         // 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();
         }
         GFFormsModel::$uploaded_files[$form_id] = $files;
         $validation = $this->validate_status_update($new_status, $form);
         if (is_wp_error($validation)) {
             return $validation;
         }
         $editable_fields = $this->get_editable_fields();
         $previous_assignees = $this->get_assignees();
         $this->save_entry($form, $entry, $editable_fields);
         remove_action('gform_after_update_entry', array(gravity_flow(), 'filter_after_update_entry'));
         do_action('gform_after_update_entry', $form, $entry['id']);
         do_action("gform_after_update_entry_{$form['id']}", $form, $entry['id']);
         $entry = GFFormsModel::get_lead($entry['id']);
         $entry = GFFormsModel::set_entry_meta($entry, $form);
         $this->refresh_entry();
         GFCache::flush();
         $this->maybe_adjust_assignment($previous_assignees);
         if ($token = gravity_flow()->decode_access_token()) {
             $assignee_key = sanitize_text_field($token['sub']);
         } else {
             $user = wp_get_current_user();
             $assignee_key = 'user_id|' . $user->ID;
         }
         $assignee = new Gravity_Flow_Assignee($assignee_key, $this);
         $feedback = $this->process_assignee_status($assignee, $new_status, $form);
     }
     return $feedback;
 }
开发者ID:jakejackson1,项目名称:gravityflow,代码行数:41,代码来源:class-step-user-input.php

示例13: get_clients

 /**
  * Return the clients.
  *
  * @return mixed
  */
 private function get_clients()
 {
     $clients = GFCache::get('campaignmonitor_clients');
     if (!$clients) {
         $this->include_api();
         $api = new CS_REST_General($this->get_key());
         //getting all clients
         $response = $api->get_clients();
         if ($response->http_status_code == 200) {
             $clients = $response->response;
             GFCache::set('campaignmonitor_clients', $clients);
         }
     }
     return $clients;
 }
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:20,代码来源:class-gf-campaignmonitor.php

示例14: clear_field_value_cache

 public static function clear_field_value_cache($form)
 {
     if (!class_exists('GFCache')) {
         return;
     }
     foreach ($form['fields'] as &$field) {
         if (GFFormsModel::get_input_type($field) == 'total') {
             GFCache::delete('GFFormsModel::get_lead_field_value__' . $field['id']);
         }
     }
 }
开发者ID:quinntron,项目名称:tmad,代码行数:11,代码来源:functions.php

示例15: get_feeds

 public function get_feeds($form_id = null)
 {
     global $wpdb;
     $cache_key = implode('_', array_filter(array($this->_slug, 'get_feeds', $form_id)));
     $feeds = GFCache::get($cache_key);
     if (is_array($feeds)) {
         return $feeds;
     }
     $form_filter = is_numeric($form_id) ? $wpdb->prepare("AND form_id=%d", absint($form_id)) : "";
     $sql = $wpdb->prepare("SELECT * FROM {$wpdb->prefix}gf_addon_feed\n                               WHERE addon_slug=%s {$form_filter}", $this->_slug);
     $results = $wpdb->get_results($sql, ARRAY_A);
     foreach ($results as &$result) {
         $result["meta"] = json_decode($result["meta"], true);
     }
     GFCache::set($cache_key, $results);
     return $results;
 }
开发者ID:danaiser,项目名称:hollandLawns,代码行数:17,代码来源:class-gf-feed-addon.php


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