Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mlbd/b748ee08ea3995ad2f233b99cc819451 to your computer and use it in GitHub Desktop.
Save mlbd/b748ee08ea3995ad2f233b99cc819451 to your computer and use it in GitHub Desktop.
/**
*
* Import Class
* A helper class for support CS to OCDI
*
*/
if ( !class_exists( 'OCDI_Plugin' ) )
return;
class CS_Import_OCDI {
public $title;
public function __construct($title = 'Codestart Framework data uploaded') {
$this->title = $title;
add_action('pt-ocdi/after_content_import_execution', array($this, 'cs_import_init'), 3, 99 );
}
public function cs_decode_string( $string ) {
return unserialize( $string );
}
public function cs_import_init( $selected_import_files, $import_files, $selected_index ) {
if ( !class_exists( 'CSFramework' ) ) {
return;
}
$downloader = new OCDI\Downloader();
if( ! empty( $import_files[$selected_index]['local_import_cs'] ) ) {
foreach( $import_files[$selected_index]['local_import_cs'] as $index => $import ) {
$file_path = $import['file_path'];
$file_raw = OCDI\Helpers::data_from_file( $file_path );
update_option( $import['option_name'], cs_decode_string( $file_raw, true ) );
}
}
$ocdi = OCDI\OneClickDemoImport::get_instance();
$log_path = $ocdi->get_log_file_path();
OCDI\Helpers::append_to_file( $this->title, $log_path );
}
}
$cs_init = new CS_Import_OCDI();
@pavliukpetro
Copy link

Hello. I tried these files but it wasn't working for me. Tell me, please, where should I put the code?

@mlbd
Copy link
Author

mlbd commented Nov 28, 2019

@pavlyukpetr you just need to put both of them in your theme functions.php or any other fucntions file you want to

@WPsmart
Copy link

WPsmart commented Apr 2, 2020

Hi

I try this method, but Ideta import not working, but log file shows it's uploaded?

i change file path (fake path) and test, but fake URL also show as Framework data uploaded in a log file

any suggestions for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment