wpdatatables_filter_serialized

Contents

Description

The filter allows you to modify the serialized content fetched from a URL before it is unserialized and processed as a table in wpDataTables.

Usage

add_filter( 'wpdatatables_filter_serialized', 'customize_serialized_content', 10, 2 );

Parameters

  • $serialized_content string
    The serialized content fetched from the specified URL.
  • $id int
    The table ID.

Examples

// Callback function for the wpdatatables_filter_serialized filter
function customize_serialized_content($serialized_content, $id) {
    // Example: Modify the content if the table ID is 1
    if ($id == 1) {
        $data = unserialize($serialized_content, ["allowed_classes" => false]);
        // Manipulate the data array as needed
        $data['custom_field'] = 'Custom Value';
        $serialized_content = serialize($data);
    }

    return $serialized_content;
}

add_filter( 'wpdatatables_filter_serialized', 'customize_serialized_content', 10, 2 );