示例#1
0
    return;
}
// Default: plain email, no link
$output = $value;
if (!isset($field_settings['emailmailto']) || !empty($field_settings['emailmailto'])) {
    $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);
 /**
  * Get the Add Note form HTML
  *
  * @todo Allow passing entry_id as a shortcode parameter to set entry from shortcode
  *
  * @since 1.17
  *
  * @return string HTML of the Add Note form, or empty string if the user doesn't have the `gravityview_add_entry_notes` cap
  */
 public static function get_add_note_part()
 {
     if (!GVCommon::has_cap('gravityview_add_entry_notes')) {
         do_action('gravityview_log_error', __METHOD__ . ': User does not have permission to add entry notes ("gravityview_add_entry_notes").');
         return '';
     }
     $gravityview_view = GravityView_View::getInstance();
     ob_start();
     $gravityview_view->get_template_part('note', 'add-note');
     $add_note_html = ob_get_clean();
     $visibility_settings = $gravityview_view->getCurrentFieldSetting('notes');
     $entry = $gravityview_view->getCurrentEntry();
     $entry_slug = GravityView_API::get_entry_slug($entry['id'], $entry);
     $nonce_field = wp_nonce_field('gv_note_add_' . $entry_slug, 'gv_note_add', false, false);
     // Only generate the dropdown if the field settings allow it
     $email_fields = '';
     if (!empty($visibility_settings['email'])) {
         $email_fields = self::get_note_email_fields($entry_slug);
     }
     $add_note_html = str_replace('{entry_slug}', $entry_slug, $add_note_html);
     $add_note_html = str_replace('{nonce_field}', $nonce_field, $add_note_html);
     $add_note_html = str_replace('{show_delete}', intval($visibility_settings['delete']), $add_note_html);
     $add_note_html = str_replace('{email_fields}', $email_fields, $add_note_html);
     return $add_note_html;
 }
 /**
  * @covers ::gv_directory_link()
  * @covers GravityView_API::directory_link()
  */
 public function test_directory_link()
 {
     $post_array = array('post_content' => 'asdasdsd', 'post_type' => 'post', 'post_status' => 'publish');
     $post_id = wp_insert_post($post_array);
     $view_post_type_id = $this->_get_new_view_id();
     $_GET['pagenum'] = 2;
     $add_pagination = false;
     $this->assertEquals(site_url('?p=' . $post_id), GravityView_API::directory_link($post_id, $add_pagination));
     $add_pagination = true;
     $this->assertEquals(site_url('?p=' . $post_id . '&pagenum=2'), GravityView_API::directory_link($post_id, $add_pagination));
     // Make sure the cache is working properly
     $this->assertEquals(site_url('?p=' . $post_id), wp_cache_get('gv_directory_link_' . $post_id));
     //
     // Use $gravityview_view data
     //
     global $gravityview_view;
     global $post;
     $post = get_post($view_post_type_id);
     GravityView_frontend::getInstance()->parse_content();
     $gravityview_view->setViewId($view_post_type_id);
     // Test post_id has been set
     $gravityview_view->setPostId($post_id);
     /* TODO - fix this assertion */
     $this->assertEquals(site_url('?p=' . $post_id . '&pagenum=2'), GravityView_API::directory_link());
     $gravityview_view->setPostId($post_id);
     //
     // TESTING AJAX
     //
     define('DOING_AJAX', true);
     // No passed post_id; use $_POST when DOING_AJAX is set
     $this->assertNull(GravityView_API::directory_link());
     $_POST['post_id'] = $post_id;
     // No passed post_id; use $_POST when DOING_AJAX is set
     $this->assertEquals(site_url('?p=' . $post_id . '&pagenum=2'), GravityView_API::directory_link());
 }
 /**
  * Get the output for a specific entry
  *
  * @param array $entry GF Entry array
  *
  * @since 1.7.2
  *
  * @uses gravityview_get_link
  * @uses GravityView_API::entry_link
  * @uses GravityView_API::replace_variables
  *
  * @return string HTML output for the entry
  */
 private function get_item_output($entry)
 {
     $link = GravityView_API::entry_link($entry, $this->post_id);
     $item_output = gravityview_get_link($link, $this->link_format);
     if (!empty($this->after_link)) {
         /**
          * Modify the item output HTML
          *
          * @since 1.7.2
          *
          * @param string $item_output The HTML output for the after_link content
          * @param array $entry Gravity Forms entry array
          * @param GravityView_Entry_List $this The current class instance
          */
         $after_link = apply_filters('gravityview/entry-list/after-link', '<div>' . $this->after_link . '</div>', $entry, $this);
         $item_output .= $after_link;
     }
     $item_output = GravityView_API::replace_variables($item_output, $this->form, $entry);
     $item_output = '<' . $this->item_tag . '>' . $item_output . '</' . $this->item_tag . '>';
     /**
      * Modify the item output HTML
      *
      * @since 1.7.2
      *
      * @param string $item_output The HTML output for the item
      * @param array $entry Gravity Forms entry array
      * @param GravityView_Entry_List $this The current class instance
      */
     $item_output = apply_filters('gravityview/entry-list/item', $item_output, $entry, $this);
     return $item_output;
 }
示例#5
0
<?php

/**
 * Display the HTML field type
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
// Tell the renderer not to wrap this field in an anchor tag.
$gravityview_view->setCurrentFieldSetting('show_as_link', false);
echo GravityView_API::replace_variables($field['content'], $form, $entry);
示例#6
0
/**
 * Output field based on a certain html markup
 *
 *   markup - string to be used on a sprintf statement.
 *      Use:
 *         {{label}} - field label
 *         {{value}} - entry field value
 *         {{class}} - field class
 *
 *   wpautop - true will filter the value using wpautop function
 *
 * @since  1.1.5
 * @param  array $passed_args Associative array with field data. `field` and `form` are required.
 * @return string Field output. If empty value and hide empty is true, return empty.
 */
function gravityview_field_output($passed_args)
{
    $defaults = array('entry' => null, 'field' => null, 'form' => null, 'hide_empty' => true, 'markup' => '<div id="{{ field_id }}" class="{{ class }}">{{label}}{{value}}</div>', 'label_markup' => '', 'wpautop' => false, 'zone_id' => null);
    $args = wp_parse_args($passed_args, $defaults);
    /**
     * @filter `gravityview/field_output/args` Modify the args before generation begins
     * @since 1.7
     * @param array $args Associative array; `field` and `form` is required.
     * @param array $passed_args Original associative array with field data. `field` and `form` are required.
     */
    $args = apply_filters('gravityview/field_output/args', $args, $passed_args);
    // Required fields.
    if (empty($args['field']) || empty($args['form'])) {
        do_action('gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args);
        return '';
    }
    $entry = empty($args['entry']) ? array() : $args['entry'];
    /**
     * Create the Context for replacing.
     * @since 1.11
     */
    $context = array();
    $context['value'] = gv_value($entry, $args['field']);
    // If the value is empty and we're hiding empty, return empty.
    if ($context['value'] === '' && !empty($args['hide_empty'])) {
        return '';
    }
    if ($context['value'] !== '' && !empty($args['wpautop'])) {
        $context['value'] = wpautop($context['value']);
    }
    // Get width setting, if exists
    $context['width'] = GravityView_API::field_width($args['field']);
    // If replacing with CSS inline formatting, let's do it.
    $context['width:style'] = GravityView_API::field_width($args['field'], 'width:' . $context['width'] . '%;');
    // Grab the Class using `gv_class`
    $context['class'] = gv_class($args['field'], $args['form'], $entry);
    $context['field_id'] = GravityView_API::field_html_attr_id($args['field'], $args['form'], $entry);
    // Get field label if needed
    if (!empty($args['label_markup'])) {
        $context['label'] = str_replace(array('{{label}}', '{{ label }}'), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup']);
    }
    if (empty($context['label'])) {
        $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>';
    }
    // Default Label value
    $context['label_value'] = gv_label($args['field'], $entry);
    /**
     * @filter `gravityview/field_output/pre_html` Allow Pre filtering of the HTML
     * @since 1.11
     * @param string $markup The HTML for the markup
     * @param array $args All args for the field output
     */
    $html = apply_filters('gravityview/field_output/pre_html', $args['markup'], $args);
    /**
     * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders
     * @since 1.11
     * @param string $open_tag Open tag for template content placeholders. Default: `{{`
     */
    $open_tag = apply_filters('gravityview/field_output/open_tag', '{{', $args);
    /**
     * @filter `gravityview/field_output/close_tag` Modify the closing tags for the template content placeholders
     * @since 1.11
     * @param string $close_tag Close tag for template content placeholders. Default: `}}`
     */
    $close_tag = apply_filters('gravityview/field_output/close_tag', '}}', $args);
    /**
     * Loop through each of the tags to replace and replace both `{{tag}}` and `{{ tag }}` with the values
     * @since 1.11
     */
    foreach ($context as $tag => $value) {
        // If the tag doesn't exist just skip it
        if (false === strpos($html, $open_tag . $tag . $close_tag) && false === strpos($html, $open_tag . ' ' . $tag . ' ' . $close_tag)) {
            continue;
        }
        // Array to search
        $search = array($open_tag . $tag . $close_tag, $open_tag . ' ' . $tag . ' ' . $close_tag);
        /**
         * `gravityview/field_output/context/{$tag}` Allow users to filter content on context
         * @since 1.11
         * @param string $value The content to be shown instead of the {{tag}} placeholder
         * @param array $args Arguments passed to the function
         */
        $value = apply_filters('gravityview/field_output/context/' . $tag, $value, $args);
        // Finally do the replace
        $html = str_replace($search, $value, $html);
    }
    /**
     * @todo  Depricate `gravityview_field_output`
     */
    $html = apply_filters('gravityview_field_output', $html, $args);
    /**
     * @filter `gravityview/field_output/html` Modify field HTML output
     * @param string $html Existing HTML output
     * @param array $args Arguments passed to the function
     */
    $html = apply_filters('gravityview/field_output/html', $html, $args);
    // Just free up a tiny amount of memory
    unset($value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag);
    return $html;
}
示例#7
0
 /**
  * @return string
  */
 public function getBackLinkLabel()
 {
     $back_link_label = GravityView_API::replace_variables($this->back_link_label, $this->getForm(), $this->getCurrentEntry());
     $back_link_label = do_shortcode($back_link_label);
     return $back_link_label;
 }
示例#8
0
<?php

/**
 * Display the website field type
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
if (!empty($value) && function_exists('gravityview_format_link')) {
    /** @since 1.8 */
    $anchor_text = !empty($field_settings['anchor_text']) ? trim(rtrim($field_settings['anchor_text'])) : false;
    // Check empty again, just in case trim removed whitespace didn't work
    if (!empty($anchor_text)) {
        // Replace the variables
        $anchor_text = GravityView_API::replace_variables($anchor_text, $form, $entry);
    } else {
        $anchor_text = empty($field_settings['truncatelink']) ? $value : gravityview_format_link($value);
    }
    $attributes = empty($field_settings['open_same_window']) ? 'target=_blank' : '';
    echo gravityview_get_link($value, $anchor_text, $attributes);
} else {
    echo $display_value;
}
示例#9
0
}
// Tell the renderer not to wrap this field in an anchor tag.
$gravityview_view->setCurrentFieldSetting('show_as_link', false);
/**
 * @filter `gravityview/fields/custom/content_before` Modify Custom Content field output before Merge Tag processing
 * @since 1.6.2
 * @param string $content HTML content of field
 */
$field_settings['content'] = apply_filters('gravityview/fields/custom/content_before', $field_settings['content']);
$field_settings['content'] = trim(rtrim($field_settings['content']));
// No custom content
if (empty($field_settings['content'])) {
    return;
}
// Replace the variables
$content = GravityView_API::replace_variables($field_settings['content'], $form, $entry);
/**
 * @filter `gravityview/fields/custom/decode_shortcodes` Decode brackets in shortcodes
 * @since 1.16.5
 * @param boolean $decode Enable/Disable decoding of brackets in the content (default: false)
 * @param string $content HTML content of field
 */
if (apply_filters('gravityview/fields/custom/decode_shortcodes', false, $content)) {
    $content = GVCommon::decode_shortcodes($content);
}
// Add paragraphs?
if (!empty($field_settings['wpautop'])) {
    $content = wpautop($content);
}
/**
 * @filter `gravityview/fields/custom/content_after` Modify Custom Content field output after Merge Tag variables get replaced, before shortcodes get processed
示例#10
0
<?php

/**
 * Display the Section field type
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
// Tell the renderer not to wrap this field in an anchor tag.
$gravityview_view->setCurrentFieldSetting('show_as_link', false);
if (!empty($field['description'])) {
    echo GravityView_API::replace_variables($field['description'], $form, $entry);
}
 /**
  * Get the URL for the entry.
  *
  * Uses the `post_id`, `view_id` params as defined in the shortcode attributes.
  *
  * @since 1.15
  *
  * @param string|null $content Content inside shortcode, if defined
  *
  * @return string|boolean If URL is fetched, the URL to the entry link. If not found, returns false.
  */
 private function get_url()
 {
     // if post_id is not defined, default to view_id
     $post_id = empty($this->settings['post_id']) ? $this->view_id : absint($this->settings['post_id']);
     switch ($this->settings['action']) {
         case 'edit':
             $url = GravityView_Edit_Entry::get_edit_link($this->entry, $this->view_id, $post_id);
             break;
         case 'delete':
             $url = GravityView_Delete_Entry::get_delete_link($this->entry, $this->view_id, $post_id);
             break;
         case 'read':
         default:
             $url = GravityView_API::entry_link($this->entry, $post_id);
     }
     $url = $this->maybe_add_field_values_query_args($url);
     return $url;
 }
 /**
  * Get the array of entry data
  *
  * @since 1.3
  *
  * @param array $view_entries Array of entries for the current search
  * @param array $view_data Data information returned from GravityView_View_Data::get_view()
  *
  * @return array
  */
 function get_output_data($view_entries, $view_data)
 {
     // build output data
     $data = array();
     if ($view_entries['count'] !== 0) {
         // For each entry
         foreach ($view_entries['entries'] as $entry) {
             $temp = array();
             // Loop through each column and set the value of the column to the field value
             if (!empty($view_data['fields']['directory_table-columns'])) {
                 foreach ($view_data['fields']['directory_table-columns'] as $field_settings) {
                     $temp[] = GravityView_API::field_value($entry, $field_settings);
                 }
             }
             // Then add the item to the output dataset
             $data[] = $temp;
         }
     }
     return $data;
 }
示例#13
0
<?php

$gravityview_view = GravityView_View::getInstance();
$view_id = $gravityview_view->getViewId();
extract($gravityview_view->getCurrentField());
// Only show the link to logged-in users with the rigth caps.
if (!GravityView_Delete_Entry::check_user_cap_delete_entry($entry, $field_settings)) {
    return;
}
$link_text = empty($field_settings['delete_link']) ? __('Delete Entry', 'gravityview') : $field_settings['delete_link'];
$link_text = apply_filters('gravityview_entry_link', GravityView_API::replace_variables($link_text, $form, $entry));
$href = GravityView_Delete_Entry::get_delete_link($entry, $view_id);
$attributes = array('onclick' => GravityView_Delete_Entry::get_confirm_dialog());
echo gravityview_get_link($href, $link_text, $attributes);
示例#14
0
 /**
  * Filter the title for the single entry view
  *
  * @param  string $title   current title
  * @param  int $passed_post_id Post ID
  * @return string          (modified) title
  */
 public function single_entry_title($title, $passed_post_id = null)
 {
     global $post;
     // If this is the directory view, return.
     if (!$this->getSingleEntry()) {
         return $title;
     }
     $entry = $this->getEntry();
     /**
      * @filter `gravityview/single/title/out_loop` Apply the Single Entry Title filter outside the WordPress loop?
      * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop
      * @param array $entry Current entry
      */
     $apply_outside_loop = apply_filters('gravityview/single/title/out_loop', in_the_loop(), $entry);
     if (!$apply_outside_loop) {
         return $title;
     }
     // User reported WooCommerce doesn't pass two args.
     if (empty($passed_post_id)) {
         return $title;
     }
     // Don't modify the title for anything other than the current view/post.
     // This is true for embedded shortcodes and Views.
     if (is_object($post) && (int) $post->ID !== (int) $passed_post_id) {
         return $title;
     }
     $context_view_id = $this->get_context_view_id();
     if ($this->getGvOutputData()->has_multiple_views() && !empty($context_view_id)) {
         $view_meta = $this->getGvOutputData()->get_view($context_view_id);
     } else {
         foreach ($this->getGvOutputData()->get_views() as $view_id => $view_data) {
             if (intval($view_data['form_id']) === intval($entry['form_id'])) {
                 $view_meta = $view_data;
                 break;
             }
         }
     }
     if (!empty($view_meta['atts']['single_title'])) {
         $title = $view_meta['atts']['single_title'];
         // We are allowing HTML in the fields, so no escaping the output
         $title = GravityView_API::replace_variables($title, $view_meta['form'], $entry);
         $title = do_shortcode($title);
     }
     return $title;
 }
示例#15
0
 /**
  * For some specific field types prepare the filter value before adding it to search criteria
  * @param  array  $filter
  * @return array
  */
 static function parse_advanced_filters($filter = array(), $view_id = NULL)
 {
     if (empty($filter['key']) || !function_exists('gravityview_get_field_type') || !class_exists('GFCommon') || !class_exists('GravityView_API')) {
         return $filter;
     }
     if (!empty($view_id)) {
         $form_id = gravityview_get_form_id($view_id);
         $form = gravityview_get_form($form_id);
     } else {
         global $gravityview_view;
         $form = $gravityview_view->form;
     }
     // replace merge tags
     $filter['value'] = GravityView_API::replace_variables($filter['value'], $form, array());
     $field_type = gravityview_get_field_type($form, $filter['key']);
     switch ($field_type) {
         case 'date':
             $local_timestamp = GFCommon::get_local_timestamp();
             $date = strtotime($filter['value'], $local_timestamp);
             if ($date) {
                 $filter['value'] = date('Y-m-d', $date);
             } else {
                 do_action('gravityview_log_error', __METHOD__ . ' - Date formatting passed to Advanced Filter is invalid', $filter['value']);
             }
             break;
     }
     return $filter;
 }
 /**
  * Add Edit Entry links when on a single entry
  *
  * @since 1.13
  * @return void
  */
 function add_edit_entry_link()
 {
     /** @var WP_Admin_Bar $wp_admin_bar */
     global $wp_admin_bar;
     $entry_id = $this->gravityview_view->getSingleEntry();
     if ($entry_id && GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_entries'), $entry_id)) {
         $entry = $this->gravityview_view->getEntry();
         $wp_admin_bar->add_menu(array('id' => 'edit-entry', 'parent' => 'gravityview', 'title' => __('Edit Entry', 'gravityview'), 'meta' => array('title' => sprintf(__('Edit Entry %s', 'gravityview'), GravityView_API::get_entry_slug($entry['id'], $entry))), 'href' => esc_url_raw(admin_url(sprintf('admin.php?page=gf_entries&amp;screen_mode=edit&amp;view=entry&amp;id=%d&lid=%d', $entry['form_id'], $entry['id'])))));
     }
 }
示例#17
0
 * @subpackage GravityView/templates
 *
 * @global GravityView_View $this
 */
gravityview_before();
?>

<div class="gv-container gv-list-single-container gv-list-container">
	<p class="gv-back-link"><?php 
echo gravityview_back_link();
?>
</p>
	<?php 
foreach ($this->getEntries() as $entry) {
    $this->setCurrentEntry($entry);
    $entry_slug = GravityView_API::get_entry_slug($entry['id'], $entry);
    ?>

		<div id="gv_list_<?php 
    echo esc_attr($entry_slug);
    ?>
" class="gv-list-view">
	<?php 
    if ($this->getFields('single_list-title') || $this->getFields('single_list-subtitle')) {
        ?>
		<div class="gv-list-view-title">
		<?php 
        if ($fields = $this->getFields('single_list-title')) {
            $i = 0;
            $title_args = array('entry' => $entry, 'form' => $this->form, 'hide_empty' => $this->atts['hide_empty']);
            foreach ($fields as $field) {
示例#18
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;
 }
示例#19
0
/**
 * Output field based on a certain html markup
 *
 *   markup - string to be used on a sprintf statement.
 *      Use:
 *         {{label}} - field label
 *         {{value}} - entry field value
 *         {{class}} - field class
 *
 *   wpautop - true will filter the value using wpautop function
 *
 * @since  1.1.5
 * @param  array $passed_args Associative array with field data. `field` and `form` are required.
 * @return string
 */
function gravityview_field_output($passed_args)
{
    $defaults = array('entry' => NULL, 'field' => NULL, 'form' => NULL, 'hide_empty' => true, 'markup' => '<div class="{{class}}">{{label}}{{value}}</div>', 'label_markup' => '', 'wpautop' => false, 'zone_id' => NULL);
    $args = wp_parse_args($passed_args, $defaults);
    /**
     * Modify the args before generation begins
     *
     * @since 1.7
     *
     * @param array $args Associative array; `field` and `form` is required.
     * @param array $passed_args Original associative array with field data. `field` and `form` are required.
     *
     */
    $args = apply_filters('gravityview/field_output/args', $args, $passed_args);
    // Required fields.
    if (empty($args['field']) || empty($args['form'])) {
        do_action('gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args);
        return '';
    }
    $entry = empty($args['entry']) ? array() : $args['entry'];
    $value = gv_value($entry, $args['field']);
    // If the value is empty and we're hiding empty, return empty.
    if ($value === '' && !empty($args['hide_empty'])) {
        return '';
    }
    if ($value !== '' && !empty($args['wpautop'])) {
        $value = wpautop($value);
    }
    // Get width setting, if exists
    $width = GravityView_API::field_width($args['field']);
    //If replacing with CSS inline formatting, let's do it.
    $width_style = GravityView_API::field_width($args['field'], 'width:' . $width . '%%;');
    $class = gv_class($args['field'], $args['form'], $entry);
    // get field label if needed
    if (!empty($args['label_markup']) || false !== strpos($args['markup'], '{{label}}')) {
        $label = gv_label($args['field'], $entry);
    } else {
        $label = '';
    }
    if (!empty($label)) {
        // If the label markup is overridden
        if (!empty($args['label_markup'])) {
            $label = str_replace('{{label}}', '<span class="gv-field-label">' . $label . '</span>', $args['label_markup']);
        } else {
            $args['markup'] = str_replace('{{label}}', '<span class="gv-field-label">{{label}}</span>', $args['markup']);
        }
    }
    $html = $args['markup'];
    $html = str_replace('{{width}}', $width, $html);
    $html = str_replace('{{width:style}}', $width_style, $html);
    $html = str_replace('{{class}}', $class, $html);
    $html = str_replace('{{label}}', $label, $html);
    $html = str_replace('{{value}}', $value, $html);
    /**
     * Modify the output
     * @param string $html Existing HTML output
     * @param array $args Arguments passed to the function
     */
    $html = apply_filters('gravityview_field_output', $html, $args);
    unset($value, $label, $class, $width, $width_style, $args, $passed_args, $entry);
    return $html;
}
示例#20
0
<?php

/**
 * Generate output for the Source URL field
 * @package GravityView
 * @subpackage GravityView/templates/fields
 * @since 1.1.6
 */
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
// If linking to the source URL
if (!empty($field_settings['link_to_source'])) {
    // If customizing the anchor text
    if (!empty($field_settings['source_link_text'])) {
        $link_text = GravityView_API::replace_variables($field_settings['source_link_text'], $form, $entry);
    } else {
        // Otherwise, it's just the URL
        $link_text = esc_html($value);
    }
    $output = gravityview_get_link($value, $link_text);
} else {
    // Otherwise, it's just the URL
    $output = $value;
}
echo $output;
示例#21
0
 /**
  * Generate a nonce link with the base URL of the current View embed
  *
  * We don't want to link to the single entry, because when deleted, there would be nothing to return to.
  *
  * @since 1.5.1
  * @param  array      $entry Gravity Forms entry array
  * @return string|null             If directory link is valid, the URL to process the delete request. Otherwise, `NULL`.
  */
 public static function get_delete_link($entry, $view_id = 0, $post_id = null)
 {
     self::getInstance()->set_entry($entry);
     $base = GravityView_API::directory_link($post_id, true);
     if (empty($base)) {
         do_action('gravityview_log_error', __METHOD__ . ' - Post ID does not exist: ' . $post_id);
         return NULL;
     }
     // Use the slug instead of the ID for consistent security
     $entry_slug = GravityView_API::get_entry_slug($entry['id'], $entry);
     $view_id = empty($view_id) ? gravityview_get_view_id() : $view_id;
     $actionurl = add_query_arg(array('action' => 'delete', 'entry_id' => $entry_slug, 'gvid' => $view_id, 'view_id' => $view_id), $base);
     $url = wp_nonce_url($actionurl, 'delete_' . $entry_slug, 'delete');
     return $url;
 }
示例#22
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);
示例#23
0
<?php

/**
 * Display the textarea field type
 *
 * Use wpautop() to format paragraphs, as expected, instead of line breaks like Gravity Forms displays by default.
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
if (!empty($field_settings['trim_words'])) {
    /**
     * @filter `gravityview_excerpt_more` Modify the "Read more" link used when "Maximum Words" setting is enabled and the output is truncated
     * @since 1.16.1
     * @param string $excerpt_more Default: ` ...`
     */
    $excerpt_more = apply_filters('gravityview_excerpt_more', ' ' . '&hellip;');
    $entry_link = GravityView_API::entry_link_html($entry, $excerpt_more, array(), $field_settings);
    $value = wp_trim_words($value, $field_settings['trim_words'], $entry_link);
    unset($entry_link, $excerpt_more);
}
if (!empty($field_settings['make_clickable'])) {
    $value = make_clickable($value);
}
if (!empty($field_settings['new_window'])) {
    $value = links_add_target($value);
}
echo wpautop($value);