Skip to content

Commit

Permalink
Merge pull request #638 from gravityview/develop
Browse files Browse the repository at this point in the history
Version 1.16.2
  • Loading branch information
zackkatz committed Feb 15, 2016
2 parents 9cf7be0 + 2f7cb53 commit 029c15d
Show file tree
Hide file tree
Showing 102 changed files with 9,802 additions and 8,593 deletions.
3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/css/admin-views.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/css/scss/admin-merge-tags.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ul#gf_merge_tag_list {
padding: 0;
max-height: 200px;
min-width: 200px;
max-width: 500px;
overflow: auto;
position: absolute;
background-color: #F8F8F8;
Expand Down
6 changes: 3 additions & 3 deletions gravityview.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin Name: GravityView
* Plugin URI: http://gravityview.co
* Description: Create directories based on a Gravity Forms form, insert them using a shortcode, and modify how they output.
* Version: 1.16.1
* Version: 1.16.2
* Author: Katz Web Services, Inc.
* Author URI: http://www.katzwebservices.com
* Text Domain: gravityview
Expand Down Expand Up @@ -89,7 +89,7 @@
*/
final class GravityView_Plugin {

const version = '1.16.1';
const version = '1.16.2';

private static $instance;

Expand Down Expand Up @@ -171,7 +171,7 @@ public function include_files() {
include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-logging.php' );

include_once( GRAVITYVIEW_DIR . 'includes/class-ajax.php' );
include_once( GRAVITYVIEW_DIR . 'includes/class-settings.php');
include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-settings.php' );
include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' );
include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' );
include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' );
Expand Down
55 changes: 55 additions & 0 deletions includes/class-admin-welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,61 @@ public function changelog_screen() {
<h2 style="border-bottom: 1px solid #ccc; padding-bottom: 1em; margin-bottom: 0;">What&rsquo;s New</h2>
</div>

<h3>1.16.2 on February 15</h3>

<ul>
<li>Added: Support for Post Image field on the Edit Entry screen</li>
<li>Added: Now use any Merge Tags as <code>[gravityview]</code> parameters</li>
<li>Fixed: Support for User Registration Addon Version 3</li>
<li>Fixed: Support for rich text editor for Post Body fields</li>
<li>Fixed: Admin-only fields may get overwritten when fields aren't visible during entry edit by user (non-admin)</li>
<li>Fixed: Address fields displayed hidden inputs</li>
<li>Fixed: Merge Tag dropdown list can be too wide when field names are long</li>
<li>Fixed: When sorting, recent entries disappeared from results</li>
<li>Fixed: Searches that included apostrophes
 or ampersands returned no results</li>
<li>Fixed: Zero values not set in fields while in Edit Entry</li>
<li>Fixed: Re-calculate fields where calculation is enabled after entry is updated</li>
<li>Fixed: Warning message when Number fields not included in custom Edit Entry configurations</li>
</ul>


<p><strong>Developer Notes:</strong></p>

<ul>
<li>Reminder: <strong>GravityView will soon require PHP 5.3</strong></li>
<li>Added: <code>gravityview/widgets/container_css_class</code> filter to modify widget container <code>&lt;div&gt;</code> CSS class

<ul>
<li>Added <code>gv-widgets-{zone}</code> class to wrapper (<code>{zone}</code> will be either <code>header</code> or <code>footer</code>)</li>
</ul>
</li>
<li>Fixed: Conflict with some plugins when <code>?action=delete</code> is processed in the Admin (<a href="https://github.com/gravityview/GravityView/issues/624">#624</a>, reported by <a href="https://github.com/dcavins">dcavins</a>)</li>
<li>Fixed: Removed <code>icon</code> CSS class name from the table sorting icon links. Now just <code>gv-icon</code> instead of <code>icon gv-icon</code>.</li>
<li>Fixed: "Clear" search link now set to <code>display: inline-block</code> instead of <code>display: block</code></li>
<li>Added: <code>gravityview/common/get_entry/check_entry_display</code> filter to disable validating whether to show entries or not against View filters</li>
<li>Fixed: <code>GravityView_API::replace_variables</code> no longer requires <code>$form</code> and <code>$entry</code> arguments</li>
</ul>

<h3>1.16.1 on January 21</h3>

<ul>
<li>Fixed: GravityView prevented Gravity Forms translations from loading</li>
<li>Fixed: Field Width setting was visible in Edit Entry</li>
<li>Fixed: Don't display embedded Gravity Forms forms when editing an entry in GravityView</li>
</ul>


<p><strong>Developer Notes:</strong></p>

<ul>
<li>Added: <code>gravityview_excerpt_more</code> filter. Modify the "Read more" link used when "Maximum Words" setting is enabled and the output is truncated.

<ul>
<li>Removed: <code>excerpt_more</code> filter on <code>textarea.php</code> - many themes use permalink values to generate links.</li>
</ul>
</li>
</ul>

<h3 id="toc_0">1.16 on January 14</h3>

<ul>
Expand Down
2 changes: 1 addition & 1 deletion includes/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function field_label( $field, $entry = array(), $force_show_label
* @param array $entry GF Entry array
* @return string Text with variables maybe replaced
*/
public static function replace_variables($text, $form, $entry ) {
public static function replace_variables( $text, $form = array(), $entry = array() ) {
return GravityView_Merge_Tags::replace_variables( $text, $form, $entry );
}

Expand Down
16 changes: 16 additions & 0 deletions includes/class-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,16 @@ public static function calculate_get_entries_criteria( $passed_criteria = array(
*/
$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
}

// don't send just the [mode] without any field filter.
if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) {
unset( $criteria['search_criteria']['field_filters']['mode'] );
}

}



/**
* Prepare date formats to be in Gravity Forms DB format;
* $passed_criteria may include date formats incompatible with Gravity Forms.
Expand Down Expand Up @@ -628,6 +636,14 @@ public static function get_entry( $entry_slug, $force_allow_ids = false, $check_
// fetch the entry
$entry = GFAPI::get_entry( $entry_id );

/**
* @filter `gravityview/common/get_entry/check_entry_display` Override whether to check entry display rules against filters
* @since 1.16.2
* @param bool $check_entry_display Check whether the entry is visible for the current View configuration. Default: true.
* @param array $entry Gravity Forms entry array
*/
$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry );

if( $check_entry_display ) {
// Is the entry allowed
$entry = self::check_entry_display( $entry );
Expand Down
13 changes: 10 additions & 3 deletions includes/class-frontend-views.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,16 @@ public function render_view( $passed_args ) {
do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' );

/**
* @filter `gravityview/render/entry/not_visible` Modify the message shown to users when the entry doesn't exist or they aren't allowed to view it.
* @since 1.6
* @param string $message Default: "You have attempted to view an entry that is not visible or may not exist."
*/
echo esc_attr( apply_filters( 'gravityview/render/entry/not_visible', __( 'You have attempted to view an entry that is not visible or may not exist.', 'gravityview' ) ) );
$message = apply_filters( 'gravityview/render/entry/not_visible', __( 'You have attempted to view an entry that is not visible or may not exist.', 'gravityview' ) );

/**
* @since 1.6
*/
echo esc_attr( $message );

return null;
}
Expand Down Expand Up @@ -889,7 +896,7 @@ public static function get_search_criteria( $args, $form_id ) {

$search_criteria['field_filters'][] = array(
'key' => rgget( 'search_field', $args ), // The field ID to search
'value' => esc_attr( $args['search_value'] ), // The value to search
'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes.
'operator' => $operator,
);
}
Expand Down Expand Up @@ -1333,7 +1340,7 @@ public function add_columns_sort_links( $label = '', $field, $form ) {

$sorting = GravityView_View::getInstance()->getSorting();

$class = 'gv-sort icon';
$class = 'gv-sort';

$sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] );

Expand Down
187 changes: 187 additions & 0 deletions includes/class-gravityview-gfformsmodel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<?php
/**
* Make some GFFormsModel public available.
* @since 1.16.2
*/


class GravityView_GFFormsModel extends GFFormsModel {

/**
* Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private.
*
* @since 1.16.2
*
* @param string $url URL of the post image to update
* @param int $post_id ID of the post image to update
* @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path.
*/
public static function copy_post_image( $url, $post_id ) {

$reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' );

/**
* If the method changes to public, use Gravity Forms' method
* @todo: If/when the method is public, remove the unneeded copied code.
*/
if( $reflection->isPublic() ) {
return parent::copy_post_image( $url, $post_id );
}

/**
* Original Gravity Forms code below:
* ==================================
*/

$time = current_time( 'mysql' );

if ( $post = get_post( $post_id ) ) {
if ( substr( $post->post_date, 0, 4 ) > 0 ) {
$time = $post->post_date;
}
}

//making sure there is a valid upload folder
if ( ! ( ( $upload_dir = wp_upload_dir( $time ) ) && false === $upload_dir['error'] ) ) {
return false;
}

$form_id = get_post_meta( $post_id, '_gform-form-id', true );

/**
* Filter the media upload location.
*
* @param array $upload_dir The current upload directory’s path and url.
* @param int $form_id The ID of the form currently being processed.
* @param int $post_id The ID of the post created from the entry currently being processed.
*/
$upload_dir = gf_apply_filters( 'gform_media_upload_path', $form_id, $upload_dir, $form_id, $post_id );

if ( ! file_exists( $upload_dir['path'] ) ) {
if ( ! wp_mkdir_p( $upload_dir['path'] ) ) {
return false;
}
}

$name = basename( $url );
$filename = wp_unique_filename( $upload_dir['path'], $name );

// the destination path
$new_file = $upload_dir['path'] . "/$filename";

// the source path
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
$target_root = RGFormsModel::get_upload_path( $form_id ) . "/$y/$m/";
$target_root_url = RGFormsModel::get_upload_url( $form_id ) . "/$y/$m/";
$upload_root_info = array( 'path' => $target_root, 'url' => $target_root_url );
$upload_root_info = gf_apply_filters( 'gform_upload_path', $form_id, $upload_root_info, $form_id );
$path = str_replace( $upload_root_info['url'], $upload_root_info['path'], $url );

// copy the file to the destination path
if ( ! copy( $path, $new_file ) ) {
return false;
}

// Set correct file permissions
$stat = stat( dirname( $new_file ) );
$perms = $stat['mode'] & 0000666;
@ chmod( $new_file, $perms );

// Compute the URL
$url = $upload_dir['url'] . "/$filename";

if ( is_multisite() ) {
delete_transient( 'dirsize_cache' );
}

$type = wp_check_filetype( $new_file );

return array( 'file' => $new_file, 'url' => $url, 'type' => $type['type'] );

}

/**
* Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private.
*
* @see GFFormsModel::media_handle_upload
* @see GravityView_Edit_Entry_Render::maybe_update_post_fields
*
* @uses copy_post_image
* @uses wp_insert_attachment
* @uses wp_update_attachment_metadata
*
* @param string $url URL of the post image to update
* @param int $post_id ID of the post image to update
* @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys.
* @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image
*/
public static function media_handle_upload( $url, $post_id, $post_data = array() ) {

$reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' );

/**
* If the method changes to public, use Gravity Forms' method
* @todo: If/when the method is public, remove the unneeded copied code.
*/
if( $reflection->isPublic() ) {
return parent::media_handle_upload( $url, $post_id, $post_data );
}

/**
* Original Gravity Forms code below:
* ==================================
*/

//WordPress Administration API required for the media_handle_upload() function
require_once( ABSPATH . 'wp-admin/includes/image.php' );

$name = basename( $url );

$file = self::copy_post_image( $url, $post_id );

if ( ! $file ) {
return false;
}

$name_parts = pathinfo( $name );
$name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );

$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
$title = $name;
$content = '';

// use image exif/iptc data for title and caption defaults if possible
if ( $image_meta = @wp_read_image_metadata( $file ) ) {
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
$title = $image_meta['title'];
}
if ( trim( $image_meta['caption'] ) ) {
$content = $image_meta['caption'];
}
}

// Construct the attachment array
$attachment = array_merge(
array(
'post_mime_type' => $type,
'guid' => $url,
'post_parent' => $post_id,
'post_title' => $title,
'post_content' => $content,
), $post_data
);

// Save the data
$id = wp_insert_attachment( $attachment, $file, $post_id );
if ( ! is_wp_error( $id ) ) {
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
}

return $id;
}


}
1 change: 1 addition & 0 deletions includes/class-gravityview-merge-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static function replace_variables($text, $form = array(), $entry = array(
* Make sure the required keys are set for GFCommon::replace_variables
*
* @internal Reported to GF Support on 12/3
* @internal Fixed in Gravity Forms
*/
$form['title'] = isset( $form['title'] ) ? $form['title'] : '';
$form['id'] = isset( $form['id'] ) ? $form['id'] : '';
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions includes/class-gravityview-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ private function parse_and_sanitize_atts( $passed_atts ) {

foreach( $filtered_atts as $key => $passed_value ) {

// Allow using {get} merge tags in shortcode attributes
$passed_value = GravityView_Merge_Tags::replace_get_variables( $passed_value );
// Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by}
$passed_value = GravityView_Merge_Tags::replace_variables( $passed_value );

switch( $defaults[ $key ]['type'] ) {

Expand Down
Loading

0 comments on commit 029c15d

Please sign in to comment.