function pl_upload_config_file()
{
    $fileOpts = new EditorFileOpts();
    $filename = $_FILES['files']['name'][0];
    $opts = array();
    $opts['global_import'] = $_POST['global_import'];
    $opts['type_import'] = $_POST['type_import'];
    $opts['page_tpl_import'] = $_POST['page_tpl_import'];
    if (preg_match('/pl\\-config[^\\.]*\\.json/', $filename)) {
        $file = $_FILES['files']['tmp_name'][0];
        $response['file'] = $file;
        if (isset($file)) {
            $response['import_reponse'] = $fileOpts->import($file, $opts);
        }
        $response['import_file'] = $file;
        $response['post'] = $_POST;
    } else {
        $response['import_error'] = $filename;
    }
    echo json_encode(pl_arrays_to_objects($response));
    die;
}
 function reset_global_child($opts)
 {
     $fileOpts = new EditorFileOpts();
     if ($fileOpts->file_exists()) {
         $fileOpts->import($fileOpts->file_exists(), $opts);
     }
 }
示例#3
0
    function import_template()
    {
        ob_start();
        $fileOpts = new EditorFileOpts();
        $show_child_import = $fileOpts->file_exists() ? true : false;
        ?>
		
		<label class="checklist-label media" for="page_tpl_import">
			<div class="img"><input name="page_tpl_import" id="page_tpl_import" type="checkbox" checked /></div>
			<div class="bd">
				<div class="ttl"><?php 
        _e('Import Page Templates', 'pagelines');
        ?>
				</div>
				<p><?php 
        _e('Add new templates and overwrite ones with the same name.', 'pagelines');
        ?>
				</p>
			</div>
		</label>
		<label class="checklist-label media" for="global_import">
			<div class="img"><input name="global_import" id="global_import" type="checkbox" checked /></div>
			<div class="bd">
				<div class="ttl"><?php 
        _e('Import New Global Settings', 'pagelines');
        ?>
				</div>
				<p><?php 
        _e('Overwrite global settings with ones from this import.', 'pagelines');
        ?>
				</p>
			</div>
		</label>
		<label class="checklist-label media" for="type_import">
			<div class="img"><input name="type_import" id="type_import" type="checkbox" checked /></div>
			<div class="bd">
				<div class="ttl"><?php 
        _e('Import Post Type Settings', 'pagelines');
        ?>
				</div>
				<p><?php 
        _e('Overwrite post type settings with ones from this import.', 'pagelines');
        ?>
				</p>
			</div>
		</label>
		
	
	
		
		<label><?php 
        _e('DMS Config Import', 'pagelines');
        ?>
		</label>
		
		<span class="btn btn-success fileinput-button import-button">
	        <i class="icon icon-plus"></i>
	        <span><?php 
        _e('Select config file (.json)', 'pagelines');
        ?>
	        </span>
	        <!-- The file input field used as target for the file upload widget -->
	        <input id="fileupload" type="file" name="files[]" multiple>
	    </span>
	
	
		<?php 
        if ($show_child_import) {
            ?>

			<label><?php 
            _e('Child Theme Config Import', 'pagelines');
            ?>
			</label>

			<div class="child-import">
				<a href="#" data-action="reset_global_child" class="btn settings-action btn-warning"><i class="icon icon-download"></i> <?php 
            _e('Load Child Theme Config', 'pagelines');
            ?>
</a>

				<div class="help-block">
					<?php 
            _e('Reset theme settings using custom config file from child theme.<br />
					<strong>Note:</strong> Once you have completed this action, you may want to publish these changes to your live site.', 'pagelines');
            ?>
					
				</div>
			</div>
		<?php 
        }
        ?>
	
	
		<?php 
        return ob_get_clean();
    }
示例#4
0
 function import_from_child()
 {
     $fileOpts = new EditorFileOpts();
     $fileOpts->import(trailingslashit(get_stylesheet_directory()) . 'pl-config.json', array());
     // only do this once!! The user will still have the option to import again under import/export menus.
     set_theme_mod('import_from_child', true);
 }