Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1470908

    Can you help with this?

    We currently have a problem that we get SQL detection false positives when we enter text while editing a blog. This causes an error and while investigating that problem we observe this error being generated by the ENFOLD Child Theme. We updated to 6.0.6 and still get this error

    [Fri Nov 08 12:53:01.560984 2024] [error] [pid 1716378] mod_proxy_fcgi.c(911): [client 93.123.39.107:0] AH01071: Got error ‘PHP message: PHP Warning: Attempt to read property “post_content” on null in /data/sites/web/axvecocom/www/wp-content/themes/enfold/includes/helper-assets.php on line 374; PHP message: PHP Warning: Attempt to read property “ID” on null in /data/sites/web/axvecocom/www/wp-content/themes/enfold/includes/helper-assets.php on line 382’

    #1470933

    Hey adowdalls,

    What happens if you remove all custom code in your child theme?

    Best regards,
    Rikard

    #1470943

    Assuming you refer to functions.php – then our site would not work! we have code in functions.php to enable the learning management system learndash to operate and to avoid conflicts between woocommerce shop and ENFOLD. We have not made any changess in this for some time. The problem of false SQL detection and helper-assets is very recent

    This is the code in the functions.php – do you see anything that may cause problems?:
    <?php

    /*
    * Add your own functions here. You can also copy some of the theme functions into this file.
    * WordPress will use those functions instead of the original functions then.
    */

    /*
    * Remove fields from woocommerce checkout page
    * /
    /**
    Remove all possible fields by removing the commented out areas
    **/
    function wc_remove_checkout_fields( $fields ) {

    // Billing fields
    //
    /*
    unset( $fields[‘billing’][‘billing_company’] );
    unset( $fields[‘billing’][‘billing_email’] );
    unset( $fields[‘billing’][‘billing_phone’] );
    unset( $fields[‘billing’][‘billing_state’] );
    unset( $fields[‘billing’][‘billing_first_name’] );
    unset( $fields[‘billing’][‘billing_last_name’] );
    unset( $fields[‘billing’][‘billing_address_1’] );
    unset( $fields[‘billing’][‘billing_address_2’] );
    unset( $fields[‘billing’][‘billing_city’] );
    unset( $fields[‘billing’][‘billing_postcode’] );
    */

    // Shipping fields
    /*
    unset( $fields[‘shipping’][‘shipping_company’] );
    unset( $fields[‘shipping’][‘shipping_phone’] );
    unset( $fields[‘shipping’][‘shipping_state’] );
    unset( $fields[‘shipping’][‘shipping_first_name’] );
    unset( $fields[‘shipping’][‘shipping_last_name’] );
    unset( $fields[‘shipping’][‘shipping_address_1’] );
    unset( $fields[‘shipping’][‘shipping_address_2’] );
    unset( $fields[‘shipping’][‘shipping_city’] );
    unset( $fields[‘shipping’][‘shipping_postcode’] );
    */
    // Order fields
    unset( $fields[‘order’][‘order_comments’] );

    return $fields;
    }
    add_filter( ‘woocommerce_checkout_fields’, ‘wc_remove_checkout_fields’ );

    /** Added 22 Feb 2021 by Alex to enable SMTP email usage
    *
    * This function will connect wp_mail to your authenticated
    * SMTP server. This improves reliability of wp_mail, and
    * avoids many potential problems.
    *
    * For instructions on the use of this script, see:
    * https://butlerblog.com/easy-smtp-email-wordpress-wp_mail/
    *
    * Values for constants are set in wp-config.php
    */
    add_action( ‘phpmailer_init’, ‘send_smtp_email’ );
    function send_smtp_email( $phpmailer ) {
    $phpmailer->isSMTP();
    $phpmailer->Host = SMTP_HOST;
    $phpmailer->SMTPAuth = SMTP_AUTH;
    $phpmailer->Port = SMTP_PORT;
    $phpmailer->Username = SMTP_USER;
    $phpmailer->Password = SMTP_PASS;
    $phpmailer->SMTPSecure = SMTP_SECURE;
    $phpmailer->From = SMTP_FROM;
    $phpmailer->FromName = SMTP_NAME;
    }

    /* Replace logo based on ‘promotion code’ – Jelmer*/
    add_action( ‘wp_head’, ‘logo_css’, 0 );
    function logo_css() {
    $user = wp_get_current_user();
    $user_info = get_userdata($user->ID);
    $code = $user->promotion_code;
    if( strcasecmp($code, ‘RightBrains’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2020/04/rsz_1rightbrains.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘Polaris’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2020/04/rsz_polaris.jpg) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘Nyenrode’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2020/03/Logo-Small.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘StrategyWorks’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2020/09/SWSA-LOGO-3-1-e1600615027209.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘EXIN’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2021/02/Screenshot-2021-02-25-at-16.18.48.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘Beeckestijn’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2020/05/Beeckestijn.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘HQAI2021’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2020/05/Screenshot-2020-05-01-at-13.53.02.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘Assurant2020’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2020/05/rsz_assurant-logo.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘Computrain’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2021/02/CT-Small-Logo.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘NCOI’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2021/02/NCOI-Small-Logo.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘NCD’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2021/03/NCD-Kleiner.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘Randstad’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2021/04/Randstad.png) no-repeat;}</style></head>”;
    }
    if( strcasecmp($code, ‘GK2021’) == 0){
    echo “<style>span.logo{display:none;}</style></head>”;
    echo “<style>div.inner-container{background:url(https://axveco.com/wp-content/uploads/2021/04/GK-Logo-small-1.jpg) no-repeat;}</style></head>”;
    }
    }

    /* ‘Edit profile’ redirects to profile page – Jelmer*/
    add_action( ‘load-profile.php’, ‘Redirect_profile_axveco’);
    function Redirect_profile_axveco (){
    if( ! current_user_can( ‘manage_options’ ) )
    exit( wp_safe_redirect( “https://axveco.com/en/profile/&#8221; ) );
    }

    /* Redirect wp-login to loginwp screen – Jelmer*/
    add_filter( ‘login_url’, ‘my_login_page’, 10, 3 );
    function my_login_page( $login_url, $redirect, $force_reauth ) {
    $login_page = “https://axveco.com/en/loginwp/&#8221; ;
    $login_url = add_query_arg( ‘redirect_to’, $redirect, $login_page );
    return $login_url;
    }

    /* Shows headers promotion code in the admin user table – Jelmer*/
    add_filter(‘manage_users_columns’, ‘add_promotion_code_column’);
    function add_promotion_code_column($columns) {
    $columns[‘promotion_code’] = ‘Promotion Code’;
    return $columns;
    }
    /* Shows content promotion code in the admin user table – Jelmer */
    add_action(‘manage_users_custom_column’, ‘show_user_promotion_code_column_content’, 10, 3);
    function show_user_promotion_code_column_content($value, $column_name, $user_id) {
    $user = get_userdata( $user_id );
    if ( ‘promotion_code’ == $column_name )
    return $user->promotion_code;
    return $value;
    }

    /*Archive category page layout JP https://kriesi.at/support/topic/category-archive-page-change-layout-to-show-excerpt
    add_filter(‘avf_blog_style’,’avia_change_category_blog_layout’, 10, 2);
    function avia_change_category_blog_layout($layout, $context){
    if($context == ‘archive’) $layout = ‘single-big’;
    return $layout;
    }*/

    add_filter(‘avf_blog_style’,’avia_change_category_blog_layout’, 10, 2);
    function avia_change_category_blog_layout($layout, $context){
    if($context == ‘archive’) $layout = ‘blog-grid’;
    return $layout;
    }

    add_action(‘wp_footer’, ‘add_custom_tooltip’);
    function add_custom_tooltip(){
    ?>
    <script>
    jQuery(window).load(function(){
    jQuery(‘a’).removeAttr(‘title’);
    jQuery(‘img’).removeAttr(‘title’);
    });
    </script>
    <?php
    }

    /*
    * This function is required to display the location map on the contact us page
    * if removed then the map does not display – API key is from Theme Google services
    */
    add_action(‘wp_footer’, ‘gmaps_workaround’);
    function gmaps_workaround(){
    ?>
    <!–Google Maps JavaScript API –>
    <script src=”https://maps.googleapis.com/maps/api/js?key=AIzaSyCWwtEsgQqGTvuqmzrZMapkbyzqyxCKZBw”
    type=”text/javascript”></script>
    <script type=”text/javascript”>
    jQuery(document).ready(function($){
    setTimeout(function(){
    $(‘#s_pdf_frame’).attr( ‘src’, function ( i, val ) { return val; });
    }, 100);
    });
    </script>
    <?php
    }

    // add_action(‘avia_builder_mode’, “builder_set_debug”);
    function builder_set_debug()
    {
    return “debug”;
    }

    /*
    * this funciton has been updated – see above post in header
    * the original code is: $meta[‘page’][] = ‘events’;
    *
    * Adds PageBuilder to LearnDash Post Typs
    * this is to enable the Advanced Builder in LearnDash – Alex
    * see post at https://kriesi.at/support/topic/learndash-plugin/
    *
    }*/
    add_filter(‘avf_builder_boxes’, ‘add_builder_to_posttype’);
    function add_builder_to_posttype($metabox)
    {
    foreach($metabox as &$meta)
    {
    if($meta[‘id’] == ‘avia_builder’ || $meta[‘id’] == ‘layout’)
    {
    /* original code: $meta[‘page’][] = ‘events’; instead add the name of the custom post type here*/
    $meta[‘page’][] = ‘sfwd-courses’;
    $meta[‘page’][] = ‘sfwd-lessons’;
    $meta[‘page’][] = ‘sfwd-topic’;
    $meta[‘page’][] = ‘sfwd-quiz’;
    }
    }
    return $metabox;
    }

    /*
    * After installing Woocommerce bookings, the events table function was no longer needed
    * I cannot determine whether ‘Events’ post type here is related to events…
    */
    add_action( ‘init’, ‘create_post_type’ );
    function create_post_type() {
    register_post_type( ‘Events’,
    array(
    ‘labels’ => array(
    ‘name’ => __( ‘Events’ ),
    ‘singular_name’ => __( ‘Event’ )
    ),
    ‘public’ => true,
    ‘has_archive’ => false,
    ‘hierarchical’ => true,
    ‘supports’ => array( ‘title’, ‘editor’)
    )
    );

    register_taxonomy(
    ‘event_categories’, //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
    ‘events’, //post type name
    array(
    ‘hierarchical’ => true,
    ‘label’ => ‘Categories’, //Display name
    ‘query_var’ => true
    )
    );
    }
    /*
    * Goal here is to disable woocommerce from opening the default shop page which is incompatible with
    * our ENFOLD Child theme and appears to be the cause of the Internal Server Error intermittent failure
    * We log that the event has occurred, disbale woocommerce and then redirect to a safe page
    */
    function custom_woocommerce_redirect_shop_page() {
    if (is_shop()) {
    // Send an email to log that this event has occured

    // Get the current user info
    $current_user = wp_get_current_user();
    $username = $current_user->user_login;
    //$is_logged_in = is_user_logged_in() ? ‘Yes’ : ‘No’;

    // Send email notification if logged in (not logged in generates a hit every minute)
    if (is_user_logged_in()) {
    $to = (Email address hidden if logged out) ‘;
    $subject = ‘WooCommerce Shop Page Disable invoked’;
    $message = ‘The WooCommerce shop page open was attempted and has been disabled.’;
    $message .= ‘<br>User: ‘ . $username;
    //$message .= ‘<br>Logged in: ‘ . $is_logged_in;
    $headers = array(‘Content-Type: text/html; charset=UTF-8’);

    wp_mail($to, $subject, $message, $headers);
    }
    // Remove the default WooCommerce content for the shop page
    remove_action(‘woocommerce_archive_description’, ‘woocommerce_taxonomy_archive_description’, 10);
    remove_action(‘woocommerce_archive_description’, ‘woocommerce_product_archive_description’, 10);
    remove_action(‘woocommerce_before_main_content’, ‘woocommerce_output_content_wrapper’, 10);
    remove_action(‘woocommerce_after_main_content’, ‘woocommerce_output_content_wrapper_end’, 10);
    remove_action(‘woocommerce_sidebar’, ‘woocommerce_get_sidebar’, 10);

    // Set up a target page to redirect to
    $alternative_shop_page = “https://axveco.com/en/your-next-step/&#8221; ;

    // Redirect to our own next steps page
    wp_redirect($alternative_shop_page);

    exit;
    }
    }
    add_action(‘template_redirect’, ‘custom_woocommerce_redirect_shop_page’);

    /*
    * End of functions.php
    */
    ?>

    #1470981

    Update on further testing – I only get this SQL insert error when i am using the Avia Screen Builder. I can update a post or a Learn Dash (our learning system) Topic (which is stored as a post) when i use the default editor.

    The problem seems to be confined to updated a LearnDash topic when using the Avia Screen Builder. We have Gutenberg disabled

    Does this help point to the source of the problem?

    Alex

    #1471042

    Hi,

    Thank you for the info.

    Please looks for the av_video_assets_required function in enfold\includes\helper-assets.php file and replace it with the following code. Let us know of the result.

    /**
     * Checks the entries for the current page for av_video, av_audio, <audio>, <video> and background video elements.
     *
     * @since 4.3
     * @added_by Kriesi
     * @param array $assets
     */
    function av_video_assets_required() {
        global $posts;
    
        // Check if we are editing a LearnDash topic and return early if true
        if ( is_admin() ) {
            $screen = get_current_screen();
            if ( $screen && $screen->post_type === 'sfwd-topic' ) {
                return false;
            }
        }
    
        $used = false;
    
        if ( ! is_array( $posts ) ) {
            return $used;
        }
    
        /**
         * https://kriesi.at/support/topic/mediaelement-loading-on-every-page/
         * Default values https://  https:// are regarded as video => extended $regex
         *
         * @since 5.6.7
         */
        $regex = "!\[av_blog|\[av_postslider|\[av_video|\[av_audio|\[av_player|\[audio|<audio|<video|video\=\'http[s]?:\/\/[^']?\S{2,}\'|video\=\"http[s]?:\/\/[^\"]?\S{2,}\"!im";
    
        foreach ( $posts as $post ) {
            $matches = array();
            $found = preg_match_all( $regex, $post->post_content, $matches, PREG_OFFSET_CAPTURE );
    
            if ( ! empty( $found ) ) {
                $used = true;
                break;
            }
    
            $format = get_post_format( $post->ID );
    
            if ( $format == 'audio' || $format == 'video' ) {
                $used = true;
                break;
            }
        }
    
        return $used;
    }
    

    You can also set the Enfold > Performance > Self Hosted Videos And Audio Features (WP-Mediaelement Scripts) to “Always load media features” to avoid the check above.

    Best regards,
    Ismael

    #1471159

    Thanks – I have implemented both steps and will monitor the error log to see if the problem has been resolved

    #1471179

    Hi,

    We’ll keep the thread open. Please let us know if the issue occurs again.

    Best regards,
    Ismael

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.