public function render_frontend($widget_args, $content = '', $context = '')
 {
     $gravityview_view = GravityView_View::getInstance();
     if (!$this->pre_render_frontend()) {
         return;
     }
     if (!empty($widget_args['title'])) {
         echo $widget_args['title'];
     }
     $pagination_counts = $gravityview_view->getPaginationCounts();
     $total = $first = $last = null;
     $output = '';
     if (!empty($pagination_counts)) {
         $first = $pagination_counts['first'];
         $last = $pagination_counts['last'];
         $total = $pagination_counts['total'];
         $class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
         $class = gravityview_sanitize_html_class($class);
         $output = '<div class="gv-widget-pagination ' . $class . '"><p>' . sprintf(__('Displaying %1$s - %2$s of %3$s', 'gravityview'), number_format_i18n($first), number_format_i18n($last), number_format_i18n($total)) . '</p></div>';
     }
     /**
      * @filter `gravityview_pagination_output` Modify the pagination widget output
      * @param string $output HTML output
      * @param int $first First entry #
      * @param int $last Last entry #
      * @param int $total Total entries #
      */
     echo apply_filters('gravityview_pagination_output', $output, $first, $last, $total);
 }
Exemplo n.º 2
0
 /**
  * Display details for the current View
  *
  * @since 1.13
  *
  * @param string $detail The information requested about the current View. Accepts `total_entries`, `first_entry` (entry #), `last_entry` (entry #), and `page_size`
  *
  * @return string Detail information
  */
 private function get_view_detail($detail = '')
 {
     $gravityview_view = GravityView_View::getInstance();
     $return = '';
     switch ($detail) {
         case 'total_entries':
             $return = number_format_i18n($gravityview_view->getTotalEntries());
             break;
         case 'first_entry':
             $paging = $gravityview_view->getPaginationCounts();
             $return = empty($paging) ? '' : number_format_i18n($paging['first']);
             break;
         case 'last_entry':
             $paging = $gravityview_view->getPaginationCounts();
             $return = empty($paging) ? '' : number_format_i18n($paging['last']);
             break;
         case 'page_size':
             $paging = $gravityview_view->getPaging();
             $return = number_format_i18n($paging['page_size']);
             break;
     }
     /**
      * @filter `gravityview/shortcode/detail/{$detail}` Filter the detail output returned from `[gravityview detail="$detail"]`
      * @since 1.13
      * @param string $return Existing output
      */
     $return = apply_filters('gravityview/shortcode/detail/' . $detail, $return);
     return $return;
 }
 public function render_frontend($widget_args, $content = '', $context = '')
 {
     $gravityview_view = GravityView_View::getInstance();
     if (!$this->pre_render_frontend()) {
         return;
     }
     $page_size = $gravityview_view->paging['page_size'];
     $total = $gravityview_view->total_entries;
     $atts = shortcode_atts(array('show_all' => !empty($this->settings['show_all']['default'])), $widget_args, 'gravityview_widget_page_links');
     // displaying info
     $curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']);
     $page_link_args = array('base' => add_query_arg('pagenum', '%#%', gv_directory_link()), 'format' => '&pagenum=%#%', 'add_args' => array(), 'prev_text' => '&laquo;', 'next_text' => '&raquo;', 'type' => 'list', 'end_size' => 1, 'mid_size' => 2, 'total' => empty($page_size) ? 0 : ceil($total / $page_size), 'current' => $curr_page, 'show_all' => !empty($atts['show_all']));
     /**
      * @filter `gravityview_page_links_args` Filter the pagination options
      * @since 1.1.4
      * @param array  $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/)
      */
     $page_link_args = apply_filters('gravityview_page_links_args', $page_link_args);
     $page_links = paginate_links($page_link_args);
     if (!empty($page_links)) {
         $class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
         $class = gravityview_sanitize_html_class($class);
         echo '<div class="gv-widget-page-links ' . $class . '">' . $page_links . '</div>';
     } else {
         do_action('gravityview_log_debug', 'GravityView_Widget_Page_Links[render_frontend] No page links; paginate_links() returned empty response.');
     }
 }
 public function widget($args, $instance)
 {
     // Don't show unless a View ID has been set.
     if (empty($instance['view_id'])) {
         do_action('gravityview_log_debug', sprintf('%s[widget]: No View ID has been defined. Not showing the widget.', get_class($this)), $instance);
         return;
     }
     /** This filter is documented in wp-includes/default-widgets.php */
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     // @todo Add to the widget configuration form
     $instance['search_layout'] = apply_filters('gravityview/widget/search/layout', 'vertical', $instance);
     $instance['context'] = 'wp_widget';
     // form
     $instance['form_id'] = GVCommon::get_meta_form_id($instance['view_id']);
     $instance['form'] = GVCommon::get_form($instance['form_id']);
     // We don't want to overwrite existing context, etc.
     $previous_view = GravityView_View::getInstance();
     /** @hack */
     new GravityView_View($instance);
     GravityView_Widget_Search::getInstance()->render_frontend($instance);
     /**
      * Restore previous View context
      * @hack
      */
     new GravityView_View($previous_view);
     echo $args['after_widget'];
 }
 public function render_frontend($widget_args, $content = '', $context = '')
 {
     $gravityview_view = GravityView_View::getInstance();
     if (!$this->pre_render_frontend()) {
         return;
     }
     if (!empty($widget_args['title'])) {
         echo $widget_args['title'];
     }
     $offset = $gravityview_view->paging['offset'];
     $page_size = $gravityview_view->paging['page_size'];
     $total = $gravityview_view->total_entries;
     if (empty($total)) {
         do_action('gravityview_log_debug', sprintf('%s[render_frontend]: No entries.', get_class($this)));
         return;
     }
     // displaying info
     if ($total == 0) {
         $first = $last = 0;
     } else {
         $first = empty($offset) ? 1 : $offset + 1;
         $last = $offset + $page_size > $total ? $total : $offset + $page_size;
     }
     /**
      * Modify the displayed pagination numbers
      * @param array $counts Array with $first, $last, $total
      * @var array array with $first, $last, $total numbers in that order.
      */
     list($first, $last, $total) = apply_filters('gravityview_pagination_counts', array($first, $last, $total));
     $class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
     $class = gravityview_sanitize_html_class($class);
     $output = '<div class="gv-widget-pagination ' . $class . '"><p>' . sprintf(__('Displaying %1$s - %2$s of %3$s', 'gravityview'), $first, $last, $total) . '</p></div>';
     echo apply_filters('gravityview_pagination_output', $output, $first, $last, $total);
 }
 /**
  * @covers GravityView_Edit_Entry::get_edit_link()
  */
 function test_get_edit_link()
 {
     $form = $this->factory->form->create_and_get();
     $editor = $this->factory->user->create_and_set(array('user_login' => 'editor', 'role' => 'editor'));
     $entry = $this->factory->entry->create_and_get(array('form_id' => $form['id'], 'created_by' => $editor->ID));
     $view = $this->factory->view->create_and_get(array('form_id' => $form['id'], 'settings' => array('user_edit' => 1)));
     $this->assertNotEmpty($view, 'There was an error creating the View');
     $post_title = new WP_UnitTest_Generator_Sequence(__METHOD__ . ' %s');
     $post_id = $this->factory->post->create(array('post_title' => $post_title->next(), 'post_content' => sprintf('[gravityview id="%d"]', $view->ID)));
     $nonce_key = GravityView_Edit_Entry::get_nonce_key($view->ID, $entry['form_id'], $entry['id']);
     $nonce = wp_create_nonce($nonce_key);
     ###
     ### NO POST
     ###
     $edit_link_no_post = GravityView_Edit_Entry::get_edit_link($entry, $view->ID);
     // A link to the raw
     $this->assertEquals('?page=gf_entries&view=entry&edit=' . $nonce, $edit_link_no_post);
     $args = array('p' => $post_id, 'entry' => $entry['id'], 'gvid' => $view->ID, 'page' => 'gf_entries', 'view' => 'entry', 'edit' => $nonce);
     // When running all tests, this test thinks we have multiple Views. Correct that.
     GravityView_View::getInstance()->setViewId($view->ID);
     ###
     ### WITH POST
     ###
     $edit_link_with_post = GravityView_Edit_Entry::get_edit_link($entry, $view->ID, $post_id);
     $this->assertEquals(add_query_arg($args, 'http://example.org/'), $edit_link_with_post);
 }
 /**
  * @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']);
 }
 /**
  * @covers GravityView_Shortcode::get_view_detail
  * @covers GravityView_View::setTotalEntries
  */
 function test_shortcode_get_view_detail_TOTAL_ENTRIES()
 {
     GravityView_View::getInstance()->setTotalEntries(0);
     $value = do_shortcode('[gravityview detail=total_entries]');
     $this->assertEquals('0', $value);
     GravityView_View::getInstance()->setTotalEntries(1000);
     $value = do_shortcode('[gravityview detail=total_entries]');
     $this->assertEquals('1,000', $value);
     add_filter('gravityview/shortcode/detail/total_entries', '__return_empty_string');
     GravityView_View::getInstance()->setTotalEntries(1000000);
     $value = do_shortcode('[gravityview detail=total_entries]');
     $this->assertEquals('', $value);
     remove_filter('gravityview/shortcode/detail/total_entries', '__return_empty_string');
 }
 /**
  * The Signature Addon only displays the output in the editable form if it thinks it's in the Admin or a form has been submitted
  *
  * @since 1.17
  *
  * @param string $field_content Always empty. Returning not-empty overrides the input.
  * @param GF_Field $field
  * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
  * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
  * @param int $form_id Form ID
  *
  * @return string Empty string forces Gravity Forms to use the $_POST values
  */
 function edit_entry_field_input($field_content = '', $field, $value = '', $lead_id = 0, $form_id = 0)
 {
     $context = function_exists('gravityview_get_context') ? gravityview_get_context() : '';
     if ('signature' !== $field->type || 'edit' !== $context) {
         return $field_content;
     }
     // We need to fetch a fresh version of the entry, since the saved entry hasn't refreshed in GV yet.
     $entry = GravityView_View::getInstance()->getCurrentEntry();
     $entry = GFAPI::get_entry($entry['id']);
     $entry_value = rgar($entry, $field->id);
     $_POST["input_{$field->id}"] = $entry_value;
     // Used when Edit Entry form *is* submitted
     $_POST["input_{$form_id}_{$field->id}_signature_filename"] = $entry_value;
     // Used when Edit Entry form *is not* submitted
     return '';
     // Return empty string to force using $_POST values instead
 }
Exemplo n.º 10
0
 /**
  * Modify search criteria
  * @param  array $criteria       Existing search criteria array, if any
  * @param  [type] $form_ids       Form IDs for the search
  * @param  [type] $passed_view_id (optional)
  * @return [type]                 [description]
  */
 function filter_search_criteria($criteria, $form_ids = null, $passed_view_id = NULL)
 {
     global $gravityview_view;
     if (is_admin() && (!defined('DOING_AJAX') || defined('DOING_AJAX') && !DOING_AJAX)) {
         return $criteria;
     }
     $view_id = !empty($passed_view_id) ? $passed_view_id : GravityView_View::getInstance()->getViewId();
     if (empty($view_id)) {
         do_action('gravityview_log_error', 'GravityView_Advanced_Filtering[filter_search_criteria] Empty View ID.', $gravityview_view);
         $criteria['search_criteria']['field_filters'][] = self::get_lock_filter();
         $criteria['search_criteria']['field_filters']['mode'] = 'all';
         return $criteria;
     }
     $view_filters = self::get_view_filter_vars($view_id);
     if (!empty($view_filters) && is_array($view_filters)) {
         do_action('gravityview_log_debug', 'GravityView_Advanced_Filtering[filter_search_criteria] about to add search criteria', $view_filters);
         //sanitize filters - no empty search values
         foreach ($view_filters as $k => $filter) {
             // Don't use `empty()` because `0` is a valid value
             if ($k !== 'mode' && (!isset($filter['value']) || $filter['value'] === '')) {
                 unset($view_filters[$k]);
             }
         }
         // add advanced filters if defined
         if (count($view_filters) > 1) {
             do_action('gravityview_log_debug', 'GravityView_Advanced_Filtering[filter_search_criteria] Added search criteria', $view_filters);
             foreach ($view_filters as $k => $filter) {
                 if ($k !== 'mode') {
                     $filter = self::parse_advanced_filters($filter, $view_id);
                     $criteria['search_criteria']['field_filters'][] = $filter;
                 } else {
                     $criteria['search_criteria']['field_filters']['mode'] = $filter;
                 }
             }
         }
     } else {
         do_action('gravityview_log_debug', 'GravityView_Advanced_Filtering[filter_search_criteria] No additional search criteria.');
     }
     return $criteria;
 }
Exemplo n.º 11
0
<?php

/**
 * Display Gravity Forms Quiz value Pass/Fail
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$field = GravityView_View::getInstance()->getCurrentField();
// If there's no grade, don't continue
if (gv_empty($field['value'], false, false)) {
    return;
}
/**
 * @filter `gravityview/field/quiz_percent/format` Modify the format of the display of Quiz Score (Percent) field.
 * @see http://php.net/manual/en/function.sprintf.php For formatting guide
 * @param string $format Format passed to printf() function. Default `%d%%`, which prints as "{number}%". Notice the double `%%`, this prints a literal '%' character.
 */
$format = apply_filters('gravityview/field/quiz_percent/format', '%d%%');
printf($format, $field['value']);
Exemplo n.º 12
0
 /**
  * Inject the sorting links on the table columns
  *
  * Callback function for hook 'gravityview/template/field_label'
  * @see GravityView_API::field_label() (in includes/class-api.php)
  *
  * @since 1.7
  *
  * @param string $label Field label
  * @param array $field Field settings
  *
  * @return string Field Label
  */
 public function add_columns_sort_links($label = '', $field, $form)
 {
     /**
      * Not a table-based template; don't add sort icons
      * @since 1.12
      */
     if (!preg_match('/table/ism', GravityView_View::getInstance()->getTemplatePartSlug())) {
         return $label;
     }
     if (!$this->is_field_sortable($field['id'], $form)) {
         return $label;
     }
     $sorting = GravityView_View::getInstance()->getSorting();
     $class = 'gv-sort icon';
     $sort_field_id = self::_override_sorting_id_by_field_type($field['id'], $form['id']);
     $sort_args = array('sort' => $field['id'], 'dir' => 'asc');
     if (!empty($sorting['key']) && (string) $sort_field_id === (string) $sorting['key']) {
         //toggle sorting direction.
         if ('asc' === $sorting['direction']) {
             $sort_args['dir'] = 'desc';
             $class .= ' gv-icon-sort-desc';
         } else {
             $sort_args['dir'] = 'asc';
             $class .= ' gv-icon-sort-asc';
         }
     } else {
         $class .= ' gv-icon-caret-up-down';
     }
     $url = add_query_arg($sort_args, remove_query_arg(array('pagenum')));
     return '<a href="' . esc_url_raw($url) . '" class="' . $class . '" ></a>&nbsp;' . $label;
 }
Exemplo n.º 13
0
 /**
  * Return an array of files prepared for output.
  *
  * Processes files by file type and generates unique output for each.
  *
  * Returns array for each file, with the following keys:
  *
  * `file_path` => The file path of the file, with a line break
  * `html` => The file output HTML formatted
  *
  * @since  1.2
  * @todo  Support `playlist` shortcode for playlist of video/audio
  * @usedby gravityview_get_files_array()
  * @param  string $value    Field value passed by Gravity Forms. String of file URL, or serialized string of file URL array
  * @param  string $gv_class Field class to add to the output HTML
  * @return array           Array of file output, with `file_path` and `html` keys (see comments above)
  */
 static function get_files_array($value, $gv_class)
 {
     $gravityview_view = GravityView_View::getInstance();
     extract($gravityview_view->getCurrentField());
     $output_arr = array();
     // Get an array of file paths for the field.
     $file_paths = rgar($field, 'multipleFiles') ? json_decode($value) : array($value);
     // Process each file path
     foreach ($file_paths as $file_path) {
         // If the site is HTTPS, use HTTPS
         if (function_exists('set_url_scheme')) {
             $file_path = set_url_scheme($file_path);
         }
         // This is from Gravity Forms's code
         $file_path = esc_attr(str_replace(" ", "%20", $file_path));
         // If the field is set to link to the single entry, link to it.
         $link = !empty($field_settings['show_as_link']) ? GravityView_API::entry_link($entry, $field) : $file_path;
         // Get file path information
         $file_path_info = pathinfo($file_path);
         $html_format = NULL;
         $disable_lightbox = false;
         $disable_wrapped_link = false;
         // Is this an image?
         $image = new GravityView_Image(array('src' => $file_path, 'class' => 'gv-image gv-field-id-' . $field_settings['id'], 'alt' => $field_settings['label'], 'width' => gravityview_get_context() === 'single' ? NULL : 250));
         $content = $image->html();
         // The new default content is the image, if it exists. If not, use the file name as the content.
         $content = !empty($content) ? $content : $file_path_info['basename'];
         // If pathinfo() gave us the extension of the file, run the switch statement using that.
         $extension = empty($file_path_info['extension']) ? NULL : strtolower($file_path_info['extension']);
         switch (true) {
             // Audio file
             case in_array($extension, wp_get_audio_extensions()):
                 $disable_lightbox = true;
                 if (shortcode_exists('audio')) {
                     $disable_wrapped_link = true;
                     /**
                      * Modify the settings passed to the `wp_video_shortcode()` function
                      *
                      * @since  1.2
                      * @var array
                      */
                     $audio_settings = apply_filters('gravityview_audio_settings', array('src' => $file_path, 'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings['id']));
                     /**
                      * Generate the audio shortcode
                      * @link http://codex.wordpress.org/Audio_Shortcode
                      * @link https://developer.wordpress.org/reference/functions/wp_audio_shortcode/
                      */
                     $content = wp_audio_shortcode($audio_settings);
                 }
                 break;
                 // Video file
             // Video file
             case in_array($extension, wp_get_video_extensions()):
                 $disable_lightbox = true;
                 if (shortcode_exists('video')) {
                     $disable_wrapped_link = true;
                     /**
                      * Modify the settings passed to the `wp_video_shortcode()` function
                      *
                      * @since  1.2
                      * @var array
                      */
                     $video_settings = apply_filters('gravityview_video_settings', array('src' => $file_path, 'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings['id']));
                     /**
                      * Generate the video shortcode
                      * @link http://codex.wordpress.org/Video_Shortcode
                      * @link https://developer.wordpress.org/reference/functions/wp_video_shortcode/
                      */
                     $content = wp_video_shortcode($video_settings);
                 }
                 break;
                 // PDF
             // PDF
             case $extension === 'pdf':
                 // PDF needs to be displayed in an IFRAME
                 $link = add_query_arg(array('TB_iframe' => 'true'), $link);
                 break;
                 // if not image, do not set the lightbox (@since 1.5.3)
             // if not image, do not set the lightbox (@since 1.5.3)
             case !in_array($extension, array('jpg', 'jpeg', 'jpe', 'gif', 'png')):
                 $disable_lightbox = true;
                 break;
         }
         // If using Link to File, override the content.
         // (We do this here so that the $disable_lightbox can be set. Yes, there's a little more processing time, but oh well.)
         if (!empty($field_settings['link_to_file'])) {
             // Force the content to be the file name
             $content = $file_path_info["basename"];
             // Restore the wrapped link
             $disable_wrapped_link = false;
         }
         // Whether to use lightbox or not
         if ($disable_lightbox || empty($gravityview_view->atts['lightbox']) || !empty($field_settings['show_as_link'])) {
             $link_atts = empty($field_settings['show_as_link']) ? "target='_blank'" : '';
             $link_atts = apply_filters('gravityview/fields/fileupload/link_atts', $link_atts, $gravityview_view->getCurrentField());
         } else {
             $link_atts = sprintf("rel='%s-{$entry['id']}' class='thickbox' target='_blank'", $gv_class);
         }
         /**
          * Filter to alter the default behaviour of wrapping images (or image names) with a link to the content object
          *
          * @since 1.5.1
          *
          * @param bool $disable_wrapped_link whether to wrap the content with a link to the content object.
          * @param array $gravityview_view->field_data
          *
          * @see GravityView_API:field_value() for info about $gravityview_view->field_data
          *
          */
         $disable_wrapped_link = apply_filters('gravityview/fields/fileupload/disable_link', $disable_wrapped_link, $gravityview_view->getCurrentField());
         // If the HTML output hasn't been overridden by the switch statement above, use the default format
         if (!empty($content) && empty($disable_wrapped_link)) {
             /**
              * Modify the link text (defaults to the file name)
              *
              * @since 1.7
              *
              * @param string $content The existing anchor content. Could be `<img>` tag, audio/video embed or the file name
              * @param array $field GravityView array of the current field being processed
              */
             $content = apply_filters('gravityview/fields/fileupload/link_content', $content, $gravityview_view->getCurrentField());
             $content = '<a href="' . esc_url_raw($link) . '" ' . $link_atts . '>' . $content . '</a>';
         }
         $output_arr[] = array('file_path' => $file_path, 'content' => $content);
     }
     // End foreach loop
     /**
      * Modify the files array
      *
      * @since 1.7
      *
      * @param array $output_arr Associative array of files {
      *      @type string $file_path The path to the file as stored in Gravity Forms
      *      @type string $content The generated output for the file
      * }
      * @param array $field GravityView array of the current field being processed
      */
     $output_arr = apply_filters('gravityview/fields/fileupload/files_array', $output_arr, $gravityview_view->getCurrentField());
     return $output_arr;
 }
Exemplo n.º 14
0
 /**
  * Enqueue the datepicker script
  *
  * It sets the $gravityview->datepicker_class parameter
  *
  * @todo Use own datepicker javascript instead of GF datepicker.js - that way, we can localize the settings and not require the changeMonth and changeYear pickers.
  * @return void
  */
 public function enqueue_datepicker()
 {
     $gravityview_view = GravityView_View::getInstance();
     wp_enqueue_script('jquery-ui-datepicker');
     add_filter('gravityview_js_dependencies', array($this, 'add_datepicker_js_dependency'));
     add_filter('gravityview_js_localization', array($this, 'add_datepicker_localization'), 10, 2);
     $scheme = is_ssl() ? 'https://' : 'http://';
     wp_enqueue_style('jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css');
     /**
      * @filter `gravityview_search_datepicker_class`
      * Modify the CSS class for the datepicker, used by the CSS class is used by Gravity Forms' javascript to determine the format for the date picker. The `gv-datepicker` class is required by the GravityView datepicker javascript.
      * @param string $css_class CSS class to use. Default: `gv-datepicker datepicker mdy` \n
      * Options are:
      * - `mdy` (mm/dd/yyyy)
      * - `dmy` (dd/mm/yyyy)
      * - `dmy_dash` (dd-mm-yyyy)
      * - `dmy_dot` (dd.mm.yyyy)
      * - `ymp_slash` (yyyy/mm/dd)
      * - `ymd_dash` (yyyy-mm-dd)
      * - `ymp_dot` (yyyy.mm.dd)
      */
     $datepicker_class = apply_filters('gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy');
     $gravityview_view->datepicker_class = $datepicker_class;
 }
Exemplo n.º 15
0
 /**
  * @uses GravityView_API_Test::_override_no_entries_text_output()
  * @covers GravityView_API::no_results()
  */
 public function test_no_results()
 {
     global $gravityview_view;
     $gravityview_view = GravityView_View::getInstance();
     $gravityview_view->curr_start = false;
     $gravityview_view->curr_end = false;
     $gravityview_view->curr_search = false;
     // Not in search by default
     $this->assertEquals('No entries match your request.', GravityView_API::no_results(false));
     $this->assertEquals('<p>No entries match your request.</p>' . "\n", GravityView_API::no_results(true));
     // Pretend we're in search
     $gravityview_view->curr_search = true;
     $this->assertEquals('This search returned no results.', GravityView_API::no_results(false));
     $this->assertEquals('<p>This search returned no results.</p>' . "\n", GravityView_API::no_results(true));
     // Add the filter that modifies output
     add_filter('gravitview_no_entries_text', array($this, '_override_no_entries_text_output'), 10, 2);
     // Test to make sure the $is_search parameter is passed correctly
     $this->assertEquals('SEARCH override the no entries text output', GravityView_API::no_results(false));
     $gravityview_view->curr_search = false;
     // Test to make sure the $is_search parameter is passed correctly
     $this->assertEquals('NO SEARCH override the no entries text output', GravityView_API::no_results(false));
     // Remove the filter for later
     remove_filter('gravitview_no_entries_text', array($this, '_override_no_entries_text_output'));
 }
 /**
  * Get array of emails addresses from the stored entry
  *
  * @since 1.17
  *
  * @return array Array of email addresses connected to the entry
  */
 private static function get_note_emails_array()
 {
     $gravityview_view = GravityView_View::getInstance();
     //getting email values
     $email_fields = GFCommon::get_email_fields($gravityview_view->getForm());
     $entry = $gravityview_view->getCurrentEntry();
     $note_emails = array();
     foreach ($email_fields as $email_field) {
         if (!empty($entry["{$email_field->id}"]) && is_email($entry["{$email_field->id}"])) {
             $note_emails[] = $entry["{$email_field->id}"];
         }
     }
     /**
      * @filter `gravityview/field/notes/emails` Modify the dropdown values displayed in the "Also email note to" dropdown
      * @since 1.17
      * @param array $note_emails Array of email addresses connected to the entry
      * @param array $entry Current entry
      */
     $note_emails = apply_filters('gravityview/field/notes/emails', $note_emails, $entry);
     return (array) $note_emails;
 }
Exemplo n.º 17
0
 /**
  * General validations when rendering the widget
  * @return boolean True: render frontend; False: don't render frontend
  */
 public function pre_render_frontend()
 {
     $gravityview_view = GravityView_View::getInstance();
     if (empty($gravityview_view)) {
         do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)));
         return false;
     }
     if (apply_filters('gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this)) {
         do_action('gravityview_log_debug', sprintf('%s[render_frontend]: Hide View data until search is performed', get_class($this)));
         return false;
     }
     return true;
 }
Exemplo n.º 18
0
 /**
  * checks if user has permissions to view the link or delete a specific entry
  *
  * @since 1.5.1
  * @since 1.15 Added `$view_id` param
  *
  * @param  array $entry Gravity Forms entry array
  * @param array $field Field settings (optional)
  * @param int $view_id Pass a View ID to check caps against. If not set, check against current View (optional)
  * @return bool
  */
 public static function check_user_cap_delete_entry($entry, $field = array(), $view_id = 0)
 {
     $gravityview_view = GravityView_View::getInstance();
     $current_user = wp_get_current_user();
     $entry_id = isset($entry['id']) ? $entry['id'] : NULL;
     // Or if they can delete any entries (as defined in Gravity Forms), we're good.
     if (GVCommon::has_cap(array('gravityforms_delete_entries', 'gravityview_delete_others_entries'), $entry_id)) {
         do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.');
         return true;
     }
     // If field options are passed, check if current user can view the link
     if (!empty($field)) {
         // If capability is not defined, something is not right!
         if (empty($field['allow_edit_cap'])) {
             do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field);
             return false;
         }
         if (GVCommon::has_cap($field['allow_edit_cap'])) {
             // Do not return true if cap is read, as we need to check if the current user created the entry
             if ($field['allow_edit_cap'] !== 'read') {
                 return true;
             }
         } else {
             do_action('gravityview_log_debug', sprintf('GravityView_Delete_Entry[check_user_cap_delete_entry] User %s is not authorized to view delete entry link ', $current_user->ID));
             return false;
         }
     }
     if (!isset($entry['created_by'])) {
         do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.');
         return false;
     }
     $view_id = empty($view_id) ? $gravityview_view->getViewId() : $view_id;
     // Only checks user_delete view option if view is already set
     if ($view_id) {
         $current_view = gravityview_get_current_view_data($view_id);
         $user_delete = isset($current_view['atts']['user_delete']) ? $current_view['atts']['user_delete'] : false;
         if (empty($user_delete)) {
             do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.');
             return false;
         }
     }
     // If the logged-in user is the same as the user who created the entry, we're good.
     if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) {
         do_action('gravityview_log_debug', sprintf('GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID));
         return true;
     }
     return false;
 }
 /**
  * Get the HTML output
  *
  * @return string HTML output for entry list
  */
 public function get_output()
 {
     // No Entries
     if (empty($this->entries)) {
         return '<div class="gv-no-results">' . $this->empty_message . '</div>';
     }
     $output = '';
     $current_entry = GravityView_View::getInstance()->getCurrentEntry();
     $output .= '<' . $this->wrapper_tag . '>';
     foreach ($this->entries as $entry) {
         if ($this->skip_entry($entry, $current_entry)) {
             continue;
         }
         $output .= $this->get_item_output($entry);
     }
     $output .= '</' . $this->wrapper_tag . '>';
     /**
      * Modify the HTML of the output
      * @param string $output HTML to be displayed
      * @param GravityView_Entry_List $this The current class instance
      */
     $output = apply_filters('gravityview/widget/recent-entries/output', $output, $this);
     return $output;
 }
Exemplo n.º 20
0
    /**
     *
     * @param $view_id
     */
    public function render_widget_hooks($view_id)
    {
        if (empty($view_id) || 'single' == gravityview_get_context()) {
            do_action('gravityview_log_debug', __METHOD__ . ' - Not rendering widgets; single entry');
            return;
        }
        $view_data = gravityview_get_current_view_data($view_id);
        // get View widget configuration
        $widgets = (array) $view_data['widgets'];
        switch (current_filter()) {
            default:
            case 'gravityview_before':
                $zone = 'header';
                break;
            case 'gravityview_after':
                $zone = 'footer';
                break;
        }
        /**
         * Filter widgets not in the current zone
         * @since 1.16
         */
        foreach ($widgets as $key => $widget) {
            // The widget isn't in the current zone
            if (false === strpos($key, $zone)) {
                unset($widgets[$key]);
            }
        }
        /**
         * Prevent output if no widgets to show.
         * @since 1.16
         */
        if (empty($widgets)) {
            do_action('gravityview_log_debug', sprintf('No widgets for View #%s', $view_id));
            return;
        }
        // Prevent being called twice
        if (did_action($zone . '_' . $view_id . '_widgets')) {
            do_action('gravityview_log_debug', sprintf('%s - Not rendering %s; already rendered', __METHOD__, $zone . '_' . $view_id . '_widgets'));
            return;
        }
        $rows = GravityView_Plugin::get_default_widget_areas();
        // TODO: Move to sep. method, use an action instead
        wp_enqueue_style('gravityview_default_style');
        $default_css_class = 'gv-grid gv-widgets-' . $zone;
        if (0 === GravityView_View::getInstance()->getTotalEntries()) {
            $default_css_class .= ' gv-widgets-no-results';
        }
        /**
         * @filter `gravityview/widgets/wrapper_css_class` The CSS class applied to the widget container `<div>`.
         * @since 1.16.2
         * @param string $css_class Default: `gv-grid gv-widgets-{zone}` where `{zone}` is replaced by the current `$zone` value. If the View has no results, adds ` gv-widgets-no-results`
         * @param string $zone Current widget zone, either `header` or `footer`
         * @param array $widgets Array of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']`
         */
        $css_class = apply_filters('gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets);
        $css_class = gravityview_sanitize_html_class($css_class);
        // TODO Convert to partials
        ?>
		<div class="<?php 
        echo $css_class;
        ?>
">
			<?php 
        foreach ($rows as $row) {
            foreach ($row as $col => $areas) {
                $column = $col == '2-2' ? '1-2 gv-right' : $col . ' gv-left';
                ?>
					<div class="gv-grid-col-<?php 
                echo esc_attr($column);
                ?>
">
						<?php 
                if (!empty($areas)) {
                    foreach ($areas as $area) {
                        if (!empty($widgets[$zone . '_' . $area['areaid']])) {
                            foreach ($widgets[$zone . '_' . $area['areaid']] as $widget) {
                                do_action("gravityview_render_widget_{$widget['id']}", $widget);
                            }
                        }
                    }
                }
                ?>
					</div>
				<?php 
            }
            // $row
            ?>
			<?php 
        }
        // $rows
        ?>
		</div>

		<?php 
        /**
         * Prevent widgets from being called twice.
         * Checking for loop_start prevents themes and plugins that pre-process shortcodes from triggering the action before displaying. Like, ahem, the Divi theme and WordPress SEO plugin
         */
        if (did_action('loop_start')) {
            do_action($zone . '_' . $view_id . '_widgets');
        }
    }
Exemplo n.º 21
0
 /**
  * checks if user has permissions to edit a specific entry
  *
  * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
  *
  * @param  array $entry Gravity Forms entry array
  * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}
  * @return bool
  */
 public static function check_user_cap_edit_entry($entry, $view_id = 0)
 {
     // No permission by default
     $user_can_edit = false;
     // If they can edit any entries (as defined in Gravity Forms)
     // Or if they can edit other people's entries
     // Then we're good.
     if (GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_others_entries'), $entry['id'])) {
         do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
         $user_can_edit = true;
     } else {
         if (!isset($entry['created_by'])) {
             do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
             $user_can_edit = false;
         } else {
             // get user_edit setting
             if (empty($view_id) || $view_id == GravityView_View::getInstance()->getViewId()) {
                 // if View ID not specified or is the current view
                 $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
             } else {
                 // in case is specified and not the current view
                 $user_edit = GVCommon::get_template_setting($view_id, 'user_edit');
             }
             $current_user = wp_get_current_user();
             // User edit is disabled
             if (empty($user_edit)) {
                 do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.');
                 $user_can_edit = false;
             } else {
                 if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) {
                     do_action('gravityview_log_debug', sprintf('GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID));
                     $user_can_edit = true;
                 } else {
                     if (!is_user_logged_in()) {
                         do_action('gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user');
                     }
                 }
             }
         }
     }
     /**
      * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
      * @since 1.15 Added `$entry` and `$view_id` parameters
      * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
      * @param[in] array $entry Gravity Forms entry array {@since 1.15}
      * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
      */
     $user_can_edit = apply_filters('gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id);
     return (bool) $user_can_edit;
 }
 /**
  * Render the widget
  *
  * @see https://www.gravityhelp.com/documentation/article/polls-add-on/
  *
  * @since 1.8
  */
 public function render_frontend($widget_args, $content = '', $context = '')
 {
     if (!$this->pre_render_frontend()) {
         return;
     }
     // Make sure the class is loaded in DataTables
     if (!class_exists('GFFormDisplay')) {
         include_once GFCommon::get_base_path() . '/form_display.php';
     }
     $this->enqueue_scripts_and_styles();
     $settings = $this->get_frontend_settings($widget_args);
     $percentages = empty($settings['percentages']) ? 'false' : 'true';
     $counts = empty($settings['counts']) ? 'false' : 'true';
     if (!empty($settings['field'])) {
         $merge_tag = sprintf('{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings['field'], $settings['style'], $percentages, $counts);
     } else {
         $merge_tag = sprintf('{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings['style'], $percentages, $counts);
     }
     $gravityview_view = GravityView_View::getInstance();
     $gravityview_view->poll_merge_tag = $merge_tag;
     $gravityview_view->poll_settings = $settings;
     $gravityview_view->render('widget', 'poll', false);
 }
Exemplo n.º 23
0
 /**
  * Force Gravity Forms to output scripts as if it were in the admin
  * @return void
  */
 function print_scripts()
 {
     $gravityview_view = GravityView_View::getInstance();
     wp_register_script('gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array('jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view'));
     GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);
     // Sack is required for images
     wp_print_scripts(array('sack', 'gform_gravityforms'));
 }
 /**
  * General validations when rendering the widget
  * @return boolean True: render frontend; False: don't render frontend
  */
 public function pre_render_frontend()
 {
     $gravityview_view = GravityView_View::getInstance();
     if (empty($gravityview_view)) {
         do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)));
         return false;
     }
     /**
      * @filter `gravityview/widget/hide_until_searched` Modify whether to hide content until search
      * @param boolean $hide_until_searched Hide until search?
      * @param GravityView_Widget $this Widget instance
      */
     $hide_until_search = apply_filters('gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this);
     if ($hide_until_search) {
         do_action('gravityview_log_debug', sprintf('%s[render_frontend]: Hide View data until search is performed', get_class($this)));
         return false;
     }
     return true;
 }
Exemplo n.º 25
0
<?php

/**
 * Display the Quiz field type
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
// Make sure the CSS file is enqueued
if (class_exists('GFSurvey') && is_callable(array('GFSurvey', 'get_instance'))) {
    wp_register_style('gsurvey_css', GFSurvey::get_instance()->get_base_url() . '/css/gsurvey.css');
    wp_print_styles('gsurvey_css');
}
echo GravityView_View::getInstance()->getCurrentField('display_value');
 /**
  * Get entry array from `entry_id` parameter. If no $entry_id
  *
  * @since 1.15
  * @uses GVCommon::get_entry
  * @uses GravityView_frontend::getSingleEntry
  *
  * @param int $entry_id Gravity Forms Entry ID. If not passed, current View's current entry ID will be used, if found.
  *
  * @return array|bool Gravity Forms array, if found. Otherwise, false.
  */
 private function get_entry($entry_id = 0)
 {
     $backup_entry = GravityView_frontend::getInstance()->getSingleEntry() ? GravityView_frontend::getInstance()->getEntry() : GravityView_View::getInstance()->getCurrentEntry();
     if (empty($entry_id)) {
         if (!$backup_entry) {
             do_action('gravityview_log_error', __METHOD__ . ' No entry defined (or entry id not valid number)', $this->settings);
             return false;
         }
         $entry = $backup_entry;
     } else {
         $entry = wp_cache_get('gv_entry_link_entry_' . $entry_id, 'gravityview_entry_link_shortcode');
         if (false === $entry) {
             $entry = GVCommon::get_entry($entry_id, true, false);
             wp_cache_add('gv_entry_link_entry_' . $entry_id, $entry, 'gravityview_entry_link_shortcode');
         }
     }
     // No search results
     if (false === $entry) {
         do_action('gravityview_log_error', __METHOD__ . ' No entries match the entry ID defined', $entry_id);
         return false;
     }
     return $entry;
 }
Exemplo n.º 27
0
 /**
  * Generate a link to the Directory view
  *
  * Uses `wp_cache_get` and `wp_cache_get` (since 1.3) to speed up repeated requests to get permalink, which improves load time. Since we may be doing this hundreds of times per request, it adds up!
  *
  * @param int $post_id Post ID
  * @param boolean $add_query_args Add pagination and sorting arguments
  * @return string      Permalink to multiple entries view
  */
 public static function directory_link($post_id = NULL, $add_query_args = true)
 {
     global $post;
     $gravityview_view = GravityView_View::getInstance();
     if (empty($post_id)) {
         $post_id = false;
         // DataTables passes the Post ID
         if (defined('DOING_AJAX') && DOING_AJAX) {
             $post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : false;
         } else {
             // The Post ID has been passed via the shortcode
             if (!empty($gravityview_view) && $gravityview_view->getPostId()) {
                 $post_id = $gravityview_view->getPostId();
             } else {
                 // This is a GravityView post type
                 if (GravityView_frontend::getInstance()->is_gravityview_post_type) {
                     $post_id = isset($gravityview_view) ? $gravityview_view->getViewId() : $post->ID;
                 } else {
                     // This is an embedded GravityView; use the embedded post's ID as the base.
                     if (GravityView_frontend::getInstance()->post_has_shortcode && is_a($post, 'WP_Post')) {
                         $post_id = $post->ID;
                     } elseif ($gravityview_view->getViewId()) {
                         // The GravityView has been embedded in a widget or in a template, and
                         // is not in the current content. Thus, we defer to the View's own ID.
                         $post_id = $gravityview_view->getViewId();
                     }
                 }
             }
         }
     }
     // No post ID, get outta here.
     if (empty($post_id)) {
         return NULL;
     }
     // If we've saved the permalink in memory, use it
     // @since 1.3
     $link = wp_cache_get('gv_directory_link_' . $post_id);
     if (empty($link)) {
         $link = get_permalink($post_id);
         // If not yet saved, cache the permalink.
         // @since 1.3
         wp_cache_set('gv_directory_link_' . $post_id, $link);
     }
     // Deal with returning to proper pagination for embedded views
     if ($add_query_args) {
         $args = array();
         if ($pagenum = rgget('pagenum')) {
             $args['pagenum'] = intval($pagenum);
         }
         if ($sort = rgget('sort')) {
             $args['sort'] = $sort;
             $args['dir'] = rgget('dir');
         }
         $link = add_query_arg($args, $link);
     }
     return $link;
 }
Exemplo n.º 28
0
 /**
  * @covers GravityView_View::add_id_specific_templates
  */
 function test_add_id_specific_templates()
 {
     GravityView_View::getInstance()->setFormId(123);
     GravityView_View::getInstance()->setViewId(45);
     GravityView_View::getInstance()->setPostId(6789);
     $templates_before = array('table-header.php');
     $templates = GravityView_View::getInstance()->add_id_specific_templates($templates_before, 'table', 'header');
     $expected = array('form-123-table-header.php', 'view-45-table-header.php', 'page-6789-table-header.php', 'table-header.php');
     $this->assertEquals($expected, $templates);
 }
Exemplo n.º 29
0
<?php

/**
 * Display the entry_link field type
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
// Don't show on single entry
if ($gravityview_view->getContext() === 'single') {
    return;
}
$link_text = empty($field_settings['entry_link_text']) ? __('View Details', 'gravityview') : $field_settings['entry_link_text'];
$output = apply_filters('gravityview_entry_link', GravityView_API::replace_variables($link_text, $form, $entry));
echo GravityView_API::entry_link_html($entry, $output, array(), $field_settings);
Exemplo n.º 30
0
 /**
  * checks if user has permissions to edit a specific entry
  *
  * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
  *
  * @param  array $entry Gravity Forms entry array
  * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}
  * @return bool
  */
 public static function check_user_cap_edit_entry($entry, $view_id = 0)
 {
     // No permission by default
     $user_can_edit = false;
     // Or if they can edit any entries (as defined in Gravity Forms), we're good.
     if (GFCommon::current_user_can_any('gravityforms_edit_entries')) {
         $user_can_edit = true;
     } else {
         if (!isset($entry['created_by'])) {
             do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
             $user_can_edit = false;
         } else {
             // get user_edit setting
             if (empty($view_id) || $view_id == GravityView_View::getInstance()->getViewId()) {
                 // if View ID not specified or is the current view
                 $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
             } else {
                 // in case is specified and not the current view
                 $user_edit = GVCommon::get_template_setting($view_id, 'user_edit');
             }
             $current_user = wp_get_current_user();
             // User edit is disabled
             if (empty($user_edit)) {
                 do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.');
                 $user_can_edit = false;
             } else {
                 if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) {
                     do_action('gravityview_log_debug', sprintf('GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID));
                     $user_can_edit = true;
                 }
             }
         }
     }
     /**
      * @param boolean $user_can_edit Can the current user edit the current entry? (Default: false)
      */
     $user_can_edit = apply_filters('gravityview/edit_entry/user_can_edit_entry', $user_can_edit);
     return (bool) $user_can_edit;
 }