Skip to content

Commit

Permalink
Merge pull request #1047 from gravityview/develop
Browse files Browse the repository at this point in the history
2.0.6.1
  • Loading branch information
zackkatz authored May 21, 2018
2 parents cf82687 + 345e354 commit 397f5b7
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 102 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ vendor/*/.git
vendor/composer/
vendor/autoload.php

### Grunt ###
### Node ###
node_modules/*
package-lock.json

### CodeKit ####
.sass-cache
Expand All @@ -45,6 +46,7 @@ languages/gravityview-pt.po
.idea/dictionaries
.idea/deployment.xml
.idea/modules.xml

.idea/php.xml

# Sensitive or high-churn files:
Expand Down Expand Up @@ -86,6 +88,3 @@ docs/html

# VIM
*.swp

.idea/php.xml
package-lock.json
50 changes: 0 additions & 50 deletions .idea/php.xml

This file was deleted.

23 changes: 15 additions & 8 deletions future/includes/class-gv-collection-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,25 @@ public static function from_post( \WP_Post $post ) {
* This is useful when using themes that store content that may contain shortcodes in custom post meta.
*
* @since 2.0
* @since 2.0.7 Added $views parameter, passed by reference
*
* @param[in,out] array $meta_keys Array of key values to check. If empty, do not check. Default: empty array
* @param[in] \WP_Post $post The post that is being checked
* @param \GV\View_Collection $views The current View Collection object, passed as reference
*/
$meta_keys = apply_filters( 'gravityview/view_collection/from_post/meta_keys', array(), $post );

/**
* @filter `gravityview/data/parse/meta_keys`
* @deprecated
* @see The `gravityview/view_collection/from_post/meta_keys` filter.
*/
$meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', $meta_keys, $post->ID );
$meta_keys = apply_filters_ref_array( 'gravityview/view_collection/from_post/meta_keys', array( array(), $post, &$views ) );

if ( function_exists( 'apply_filters_deprecated' ) ) {
$meta_keys = (array) apply_filters_deprecated( 'gravityview/data/parse/meta_keys', array( $meta_keys, $post->ID ), '2.0.7', 'gravityview/view_collection/from_post/meta_keys' );
} else {
/**
* @filter `gravityview/data/parse/meta_keys`
* @deprecated
* @todo Require WP 4.6.0 so that `apply_filters_deprecated` is always available
* @see The `gravityview/view_collection/from_post/meta_keys` filter.
*/
$meta_keys = (array) apply_filters( 'gravityview/data/parse/meta_keys', $meta_keys, $post->ID );
}

/** What about inside post meta values? */
foreach ( $meta_keys as $meta_key ) {
Expand Down
39 changes: 38 additions & 1 deletion future/includes/class-gv-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,44 @@ public function is_search() {
$get = $_GET;
}

return $this->is_view() && ( isset( $get['gv_search'] ) || isset( $get['gv_start'] ) || isset( $get['gv_end'] ) || isset( $get['gv_by'] ) || isset( $get['gv_id'] ) );
$has_field_key = $this->_has_field_key( $get );

return $this->is_view() && ( $has_field_key || isset( $get['gv_search'] ) || isset( $get['gv_start'] ) || isset( $get['gv_end'] ) || isset( $get['gv_by'] ) || isset( $get['gv_id'] ) );
}

/**
* Calculate whether the $_REQUEST has a GravityView field
*
* @internal
* @todo Roll into the future Search refactor
*
* @since 2.0.7
*
* @param array $get $_POST or $_GET array
*
* @return bool True: GravityView-formatted field detected; False: not detected
*/
private function _has_field_key( $get ) {

$has_field_key = false;

$fields = \GravityView_Fields::get_all();

$meta = array();
foreach ( $fields as $field ) {
if( empty( $field->_gf_field_class_name ) ) {
$meta[] = preg_quote( $field->name );
}
}

foreach ( $get as $key => $value ) {
if ( preg_match('/^filter_(([0-9_]+)|'. implode( '|', $meta ) .')$/ism', $key ) ) {
$has_field_key = true;
break;
}
}

return $has_field_key;
}
}

Expand Down
4 changes: 2 additions & 2 deletions gravityview.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: GravityView
* Plugin URI: https://gravityview.co
* Description: The best, easiest way to display Gravity Forms entries on your website.
* Version: 2.0.6
* Version: 2.0.6.1
* Author: GravityView
* Author URI: https://gravityview.co
* Text Domain: gravityview
Expand All @@ -22,7 +22,7 @@
/**
* The plugin version.
*/
define( 'GV_PLUGIN_VERSION', '2.0.6' );
define( 'GV_PLUGIN_VERSION', '2.0.6.1' );

/**
* Full path to the GravityView file
Expand Down
8 changes: 8 additions & 0 deletions includes/class-admin-welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ public function changelog_screen() {
</ul>
</div>

<h3>2.0.6.1 on May 21, 2018</h3>

<ul>
<li>Fixed: "Hide View data until search is performed" not working</li>
<li>Added: Support for SiteOrigin Page Builder and LiveMesh SiteOrigin Widgets</li>
<li>Fixed: Enfold Theme layout builder no longer rendering Views</li>
</ul>

<h3>2.0.6 on May 17, 2018</h3>

<ul>
Expand Down
4 changes: 3 additions & 1 deletion includes/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,9 @@ function gv_container_class( $passed_css_class = '', $echo = true, $context = nu
$view_id = 0;
if ( $context->view ) {
$view_id = $context->view->ID;
$hide_until_searched = $context->view->settings->get( 'hide_until_searched' );
if( $context->view->settings->get( 'hide_until_searched' ) ) {
$hide_until_searched = ! $context->request->is_search();
}
}
if ( $context->entries ) {
$total_entries = $context->entries->total();
Expand Down
49 changes: 24 additions & 25 deletions includes/class-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,39 +659,38 @@ public static function get_entry_id( $entry_id_or_slug = '', $force_allow_ids =
*/
public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) {

if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) {

$entry_id = self::get_entry_id( $entry_slug, $force_allow_ids );
if ( ! class_exists( 'GFAPI' ) || empty( $entry_slug ) ) {
return false;
}

if ( empty( $entry_id ) ) {
return false;
}
$entry_id = self::get_entry_id( $entry_slug, $force_allow_ids );

// fetch the entry
$entry = GFAPI::get_entry( $entry_id );
if ( empty( $entry_id ) ) {
return false;
}

/**
* @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 );
// fetch the entry
$entry = GFAPI::get_entry( $entry_id );

if( $check_entry_display ) {
// Is the entry allowed
$entry = self::check_entry_display( $entry );
}
/**
* @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( is_wp_error( $entry ) ) {
gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) );
return false;
}
if( $check_entry_display ) {
// Is the entry allowed
$entry = self::check_entry_display( $entry );
}

return $entry;
if( is_wp_error( $entry ) ) {
gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) );
return false;
}

return false;
return $entry;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,33 @@ abstract class GravityView_Plugin_and_Theme_Hooks {
*/
protected $constant_name = false;

/**
* Define the keys to be parsed by the `gravityview/view_collection/from_post/meta_keys` hook
* @see View_Collection::from_post
* @since 2.0
* @type array
*/
protected $content_meta_keys = array();

/**
* Define the keys to be parsed by the `gravityview/data/parse/meta_keys` hook
* @see GravityView_View_Data::parse_post_meta
* @deprecated 2.0
* @since 1.15.2
* @type array
*/
protected $content_meta_keys = array();
protected $meta_keys = array();

/**
* Define script handles used by the theme or plugin to be parsed by the `gravityview/data/parse/meta_keys` hook
* Define script handles used by the theme or plugin to be added to allowed no-conflict scripts
* @see GravityView_Admin::remove_conflicts
* @since 1.15.2
* @type array
*/
protected $script_handles = array();

/**
* Define style handles used by the theme or plugin to be parsed by the `gravityview/data/parse/meta_keys` hook
* Define style handles used by the theme or plugin to be added to allowed no-conflict styles
* @see GravityView_Admin::remove_conflicts
* @since 1.15.2
* @type array
Expand Down Expand Up @@ -114,8 +123,13 @@ private function maybe_add_hooks() {
* @return void
*/
protected function add_hooks() {

if( $this->meta_keys ) {
add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_meta_keys' ), 10, 2 );
}

if( $this->content_meta_keys ) {
add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 );
add_filter( 'gravityview/view_collection/from_post/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 3 );
}

if( $this->script_handles ) {
Expand Down Expand Up @@ -179,12 +193,28 @@ public function merge_noconflict_scripts( $handles ) {
*
* @since 1.15.2
*
* @deprecated 2.0.7
*
* @param array $handles Array of meta keys to check for existence of shortcodes
* @param int $post_id The ID being checked by GravityView
*
* @return array Meta key array, merged with existing meta keys
*/
public function merge_content_meta_keys( $meta_keys = array(), $post_id = 0 ) {
public function merge_meta_keys( $meta_keys = array(), $post_id = 0 ) {
return array_merge( $this->meta_keys, $meta_keys );
}

/**
* Merge plugin or theme meta keys that store shortcode data with existing keys to check
*
* @since 2.0.7
*
* @param array $handles Array of meta keys to check for existence of shortcodes
* @param \WP_Post $post The ID being checked by GravityView
*
* @return array Meta key array, merged with existing meta keys
*/
public function merge_content_meta_keys( $meta_keys = array(), $post = null, & $views = null ) {
return array_merge( $this->content_meta_keys, $meta_keys );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GravityView_Theme_Hooks_Avia extends GravityView_Plugin_and_Theme_Hooks {
* @inheritDoc
* @since 1.15.2
*/
protected $meta_keys = array(
protected $content_meta_keys = array(
'_aviaLayoutBuilderCleanData'
);

Expand Down
Loading

0 comments on commit 397f5b7

Please sign in to comment.