Пример #1
0
 function install($package)
 {
     $this->init();
     $this->install_strings();
     global $wp_filesystem;
     //add_filter('upgrader_source_selection', array($this, 'check_package') );
     // $package is the path to zip file, so unzip it
     $destination = OP_LIB . 'content_layouts/working';
     // clear destination
     foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($destination, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
         $path->isFile() ? unlink($path->getPathname()) : rmdir($path->getPathname());
     }
     if (class_exists('ZipArchive')) {
         $zip = new ZipArchive();
         if ($zip->open($package) === true) {
             $zip->extractTo($destination);
             $zip->close();
             echo $this->strings['process_success'];
             // install the template
             require_once OP_LIB . 'admin/install.php';
             $ins = new OptimizePress_Install();
             $this->result = $ins->add_content_templates($destination, '', '', true, false);
             // refresh everything
             $GLOBALS['op_layout_uploaded'] = true;
             echo '<script type="text/javascript">var win = window.dialogArguments || opener || parent || top; win.op_refresh_content_layouts();</script>';
         } else {
             echo $this->strings['process_failed'];
         }
     } else {
         require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
         $zip = new PclZip($package);
         $zip->extract(PCLZIP_OPT_PATH, $destination);
         echo $this->strings['process_success'];
         // install the template
         require_once OP_LIB . 'admin/install.php';
         $ins = new OptimizePress_Install();
         $this->result = $ins->add_content_templates($destination, '', '', true, false);
         // refresh everything
         $GLOBALS['op_layout_uploaded'] = true;
         echo '<script type="text/javascript">var win = window.dialogArguments || opener || parent || top; win.op_refresh_content_layouts();</script>';
     }
     /*$this->run(array(
     					'package' => $package,
     					'destination' => OP_LIB.'content_layouts/working',//rtrim(OP_ASSETS,'/'),
     					'clear_destination' => true, //Do not overwrite files.
     					'clear_working' => true,
     					//'hook_extra' => array($this,'install_content_layout')
     					));
     
     		remove_filter('upgrader_source_selection', array($this, 'check_package') );
     
     		if ( ! $this->result || is_wp_error($this->result) )
     			return $this->result;
     		*/
     // Force refresh of plugin update information
     //delete_site_transient('update_plugins');
     //remove_filter('upgrader_source_selection', array($this, 'check_package') );
     return true;
 }
Пример #2
0
 function content_templates_reset($op)
 {
     $reset = op_get_var($op, 'content_templates_reset');
     if (!empty($reset)) {
         global $wpdb;
         // removing old templates from db
         $sql = "delete from " . $wpdb->prefix . "optimizepress_predefined_layouts";
         $wpdb->query($sql);
         // removing option
         delete_option(OP_SN . '_content_templates_version');
         require_once OP_ADMIN . 'install.php';
         $install = new OptimizePress_Install();
         $install->install_content_templates();
     }
 }