Skip to content

Commit

Permalink
Merge pull request #1087 from gravityview/develop
Browse files Browse the repository at this point in the history
2.0.9
  • Loading branch information
zackkatz authored Jun 3, 2018
2 parents f1fcfde + 27f4317 commit e694f85
Show file tree
Hide file tree
Showing 23 changed files with 197 additions and 44 deletions.
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ notifications:
branches:
only:
- master
- future
- 2.0
- develop

php:
- 5.3
- 5.4
- 5.6
- 7.0
- 7.1
- 7.2
- 7.1
- 7.0
- 5.6
- 5.4
- 5.3

env:
- WP_VERSION=latest WP_MULTISITE=0
Expand Down
6 changes: 5 additions & 1 deletion future/includes/class-gv-field-internal.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ public function get_label( View $view = null, Source $source = null, Entry $entr
return $label;
}

return $this->field ? $this->field->label : $this->label;
if ( $this->label ) {
return $this->label;
}

return $this->field ? $this->field->label : '';
}

/**
Expand Down
22 changes: 18 additions & 4 deletions future/includes/class-gv-form-join.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,27 @@ public function __construct( $join, $join_column, $join_on, $join_on_column ) {
* @return \GF_Query The $query
*/
public function as_query_join( $query ) {
if ( ! gravityview()->plugin->supports( Plugin::FEATURE_JOINS ) || ! $query instanceof \GF_Query ) {
return null;

if ( ! gravityview()->plugin->supports( Plugin::FEATURE_JOINS ) ) {
return null;
}

if ( ! $query instanceof \GF_Query ) {
gravityview()->log->error( 'Query not instance of \GF_Query.' );
return null;
}

$join_id = intval( $this->join->ID );
$join_on_id = intval( $this->join_on->ID );

if ( empty( $join_id ) || empty( $join_on_id ) ) {
gravityview()->log->error( 'Query join form not an integer.', array( 'data' => $this ) );
return null;
}

return $query->join(
new \GF_Query_Column( $this->join_on_column->ID, $this->join_on->ID ),
new \GF_Query_Column( $this->join_column->ID, $this->join->ID )
new \GF_Query_Column( $this->join_on_column->ID, $join_on_id ),
new \GF_Query_Column( $this->join_column->ID, $join_id )
);
}
}
2 changes: 2 additions & 0 deletions future/includes/class-gv-shortcode-gventry.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function callback( $atts, $content = null ) {
'view_id' => 0,
) );

$atts = gv_map_deep( $atts, array( 'GravityView_Merge_Tags', 'replace_get_variables' ) );

/**
* @filter `gravityview/shortcodes/gventry/atts` Filter the [gventry] shortcode attributes.
* @param array $atts The initial attributes.
Expand Down
2 changes: 2 additions & 0 deletions future/includes/class-gv-shortcode-gvfield.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function callback( $atts, $content = null ) {
'field_id' => null,
) );

$atts = gv_map_deep( $atts, array( 'GravityView_Merge_Tags', 'replace_get_variables' ) );

/**
* @filter `gravityview/shortcodes/gvfield/atts` Filter the [gvfield] shortcode attributes.
* @param array $atts The initial attributes.
Expand Down
6 changes: 3 additions & 3 deletions future/includes/class-gv-template-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ public static function add_id_specific_templates( $template ) {

/**
* Legacy.
* Ignore some types that conflict.
*/
if ( $field_type ) {
if ( ! in_array( $field_type, array( 'notes' ) ) ) {
$specifics []= sprintf( '%s.php', $field_type );
$specifics []= sprintf( 'fields/%s.php', $field_type );
}
Expand Down Expand Up @@ -258,7 +259,6 @@ public function render() {

\GV\Mocks\Legacy_Context::load( array(
'field' => $this->field,
'entry' => $this->entry,
) );

/** Alter the display value according to Gravity Forms. */
Expand Down Expand Up @@ -322,7 +322,7 @@ public function render() {

/** A compatibility array that's required by some of the deprecated filters. */
$field_compat = array(
'form' => $source_backend == \GV\Source::BACKEND_GRAVITYFORMS ? $this->source->form : null,
'form' => $source_backend == \GV\Source::BACKEND_GRAVITYFORMS ? $this->source->form : ( $this->view->form ? $this->view->form->form : null ),
'field_id' => $this->field->ID,
'field' => $this->field->field,
'field_settings' => $this->field->as_configuration(),
Expand Down
6 changes: 4 additions & 2 deletions future/includes/class-gv-wrappers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file contains magic wrapper code for `gravityview()`.
*
* Every `gravityview()` magic key maps to a class that exposes more magic.
* Chains of inifite magic can be constructed spanning seas of mermaids,
* Chains of infinite magic can be constructed spanning seas of mermaids,
* valleys of unicorns and whirlwinds of shooting stars.
*/

Expand All @@ -26,7 +26,7 @@ class views {
* out what you need from the current context, from the supplied
* args, etc.
*
* @param string|int|array|\GV\View\WP_Post|null Anything goes.
* @param string|int|array|\GV\View|\WP_Post|null Anything goes.
*
* @return \GV\View|null The detected View.
*/
Expand Down Expand Up @@ -79,6 +79,8 @@ public function get( $view = null ) {
*/
return $this->view;
}

return null;
}

/**
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.8.1
* Version: 2.0.9
* 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.8.1' );
define( 'GV_PLUGIN_VERSION', '2.0.9' );

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

<h3>2.0.9 on June 1, 2016</h3>

<ul>
<li>Added: Allow passing <code>{get}</code> Merge Tags to [gventry] and [gvfield] shortcodes</li>
<li>Fixed: Searching by entry creator using the Search Bar wasn't working</li>
<li>Fixed: Edit Entry showing "Invalid link" warnings when multiple Views are embedded on a page</li>
<li>Fixed: Issues with legacy template back-compatiblity (A-Z Filters) and newer API widgets (Maps)</li>
<li>Fixed: Translations for entry "meta", like "Created By" or "Date Created"</li>
<li>Fixed: When searching State/Province with the Search Bar, use "exact match" search</li>
</ul>

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

<ul>
<li>Added: Auto-prefixing for all CSS rules, set to cover 99.7% of browsers. We were already prefixing, so it doesn't change much, but it will update automatically from now on, based on browser support.</li>
</ul>

<h3>2.0.8.1 on May 31, 2018</h3>

<ul>
Expand Down
2 changes: 1 addition & 1 deletion includes/class-frontend-views.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function parse_query_fix_frontpage( &$query ) {
// this is where will break from core wordpress
/** @internal Don't use this filter; it will be unnecessary soon - it's just a patch for specific use case */
$ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query );
$endpoints = rgobj( $wp_rewrite, 'endpoints' );
$endpoints = \GV\Utils::get( $wp_rewrite, 'endpoints' );
foreach ( (array) $endpoints as $endpoint ) {
$ignore[] = $endpoint[1];
}
Expand Down
5 changes: 5 additions & 0 deletions includes/class-gravityview-merge-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ private static function modifier_strings( $raw_value, $matches, $value = '', $fi
*/
public static function replace_variables( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true, $nl2br = true, $format = 'html', $aux_data = array() ) {

if ( ! is_string( $text ) ) {
gravityview()->log->error( '$text is not a string.', array( 'data' => $text ) );
return $text;
}

/**
* @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n
* Useful where you want to process variables yourself. We do this in the Math Extension.
Expand Down
7 changes: 7 additions & 0 deletions includes/class-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,13 @@ public function render_widget_hooks( $view_id_or_context ) {
$is_single = gravityview_get_context() == 'single';
$total_entries = GravityView_View::getInstance()->getTotalEntries();

/**
* Fake new context for legacy template code.
*/
$view_id_or_context = \GV\Template_Context::from_template( array(
'view' => $view,
) );

} else if ( $view_id_or_context instanceof \GV\Template_Context ) {
$view = $view_id_or_context->view;
$is_single = (boolean)$view_id_or_context->request->is_entry();
Expand Down
2 changes: 1 addition & 1 deletion includes/extensions/edit-entry/class-edit-entry-render.php
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ public function custom_validation( $validation_results ) {
}

// validate if multi file upload reached max number of files [maxFiles] => 2
if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) {
if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {

$input_name = 'input_' . $field->id;
//uploaded
Expand Down
4 changes: 4 additions & 0 deletions includes/extensions/edit-entry/class-edit-entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ public static function get_edit_link( $entry, $view_id, $post_id = null, $field_
'edit' => wp_create_nonce( $nonce_key )
), $base );

if( $post_id ) {
$url = add_query_arg( array( 'gvid' => $view_id ), $url );
}

/**
* Allow passing params to dynamically populate entry with values
* @since 1.9.2
Expand Down
34 changes: 30 additions & 4 deletions includes/widgets/search-widget/class-search-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,15 +448,17 @@ public function add_no_permalink_fields( $search_fields, $object, $widget_args =
* Get the fields that are searchable for a View
*
* @since 2.0
* @since 2.0.9 Added $with_full_field parameter
*
* @param \GV\View|null $view
* @param bool $with_full_field Return full field array, or just field ID? Default: false (just field ID)
*
* TODO: Move to \GV\View, perhaps? And return a Field_Collection
* TODO: Use in gravityview()->request->is_search() to calculate whether a valid search
*
* @return array If no View, returns empty array. Otherwise, returns array of fields configured in widgets and Search Bar for a View
*/
private function get_view_searchable_fields( $view ) {
private function get_view_searchable_fields( $view, $with_full_field = false ) {

/**
* Find all search widgets on the view and get the searchable fields settings.
Expand All @@ -476,7 +478,7 @@ private function get_view_searchable_fields( $view ) {
if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) {
if( $_fields = json_decode( $widget['search_fields'], true ) ) {
foreach ( $_fields as $field ) {
$searchable_fields [] = $field['field'];
$searchable_fields [] = $with_full_field ? $field : $field['field'];
}
}
}
Expand All @@ -485,7 +487,7 @@ private function get_view_searchable_fields( $view ) {
foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) {
if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
foreach ( $_fields as $field ) {
$searchable_fields [] = $field['field'];
$searchable_fields [] = $with_full_field ? $field : $field['field'];
}
}
}
Expand Down Expand Up @@ -619,7 +621,7 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array
}

// search for a specific Created_by ID
if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'entry_creator', $searchable_fields ) ) {
if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) {
$search_criteria['field_filters'][] = array(
'key' => 'created_by',
'value' => absint( $get['gv_by'] ),
Expand Down Expand Up @@ -811,6 +813,30 @@ public function prepare_field_filter( $filter_key, $value, $view ) {
$filter = $filters;
}

// State/Province should be exact matches
if ( 'address' === $form_field->field->type ) {

$searchable_fields = $this->get_view_searchable_fields( $view, true );

foreach ( $searchable_fields as $searchable_field ) {

if( $form_field->ID !== $searchable_field['field'] ) {
continue;
}

// Only exact-match dropdowns, not text search
if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) {
continue;
}

$input_id = gravityview_get_input_id_from_id( $form_field->ID );

if ( 4 === $input_id ) {
$filter['operator'] = 'is';
};
}
}

break;

case 'date':
Expand Down
12 changes: 6 additions & 6 deletions languages/gravityview.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is distributed under the GPLv2 or later.
msgid ""
msgstr ""
"Project-Id-Version: GravityView 2.0.8.1\n"
"Project-Id-Version: GravityView 2.0.8.2\n"
"Report-Msgid-Bugs-To: https://gravityview.co/support/\n"
"POT-Creation-Date: 2018-05-08 22:37:16+00:00\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -1482,23 +1482,23 @@ msgstr ""
msgid "What&rsquo;s New"
msgstr ""

#: includes/class-admin-welcome.php:504
#: includes/class-admin-welcome.php:514
msgid "View change history"
msgstr ""

#: includes/class-admin-welcome.php:525
#: includes/class-admin-welcome.php:535
msgid "GravityView is brought to you by:"
msgstr ""

#: includes/class-admin-welcome.php:560
#: includes/class-admin-welcome.php:570
msgid "Contributors"
msgstr ""

#: includes/class-admin-welcome.php:585
#: includes/class-admin-welcome.php:595
msgid "Want to contribute?"
msgstr ""

#: includes/class-admin-welcome.php:586
#: includes/class-admin-welcome.php:596
msgid ""
"If you want to contribute to the code, %syou can on Github%s. If your "
"contributions are accepted, you will be thanked here."
Expand Down
13 changes: 13 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ Beautifully display your Gravity Forms entries. Learn more on [gravityview.co](h

== Changelog ==

= 2.0.9 on June 1, 2016 =

* Added: Allow passing `{get}` Merge Tags to [gventry] and [gvfield] shortcodes
* Fixed: Searching by entry creator using the Search Bar wasn't working
* Fixed: Edit Entry showing "Invalid link" warnings when multiple Views are embedded on a page
* Fixed: Issues with legacy template back-compatiblity (A-Z Filters) and newer API widgets (Maps)
* Fixed: Translations for entry "meta", like "Created By" or "Date Created"
* Fixed: When searching State/Province with the Search Bar, use "exact match" search

__Developer Notes__

* Added: Auto-prefixing for all CSS rules, set to cover 99.7% of browsers. We were already prefixing, so it doesn't change much, but it will update automatically from now on, based on browser support.

= 2.0.8.1 on May 31, 2018 =

* Fixed: Standalone map fields not displaying on the [Maps layout](https://gravityview.co/extensions/maps/)
Expand Down
2 changes: 1 addition & 1 deletion templates/fields/field-custom-html.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$content = GravityView_API::replace_variables( $content, $form, $entry, false, true, false );

/**
* @filter `gravityview/fields/custom/decode_shortcodes` Decode brackets in shortcodes
* @filter `gravityview/fields/custom/decode_shortcodes` Decode brackets in shortcodes, rendering them inert (escape brackets).
* @since 1.16.5
* @param boolean $decode Enable/Disable decoding of brackets in the content (default: false)
* @param string $content HTML content of field
Expand Down
9 changes: 8 additions & 1 deletion tests/bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,15 @@ install_gravity_forms_22(){
install_gravity_forms(){
mkdir -p "$GF_CORE_DIR"

# If you have an access token to Gravity Forms repo, grab and install
if [[ $GITHUB_ACCESS_TOKEN != '' ]]; then

rm -rf /tmp/gravityforms/

git clone "https://${GITHUB_ACCESS_TOKEN}@github.com/gravityforms/gravityforms.git" /tmp/gravityforms/

# If you have passed an URL with a ZIP file, grab it and install
if [[ $GRAVITY_FORMS_DL_PATH_OR_URL = *".zip"* ]]; then
elif [[ $GRAVITY_FORMS_DL_PATH_OR_URL = *".zip"* ]]; then

# Pull from remote
curl -L "$GRAVITY_FORMS_DL_PATH_OR_URL" --output /tmp/gravityforms.zip
Expand Down
Loading

0 comments on commit e694f85

Please sign in to comment.