dir = VAMTAM_SAMPLES_DIR . 'revslider';
}
/**
* Registered callback function for the WordPress Importer
*
* Manages the three separate stages of the WXR import process
*/
public function dispatch() {
$this->header();
check_admin_referer( 'vamtam-import-revslider' );
set_time_limit( 0 );
$this->import( );
$this->footer();
}
/**
* The main controller for the actual import stage.
*/
public function import() {
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
$this->import_start();
wp_suspend_cache_invalidation( true );
$this->import_sliders();
wp_suspend_cache_invalidation( false );
$this->import_end();
}
private function import_sliders() {
$dir = opendir( $this->dir );
ob_start();
while ( $file = readdir( $dir ) ) {
if ( $file != '.' && $file != '..' && preg_match( '/\.zip$/', $file ) ) {
$origpath = $this->dir . '/' . $file;
if ( ! isset( $_FILES['import_file'] ) ) {
$_FILES['import_file'] = array(
'name' => $file,
'type' => 'application/zip',
'error' => 0,
'size' => filesize( $origpath ),
);
}
$temp = tmpfile();
fwrite( $temp, file_get_contents( $origpath ) );
$meta_data = stream_get_meta_data( $temp );
$filepath = $meta_data['uri'];
$_FILES['import_file']['tmp_name'] = $filepath;
if ( ! defined( 'FS_CHMOD_DIR' ) ) {
define( 'FS_CHMOD_DIR', (0755 & ~ umask()) );
}
$slider = new RevSlider();
$response = $slider->importSliderFromPost( 'true', 'none', false, false, false, 'true' );
if ( WP_DEBUG ) {
echo 'WP_DEBUG enabled
';
echo 'Import status:
';
}
fclose( $temp );
}
}
if ( WP_DEBUG ) {
echo ob_get_clean(); // xss ok
} else {
ob_end_clean();
}
}
private function import_start() {
if ( ! is_dir( $this->dir ) ) {
echo '
' . esc_html__( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
';
echo esc_html__( 'The file does not exist, please try again.', 'wordpress-importer' ) . '
' . esc_html__( 'All done.', 'wordpress-importer' ) . ' ' . esc_html__( 'Have fun!', 'wordpress-importer' ) . '
'; echo ''; do_action( 'import_end' ); } // Display import page title private function header() { echo '