DEV Community

lray138
lray138

Posted on

The Biggest Mind F**k

"this will be the day"

reality,

It's just another day keep moving.

...

function get_config_page(string $template): ?WP_Post
{
    $slug = basename($template, '.php');

    $q = new WP_Query([
        'post_type'      => 'page',
        'posts_per_page' => 1,
        'name'           => $slug,
        'meta_query'     => [
            [
                'key'   => '_wp_page_template',
                'value' => 'templates/template-config.php',
            ],
        ],
    ]);

    return $q->have_posts() ? $q->posts[0] : null;
}
Enter fullscreen mode Exit fullscreen mode

is obviously a Claude generated functoin since I use pascal case.

I will change this to tryConfigPage where now try is the version of "get" that returns a Result.

hermm

// $sections->forEach( function( Kvm $s, Num $n ) use ( &$out, $type, $data ) {
//     $out = $out->append( handlePageSection(
//         $s->set( 'index', $n )
//             ->set( 'id', Str::of("s")->append($n) ) 
//             ->set( 'complex_field', $type )
//             ->set( 'data', $data )
//     ) );
// } );

$out = $sections->reduce(function(array $acc, array $x) use (&$out, $type, $data) {
    $x = Kvm::of($x);
    return [$acc[0]->append(handlePageSection(
        $x->set( 'index', $acc[1] )
            ->set( 'id', Str::of("s")->append($acc[1]) ) 
            ->set( 'complex_field', $type )
            ->set( 'data', $data )
    )), $acc[1] + 1];
}, [Str::of(''), 0]);

return Str::of($out[0]);
Enter fullscreen mode Exit fullscreen mode

P.S.

I don't care if this is all over the place and doesn't make sense...

I will hopefully come back and clean this up and turn it into something valueble.

Top comments (0)