403Webshell
Server IP : 198.71.58.22  /  Your IP : 216.73.216.72
Web Server : Apache/2.4.62 (AlmaLinux) OpenSSL/3.2.2
System : Linux localhost 5.14.0-570.33.2.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 14 07:37:35 EDT 2025 x86_64
User : root ( 0)
PHP Version : 8.3.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/gladstonespeech.com/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/gladstonespeech.com//export_all_pages.php
<?php
/**
 * Export all published pages to templates/<post_name>.json
 * Run: wp --allow-root eval-file export_all_pages.php
 */

$templates_dir = __DIR__ . '/templates';

$pages = get_posts( [
    'post_type'      => 'page',
    'post_status'    => 'publish',
    'posts_per_page' => -1,
    'orderby'        => 'title',
    'order'          => 'ASC',
] );

foreach ( $pages as $page ) {
    $post_id   = $page->ID;
    $slug      = $page->post_name;
    $out_file  = "{$templates_dir}/{$slug}.json";

    $raw = get_post_meta( $post_id, 'panels_data', true );

    if ( ! $raw ) {
        WP_CLI::warning( "  Skipped \"{$page->post_title}\" (ID {$post_id}) — no panels_data." );
        continue;
    }

    $export = [
        'page_id'     => $post_id,
        'page_title'  => $page->post_title,
        'post_name'   => $slug,
        'post_status' => $page->post_status,
        'panels_data' => $raw,
    ];

    $json = json_encode( $export, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );

    if ( $json === false ) {
        WP_CLI::warning( "  JSON encode failed for \"{$page->post_title}\": " . json_last_error_msg() );
        continue;
    }

    file_put_contents( $out_file, $json . "\n" );
    $lines = substr_count( $json, "\n" ) + 1;
    WP_CLI::success( "  \"{$page->post_title}\" (ID {$post_id}) → {$slug}.json ({$lines} lines)" );
}

Youez - 2016 - github.com/yon3zu
LinuXploit