/**
  * Filter the value of the field
  *
  * @todo Consider how to add to parent class
  *
  * @since 1.16
  *
  * @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 Current field being displayed
  *
  * @return String values for this field based on the numeric values used by Gravity Forms
  */
 public function get_content($output = '', $entry = array(), $field_settings = array(), $field = array())
 {
     /** Overridden by a template. */
     if (!empty($field['field_path'])) {
         return $output;
     }
     return GVCommon::format_date($field['value'], 'format=' . rgar($field_settings, 'date_display'));
 }
 /**
  * Add Edit View link when in embedded View
  *
  * @since 1.13
  * @return void
  */
 function add_edit_view_link()
 {
     /** @var WP_Admin_Bar $wp_admin_bar */
     global $wp_admin_bar;
     if (GVCommon::has_cap('edit_gravityviews')) {
         $view_data = GravityView_View_Data::getInstance();
         $views = $view_data->get_views();
         // If there is a View embed, shor Edit View link.
         // todo: Support multiple View embeds with a drop-down menu
         if (!$this->gravityview_view->isGravityviewPostType() && !empty($views) && !$view_data->has_multiple_views()) {
             $view = reset($views);
             if (GVCommon::has_cap('edit_gravityview', $view['id'])) {
                 $wp_admin_bar->add_menu(array('id' => 'edit-view', 'title' => __('Edit View', 'gravityview'), 'href' => esc_url_raw(admin_url(sprintf('post.php?post=%d&action=edit', $view['id'])))));
             }
         }
     }
 }
    /**
     * Add shortcode button to the Add Media right
     *
     * @access public
     * @return void
     */
    function add_shortcode_button()
    {
        /**
         * @since 1.15.3
         */
        if (!GVCommon::has_cap(array('publish_gravityviews'))) {
            return;
        }
        if (!$this->is_post_editor_screen()) {
            return;
        }
        ?>
		<a href="#TB_inline?width=600&amp;height=800&amp;inlineId=select_gravityview_view" class="thickbox hide-if-no-js button gform_media_link" id="add_gravityview" title="<?php 
        esc_attr_e("Insert View", 'gravityview');
        ?>
"><span class="icon gv-icon-astronaut-head"></span><?php 
        esc_html_e('Add View', 'gravityview');
        ?>
</a>
		<?php 
    }
 /**
  * @since 1.15
  * @covers GravityView_Uninstall::fire_everything()
  */
 function test_fire_everything()
 {
     $create_count = 10;
     $form = $this->factory->form->create_and_get();
     $all_forms = GFAPI::get_forms();
     $views = $this->factory->view->create_many($create_count, array('form_id' => $form['id']));
     $entry_ids = $this->factory->entry->create_many($create_count, array('form_id' => $form['id']));
     $connected = gravityview_get_connected_views($form['id']);
     $entry_count = GFAPI::count_entries($form['id']);
     // Make sure the objects were created and connected
     $this->assertEquals($create_count, count(array_filter($views)));
     $this->assertEquals($create_count, count(array_filter($connected)));
     $this->assertEquals($create_count, count(array_filter($entry_ids)));
     $this->_set_up_expected_options();
     ### DO NOT DELETE WHEN THE USER DOESN'T HAVE THE CAPABILITY
     $user = $this->factory->user->create_and_set(array('user_login' => 'administrator', 'user_pass' => 'administrator', 'role' => 'administrator'));
     $this->assertTrue(GVCommon::has_cap('gravityview_uninstall'));
     ### DO NOT DELETE WHEN IT IS NOT SET OR SET TO FALSE
     // TRY deleting when the settings aren't configured.
     $this->_set_up_gravityview_settings(NULL);
     $this->uninstall();
     $this->_check_deleted_options(false);
     // TRY deleting when the Delete setting is set to No
     $this->_set_up_gravityview_settings('0');
     $this->uninstall();
     $this->_check_deleted_options(false);
     ### REALLY DELETE NOW
     // Create the items
     $this->_set_up_gravityview_settings('delete');
     $this->_set_up_notes($entry_ids);
     $this->_set_up_entry_meta($entry_ids, $form);
     $this->uninstall();
     // No Forms should be deleted
     $this->assertEquals($all_forms, GFAPI::get_forms());
     $this->_check_posts();
     $this->_check_entries($form, $entry_count);
     $this->_check_deleted_options();
     $this->_check_deleted_entry_notes($entry_ids);
     $this->_check_deleted_entry_meta($entry_ids);
 }
Exemplo n.º 5
0
/**
 * Generate an HTML anchor tag with a list of supported attributes
 *
 * @see GVCommon::get_link_html()
 *
 * @since 1.6
 *
 * @param string $href URL of the link.
 * @param string $anchor_text The text or HTML inside the anchor. This is not sanitized in the function.
 * @param array $atts Attributes to be added to the anchor tag
 *
 * @return string HTML output of anchor link. If empty $href, returns NULL
 */
function gravityview_get_link($href = '', $anchor_text = '', $atts = array())
{
    return GVCommon::get_link_html($href, $anchor_text, $atts);
}
Exemplo n.º 6
0
$criteria['paging'] = array('offset' => 0, 'page_size' => $view_settings['page_size']);
// Prepare Search Criteria
$criteria['search_criteria'] = array('field_filters' => array(array('key' => 'created_by', 'value' => $created_by, 'operator' => 'is')));
$criteria['search_criteria'] = GravityView_frontend::process_search_only_approved($view_settings, $criteria['search_criteria']);
$criteria['search_criteria']['status'] = apply_filters('gravityview_status', 'active', $view_settings);
/**
 * Modify the search parameters before the entries are fetched
 *
 * @since 1.11
 *
 * @param array $criteria Gravity Forms search criteria array, as used by GVCommon::get_entries()
 * @param array $view_settings Associative array of settings with plugin defaults used if not set by the View
 * @param int $form_id The Gravity Forms ID
 */
$criteria = apply_filters('gravityview/field/other_entries/criteria', $criteria, $view_settings, $form_id);
$entries = GVCommon::get_entries($form_id, $criteria);
// Don't show if no entries and the setting says so
if (empty($entries) && $gravityview_view->getCurrentFieldSetting('no_entries_hide')) {
    return;
}
// If there are search results, get the entry list object
$list = new GravityView_Entry_List($entries, $gravityview_view->getPostId(), $field['form'], $gravityview_view->getCurrentFieldSetting('link_format'), $gravityview_view->getCurrentFieldSetting('after_link'), 'other_entries');
// Generate and echo the output
$list->output();
/**
 * @since 1.7.6
 * @deprecated since 1.11
 */
$deprecated = apply_filters('gravityview/field/other_entries/args', array(), $field);
if (!empty($deprecated)) {
    _deprecated_function('The "gravityview/field/other_entries/args" filter', 'GravityView 1.11', 'gravityview/field/other_entries/criteria');
 /**
  * Should the Approve/Reject Entry column be shown in the GF Entries page?
  *
  * @since 1.7.2
  *
  * @param int $form_id The ID of the Gravity Forms form for which entries are being shown
  *
  * @return bool True: Show column; False: hide column
  */
 private function show_approve_entry_column($form_id)
 {
     $show_approve_column = GVCommon::has_cap('gravityview_moderate_entries');
     /**
      * @filter `gravityview/approve_entries/hide-if-no-connections` Return true to hide reject/approve if there are no connected Views
      * @since 1.7.2
      * @param boolean $hide_if_no_connections
      */
     $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false);
     if ($hide_if_no_connections) {
         $connected_views = gravityview_get_connected_views($form_id);
         if (empty($connected_views)) {
             $show_approve_column = false;
         }
     }
     /**
      * @filter `gravityview/approve_entries/show-column` Override whether the column is shown
      * @param boolean $show_approve_column Whether the column will be shown
      * @param int $form_id The ID of the Gravity Forms form for which entries are being shown
      */
     $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id);
     return $show_approve_column;
 }
 /**
  * checks if user has permissions to edit a specific field
  *
  * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_field for maximum security!!
  *
  * @param  [type] $field [description]
  * @return bool
  */
 private function check_user_cap_edit_field($field)
 {
     // If they can edit any entries (as defined in Gravity Forms), we're good.
     if (GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_others_entries'))) {
         return true;
     }
     $field_cap = isset($field['allow_edit_cap']) ? $field['allow_edit_cap'] : false;
     // If the field has custom editing capaibilities set, check those
     if ($field_cap) {
         return GVCommon::has_cap($field['allow_edit_cap']);
     }
     return false;
 }
 /**
  * Get the entries that will be shown in the current widget
  *
  * @param  array $instance Settings for the current widget
  *
  * @return array $entries Multidimensional array of Gravity Forms entries
  */
 private function get_entries($instance, $form_id)
 {
     // Get the settings for the View ID
     $view_settings = gravityview_get_template_settings($instance['view_id']);
     // Set the context view ID to avoid conflicts with the Advanced Filter extension.
     $criteria['context_view_id'] = $instance['view_id'];
     $instance['limit'] = isset($instance['limit']) ? $instance['limit'] : 10;
     $view_settings['id'] = $instance['view_id'];
     $view_settings['page_size'] = $instance['limit'];
     // Prepare paging criteria
     $criteria['paging'] = array('offset' => 0, 'page_size' => $instance['limit']);
     // Prepare Search Criteria
     $criteria['search_criteria'] = array('field_filters' => array());
     $criteria['search_criteria'] = GravityView_frontend::process_search_only_approved($view_settings, $criteria['search_criteria']);
     $criteria['search_criteria']['status'] = apply_filters('gravityview_status', 'active', $view_settings);
     /**
      * Modify the search parameters before the entries are fetched
      */
     $criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id);
     $results = GVCommon::get_entries($form_id, $criteria);
     return $results;
 }
 /**
  * Check whether to show Support for a user
  *
  * If the user doesn't have the `gravityview_support_port` capability, returns false.
  * If there is no preference set for the user, use the global plugin setting.
  *
  * @since 1.15
  *
  * @param int $user Optional. ID of the user to check, defaults to 0 for current user.
  *
  * @return bool Whether to show GravityView support
  */
 public static function show_for_user($user = 0)
 {
     if (!GVCommon::has_cap('gravityview_support_port')) {
         return false;
     }
     $pref = get_user_option(self::user_pref_name, $user);
     // Not set; default to plugin setting
     if (false === $pref) {
         return GravityView_Settings::getSetting('support_port');
     }
     return !empty($pref);
 }
Exemplo n.º 11
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;
 }
Exemplo n.º 12
0
/**
 * Returns the GF Form field type for a certain field(id) of a form
 * @param  object $form     Gravity Forms form
 * @param  mixed $field_id Field ID or Field array
 * @return string field type
 */
function gravityview_get_field_type($form = null, $field_id = '')
{
    return GVCommon::get_field_type($form, $field_id);
}
 /**
  * Specify the settings fields to be rendered on the plugin settings page
  * @return array
  */
 public function app_settings_fields()
 {
     $default_settings = $this->get_default_settings();
     $disabled_attribute = GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled';
     $fields = apply_filters('gravityview_settings_fields', array(array('name' => 'license_key', 'required' => true, 'label' => __('License Key', 'gravityview'), 'description' => __('Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview') . $this->get_license_handler()->license_details($this->get_app_setting('license_key_response')), 'type' => 'edd_license', 'data-pending-text' => __('Verifying license&hellip;', 'gravityview'), 'default_value' => $default_settings['license_key'], 'class' => '' == $this->get_app_setting('license_key') ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key'), array('name' => 'license_key_response', 'default_value' => $default_settings['license_key_response'], 'type' => 'hidden'), array('name' => 'license_key_status', 'default_value' => $default_settings['license_key_status'], 'type' => 'hidden'), array('name' => 'support-email', 'type' => 'text', 'validate' => 'email', 'default_value' => $default_settings['support-email'], 'label' => __('Support Email', 'gravityview'), 'description' => __('In order to provide responses to your support requests, please provide your email address.', 'gravityview'), 'class' => 'code regular-text'), array('name' => 'support_port', 'type' => 'radio', 'label' => __('Show Support Port?', 'gravityview'), 'default_value' => $default_settings['support_port'], 'horizontal' => 1, 'choices' => array(array('label' => _x('Show', 'Setting: Show or Hide', 'gravityview'), 'value' => '1'), array('label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'), 'value' => '0')), 'tooltip' => '<p><img src="' . esc_url_raw(plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE)) . '" alt="' . esc_attr__('The Support Port looks like this.', 'gravityview') . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview') . '</p>', 'description' => __('Show the Support Port on GravityView pages?', 'gravityview')), array('name' => 'no-conflict-mode', 'type' => 'radio', 'label' => __('No-Conflict Mode', 'gravityview'), 'default_value' => $default_settings['no-conflict-mode'], 'horizontal' => 1, 'choices' => array(array('label' => _x('On', 'Setting: On or off', 'gravityview'), 'value' => '1'), array('label' => _x('Off', 'Setting: On or off', 'gravityview'), 'value' => '0')), 'description' => __('Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview') . ' ' . __('If your Edit View tabs are ugly, enable this setting.', 'gravityview')), array('name' => 'delete-on-uninstall', 'type' => 'radio', 'label' => __('Remove Data on Delete?', 'gravityview'), 'default_value' => $default_settings['delete-on-uninstall'], 'horizontal' => 1, 'choices' => array(array('label' => _x('Keep GravityView Data', 'Setting: what to do when uninstalling plugin', 'gravityview'), 'value' => '0', 'tooltip' => sprintf('<h6>%s</h6><p>%s</p>', __('Keep GravityView content and settings', 'gravityview'), __('If you delete then re-install the plugin, all GravityView data will be kept. Views, settings, etc. will be untouched.', 'gravityview'))), array('label' => _x('Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview'), 'value' => 'delete', 'tooltip' => sprintf('<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __('Delete all GravityView content and settings', 'gravityview'), __('If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview'), __('When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview')))), 'description' => sprintf(__('Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview'), __('Permanently Delete', 'gravityview')))));
     /**
      * Redux backward compatibility
      * @since 1.7.4
      */
     foreach ($fields as &$field) {
         $field['name'] = isset($field['name']) ? $field['name'] : rgget('id', $field);
         $field['label'] = isset($field['label']) ? $field['label'] : rgget('title', $field);
         $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : rgget('default', $field);
         $field['description'] = isset($field['description']) ? $field['description'] : rgget('subtitle', $field);
         if ($disabled_attribute) {
             $field['disabled'] = $disabled_attribute;
         }
     }
     $sections = array(array('description' => sprintf('<span class="version-info description">%s</span>', sprintf(__('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version)), 'fields' => $fields));
     // custom 'update settings' button
     $button = array('class' => 'button button-primary button-hero', 'type' => 'save');
     if ($disabled_attribute) {
         $button['disabled'] = $disabled_attribute;
     }
     /**
      * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
      * Extensions can tap in here to insert their own section and settings.
      * <code>
      *   $sections[] = array(
      *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
      *      'fields' => $settings,
      *   );
      * </code>
      * @param array $extension_settings Empty array, ready for extension settings!
      */
     $extension_sections = apply_filters('gravityview/settings/extension/sections', array());
     // If there are extensions, add a section for them
     if (!empty($extension_sections)) {
         if ($disabled_attribute) {
             foreach ($extension_sections as &$section) {
                 foreach ($section['fields'] as &$field) {
                     $field['disabled'] = $disabled_attribute;
                 }
             }
         }
         $k = count($extension_sections) - 1;
         $extension_sections[$k]['fields'][] = $button;
         $sections = array_merge($sections, $extension_sections);
     } else {
         // add the 'update settings' button to the general section
         $sections[0]['fields'][] = $button;
     }
     return $sections;
 }
 /**
  * Test if the user is allowed to copy Views
  *
  * @since 1.6
  */
 private function current_user_can_copy($post)
 {
     $id = is_object($post) ? $post->ID : $post;
     // Can't edit this current View
     return GVCommon::has_cap('copy_gravityviews', $id);
 }
Exemplo n.º 15
0
 /**
  * Perform the call to EDD based on the AJAX call or passed data
  *
  * @since 1.7.4
  *
  * @param array $array {
  * @type string $license The license key
  * @type string $edd_action The EDD action to perform, like `check_license`
  * @type string $field_id The ID of the field to check
  * @type boolean $update Whether to update plugin settings. Prevent updating the data by setting an `update` key to false
  * @type string $format If `object`, return the object of the license data. Else, return the JSON-encoded object
  * }
  *
  * @return mixed|string|void
  */
 public function license_call($array = array())
 {
     $is_ajax = defined('DOING_AJAX') && DOING_AJAX;
     $data = empty($array) ? $_POST['data'] : $array;
     $has_cap = GVCommon::has_cap('gravityview_edit_settings');
     if ($is_ajax && empty($data['license'])) {
         die(-1);
     }
     // If the user isn't allowed to edit settings, show an error message
     if (!$has_cap) {
         $license_data = new stdClass();
         $license_data->error = 'capability';
         $license_data->message = $this->get_license_message($license_data);
         $json = json_encode($license_data);
     } else {
         $license = esc_attr(rgget('license', $data));
         $license_data = $this->_license_get_remote_response($data, $license);
         // Empty is returned when there's an error.
         if (empty($license_data)) {
             if ($is_ajax) {
                 exit(json_encode(array()));
             } else {
                 // Non-ajax call
                 return json_encode(array());
             }
         }
         $license_data->message = $this->get_license_message($license_data);
         $json = json_encode($license_data);
         $update_license = !isset($data['update']) || !empty($data['update']);
         $is_check_action_button = 'check_license' === $data['edd_action'] && defined('DOING_AJAX') && DOING_AJAX;
         // Failed is the response from trying to de-activate a license and it didn't work.
         // This likely happened because people entered in a different key and clicked "Deactivate",
         // meaning to deactivate the original key. We don't want to save this response, since it is
         // most likely a mistake.
         if ($license_data->license !== 'failed' && !$is_check_action_button && $update_license) {
             if (!empty($data['field_id'])) {
                 set_transient('gravityview_' . esc_attr($data['field_id']) . '_valid', $license_data, DAY_IN_SECONDS);
             }
             $this->license_call_update_settings($license_data, $data);
         }
     }
     // End $has_cap
     if ($is_ajax) {
         exit($json);
     } else {
         // Non-ajax call
         return rgget('format', $data) === 'object' ? $license_data : $json;
     }
 }
Exemplo n.º 16
0
 /**
  * Get text for no views found.
  * @todo Move somewhere appropriate.
  * @return string HTML message with no container tags.
  */
 static function no_views_text()
 {
     if (!class_exists('GravityView_Admin')) {
         require_once GRAVITYVIEW_DIR . 'includes/class-admin.php';
     }
     // Floaty the astronaut
     $image = GravityView_Admin::get_floaty();
     if (GVCommon::has_cap('edit_gravityviews')) {
         $output = sprintf(esc_attr__("%sYou don't have any active views. Let&rsquo;s go %screate one%s!%s\n\nIf you feel like you're lost in space and need help getting started, check out the %sGetting Started%s page.", 'gravityview'), '<h3>', '<a href="' . admin_url('post-new.php?post_type=gravityview') . '">', '</a>', '</h3>', '<a href="' . admin_url('edit.php?post_type=gravityview&page=gv-getting-started') . '">', '</a>');
     } else {
         $output = esc_attr__('There are no active Views', 'gravityview');
     }
     return $image . wpautop($output);
 }
Exemplo n.º 17
0
<?php

/**
 * Display the date_created field type
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
echo GVCommon::format_date($value, 'format=' . rgar($field_settings, 'date_display'));
Exemplo n.º 18
0
 /**
  * Modify plugin action links at plugins screen
  *
  * @since 1.15 Added check for `gravityview_view_settings` and `gravityview_support_port` capabilities
  * @access public
  * @static
  * @param array $links Array of action links under GravityView on the plugin page
  * @return array Action links with Settings and Support included, if the user has the appropriate caps
  */
 public static function plugin_action_links($links)
 {
     $actions = array();
     if (GVCommon::has_cap('gravityview_view_settings')) {
         $actions[] = sprintf('<a href="%s">%s</a>', admin_url('edit.php?post_type=gravityview&page=gravityview_settings'), esc_html__('Settings', 'gravityview'));
     }
     if (GVCommon::has_cap('gravityview_support_port')) {
         $actions[] = '<a href="http://docs.gravityview.co">' . esc_html__('Support', 'gravityview') . '</a>';
     }
     return array_merge($actions, $links);
 }
Exemplo n.º 19
0
 /**
  * Save View configuration
  *
  * @access public
  * @param mixed $post_id
  * @return void
  */
 function save_postdata($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // validate post_type
     if (!isset($_POST['post_type']) || 'gravityview' != $_POST['post_type']) {
         return;
     }
     // validate user can edit and save post/page
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
     }
     do_action('gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST);
     $statii = array();
     // check if this is a start fresh View
     if (isset($_POST['gravityview_select_form_nonce']) && wp_verify_nonce($_POST['gravityview_select_form_nonce'], 'gravityview_select_form')) {
         $form_id = !empty($_POST['gravityview_form_id']) ? $_POST['gravityview_form_id'] : '';
         // save form id
         $statii['form_id'] = update_post_meta($post_id, '_gravityview_form_id', $form_id);
     }
     // Was this a start fresh?
     if (!empty($_POST['gravityview_form_id_start_fresh'])) {
         $statii['start_fresh'] = add_post_meta($post_id, '_gravityview_start_fresh', 1);
     } else {
         $statii['start_fresh'] = delete_post_meta($post_id, '_gravityview_start_fresh');
     }
     // Check if we have a template id
     if (isset($_POST['gravityview_select_template_nonce']) && wp_verify_nonce($_POST['gravityview_select_template_nonce'], 'gravityview_select_template')) {
         $template_id = !empty($_POST['gravityview_directory_template']) ? $_POST['gravityview_directory_template'] : '';
         // now save template id
         $statii['directory_template'] = update_post_meta($post_id, '_gravityview_directory_template', $template_id);
     }
     // save View Configuration metabox
     if (isset($_POST['gravityview_view_configuration_nonce']) && wp_verify_nonce($_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration')) {
         // template settings
         if (empty($_POST['template_settings'])) {
             $_POST['template_settings'] = array();
         }
         $statii['template_settings'] = update_post_meta($post_id, '_gravityview_template_settings', $_POST['template_settings']);
         $fields = array();
         // Directory&single Visible Fields
         if (!empty($preset_fields)) {
             $fields = $preset_fields;
         } elseif (!empty($_POST['fields'])) {
             if (!is_array($_POST['fields'])) {
                 // Fields are passed as a jQuery-serialized array, created in admin-views.js in the serializeForm method
                 // Not using parse_str due to max_input_vars limitation
                 $fields_holder = array();
                 GVCommon::gv_parse_str($_POST['fields'], $fields_holder);
                 if (isset($fields_holder['fields'])) {
                     // When parsed, there's a m
                     $fields = $fields_holder['fields'];
                 } else {
                     do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder);
                 }
             } else {
                 $fields = $_POST['fields'];
             }
         }
         $statii['directory_fields'] = update_post_meta($post_id, '_gravityview_directory_fields', $fields);
         // Directory Visible Widgets
         if (empty($_POST['widgets'])) {
             $_POST['widgets'] = array();
         }
         $statii['directory_widgets'] = update_post_meta($post_id, '_gravityview_directory_widgets', $_POST['widgets']);
     }
     // end save view configuration
     do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map('intval', $statii));
 }
Exemplo n.º 20
0
    $params = array();
    // The default link is a mailto link
    $link = 'mailto:' . $value;
    // Is the subject set?
    if (!empty($field_settings['emailsubject'])) {
        $subject = GravityView_API::replace_variables($field_settings['emailsubject'], $form, $entry);
        $params[] = 'subject=' . str_replace('+', '%20', urlencode($subject));
    }
    // Is the body set?
    if (!empty($field_settings['emailbody'])) {
        $body = GravityView_API::replace_variables($field_settings['emailbody'], $form, $entry);
        $params[] = 'body=' . str_replace('+', '%20', urlencode($body));
    }
    // If the subject and body have been set, use them
    if (!empty($params)) {
        $link .= '?' . implode('&', $params);
    }
    // Generate the link HTML
    $output = gravityview_get_link($link, $value);
}
/**
 * Prevent encrypting emails no matter what - this is handy for DataTables exports, for example
 * @since 1.1.6
 * @var boolean
 */
$prevent_encrypt = apply_filters('gravityview_email_prevent_encrypt', false);
// If encrypting the link
if (!empty($field_settings['emailencrypt']) && !$prevent_encrypt) {
    $output = GVCommon::js_encrypt($output);
}
echo $output;
 /**
  * Check whether a field is editable by the current user, and optionally display an error message
  * @uses  GravityView_Edit_Entry->check_user_cap_edit_field() Check user capabilities
  * @param  array  $field Field or field settings array
  * @param  boolean $echo  Whether to show error message telling user they aren't allowed
  * @return boolean         True: user can edit the current field; False: nope, they can't.
  */
 private function user_can_edit_field($field, $echo = false)
 {
     $error = NULL;
     if (!$this->check_user_cap_edit_field($field)) {
         $error = __('You do not have permission to edit this field.', 'gravityview');
     }
     // No errors; everything's fine here!
     if (empty($error)) {
         return true;
     }
     if ($echo) {
         echo GVCommon::generate_notice(wpautop(esc_html($error)), 'gv-error error');
     }
     do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error);
     return false;
 }
 /**
  * If note has an email to send, and the user has the right caps, send it
  *
  * @since 1.17
  *
  * @param false|object $note If note was created, object. Otherwise, false.
  * @param array $entry Entry data
  * @param array $data $_POST data
  *
  * @return void Tap in to Gravity Forms' `gform_after_email` action if you want a return result from sending the email.
  */
 private function maybe_send_entry_notes($note = false, $entry, $data)
 {
     if (!$note || !GVCommon::has_cap('gravityview_email_entry_notes')) {
         do_action('gravityview_log_debug', __METHOD__ . ': User doesnt have "gravityview_email_entry_notes" cap, or $note is empty', $note);
         return;
     }
     do_action('gravityview_log_debug', __METHOD__ . ': $data', $data);
     //emailing notes if configured
     if (!empty($data['gv-note-to'])) {
         $default_data = array('gv-note-to' => '', 'gv-note-to-custom' => '', 'gv-note-subject' => '', 'gv-note-content' => '');
         $current_user = wp_get_current_user();
         $email_data = wp_parse_args($data, $default_data);
         $from = $current_user->user_email;
         $to = $email_data['gv-note-to'];
         /**
          * Documented in get_note_email_fields
          * @see get_note_email_fields
          */
         $include_custom = apply_filters('gravityview/field/notes/custom-email', true);
         if ('custom' === $to && $include_custom) {
             $to = $email_data['gv-note-to-custom'];
             do_action('gravityview_log_debug', __METHOD__ . ': Sending note to a custom email address: ' . $to);
         }
         if (!is_email($to)) {
             do_action('gravityview_log_error', __METHOD__ . ': $to not a valid email address: ' . $to, $email_data);
             return;
         }
         $bcc = false;
         $reply_to = $from;
         $subject = trim($email_data['gv-note-subject']);
         // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF
         $subject = empty($subject) ? self::strings('default-email-subject') : $subject;
         $message = $email_data['gv-note-content'];
         $from_name = $current_user->display_name;
         $message_format = 'html';
         /**
          * @filter `gravityview/field/notes/email_content` Modify the values passed when sending a note email
          * @see GVCommon::send_email
          * @since 1.17
          * @param[in,out] array $email_settings Values being passed to the GVCommon::send_email() method: 'from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'entry'
          */
         $email_content = apply_filters('gravityview/field/notes/email_content', compact('from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'entry'));
         extract($email_content);
         GVCommon::send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false);
         $form = isset($entry['form_id']) ? GFAPI::get_form($entry['form_id']) : array();
         /**
          * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms
          */
         do_action('gform_post_send_entry_note', __METHOD__, $to, $from, $subject, $message, $form, $entry);
     }
 }
Exemplo n.º 23
0
 /**
  * Save View configuration
  *
  * @access public
  * @param int $post_id Currently saved Post ID
  * @return void
  */
 function save_postdata($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // validate post_type
     if (!isset($_POST['post_type']) || 'gravityview' != $_POST['post_type']) {
         return;
     }
     // validate user can edit and save View
     if (!GVCommon::has_cap('edit_gravityview', $post_id)) {
         do_action('gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to edit View #' . $post_id, wp_get_current_user());
         return;
     }
     do_action('gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST);
     $statii = array();
     // check if this is a start fresh View
     if (isset($_POST['gravityview_select_form_nonce']) && wp_verify_nonce($_POST['gravityview_select_form_nonce'], 'gravityview_select_form')) {
         $form_id = !empty($_POST['gravityview_form_id']) ? $_POST['gravityview_form_id'] : '';
         // save form id
         $statii['form_id'] = update_post_meta($post_id, '_gravityview_form_id', $form_id);
     }
     if (false === GVCommon::has_cap('gravityforms_create_form') && empty($statii['form_id'])) {
         do_action('gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to create a new Form.', wp_get_current_user());
         return;
     }
     // Was this a start fresh?
     if (!empty($_POST['gravityview_form_id_start_fresh'])) {
         $statii['start_fresh'] = add_post_meta($post_id, '_gravityview_start_fresh', 1);
     } else {
         $statii['start_fresh'] = delete_post_meta($post_id, '_gravityview_start_fresh');
     }
     // Check if we have a template id
     if (isset($_POST['gravityview_select_template_nonce']) && wp_verify_nonce($_POST['gravityview_select_template_nonce'], 'gravityview_select_template')) {
         $template_id = !empty($_POST['gravityview_directory_template']) ? $_POST['gravityview_directory_template'] : '';
         // now save template id
         $statii['directory_template'] = update_post_meta($post_id, '_gravityview_directory_template', $template_id);
     }
     // save View Configuration metabox
     if (isset($_POST['gravityview_view_configuration_nonce']) && wp_verify_nonce($_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration')) {
         // template settings
         if (empty($_POST['template_settings'])) {
             $_POST['template_settings'] = array();
         }
         $statii['template_settings'] = update_post_meta($post_id, '_gravityview_template_settings', $_POST['template_settings']);
         $fields = array();
         // Directory&single Visible Fields
         if (!empty($preset_fields)) {
             $fields = $preset_fields;
         } elseif (!empty($_POST['fields'])) {
             $fields = _gravityview_process_posted_fields();
         }
         $statii['directory_fields'] = update_post_meta($post_id, '_gravityview_directory_fields', $fields);
         // Directory Visible Widgets
         if (empty($_POST['widgets'])) {
             $_POST['widgets'] = array();
         }
         $statii['directory_widgets'] = update_post_meta($post_id, '_gravityview_directory_widgets', $_POST['widgets']);
     }
     // end save view configuration
     /**
      * @action `gravityview_view_saved` After a View has been saved in the admin
      * @param int $post_id ID of the View that has been saved
      * @param array $statii Array of statuses of the post meta saving processes. If saving worked, each key should be mapped to a value of the post ID (`directory_widgets` => `124`). If failed (or didn't change), the value will be false.
      * @since 1.17.2
      */
     do_action('gravityview_view_saved', $post_id, $statii);
     do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map('intval', $statii));
 }
Exemplo n.º 24
0
 /**
  * Calculate the search choices for the users
  *
  * @since 1.8
  *
  * @return array Array of user choices (value = ID, text = display name)
  */
 private static function get_created_by_choices()
 {
     /**
      * filter gravityview/get_users/search_widget
      * @see \GVCommon::get_users
      */
     $users = GVCommon::get_users('search_widget', array('fields' => array('ID', 'display_name')));
     $choices = array();
     foreach ($users as $user) {
         $choices[] = array('value' => $user->ID, 'text' => $user->display_name);
     }
     return $choices;
 }
Exemplo n.º 25
0
 /**
  * return href for single entry
  * @param  array|int $entry   Entry array or entry ID
  * @param  int|null $post_id If wanting to define the parent post, pass a post ID
  * @param boolean $add_directory_args True: Add args to help return to directory; False: only include args required to get to entry {@since 1.7.3}
  * @return string          Link to the entry with the directory parent slug
  */
 public static function entry_link($entry, $post_id = NULL, $add_directory_args = true)
 {
     if (!empty($entry) && !is_array($entry)) {
         $entry = GVCommon::get_entry($entry);
     } else {
         if (empty($entry)) {
             $entry = GravityView_frontend::getInstance()->getEntry();
         }
     }
     // Second parameter used to be passed as $field; this makes sure it's not an array
     if (!is_numeric($post_id)) {
         $post_id = NULL;
     }
     // Get the permalink to the View
     $directory_link = self::directory_link($post_id, false);
     // No post ID? Get outta here.
     if (empty($directory_link)) {
         return '';
     }
     $query_arg_name = GravityView_Post_Types::get_entry_var_name();
     $entry_slug = self::get_entry_slug($entry['id'], $entry);
     if (get_option('permalink_structure') && !is_preview()) {
         $args = array();
         $directory_link = trailingslashit($directory_link) . $query_arg_name . '/' . $entry_slug . '/';
     } else {
         $args = array($query_arg_name => $entry_slug);
     }
     /**
      * @since 1.7.3
      */
     if ($add_directory_args) {
         if (!empty($_GET['pagenum'])) {
             $args['pagenum'] = intval($_GET['pagenum']);
         }
         /**
          * @since 1.7
          */
         if ($sort = rgget('sort')) {
             $args['sort'] = $sort;
             $args['dir'] = rgget('dir');
         }
     }
     /**
      * Check if we have multiple views embedded in the same page and in that case make sure the single entry link
      * has the view id so that Advanced Filters can be applied correctly when rendering the single view
      * @see GravityView_frontend::get_context_view_id()
      */
     if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views()) {
         $args['gvid'] = gravityview_get_view_id();
     }
     return add_query_arg($args, $directory_link);
 }
Exemplo n.º 26
0
<?php

/**
 * Display Gravity Forms Quiz value letter grade
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$gravityview_view = GravityView_View::getInstance();
$field = $gravityview_view->getCurrentField();
// If there's no grade, don't continue
if (gv_empty($field['value'], false, false)) {
    return;
}
// Check if grading is enabled for the form. If not set, default to false.
$grading_type_enabled = !empty($field['form']['gravityformsquiz']['grading']) ? $field['form']['gravityformsquiz']['grading'] : 'none';
if ('letter' === $grading_type_enabled) {
    echo $field['value'];
} elseif (GVCommon::has_cap('gravityforms_edit_forms')) {
    $grade_type = __('Letter', 'gravityview');
    printf(esc_html_x('%s grading is disabled for this form. %sChange the setting%s', '%s is the current Quiz field type ("Letter" or "Pass/Fail")', 'gravityview'), $grade_type, '<a href="' . admin_url('admin.php?page=gf_edit_forms&amp;view=settings&amp;subview=gravityformsquiz&amp;id=' . $gravityview_view->getFormId()) . '">', '</a>');
}
    /**
     * @inheritDoc
     */
    public function form($instance)
    {
        // @todo Make compatible with Customizer
        if ($this->is_preview()) {
            $warning = sprintf(esc_html__('This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview'), '<a href="' . admin_url('widgets.php') . '">', '</a>');
            echo wpautop(GravityView_Admin::get_floaty() . $warning);
            return;
        }
        $defaults = array('title' => '', 'view_id' => 0, 'post_id' => '', 'search_fields' => '');
        $instance = wp_parse_args((array) $instance, $defaults);
        $title = $instance['title'];
        $view_id = $instance['view_id'];
        $post_id = $instance['post_id'];
        $search_fields = $instance['search_fields'];
        $views = GVCommon::get_all_views();
        // If there are no views set up yet, we get outta here.
        if (empty($views)) {
            ?>
			<div id="select_gravityview_view">
				<div class="wrap"><?php 
            echo GravityView_Post_Types::no_views_text();
            ?>
</div>
			</div>
			<?php 
            return;
        }
        ?>

		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'gravityview');
        ?>
 <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></label></p>

		<?php 
        /**
         * Display errors generated for invalid embed IDs
         * @see GravityView_View_Data::is_valid_embed_id
         */
        if (isset($instance['updated']) && empty($instance['view_id'])) {
            ?>
			<div class="error inline hide-on-view-change">
				<p><?php 
            esc_html_e('Please select a View to search.', 'gravityview');
            ?>
</p>
			</div>
			<?php 
            unset($error);
        }
        ?>

		<p>
			<label for="gravityview_view_id"><?php 
        _e('View:', 'gravityview');
        ?>
</label>
			<select id="gravityview_view_id" name="<?php 
        echo $this->get_field_name('view_id');
        ?>
" class="widefat">
				<option value=""><?php 
        esc_html_e('&mdash; Select a View &mdash;', 'gravityview');
        ?>
</option>
				<?php 
        foreach ($views as $view_option) {
            $title = empty($view_option->post_title) ? __('(no title)', 'gravityview') : $view_option->post_title;
            echo '<option value="' . $view_option->ID . '" ' . selected(esc_attr($view_id), $view_option->ID, false) . '>' . esc_html(sprintf('%s #%d', $title, $view_option->ID)) . '</option>';
        }
        ?>
			</select>

		</p>

		<?php 
        /**
         * Display errors generated for invalid embed IDs
         * @see GravityView_View_Data::is_valid_embed_id
         */
        if (!empty($instance['error_post_id'])) {
            ?>
			<div class="error inline">
				<p><?php 
            echo $instance['error_post_id'];
            ?>
</p>
			</div>
			<?php 
            unset($error);
        }
        ?>

		<p>
			<label for="<?php 
        echo $this->get_field_id('post_id');
        ?>
"><?php 
        esc_html_e('If Embedded, Page ID:', 'gravityview');
        ?>
</label>
			<input class="code" size="3" id="<?php 
        echo $this->get_field_id('post_id');
        ?>
" name="<?php 
        echo $this->get_field_name('post_id');
        ?>
" type="text" value="<?php 
        echo esc_attr($post_id);
        ?>
" />
			<span class="howto"><?php 
        esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview');
        echo ' ' . gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more&hellip;', 'gravityview'), 'target=_blank');
        ?>
</span>
		</p>

		<hr />

		<?php 
        // @todo: move style to CSS
        ?>
		<div style="margin-bottom: 1em;">
			<label class="screen-reader-text" for="<?php 
        echo $this->get_field_id('search_fields');
        ?>
"><?php 
        _e('Searchable fields:', 'gravityview');
        ?>
</label>
			<div class="gv-widget-search-fields" title="<?php 
        esc_html_e('Search Fields', 'gravityview');
        ?>
">
				<input id="<?php 
        echo $this->get_field_id('search_fields');
        ?>
" name="<?php 
        echo $this->get_field_name('search_fields');
        ?>
" type="hidden" value="<?php 
        echo esc_attr($search_fields);
        ?>
" class="gv-search-fields-value">
			</div>

		</div>

		<script>
			// When the widget is saved or added, refresh the Merge Tags (here for backward compatibility)
			// WordPress 3.9 added widget-added and widget-updated actions
			jQuery('#<?php 
        echo $this->get_field_id('view_id');
        ?>
').trigger( 'change' );
		</script>
	<?php 
    }
Exemplo n.º 28
0
 /**
  * Register styles and scripts
  *
  * @access public
  * @return void
  */
 public function add_scripts_and_styles()
 {
     global $post, $posts;
     // enqueue template specific styles
     if ($this->getGvOutputData()) {
         $views = $this->getGvOutputData()->get_views();
         foreach ($views as $view_id => $data) {
             /**
              * Don't enqueue the scripts or styles if it's not going to be displayed.
              * @since 1.15
              */
             if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) {
                 continue;
             }
             // By default, no thickbox
             $js_dependencies = array('jquery', 'gravityview-jquery-cookie');
             $css_dependencies = array();
             // If the thickbox is enqueued, add dependencies
             if (!empty($data['atts']['lightbox'])) {
                 /**
                  * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox`
                  * @param string $script_slug If you want to use a different lightbox script, return the name of it here.
                  */
                 $js_dependencies[] = apply_filters('gravity_view_lightbox_script', 'thickbox');
                 /**
                  * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox`
                  * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here.
                  */
                 $css_dependencies[] = apply_filters('gravity_view_lightbox_style', 'thickbox');
             }
             /**
              * If the form has checkbox fields, enqueue dashicons
              * @see https://github.com/katzwebservices/GravityView/issues/536
              * @since 1.15
              */
             if (gravityview_view_has_single_checkbox_or_radio($data['form'], $data['fields'])) {
                 $css_dependencies[] = 'dashicons';
             }
             wp_register_script('gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version, true);
             $script_debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
             wp_register_script('gravityview-fe-view', plugins_url('assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE), apply_filters('gravityview_js_dependencies', $js_dependencies), GravityView_Plugin::version, true);
             wp_enqueue_script('gravityview-fe-view');
             if (!empty($data['atts']['sort_columns'])) {
                 wp_enqueue_style('gravityview_font', plugins_url('assets/css/font.css', GRAVITYVIEW_FILE), $css_dependencies, GravityView_Plugin::version, 'all');
             }
             wp_enqueue_style('gravityview_default_style', plugins_url('templates/css/gv-default-styles.css', GRAVITYVIEW_FILE), $css_dependencies, GravityView_Plugin::version, 'all');
             self::add_style($data['template_id']);
         }
         if ('wp_print_footer_scripts' === current_filter()) {
             $js_localization = array('cookiepath' => COOKIEPATH, 'clear' => _x('Clear', 'Clear all data from the form', 'gravityview'), 'reset' => _x('Reset', 'Reset the search form to the state that existed on page load', 'gravityview'));
             /**
              * @filter `gravityview_js_localization` Modify the array passed to wp_localize_script()
              * @param array $js_localization The data padded to the Javascript file
              * @param array $views Array of View data arrays with View settings
              */
             $js_localization = apply_filters('gravityview_js_localization', $js_localization, $views);
             wp_localize_script('gravityview-fe-view', 'gvGlobals', $js_localization);
         }
     }
 }
 /**
  * Outputs the admin notices generated by the plugin
  *
  * @uses GVCommon::has_cap()
  * @since 1.12
  *
  * @return void
  */
 public function admin_notice()
 {
     /**
      * @filter `gravityview/admin/notices` Modify the notices displayed in the admin
      * @since 1.12
      */
     $notices = apply_filters('gravityview/admin/notices', self::$admin_notices);
     if (empty($notices) || !$this->check_show_multisite_notices()) {
         return;
     }
     //don't display a message if use has dismissed the message for this version
     // TODO: Use get_user_meta instead of get_transient
     self::$dismissed_notices = isset($_GET['show-dismissed-notices']) ? array() : (array) get_transient('gravityview_dismissed_notices');
     $output = '';
     foreach ($notices as $notice) {
         // If the user doesn't have the capability to see the warning
         if (isset($notice['cap']) && false === GVCommon::has_cap($notice['cap'])) {
             do_action('gravityview_log_debug', 'Notice not shown because user does not have the capability to view it.', $notice);
             continue;
         }
         if (true === $this->is_notice_dismissed($notice)) {
             do_action('gravityview_log_debug', 'Notice not shown because the notice has already been dismissed.', $notice);
             continue;
         }
         $output .= '<div id="message" style="position:relative" class="notice ' . gravityview_sanitize_html_class($notice['class']) . '">';
         // Too cute to leave out.
         $output .= gravityview_get_floaty();
         if (!empty($notice['title'])) {
             $output .= '<h3>' . esc_html($notice['title']) . '</h3>';
         }
         $message = isset($notice['message']) ? $notice['message'] : '';
         if (!empty($notice['dismiss'])) {
             $dismiss = esc_attr($notice['dismiss']);
             $url = esc_url(add_query_arg(array('gv-dismiss' => wp_create_nonce('dismiss'), 'notice' => $dismiss)));
             $align = is_rtl() ? 'alignleft' : 'alignright';
             $message .= '<a href="' . $url . '" data-notice="' . $dismiss . '" class="' . $align . ' button button-link">' . esc_html__('Dismiss', 'gravityview') . '</a></p>';
         }
         $output .= wpautop($message);
         $output .= '<div class="clear"></div>';
         $output .= '</div>';
     }
     echo $output;
     unset($output, $align, $message, $notices);
     //reset the notices handler
     self::$admin_notices = array();
 }
 /**
  * Add Edit View link when in embedded View
  *
  * @since 1.13
  * @return void
  */
 function add_edit_view_and_form_link()
 {
     /** @var WP_Admin_Bar $wp_admin_bar */
     global $wp_admin_bar;
     if (GVCommon::has_cap(array('edit_gravityviews', 'edit_gravityview', 'gravityforms_edit_forms'))) {
         $view_data = GravityView_View_Data::getInstance();
         $views = $view_data->get_views();
         // If there is a View embed, show Edit View link.
         if (!empty($views)) {
             $added_forms = array();
             $added_views = array();
             foreach ($views as $view) {
                 $edit_view_title = __('Edit View', 'gravityview');
                 $edit_form_title = __('Edit Form', 'gravityview');
                 if (sizeof($views) > 1) {
                     $edit_view_title = sprintf(_x('Edit View #%d', 'Edit View with the ID of %d', 'gravityview'), $view['id']);
                     $edit_form_title = sprintf(__('Edit Form #%d', 'Edit Form with the ID of %d', 'gravityview'), $view['form_id']);
                 }
                 if (GVCommon::has_cap('edit_gravityview', $view['id']) && !in_array($view['id'], $added_views)) {
                     $added_views[] = $view['id'];
                     $wp_admin_bar->add_menu(array('id' => 'edit-view-' . $view['id'], 'parent' => 'gravityview', 'title' => $edit_view_title, 'href' => esc_url_raw(admin_url(sprintf('post.php?post=%d&action=edit', $view['id'])))));
                 }
                 if (!empty($view['form_id']) && GVCommon::has_cap(array('gravityforms_edit_forms'), $view['form_id']) && !in_array($view['form_id'], $added_forms)) {
                     $added_forms[] = $view['form_id'];
                     $wp_admin_bar->add_menu(array('id' => 'edit-form-' . $view['form_id'], 'parent' => 'gravityview', 'title' => $edit_form_title, 'href' => esc_url_raw(admin_url(sprintf('admin.php?page=gf_edit_forms&id=%d', $view['form_id'])))));
                 }
             }
         }
     }
 }