| 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/maryobrienslp.com/templates/ |
Upload File : |
<?php
/**
* Export SiteOrigin panels_data for a given page to a pretty-printed JSON file.
* Usage: wp --allow-root eval-file export_so_page.php <post_id> <output_file>
*/
$post_id = isset( $args[0] ) ? (int) $args[0] : 0;
$output_file = isset( $args[1] ) ? $args[1] : '';
if ( ! $post_id || ! $output_file ) {
WP_CLI::error( 'Usage: wp eval-file export_so_page.php <post_id> <output_file>' );
}
$post = get_post( $post_id );
if ( ! $post ) {
WP_CLI::error( "Post {$post_id} not found." );
}
$raw = get_post_meta( $post_id, 'panels_data', true );
if ( ! $raw ) {
WP_CLI::error( "No panels_data found for post {$post_id} ({$post->post_title})." );
}
// panels_data is already unserialized by get_post_meta — wrap with page info
$export = [
'page_id' => $post_id,
'page_title' => $post->post_title,
'post_name' => $post->post_name,
'post_status' => $post->post_status,
'panels_data' => $raw,
];
$json = json_encode( $export, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
if ( $json === false ) {
WP_CLI::error( 'json_encode failed: ' . json_last_error_msg() );
}
file_put_contents( $output_file, $json . "\n" );
WP_CLI::success( "Exported \"{$post->post_title}\" (ID {$post_id}) → {$output_file}" );