Escaping inline JS correctly

The wp_kses() call looks to me unneccessary as you’re already escaping the values within the foreach loop. esc_js() should be just fine as the strings are mostly hard-coded and the only part that is changing is the date value, so escape that. If value is always 1, then escaping it doesn’t add any real value.

If you want to make the code a bit more readable, I would suggest first mapping the posts into a PHP array and then turning it into script friendly format with json_encode() and wp_add_inline_script(). This way there is a smaller risk of having typos in the code and data variable.

function test_dashboard_content(): void {
    $testlist = json_encode( wpse_425118_get_posts_data() );
    
    wp_add_inline_script(
        'my-script-handle',
        "var massive = {$testlist};",
        'before'
    );
}

function wpse_425118_get_posts_data(): array {
    $posts = get_posts( array( 
        'posts_per_page' => -1,
        'post_type' => array( 'post', 'page' ),
        'post_status' => 'publish',
        'date_query' => array( 'after' => '1 year ago' )
    ) );

    return array_map(
        function( WP_Post $post ) {
            return array(
                'date' => esc_attr( get_the_date( 'Y-n-j', $post ) ),
                'value' => 1,
            );
        },
        $posts
    );
}

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino