/**
  * @param array $atts {
  *   @type string $view_id Define the ID for the View where the entry will
  *   @type string $entry_id ID of the entry to edit. If undefined, uses the current entry ID
  *   @type string $post_id ID of the base post or page to use for an embedded View
  *   @type string $link_atts Whether to open Edit Entry link in a new window or the same window
  *   @type string $return What should the shortcode return: link HTML (`html`) or the URL (`url`). Default: `html`
  *   @type string $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
  * }
  * @param string $content
  * @param string $context
  *
  * @return string|void
  */
 public function shortcode($atts = array(), $content = '', $context = 'gv_edit_entry')
 {
     // Make sure GV is loaded
     if (!class_exists('GravityView_frontend') || !class_exists('GravityView_View')) {
         return null;
     }
     $defaults = array('view_id' => 0, 'entry_id' => 0, 'post_id' => 0, 'link_atts' => '', 'return' => 'html', 'field_values' => '');
     $settings = shortcode_atts($defaults, $atts, $context);
     if (empty($settings['view_id'])) {
         $view_id = GravityView_View::getInstance()->getViewId();
     } else {
         $view_id = absint($settings['view_id']);
     }
     if (empty($view_id)) {
         do_action('gravityview_log_debug', __METHOD__ . ' A View ID was not defined');
         return null;
     }
     $post_id = empty($settings['post_id']) ? $view_id : absint($settings['post_id']);
     $form_id = gravityview_get_form_id($view_id);
     $backup_entry_id = GravityView_frontend::getInstance()->getSingleEntry() ? GravityView_frontend::getInstance()->getSingleEntry() : GravityView_View::getInstance()->getCurrentEntry();
     $entry_id = empty($settings['entry_id']) ? $backup_entry_id : absint($settings['entry_id']);
     if (empty($entry_id)) {
         do_action('gravityview_log_debug', __METHOD__ . ' No entry defined');
         return null;
     }
     // By default, show only current user
     $user = wp_get_current_user();
     if (!$user) {
         do_action('gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user');
         return null;
     }
     $entry = $this->get_entry($entry_id, $form_id);
     // No search results
     if (false === $entry) {
         do_action('gravityview_log_debug', __METHOD__ . ' No entries match the entry ID defined', $entry_id);
         return null;
     }
     // Check permissions
     if (false === GravityView_Edit_Entry::check_user_cap_edit_entry($entry, $view_id)) {
         do_action('gravityview_log_debug', __METHOD__ . ' User does not have the capability to edit this entry: ' . $entry_id);
         return null;
     }
     $href = GravityView_Delete_Entry::get_delete_link($entry, $view_id, $post_id, $settings);
     // Get just the URL, not the tag
     if ('url' === $settings['return']) {
         return $href;
     }
     $link_text = empty($content) ? __('Delete Entry', 'gravityview') : $content;
     return gravityview_get_link($href, $link_text, $settings['link_atts']);
 }
 /**
  * Render html for 'View Configuration' metabox
  *
  * @access public
  * @param mixed $post
  * @return void
  */
 function render_view_configuration_metabox($post)
 {
     // Use nonce for verification
     wp_nonce_field('gravityview_view_configuration', 'gravityview_view_configuration_nonce');
     // Selected Form
     $curr_form = gravityview_get_form_id($post->ID);
     // Selected template
     $curr_template = gravityview_get_template_id($post->ID);
     echo self::render_merge_tags_scripts($curr_form);
     include self::$metaboxes_dir . 'views/view-configuration.php';
 }
    /**
     * Generic function to render rows and columns of active areas for widgets & fields
     * @param  string $template_id The current slug of the selected View template
     * @param  string $type   Either 'widget' or 'field'
     * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
     * @param  array $rows    The layout structure: rows, columns and areas
     * @param  array $values  Saved objects
     * @return void
     */
    function render_active_areas($template_id, $type, $zone, $rows, $values)
    {
        global $post;
        if ($type === 'widget') {
            $button_label = __('Add Widget', 'gravityview');
        } else {
            $button_label = __('Add Field', 'gravityview');
        }
        $available_items = array();
        // if saved values, get available fields to label everyone
        if (!empty($values) && (!empty($post->ID) || !empty($_POST['template_id']))) {
            if (!empty($_POST['template_id'])) {
                $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']);
            } else {
                $form = gravityview_get_form_id($post->ID);
            }
            if ('field' === $type) {
                $available_items = $this->get_available_fields($form, $zone);
            } else {
                $available_items = $this->get_registered_widgets();
            }
        }
        foreach ($rows as $row) {
            foreach ($row as $col => $areas) {
                $column = $col == '2-2' ? '1-2' : $col;
                ?>

				<div class="gv-grid-col-<?php 
                echo esc_attr($column);
                ?>
">

					<?php 
                foreach ($areas as $area) {
                    ?>

						<div class="gv-droppable-area">
							<div class="active-drop active-drop-<?php 
                    echo esc_attr($type);
                    ?>
" data-areaid="<?php 
                    echo esc_attr($zone . '_' . $area['areaid']);
                    ?>
">

								<?php 
                    // render saved fields
                    if (!empty($values[$zone . '_' . $area['areaid']])) {
                        foreach ($values[$zone . '_' . $area['areaid']] as $uniqid => $field) {
                            $input_type = NULL;
                            $original_item = isset($available_items[$field['id']]) ? $available_items[$field['id']] : false;
                            if (!$original_item) {
                                do_action('gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array('available_items' => $available_items, 'field' => $field));
                                $original_item = $field;
                            } else {
                                $input_type = isset($original_item['type']) ? $original_item['type'] : NULL;
                            }
                            // Field options dialog box
                            $field_options = GravityView_Render_Settings::render_field_options($type, $template_id, $field['id'], $original_item['label'], $zone . '_' . $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item);
                            $item = array('input_type' => $input_type, 'settings_html' => $field_options, 'label_type' => $type);
                            // Merge the values with the current item to pass things like widget descriptions and original field names
                            if ($original_item) {
                                $item = wp_parse_args($item, $original_item);
                            }
                            switch ($type) {
                                case 'widget':
                                    echo new GravityView_Admin_View_Widget($item['label'], $field['id'], $item, $field);
                                    break;
                                default:
                                    echo new GravityView_Admin_View_Field($item['label'], $field['id'], $item, $field);
                            }
                            //endif;
                        }
                    }
                    // End if zone is not empty
                    ?>

								<span class="drop-message"><?php 
                    echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type);
                    ?>
</span>
							</div>
							<div class="gv-droppable-area-action">
								<a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php 
                    echo esc_attr($type);
                    ?>
" data-areaid="<?php 
                    echo esc_attr($zone . '_' . $area['areaid']);
                    ?>
" data-context="<?php 
                    echo esc_attr($zone);
                    ?>
"><?php 
                    echo '+ ' . esc_html($button_label);
                    ?>
</a>
								<p class="gv-droppable-area-title"><strong><?php 
                    echo esc_html($area['title']);
                    ?>
</strong><?php 
                    if (!empty($area['subtitle'])) {
                        ?>
<span class="gv-droppable-area-subtitle"> &ndash; <?php 
                        echo esc_html($area['subtitle']);
                        ?>
</span><?php 
                    }
                    ?>
</p>
							</div>
						</div>

					<?php 
                }
                ?>

				</div>
			<?php 
            }
        }
    }
 /**
  * Get the HTML output for the entry list.
  *
  * @since 1.7.2
  *
  * @param array $instance The settings for the particular instance of the widget.
  *
  * @return string
  */
 private function get_output($instance)
 {
     $form_id = gravityview_get_form_id($instance['view_id']);
     $form = gravityview_get_form($form_id);
     $entries = $this->get_entries($instance, $form_id);
     /**
      * @since 1.6.1
      * @var int $entry_link_post_id The ID to use as the parent post for the entry
      */
     $entry_link_post_id = empty($instance['error_post_id']) && !empty($instance['post_id']) ? $instance['post_id'] : $instance['view_id'];
     /**
      * Generate list output
      * @since 1.7.2
      */
     $List = new GravityView_Entry_List($entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget');
     $output = $List->get_output();
     /**
      * Modify the HTML before it's echo'd
      * @param string $output HTML to be displayed
      * @param array $instance Widget settings
      */
     $output = apply_filters('gravityview/widget/recent-entries/output', $output, $instance);
     return $output;
 }
 /**
  * In case View post is called directly, insert the view in the post content
  *
  * @access public
  * @static
  * @param mixed $content
  * @return string Add the View output into View CPT content
  */
 public function insert_view_in_content($content)
 {
     // Plugins may run through the content in the header. WP SEO does this for its OpenGraph functionality.
     if (!did_action('loop_start')) {
         do_action('gravityview_log_debug', '[insert_view_in_content] Not processing yet: loop_start hasn\'t run yet. Current action:', current_filter());
         return $content;
     }
     //	We don't want this filter to run infinite loop on any post content fields
     remove_filter('the_content', array($this, 'insert_view_in_content'));
     // Otherwise, this is called on the Views page when in Excerpt mode.
     if (is_admin()) {
         return $content;
     }
     if ($this->isGravityviewPostType()) {
         /** @since 1.7.4 */
         if (is_preview() && !gravityview_get_form_id($this->post_id)) {
             $content .= __('When using a Start Fresh template, you must save the View before a Preview is available.', 'gravityview');
         } else {
             foreach ($this->getGvOutputData()->get_views() as $view_id => $data) {
                 $content .= $this->render_view(array('id' => $view_id));
             }
         }
     }
     //	Add the filter back in
     add_filter('the_content', array($this, 'insert_view_in_content'));
     return $content;
 }
 /**
  * Ajax
  * Given a View id, calculates the assigned form, and returns the form fields (only the sortable ones )
  *
  * @access public
  * @return void
  */
 function get_sortable_fields()
 {
     // Not properly formatted request
     if (empty($_POST['viewid']) || !is_numeric($_POST['viewid'])) {
         exit(false);
     }
     // Not valid request
     if (empty($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxaddshortcode')) {
         exit(false);
     }
     $viewid = (int) $_POST['viewid'];
     // fetch form id assigned to the view
     $formid = gravityview_get_form_id($viewid);
     // Get the default sort field for the view
     $sort_field = gravityview_get_template_setting($viewid, 'sort_field');
     // Generate the output `<option>`s
     $response = gravityview_get_sortable_fields($formid, $sort_field);
     exit($response);
 }
 /**
  * Ajax
  * Returns the form fields ( only the searchable ones )
  *
  * @access public
  * @return void
  */
 public static function get_searchable_fields()
 {
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxsearchwidget')) {
         exit('0');
     }
     $form = '';
     // Fetch the form for the current View
     if (!empty($_POST['view_id'])) {
         $form = gravityview_get_form_id($_POST['view_id']);
     } elseif (!empty($_POST['formid'])) {
         $form = (int) $_POST['formid'];
     } elseif (!empty($_POST['template_id']) && class_exists('GravityView_Ajax')) {
         $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']);
     }
     // fetch form id assigned to the view
     $response = self::render_searchable_fields($form);
     exit($response);
 }
 /**
  * Return the field's time format by fetching the form ID and checking the field settings
  *
  * @since 1.14
  *
  * @return string Either "12" or "24". "12" is default.
  */
 private function _get_time_format()
 {
     global $post;
     $current_form = isset($_POST['form_id']) ? intval($_POST['form_id']) : gravityview_get_form_id($post->ID);
     return self::_get_time_format_for_field($this->_field_id, $current_form);
 }
Example #9
0
    /**
     * Filter Admin messages
     *
     * @param  array      $messages Existing messages
     * @return array                Messages with GravityView views!
     */
    function post_updated_messages($messages, $bulk_counts = NULL)
    {
        global $post;
        $post_id = isset($_GET['post']) ? intval($_GET['post']) : (is_object($post) && isset($post->ID) ? $post->ID : NULL);
        // By default, there will only be one item being modified.
        // When in the `bulk_post_updated_messages` filter, there will be passed a number
        // of modified items that will override this array.
        $bulk_counts = is_null($bulk_counts) ? array('updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1) : $bulk_counts;
        // If we're starting fresh, a new form was created.
        // We should let the user know this is the case.
        $start_fresh = get_post_meta($post_id, '_gravityview_start_fresh', true);
        $new_form_text = '';
        if (!empty($start_fresh)) {
            // Get the form that was created
            $connected_form = gravityview_get_form_id($post_id);
            if (!empty($connected_form)) {
                $form = gravityview_get_form($connected_form);
                $form_name = esc_attr($form['title']);
                $image = self::get_floaty();
                $new_form_text .= '<h3>' . $image . sprintf(__('A new form was created for this View: "%s"', 'gravityview'), $form_name) . '</h3>';
                $new_form_text .= sprintf(__('%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s

					You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don&rsquo;t forget to %scustomize the form settings%s.
					', 'gravityview'), '<strong>', '</strong>', '<a href="' . site_url('?gf_page=preview&amp;id=' . $connected_form) . '">', '</a>', '<code>[gravityform id="' . $connected_form . '" name="' . $form_name . '"]</code>', '<a href="' . admin_url('admin.php?page=gf_edit_forms&amp;id=' . $connected_form) . '">', '</a>', '<a href="' . admin_url('admin.php?page=gf_edit_forms&amp;view=settings&amp;id=' . $connected_form) . '">', '</a>');
                $new_form_text = wpautop($new_form_text);
                delete_post_meta($post_id, '_gravityview_start_fresh');
            }
        }
        $messages['gravityview'] = array(0 => '', 1 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="' . get_permalink($post_id) . '">', '</a>'), 2 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="' . get_permalink($post_id) . '">', '</a>'), 3 => __('View deleted.', 'gravityview'), 4 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="' . get_permalink($post_id) . '">', '</a>'), 5 => isset($_GET['revision']) ? sprintf(__('View restored to revision from %s', 'gravityview'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('View published. %sView on website.%s', 'gravityview'), '<a href="' . get_permalink($post_id) . '">', '</a>') . $new_form_text, 7 => sprintf(__('View saved. %sView on website.%s', 'gravityview'), '<a href="' . get_permalink($post_id) . '">', '</a>') . $new_form_text, 8 => __('View submitted.', 'gravityview'), 9 => sprintf(__('View scheduled for: %1$s.', 'gravityview'), date_i18n(__('M j, Y @ G:i', 'gravityview'), strtotime(isset($post->post_date) ? $post->post_date : NULL))) . $new_form_text, 10 => sprintf(__('View draft updated. %sView on website.%s', 'gravityview'), '<a href="' . get_permalink($post_id) . '">', '</a>'), 'updated' => _n('%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview'), 'locked' => _n('%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview'), 'deleted' => _n('%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview'), 'trashed' => _n('%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview'), 'untrashed' => _n('%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview'));
        return $messages;
    }
Example #10
0
 static function get_field_filters($post_id)
 {
     $form_id = gravityview_get_form_id($post_id);
     $form = gravityview_get_form($form_id);
     // Fixes issue on Views screen when deleting a view
     if (empty($form)) {
         return;
     }
     $field_filters = GFCommon::get_field_filter_settings($form);
     if ($approved_column = GravityView_Admin_ApproveEntries::get_approved_column($form)) {
         $approved_column = intval(floor($approved_column));
     }
     // Add currently logged in user option
     foreach ($field_filters as &$filter) {
         // Add negative match to approval column
         if ($approved_column && $filter['key'] === $approved_column) {
             $filter['operators'][] = 'isnot';
             continue;
         }
         // Gravity Forms already creates a "User" option.
         // We don't care about specific user, just the logged in status.
         if ($filter['key'] === 'created_by') {
             // Update the default label to be more descriptive
             $filter['text'] = esc_attr__('Created By', 'gravity-view-advanced-filter');
             $current_user_filters = array(array('text' => __('Logged-in User (disabled for Admins)', 'gravity-view-advanced-filter'), 'value' => 'created_by_or_admin'), array('text' => __('Logged-in User', 'gravity-view-advanced-filter'), 'value' => 'created_by'));
             foreach ($current_user_filters as $user_filter) {
                 // Add to the beginning on the value options
                 array_unshift($filter['values'], $user_filter);
             }
         }
     }
     $init_field_id = 0;
     $init_field_operator = "contains";
     $default_init_filter_vars = array("mode" => "all", "filters" => array(array("field" => $init_field_id, "operator" => $init_field_operator, "value" => '')));
     $view_filter_vars = self::get_view_filter_vars($post_id, true);
     $init_filter_vars = !empty($view_filter_vars) ? $view_filter_vars : $default_init_filter_vars;
     /**
      * allow field filters manipulation
      * @param array $field_filters configured filters
      */
     $field_filters = apply_filters('gravityview/adv_filter/field_filters', $field_filters, $post_id);
     return array('field_filters' => $field_filters, 'init_filter_vars' => $init_filter_vars);
 }
Example #11
0
<?php

/**
 * @package GravityView
 * @subpackage Gravityview/admin/metaboxes/views
 * @since 1.8
 */
// Use nonce for verification
wp_nonce_field('gravityview_select_form', 'gravityview_select_form_nonce');
//current value
$current_form = gravityview_get_form_id($post->ID);
// check for available gravity forms
$forms = gravityview_get_forms();
?>
<label for="gravityview_form_id" ><?php 
esc_html_e('Where would you like the data to come from for this View?', 'gravityview');
?>
</label>

<p>
	<?php 
if (empty($current_form)) {
    ?>
		<a class="button button-primary" href="#gv_start_fresh" title="<?php 
    esc_attr_e('Start Fresh', 'gravityview');
    ?>
"><?php 
    esc_html_e('Start Fresh', 'gravityview');
    ?>
</a>
Example #12
0
 /**
  *
  * Add a view to the views array
  *
  * @param int|array $view_id View ID or array of View IDs
  * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional)
  * @return type
  */
 function add_view($view_id, $atts = NULL)
 {
     // Handle array of IDs
     if (is_array($view_id)) {
         foreach ($view_id as $id) {
             $this->add_view($id, $atts);
         }
         return $this->views;
     }
     // The view has been set already; returning stored view.
     if (!empty($this->views[$view_id])) {
         do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id));
         return $this->views[$view_id];
     }
     if (!$this->view_exists($view_id)) {
         do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id));
         return false;
     }
     $form_id = gravityview_get_form_id($view_id);
     if (empty($form_id)) {
         do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id));
         return false;
     }
     // Get the settings for the View ID
     $view_settings = gravityview_get_template_settings($view_id);
     do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings);
     // Merge the view settings with the defaults
     $view_defaults = wp_parse_args($view_settings, self::get_default_args());
     do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults);
     if (!empty($atts) && is_array($atts)) {
         do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts);
         // Get the settings from the shortcode and merge them with defaults.
         $atts = shortcode_atts($view_defaults, $atts);
         do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts);
     } else {
         // If there are no passed $atts, the defaults will be used.
         $atts = $view_defaults;
     }
     unset($atts['id'], $view_defaults, $view_settings);
     $data = array('id' => $view_id, 'view_id' => $view_id, 'form_id' => $form_id, 'template_id' => gravityview_get_template_id($view_id), 'atts' => $atts, 'fields' => $this->get_fields($view_id), 'widgets' => get_post_meta($view_id, '_gravityview_directory_widgets', true), 'form' => gravityview_get_form($form_id));
     do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data);
     $this->views[$view_id] = $data;
     return $this->views[$view_id];
 }
 /**
  * Check whether the `enableChoiceValue` flag is set for a GF field
  *
  * Gets the current form ID, gets the field at that ID, then checks for the enableChoiceValue value.
  *
  * @access protected
  *
  * @uses GFAPI::get_form
  *
  * @since 1.17
  *
  * @return bool True: Enable Choice Value is active for field; False: not active, or form invalid, or form not found.
  */
 protected function is_choice_value_enabled()
 {
     // If "Add Field" button is processing, get the Form ID
     $connected_form = rgpost('form_id');
     // Otherwise, get the Form ID from the Post page
     if (empty($connected_form)) {
         $connected_form = gravityview_get_form_id(get_the_ID());
     }
     if (empty($connected_form)) {
         do_action('gravityview_log_error', sprintf('%s: Form not found for form ID "%s"', __METHOD__, $connected_form));
         return false;
     }
     $form = GFAPI::get_form($connected_form);
     if (!$form) {
         do_action('gravityview_log_error', sprintf('%s: Form not found for field ID of "%s", when checking for a form with ID of "%s"', __METHOD__, $this->_field_id, $connected_form));
         return false;
     }
     $field = gravityview_get_field($form, $this->_field_id);
     return !empty($field->enableChoiceValue);
 }
Example #14
0
 /**
  *
  * Checks if a certain entry is valid according to the View search filters (specially the Adv Filters)
  *
  * @see GFFormsModel::is_value_match()
  *
  * @since 1.7.4
  * @todo Return WP_Error instead of boolean
  *
  * @param array $entry Gravity Forms Entry object
  * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter)
  */
 public static function check_entry_display($entry)
 {
     if (!$entry || is_wp_error($entry)) {
         do_action('gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry);
         return false;
     }
     if (empty($entry['form_id'])) {
         do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry);
         return false;
     }
     $criteria = self::calculate_get_entries_criteria();
     // Make sure the current View is connected to the same form as the Entry
     if (!empty($criteria['context_view_id'])) {
         $context_view_id = intval($criteria['context_view_id']);
         $context_form_id = gravityview_get_form_id($context_view_id);
         if (intval($context_form_id) !== intval($entry['form_id'])) {
             do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id']), $criteria['context_view_id']);
             return false;
         }
     }
     if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) {
         do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria);
         return $entry;
     }
     $search_criteria = $criteria['search_criteria'];
     unset($criteria);
     // check entry status
     if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) {
         do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria);
         return false;
     }
     // check entry date
     // @todo: Does it make sense to apply the Date create filters to the single entry?
     // field_filters
     if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) {
         do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria);
         return $entry;
     }
     $filters = $search_criteria['field_filters'];
     unset($search_criteria);
     $mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all';
     unset($filters['mode']);
     $form = self::get_form($entry['form_id']);
     foreach ($filters as $filter) {
         if (!isset($filter['key'])) {
             continue;
         }
         $k = $filter['key'];
         if (in_array($k, array('created_by', 'payment_status'))) {
             $field_value = $entry[$k];
             $field = null;
         } else {
             $field = self::get_field($form, $k);
             $field_value = GFFormsModel::get_lead_field_value($entry, $field);
         }
         $operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is';
         $is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field);
         // verify if we are already free to go!
         if (!$is_value_match && 'all' === $mode) {
             do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter);
             return false;
         } elseif ($is_value_match && 'any' === $mode) {
             return $entry;
         }
     }
     // at this point, if in ALL mode, then entry is approved - all conditions were met.
     // Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved
     if ('all' === $mode) {
         return $entry;
     } else {
         do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters);
         return false;
     }
 }