• Resolved siavashkhazaei

    (@siavashkhazaei)


    Warning: Undefined variable $post in?/home/****/public_html/wp-content/plugins/adminimize/adminimize.php?on line?285

    Warning: Attempt to read property “ID” on null in?/home/*****/public_html/wp-content/plugins/adminimize/adminimize.php?on line?285

Viewing 8 replies - 1 through 8 (of 8 total)
  • Same warning fills debug.log

    same here
    roll back to 1.11.9

    Same warning fills debug.log


    Warning: Undefined variable $post in /wp-content/plugins/adminimize/adminimize.php on line 285

    Warning: Attempt to read property “ID” on null in /wp-content/plugins/adminimize/adminimize.php on line 285

    choegl

    (@choegl)

    Enclosing line 285 in an if statement and checking if $post is set resolves the issue. Necessary code below. Replace line 285 of adminimize.php with the entire code.

    What is the best way to get that included in the next official release?

        // Ensure $post is set and not null before accessing its properties
        if ( isset( $post ) && $post !== null ) {
            $current_post_type = get_post_type($post->ID);   // current line 285
        } else {
            // Fallback logic if $post is not set or is null
            $current_post_type = null;
        }
    choegl

    (@choegl)

    Turns out this resulted in another error in inc-setup/dashboard.php. I replaced the loop in lines 150-177 with this code:

    foreach ( (array) $wp_meta_boxes['dashboard'] as $context => $datas ) {
    
    foreach ( (array) $datas as $priority => $data ) {
    
    foreach ( (array) $data as $widget => $value ) {
    
    // Use a temporary variable for title manipulation
    
    $title = isset($value['title']) ? $value['title'] : '';
    
    // Convert boolean false to an empty string
    
    if ($title === FALSE) {
    
    $title = '';
    
    }
    
    // If title is an array, reset to empty string
    
    if (is_array($title)) {
    
    $title = '';
    
    }
    
    $widgets[$widget] = array(
    
    'id' => $widget,
    
    'title' => strip_tags(
    
    preg_replace('/( |)<span.*span>/im', '', $title)
    
    ),
    
    'context' => $context,
    
    'priority' => $priority,
    
    );
    
    }
    
    }
    
    }

    Thanks a lot.

    Anyone know when the fix for this will be updated in the plugin? Filling my debug log as well. Not really feeling confident to change some of the code that choegl talked about.

    Plugin Author Frank Bueltge

    (@bueltge)

    @choegl The current version does not have this line of code, you are in the last version 1.11.10?
    see https://github.com/wp-media/adminimize/blob/ae8f7b0d75f6d783f2b4572e3f92fca05fb5559b/adminimize.php#L285

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WordPress Debug line 285’ is closed to new replies.