• Hi, I’m experiencing the following error when saving posts with the plugin enabled:

    Warning: Undefined array key "menu_status" in /wp-content/plugins/floating-side-tab/includes/classes/admin/class-fsdt-metabox.php on line 88

    Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/floating-side-tab/includes/classes/admin/class-fsdt-metabox.php:88) in /wp-admin/post.php on line 231

    Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/floating-side-tab/includes/classes/admin/class-fsdt-metabox.php:88) in /wp-includes/pluggable.php on line 1450

    Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/floating-side-tab/includes/classes/admin/class-fsdt-metabox.php:88) in /wp-includes/pluggable.php on line 1453

    I’ve fixed it with AI support, but maybe you would like to review and incorporate the fix in your stable version. Error explanation: The core issue is that the code attempts to access array keys (menu_status and post_type_menu) from the $_POST array without first checking if those keys exist, which triggers the “Undefined array key” warning. This warning is then interpreted as output, causing the “headers already sent” error and preventing the post from being saved.

    Here is the suggested improvement of the class-fsdt-metabox.php file:

    function fsdt_save_meta_box($post_id, $post)
    {
    // Check if the nonce field is present and valid
    if (
    !empty($_POST['fsdt_settings_post_nonce_field']) &&
    wp_verify_nonce($_POST['fsdt_settings_post_nonce_field'], 'fsdt_settings_post_nonce')
    ) {
    // Initialize an empty array for meta details
    $fsdt_meta_detail = array();

    // Safely check and sanitize the menu_status key
    if (isset($_POST['fsdt_meta_detail']['menu_status'])) {
    $fsdt_meta_detail['menu_status'] = sanitize_text_field($_POST['fsdt_meta_detail']['menu_status']);
    } else {
    // Set a default value if the key is not present
    $fsdt_meta_detail['menu_status'] = '';
    }

    // Safely check and sanitize the post_type_menu key
    if (isset($_POST['fsdt_meta_detail']['post_type_menu'])) {
    $fsdt_meta_detail['post_type_menu'] = sanitize_text_field($_POST['fsdt_meta_detail']['post_type_menu']);
    } else {
    // Set a default value if the key is not present
    $fsdt_meta_detail['post_type_menu'] = 'Default';
    }

    // Update the post meta with the safely retrieved and sanitized data
    update_post_meta($post_id, 'fsdt_meta_detail', $fsdt_meta_detail);
    }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support aacesc

    (@aacesc)

    Hello @sko4a

    Thank you for notifying the issue regarding this. We are checking and get back to you shortly.

    Thanks.

    Plugin Support aacesc

    (@aacesc)

    Hello @sko4a

    Just to inform you, we have fixed the issue and already released an update today. Please update the plugin and let us know if the issue has been resolved or not.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Undefined array key “menu_status”’ is closed to new replies.