Skip to content

Commit

Permalink
Release 2.18 (#1865)
Browse files Browse the repository at this point in the history
* Fixed: Issue where "Edit Entry" link was not appearing under the
Single Entry layout when the View was filtered using the "Created By"
criterion with the "{user:ID}" merge tag
* Fixed: REST API response breaking the functionality of Maps Layout 2.0
* Updated: [Foundation](https://www.gravitykit.com/foundation/) to
version 1.1

__Developer Notes:__

* Deprecated: `get_gravityview()` and the `the_gravityview()` global
functions
* Added: `GravityView_Field_Delete_Link` class to render the Delete
Entry link instead of relying on filtering
- `delete_link` will now be properly returned in the
`GravityView_Fields::get_all('gravityview');` response
  • Loading branch information
mrcasual authored Jun 20, 2023
2 parents c37ec6c + cd217af commit 1b505ed
Show file tree
Hide file tree
Showing 19 changed files with 501 additions and 594 deletions.
2 changes: 1 addition & 1 deletion assets/js/admin-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@
vcfg.selectTemplateContinue( slugmatch );
}
} else {
// revert back to how things before before clicking "use a form preset"
// revert back to how things were before clicking "use a form preset"
vcfg.toggleViewTypeMetabox();
vcfg.showViewConfig();
}
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

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

13 changes: 12 additions & 1 deletion future/includes/class-gv-entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul

$args = array();

/**
* @filter `gravityview/entry_link/add_query_args` Modify whether to include passed $_GET parameters to the end of the url
* @since 2.10
* @param bool $add_query_params Whether to include passed $_GET parameters to the end of the Entry Link URL. Default: true.
*/
$add_query_args = apply_filters( 'gravityview/entry_link/add_query_args', true );

if ( $add_query_args ) {
$args = gv_get_query_args();
}

$view_id = is_null ( $view ) ? null : $view->ID;

$permalink = null;
Expand All @@ -121,7 +132,7 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul
if ( ! $request->is_view( false ) ) {

/** Must be an embed of some sort. */
if ( is_object( $post ) && is_numeric( $post->ID ) ) {
if ( $post instanceof \WP_Post && is_numeric( $post->ID ) ) {
$permalink = get_permalink( $post->ID );

$view_collection = View_Collection::from_post( $post );
Expand Down
43 changes: 3 additions & 40 deletions future/includes/class-gv-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ final class Plugin {
*/
public static $min_gf_version = GV_MIN_GF_VERSION;

/**
* @var string Minimum PHP version.
*
* GravityView requires at least this version of PHP to function properly.
*/
private static $min_php_version = GV_MIN_PHP_VERSION;

/**
* @var string|bool Minimum future PHP version.
*
Expand Down Expand Up @@ -380,23 +373,7 @@ public function url( $path = '/' ) {
*/
public function is_compatible() {

return
$this->is_compatible_php()
&& $this->is_compatible_wordpress()
&& $this->is_compatible_gravityforms();
}

/**
* Is this version of GravityView compatible with the current version of PHP?
*
* @since 2.0
*
* @return bool true if compatible, false otherwise.
* @api
*/
public function is_compatible_php() {

return version_compare( $this->get_php_version(), self::$min_php_version, '>=' );
return $this->is_compatible_wordpress() && $this->is_compatible_gravityforms();
}

/**
Expand All @@ -407,9 +384,8 @@ public function is_compatible_php() {
* @return bool true if compatible, false otherwise.
* @api
*/
public function is_compatible_future_php() {

return version_compare( $this->get_php_version(), self::$future_min_php_version, '>=' );
public function is_compatible_future_php(): bool {
return version_compare( phpversion(), self::$future_min_php_version, '>=' );
}

/**
Expand Down Expand Up @@ -476,19 +452,6 @@ public function is_compatible_future_gravityforms() {
return $version ? version_compare( $version, self::$future_min_gf_version, '>=' ) : false;
}

/**
* Retrieve the current PHP version.
*
* Overridable with GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE during testing.
*
* @return string The version of PHP.
*/
private function get_php_version() {

return ! empty( $GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] ) ?
$GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] : phpversion();
}

/**
* Retrieve the current WordPress version.
*
Expand Down
6 changes: 6 additions & 0 deletions future/includes/class-gv-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ public static function _SERVER( $name, $default = null ) {
* @return mixed The value or $default if not found.
*/
public static function get( $array, $key, $default = null ) {

if ( ! is_array( $array ) && ! is_object( $array ) ) {
return $default;
}

// Only allow string or integer keys. No null, array, etc.
if ( ! is_string( $key ) && ! is_int( $key ) ) {
return $default;
}

/**
* Try direct key.
*/
Expand Down
7 changes: 5 additions & 2 deletions future/includes/rest/class-gv-rest-views-route.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,13 @@ public function prepare_entry_for_response( $view, $entry, \WP_REST_Request $req
* @return \WP_Error|\WP_REST_Response
*/
public function get_sub_items( $request ) {
global $post;

$url = $request->get_url_params();
$view_id = intval( $url['id'] );
$format = \GV\Utils::get( $url, 'format', 'json' );

if( $post_id = $request->get_param('post_id') ) {
global $post;

$post = get_post( $post_id );

if ( ! $post || is_wp_error( $post ) ) {
Expand All @@ -232,6 +231,10 @@ public function get_sub_items( $request ) {

$view = \GV\View::by_id( $view_id );

if ( null !== $view ) {
$post = $view->get_post();
}

if ( 'html' === $format ) {

$renderer = new \GV\View_Renderer();
Expand Down
49 changes: 0 additions & 49 deletions future/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,6 @@
die();
}

/**
* Do not allow activation if PHP version is lower than GV_MIN_PHP_VERSION
*/
if ( version_compare( phpversion(), GV_MIN_PHP_VERSION, '<' ) ) {
$php_notices = array(
esc_html__( 'GravityView requires PHP [php_required_version] or newer.', 'gk-gravityview' ),
esc_html__( 'You are using version [php_installed_version].', 'gk-gravityview' ),
esc_html__( 'Please ask your host to upgrade PHP on the server.', 'gk-gravityview' ),
);

foreach ( $php_notices as &$notice ) {
$notice = strtr(
$notice,
array(
'[php_required_version]' => GV_MIN_PHP_VERSION,
'[php_installed_version]' => phpversion()
)
);
}

if ( 'cli' === php_sapi_name() ) {
printf( join( ' ', $php_notices ) );
} else {
add_action( 'admin_notices', function () use ( $php_notices ) {
$floaty_image = plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE );
$floaty_image_alt = esc_attr__( 'The GravityKit Astronaut Says:', 'gk-gravityview' );

list( $requires, $installed, $call_to_action ) = $php_notices;

echo <<<HTML
<div class="error">
<div style="margin-top: 1em;">
<img src="{$floaty_image}" alt="{$floaty_image_alt}" style="float: left; height: 5em; margin-right: 1em;" />
<h3 style="font-size:16px; margin: 0 0 8px 0;">
{$requires}
</h3>
<p>{$installed}</p>
<p>{$call_to_action}</p>
</div>
</div>
HTML;
} );
}

deactivate_plugins( GRAVITYVIEW_FILE );

return;
}

require_once GRAVITYVIEW_DIR . 'vendor/autoload.php';
require_once GRAVITYVIEW_DIR . 'vendor_prefixed/autoload.php';

Expand Down
14 changes: 2 additions & 12 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://www.gravitykit.com
* Description: The best, easiest way to display Gravity Forms entries on your website.
* Version: 2.17.8
* Version: 2.18
* Author: GravityKit
* Author URI: https://www.gravitykit.com
* Text Domain: gk-gravityview
Expand All @@ -22,16 +22,12 @@
return;
}

if ( ! GravityKit\GravityView\Foundation\meets_min_php_version_requirement( __FILE__, '7.2.0' ) ) {
return;
}

/** Constants */

/**
* The plugin version.
*/
define( 'GV_PLUGIN_VERSION', '2.17.8' );
define( 'GV_PLUGIN_VERSION', '2.18' );

/**
* Full path to the GravityView file
Expand Down Expand Up @@ -71,12 +67,6 @@
*/
define( 'GV_FUTURE_MIN_WP_VERSION', '5.3' );

/**
* GravityView requires at least this version of PHP to function properly.
* @since 1.12
*/
define( 'GV_MIN_PHP_VERSION', '7.2.0' );

/**
* GravityView will require this version of PHP soon. False if no future PHP version changes are planned.
* @since 1.19.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,13 @@ class GravityView_Admin_Metaboxes {
*
*/
function __construct() {

if ( ! GravityView_Compatibility::is_valid() ) {
return;
}

self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/';

include_once self::$metaboxes_dir . 'class-gravityview-metabox-tab.php';

include_once self::$metaboxes_dir . 'class-gravityview-metabox-tabs.php';

$this->initialize();

}

/**
Expand Down
45 changes: 30 additions & 15 deletions includes/class-admin-welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function admin_menus( $foundation ) {
'capability' => $this->minimum_capability,
'callback' => array( $this, 'changelog_screen' ),
'order' => 40,
'hide' => true,
], 'center' );

// Changelog Page
Expand All @@ -75,16 +76,18 @@ public function admin_menus( $foundation ) {
'capability' => $this->minimum_capability,
'callback' => array( $this, 'credits_screen' ),
'order' => 50,
'hide' => true,
], 'center' );

// Add Getting Started page to GravityView menu
$admin_menu::add_submenu_item( [
'id' => 'gv-getting-started',
'page_title' => __( 'GravityView: Getting Started', 'gk-gravityview' ),
'menu_title' => __( 'Getting Started', 'gk-gravityview' ),
'capability' => $this->minimum_capability,
'callback' => array( $this, 'getting_started_screen' ),
'order' => 60, // Make it the last so that the border divider remains
'id' => 'gv-getting-started',
'page_title' => __( 'GravityView: Getting Started', 'gk-gravityview' ),
'menu_title' => __( 'Getting Started', 'gk-gravityview' ),
'capability' => $this->minimum_capability,
'callback' => array( $this, 'getting_started_screen' ),
'order' => 60, // Make it the last so that the border divider remains
'exclude_from_top_level_menu_action' => true,
], 'center' );
}

Expand Down Expand Up @@ -114,13 +117,6 @@ public function is_dashboard_page( $is_page = false, $hook = NULL ) {
* @return void
*/
public function admin_head() {

/** @var \GravityKit\GravityView\Foundation\WP\AdminMenu $admin_menu */
$admin_menu = GravityKitFoundation::admin_menu();

$admin_menu::remove_submenu_item( 'gv-credits' );
$admin_menu::remove_submenu_item( 'gv-changelog' );

if( ! $this->is_dashboard_page() ) {
return;
}
Expand Down Expand Up @@ -185,7 +181,7 @@ public function getting_started_screen() {
<div class="feature-video" style="text-align:center;">
<iframe height="315" src="https://www.youtube-nocookie.com/embed/WrXsZhqKRY8?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>

<p style="text-align:center; padding-top: 1em;"><a class="button button-primary button-hero" href="https://docs.gravityview.co/category/24-category" rel="noopener noreferrer external" target="_blank">Read more: Setting Up Your First View<span class='screen-reader-text'> <?php esc_attr_e( 'This link opens in a new window.', 'gk-gravityview' ); ?></span></a></p>
<p style="text-align:center; padding-top: 1em;"><a class="button button-primary button-hero" href="https://docs.gravitykit.com/article/380-how-to-setup-your-first-view" rel="noopener noreferrer external" target="_blank">Read more: Setting Up Your First View<span class='screen-reader-text'> <?php esc_attr_e( 'This link opens in a new window.', 'gk-gravityview' ); ?></span></a></p>
</div>

<div class="feature-section two-col has-2-columns is-fullwidth">
Expand Down Expand Up @@ -277,6 +273,25 @@ public function changelog_screen() {
<h2 style="border-bottom: 1px solid #ccc; padding-bottom: 1em; margin-bottom: 0; margin-top: 0"><?php esc_html_e( 'What&rsquo;s New', 'gk-gravityview' ); ?></h2>
</div>

<h3>2.18 on June 20, 2023</h3>

<ul>
<li>Fixed: Issue where "Edit Entry" link was not appearing under the Single Entry layout when the View was filtered using the "Created By" criterion with the "{user:ID}" merge tag</li>
<li>Fixed: REST API response breaking the functionality of Maps Layout 2.0</li>
<li>Updated: <a href='https://www.gravitykit.com/foundation/'>Foundation</a> to version 1.1</li>
</ul>

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

<ul>
<li>Deprecated: <code>get_gravityview()</code> and the <code>the_gravityview()</code> global functions</li>
<li>Added: <code>GravityView_Field_Delete_Link</code> class to render the Delete Entry link instead of relying on filtering
<ul>
<li><code>delete_link</code> will now be properly returned in the <code>GravityView_Fields::get_all('gravityview');</code> response</li>
</ul>
</li>
</ul>

<h3>2.17.8 on May 16, 2023</h3>

<ul>
Expand Down Expand Up @@ -876,7 +891,7 @@ public function credits_screen() { ?>
<div class="col">
<h3>Vlad K.</h3>
<h4>Core Developer</h4>
<p><img alt="Vlad K." class="alignleft avatar" src="<?php echo plugins_url( 'assets/images/team/Vlad.jpg', GRAVITYVIEW_FILE ); ?>" width="94" height="94" />Vlad is GravityKit&rsquo;s lead developer. He focuses on GravityKit&rsquo;s user-facing code in the Dashboard and front end. Vlad comes from Russia and lives in Canada.</p>
<p><img alt="Vlad K." class="alignleft avatar" src="<?php echo plugins_url( 'assets/images/team/Vlad.jpg', GRAVITYVIEW_FILE ); ?>" width="94" height="94" />Vlad is GravityKit&rsquo;s lead developer. Known for his versatility, Vlad handles both front-end and back-end programming, as well as testing and DevOps. He lives in Ottawa, Canada, and frequently travels the world in pursuit of unique experiences that fuel his creativity and broaden his worldview.</p>
</div>

<div class="col">
Expand Down
Loading

0 comments on commit 1b505ed

Please sign in to comment.