Plugin Directory

Changeset 3349074


Ignore:
Timestamp:
08/23/2025 09:39:25 PM (7 months ago)
Author:
jhorowitz
Message:

Catch errors in visibility expression evaluation and email site admins when this occurs.

Location:
content-visibility-for-divi-builder/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • content-visibility-for-divi-builder/trunk/content-visibility-for-divi-builder.php

    r2682153 r3349074  
    88 * Plugin Name:       Content Visibility for Divi Builder
    99 * Description:       Allows Sections and Modules to be displayed/hidden based on the outcome of a PHP boolean expression.
    10  * Version:           3.22
     10 * Version:           3.23
    1111 * Author:            AoD Technologies LLC
    1212 * Author URI:        http://www.aod-tech.com/
     
    114114    $wp_version = get_bloginfo( 'version' );
    115115
    116     $version = '3.22';
     116    $version = '3.23';
    117117    $stored_version = get_option( 'content_visibility_for_divi_builder_version' );
    118118
     
    176176
    177177                    $visibility = true;
    178 
    179                     eval( '$visibility = ' . str_replace( array( '%22', '%5D' ), array( '"', ']' ), $atts['cvdb_content_visibility_check'] ) . ';' );
     178                    $expression = str_replace( array( '%22', '%5D' ), array( '"', ']' ), $atts['cvdb_content_visibility_check'] );
     179
     180                    try {
     181                        eval( '$visibility = ' . $expression . ';' );
     182                    } catch (ParseError | Error $error) {
     183                        global $wp;
     184                        global $wp_filesystem;
     185
     186                        $attachment_file_name = wp_tempnam();
     187                        try {
     188                            $attachments = array();
     189                            $error_message_format = "An error has been detected while evaluating a visibility expression.\nNOTE: This section/module will not be displayed until the error is corrected.\n\nPage URL:\n%1\$s\n\nVisibility expression:\n%2\$s\n\nError message:\n%3\$s";
     190
     191                            if ( $wp_filesystem->put_contents( $attachment_file_name, print_r( $et_pb_element, true ), FS_CHMOD_FILE ) ) {
     192                                $error_message_format .= "\n\nThe full Divi Section/Module shortcode is attached to this email for reference.";
     193                                $attachments['full-divi-shortcode.txt'] = $attachment_file_name;
     194                            }
     195
     196                            wp_mail( get_bloginfo( 'admin_email' ), '[' . get_bloginfo( 'name' ) . '] Content Visibility for Divi Builder - Visibility Expression Error Detected', sprintf( $error_message_format, home_url( add_query_arg( isset( $_SERVER['QUERY_STRING'] ) ? $_SERVER['QUERY_STRING'] : array(), '', $wp->request ) ), $expression, $error->getMessage() ), array('Content-Type: text/plain; charset=UTF-8'), $attachments );
     197                        } finally {
     198                            $wp_filesystem->delete( $attachment_file_name, false, 'f' );
     199                        }
     200
     201                        $visibility = false;
     202                    }
    180203
    181204                    if ( !$visibility ) {
  • content-visibility-for-divi-builder/trunk/readme.txt

    r2876806 r3349074  
    33Donate link: https://www.aod-tech.com/donate/
    44Tags: divi, divi theme, divi builder, elegant themes, elegantthemes, page builder, pagebuilder, conditional-tags, conditional tags, conditional, tags, show, hide, show hide
    5 Requires at least: 3.0
    6 Tested up to: 6.1.1
    7 Stable tag: 3.22
     5Requires at least: 4.7
     6Tested up to: 6.8.2
     7Requires PHP: 7.0
     8Stable tag: 3.23
    89License: GPLv2 or later
    910License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5556
    5657== Changelog ==
     58= 3.23 =
     59* Catch errors in visibility expression evaluation; this allows the rest of the page to load while only hiding the module or section that triggered the error.
     60* Email site admin when errors in visibility expression evalution occur with helpful debugging information (i.e. the error that occured, the URL on which it occured, and the full shortcode contents of the relevant module or section as an attachment).
     61
    5762= 3.22 =
    5863* Fix compatibility with Stop Spammers plugin. Thanks to @kindred for providing access to a test environment exhibiting the issue!
Note: See TracChangeset for help on using the changeset viewer.