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
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;
}
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,
);
}
}
}
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.