Plugin Directory

Changeset 3043837


Ignore:
Timestamp:
03/01/2024 10:17:13 PM (2 years ago)
Author:
samuelaguilera
Message:

1.4.16

  • Prevent fatal error if post content is not a string (as required by WordPress has_shortcode function). Which could happen for not supported embedding methods or when a third-party is altering the expected post content.
Location:
fresh-forms-for-gravity
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • fresh-forms-for-gravity/trunk/class-fresh-forms-for-gravity.php

    r3043598 r3043837  
    421421    public function find_gf_shortcode( $post_content ) {
    422422
     423        // Prevent fatal error if post content is not a string (as required by WordPress has_shortcode function).
     424        // Which could happen for not supported embedding methods or when a third-party is altering the expected post content.
     425        if ( ! is_string( $post_content ) ) {
     426            $this->log_debug( __METHOD__ . '(): Post Content is not a string. Aborting...' );
     427            return false;
     428        }
     429
    423430        // Check for a GF shortcode.
    424431        if ( has_shortcode( $post_content, 'gravityform' ) ) {
     
    462469     */
    463470    public function scan_content( $content, $value, $generator ) {
     471
     472        // Return without scanning if there's no content to scan.
     473        if ( empty( $content ) ){
     474            $this->log_debug( __METHOD__ . "(): {$generator} content is empty. Nothing to scan." );
     475            return false;
     476        }
     477
    464478        $this->log_debug( __METHOD__ . "(): {$generator} content to scan: {$content} " );
    465479        // Look for the gform_wrapper.
     
    483497
    484498        foreach ( $acf_fields as $acf_field ) {
     499            //$this->log_debug( __METHOD__ . '(): ACF field properties: ' . print_r( $acf_field, true ) );
     500
    485501            if ( ! in_array( $acf_field['type'], $supported_acf_fields, true ) ) {
    486502                continue;
     
    488504
    489505            if ( 'text' === $acf_field['type'] || 'textarea' === $acf_field['type'] ) { // Look for a GF shortcode inside a standalone text or textarea fields.
    490                 if ( true === $this->find_gf_shortcode( $acf_field['value'], 'gform_wrapper' ) ) {
     506                if ( is_string( $acf_field['value'] ) && true === $this->find_gf_shortcode( $acf_field['value'] ) ) {
    491507                    $this->log_debug( __METHOD__ . "(): ACF {$acf_field['type']} field has a GF form!" );
    492508                    return true;
    493509                }
    494510            } elseif ( 'wysiwyg' === $acf_field['type'] ) { // Look for a GF class inside a standalone wysiwyg field.
    495                 if ( true === $this->scan_content( $acf_field['value'], 'gform_wrapper', 'ACF' ) ) {
     511                if ( is_string( $acf_field['value'] ) && true === $this->scan_content( $acf_field['value'], 'gform_wrapper', 'ACF' ) ) {
    496512                    $this->log_debug( __METHOD__ . "(): ACF {$acf_field['type']} field has a GF form!" );
    497513                    return true;
     
    501517                foreach ( $acf_field['value'] as $acf_subfield_array ) {
    502518                    foreach ( $acf_subfield_array as $key => $value ) {
    503                         if ( true === $this->find_gf_shortcode( $value ) ) {
     519                        if ( is_string( $value ) && true === $this->find_gf_shortcode( $value ) ) {
    504520                            $this->log_debug( __METHOD__ . "(): ACF {$acf_field['type']} field has a GF form!" );
    505521                            return true;
    506                         } elseif ( true === $this->scan_content( $value, 'gform_wrapper', 'ACF' ) ) {
     522                        } elseif ( is_string( $value ) && true === $this->scan_content( $value, 'gform_wrapper', 'ACF' ) ) {
    507523                            $this->log_debug( __METHOD__ . "(): ACF {$acf_field['type']} field has a GF form!" );
    508524                            return true;
  • fresh-forms-for-gravity/trunk/fresh-forms-for-gravity.php

    r3043598 r3043837  
    44 * Description: Prevent posts and pages with a Gravity Forms shortcode or Gutenberg block from being cached.
    55 * Author: Samuel Aguilera
    6  * Version: 1.4.15
     6 * Version: 1.4.16
    77 * Author URI: https://www.samuelaguilera.com
    88 * Text Domain: fresh-forms-for-gravity
     
    2727*/
    2828
    29 define( 'FRESH_FORMS_FOR_GRAVITY_VERSION', '1.4.15' );
     29define( 'FRESH_FORMS_FOR_GRAVITY_VERSION', '1.4.16' );
    3030
    3131// Scripts handlers for plugins using them for exclusion filters (e.g. SG Optimizer or Hummingbird). - Defined here to allow WordPress functions to access them.
  • fresh-forms-for-gravity/trunk/readme.txt

    r3043806 r3043837  
    44Requires at least: 4.9
    55Tested up to: 6.4.3
    6 Stable tag: 1.4.15
     6Stable tag: 1.4.16
    77Requires PHP: 7.0
    88License: GPLv3
     
    5656* [Page Optimize](https://wordpress.org/plugins/page-optimize/) (Script concatenation only)
    5757* Perfmatters (Delay JS exclusions only)
    58 * SiteGround Optimizer
     58* Speed Optimizer (by SiteGround, the plugin with more name changes in the history of WordPress!)
    5959* Surge
    6060* W3 Total Cache
     
    167167== Changelog ==
    168168
     169= 1.4.16 =
     170
     171* Prevent fatal error if post content is not a string (as required by WordPress has_shortcode function). Which could happen for not supported embedding methods or when a third-party is altering the expected post content.
     172
    169173= 1.4.15 =
    170174
Note: See TracChangeset for help on using the changeset viewer.