function ultimatum_css_regenerator(){
	
global $wpdb;
$query = "SELECT * FROM `".ULTIMATUM_TABLE_LAYOUT."` WHERE `type`='full' AND `theme`='".$_REQUEST['theme']."'";
$results = $wpdb->get_results($query);
require_once (ULTIMATUM_ADMIN_HELPERS .DS. 'class.css.saver.php');
WonderWorksCSS::saveCSS($_REQUEST['theme'],'template');
echo '<li>Template css file(s) generated.</li>';
foreach ($results as $result){
	WonderWorksCSS::saveCSS($result->id);
	echo "<li>".$result->title.' css file(s) regenerated.</li>';
}
}
function ultimatum_css_generator_fromimport($id,$echo=true){
	global $wpdb;

    $query = "SELECT * FROM `".ULTIMATUM_TABLE_LAYOUT."` WHERE `type`='full' AND `theme`='$id'";
	$results = $wpdb->get_results($query);
	require_once (ULTIMATUM_ADMIN_HELPERS .DS. 'class.css.saver.php');
	WonderWorksCSS::saveCSS($id,'template');
	if($echo) echo '<li>Template css file(s) generated.</li>';
	foreach ($results as $result){
		WonderWorksCSS::saveCSS($result->id);
		if($echo) echo "<li>".$result->title.' css file(s) generated.</li>';
	}
}
	function save_options() {
		$setter='_';
		if(isset($_GET["layout_id"])){
			$setter='_'.$_GET["layout_id"].'_';	
		}
		if(isset($_GET["template_id"])){
			$setter='_template_'.$_GET["template_id"].'_';
		}
		if(preg_match('/ultimatum_/i', $this->name)){
			$optionmane = $this->name;
		} else {
			$optionmane=THEME_SLUG .$setter. $this->name;
		}
		
		$options = get_option($optionmane);
		if('ultimatum_toolset' == $this->name){
			$options = get_site_option($optionmane);
		}
		if (isset($_POST['save_options'])) {
			
			foreach($this->options as $value) {
				
				if (isset($value['id']) && ! empty($value['id'])) {
					if (isset($_POST[$value['id']])) {
						if($value['type'] == 'toggle'){
							if($_POST[$value['id']] == 'true'){
								$options[$value['id']] = true;
							}else{
								$options[$value['id']] = false;
							}
						} else {
							$options[$value['id']] = $_POST[$value['id']];
						}
					} else {
						$options[$value['id']] = false;
					}
				}
				if (isset($value['process']) && function_exists($value['process'])) {
					$options[$value['id']] = $value['process']($value,$options[$value['id']]);
				}
			}
			if ($options != $this->options) {
				if('ultimatum_toolset' == $this->name){
					update_site_option($optionmane, $options);
				} else {
					update_option($optionmane, $options);
				}
				global $theme_options;
				$theme_options[$this->name] = $options;
				if($this->name=='css'){
					require_once (ULTIMATUM_ADMIN_HELPERS .DS. 'class.css.saver.php');
					if(isset($_GET['layout_id'])){
						WonderWorksCSS::saveCSS($_GET["layout_id"]);
					}
					if(isset($_GET['template_id'])){
						WonderWorksCSS::saveCSS($_GET["template_id"],'template');
					}	
				}
			}
			echo '<div id="message" class="updated fade"><p><strong>Updated Successfully</strong></p></div>';
		}
		$this->saved_options = $options;
	}
	static public function partCSS($layoutid){
		global $wpdb;
		$csstable = $wpdb->prefix.ULTIMATUM_PREFIX.'_css';
		$query = "SELECT * FROM $csstable WHERE layout_id='$layoutid'";
		
		$res = $wpdb->get_results($query,ARRAY_A);
		$css='';
		
		foreach($res as $fetch){
			if($fetch["element"]=='general'){
				if($fetch["container"]!='body'){
					if(preg_match('/col-/i',$fetch["container"])){
						$el = '#'.$fetch["container"].' .colwrapper';
					} else {
						$el = '#'.$fetch["container"];
					}
				}else{
					$el = $fetch["container"];
				}
			} elseif($fetch["container"]=='body'){
				if($fetch["element"]=='h1' || $fetch["element"]=='h2' || $fetch["element"]=='h3' || $fetch["element"]=='h4' || $fetch["element"]=='h5' || $fetch["element"]=='h6'){
					$fetch["element"]=$fetch["element"].', '.$fetch["element"].' a,'.$fetch["element"].' a:hover';
				}
				$el = $fetch["element"];
				if($el=='ahover'){$el = 'a:hover'; }
		
			} else {
				if($fetch["element"]=='ahover'){$fetch["element"] = 'a:hover'; }
				if($fetch["element"]=='h1' || $fetch["element"]=='h2' || $fetch["element"]=='h3' || $fetch["element"]=='h4' || $fetch["element"]=='h5' || $fetch["element"]=='h6'){
					//$fetch["element"]=$fetch["element"].', '.$fetch["element"].' a,'.$fetch["element"].' a:hover';
					$el = '#'.$fetch["container"].' '.$fetch["element"].', #'.$fetch["container"].' '.$fetch["element"].' a, #'.$fetch["container"].' '.$fetch["element"].' a:hover';
				} else {
					$el = '#'.$fetch["container"].' '.$fetch["element"];
				}
			}
			$proprties =WonderWorksCSS::parseCSS($fetch["properties"]);
				
				
			if(count($proprties)!=0){
				//print_r($proprties);
				$css .= $el.'{'.@implode(';',$proprties).'}';
			}
		}
		return $css;
	}
Exemple #5
0
function createChild(){
	global $wpdb;
	$theme_root =  get_theme_root();
 	if(!$_POST):
 	// Check if we can write the folders
  	$theme_root =  get_theme_root();
 	if(is_writable($theme_root)):
	 	?>
	 	<form action="" method="post"  enctype="multipart/form-data">
	 	<table class="table table-bordered">
			<thead>
			<tr class="info">
			<td colspan="3"><h3><?php _e('Create a Child Theme','ultimatum');?></h3></td>
			</thead>
			<tfoot>
			<tr>
				<th colspan="3">
					<button class="btn btn-info"><i class="fa fa-save"></i> <?php _e('Save','ultimatum');?></button>
				</th>
			</tr>
			</tfoot>
			<tbody>
			<tr>
				<td width="200"><?php _e('Child Theme Name','ultimatum'); ?>: </td>
				<td width="200"><input type="text" name="name" value="" /></td>
				<td><?php _e('Name for your Child Theme it can be anything you want. Eg. My Cool Theme','ultimatum');?></td>
			</tr>

			<tr>
					<th><?php _e('Child Theme Image','ultimatum');?> :</th>
					<td><input type="file" name="childimage" /></td>
					<td><?php _e('The ScreenShot image which will be shon in Themes Screen. Must be a png file!!','ultimatum');?></td>
				</tr>
			<tr>
				<td><?php _e('Select Templates you want to move to the new child theme','ultimatum');?></td>
				<td>
				<?php 
					$query = "SELECT * FROM `".ULTIMATUM_TABLE_TEMPLATES."` WHERE `theme`='ultimatum'";
					$templates = $wpdb->get_results($query);
					if(isset($templates) && count($templates)!=0){
						foreach ($templates as $temp){
							echo '<input type="checkbox" name="templates[]" value="'.$temp->id.'" /> '.$temp->name.'<br />';
						}
					}		
				?>
				</td>
				<td><?php _e('If non selected an empty child theme with no layouts will be created','ultimatum');?></td>
			</tr>
			
			
			</tbody>
		</table>
	 	</form>
	 	<?php 
	 	
	else:
		_e('Sorry your themes folder is not writable you cannot use this function until you set permissions.','ultimatum');
 	endif;
	
 	else:
 	// create the folder
 	$themedir = $theme_root.DS.sanitize_title($_POST['name']);
	mkdir($themedir);
	WP_Filesystem();
    //    print_r($_FILES['childimage']);
	if(!empty($_FILES["childimage"]['name'])){
      //  echo 'onur2';
        move_uploaded_file($_FILES["childimage"]["tmp_name"], $themedir."/screenshot.png");
    } else {
        $current_file   = ULTIMATUM_DIR.'/screenshot-child.png';
        $target_file    = $themedir.'/screenshot.png';
        //echo 'onur';
        copy($current_file,$target_file);
    }
 	// create the style.css
$stylecss = <<<CSS
/*
Theme Name:     {$_POST['name']}
Description:    Child theme for Ultimatum
Author:         Ultimatum Theme
Template:       ultimatum
Version:        0.1.0
*/
CSS;
$cfile = $themedir.DS.'style.css';
$fhandler = @fopen($cfile, 'w+');
if($fhandler){ fwrite($fhandler, $stylecss, strlen($stylecss));} 	
 	// create the functions.php
$functionsphp = <<<PHP
<?php
/*
 * Simple Child Theme generated by Ultimatum Framework
*/

PHP;

$ffile = $themedir.DS.'functions.php';
$fhandler = @fopen($ffile, 'w+');
if($fhandler){ fwrite($fhandler, $functionsphp, strlen($functionsphp));}	
 	if(isset($_POST['templates'])):
 	foreach($_POST['templates'] as $tmplt){
		$quer = "UPDATE `".ULTIMATUM_TABLE_TEMPLATES."` SET `theme`='".sanitize_title($_POST['name'])."' WHERE `id`='$tmplt'";
		$wpdb->query($quer);
        $oldtheme_css_option = get_option('ultimatum_template_'.$tmplt.'_css',false);
        if($oldtheme_css_option){
            update_option(sanitize_title($_POST['name']).'_template_'.$tmplt.'_css',$oldtheme_css_option);
        }
        // Custom CSS
        $tmp_custom_css = get_option('ultimatum_custom_template_css_'.$tmplt,false);
        if($tmp_custom_css){
            update_option(sanitize_title($_POST['name']).'_custom_template_css_'.$tmplt,$tmp_custom_css);
        }

		$qury = "SELECT * FROM `".ULTIMATUM_TABLE_LAYOUT."` WHERE `type`='full' AND `theme`='".$tmplt."'";
		$results = $wpdb->get_results($qury);
		require_once (ULTIMATUM_ADMIN_HELPERS .DS. 'class.css.saver.php');
		WonderWorksCSS::saveCSS($tmplt,'template');
		foreach ($results as $result){
            $oldtheme_css_option = get_option('ultimatum_'.$result->id.'_css',false);
            if($oldtheme_css_option){
                update_option(sanitize_title($_POST['name']).'_'.$result->id.'_css',$oldtheme_css_option);
            }
            // Custom CSS
            $tmp_custom_css = get_option('ultimatum_custom_css_'.$result->id,false);
            if($tmp_custom_css){
                update_option(sanitize_title($_POST['name']).'_custom_css_'.$result->id,$tmp_custom_css);
            }
			WonderWorksCSS::saveCSS($result->id);


		}
	}
 	endif;
 	// all done tell user the good news and show a link to themes page to get the theme activated.
 	_e('Your Child theme is created you can now go to <a href="./themes.php">Themes</a> screen and activate it','ultimatum');
 	endif;
}
Exemple #6
0
function ultimatum_list_layouts(){
	require_once('ultimatum-widgets.php');
	global $wp_registered_widgets, $wp_registered_widget_controls;
	$sidebars_widgets = wp_get_sidebars_widgets();
	global $wpdb;
	if(isset($_GET['delassigner'])){
		$sql1 = "DELETE FROM `".ULTIMATUM_TABLE_LAYOUT_ASSIGN."` WHERE `post_type`='".$_GET['delassigner']."' AND `layout_id`='".$_GET['delposter']."'";
		$wpdb->query($sql1);
		$url = "admin.php?page=wonder-layout&theme=".$_GET['theme'];
		echo '<script type="text/javascript">parent.location.href="'.$url.'"</script>';
	}
	if($_POST){
		switch ($_POST['action']){
			case 'copycss':
				$tobecloned = $_POST["source"];
				$cloneid = $_POST["cloneid"];
				$option = get_option(THEME_SLUG.'_'.$tobecloned.'_css');
				$newopt = update_option(THEME_SLUG.'_'.$cloneid.'_css', $option);
				$custom_css = get_option(THEME_SLUG.'_custom_css_'.$tobecloned);
				if(strlen($custom_css)) update_option(THEME_SLUG.'_custom_css_'.$cloneid,$custom_css);
				unset($_POST);
				require_once (ULTIMATUM_ADMIN_HELPERS.DS.'class.css.saver.php');
				WonderWorksCSS::saveCSS($cloneid);
				$url= 'admin.php?page=wonder-css&layout='.$cloneid;
				echo '<script type="text/javascript">parent.location.href="'.$url.'"</script>';
			break;
			default:
				echo '<h3>Illegal operation</h3>';
			break;
		}
	}
	$theme=$_REQUEST['theme'];
	$themeinfo = getTemplateInfo($theme);
	
	?>
	<h2><?php _e('LAYOUTS','ultimatum')?> - <small><em>(<?php echo $themeinfo->name;?>)</em></small>
	 <a class="add-new-h2 thickbox" href="<?php echo './index.php?page=layout-create&theme='.$_REQUEST['theme'].'&modal=true&TB_iframe=1&width=640&height=380'; ?>"><?php _e('Add New', 'ultimatum');?></a>
	 <a class="add-new-h2 thickbox" href="<?php echo './index.php?page=layout-assigner&theme='.$_REQUEST['theme'].'&modal=true&TB_iframe=1&width=95%&height=100%'; ?>"><?php _e('Assign Layouts','ultimatum');?></a>
	 <a class="add-new-h2" href="./admin.php?page=wonder-templates"><?php _e('Templates','ultimatum');?></a>
	</h2>
	
 	<div id="ultimatum_layout_list">
	<?php include(ULTIMATUM_ADMIN_AJAX.DS.'list-layouts.php') ;?>
	</div>
	<?php
}
function ultimatum_clone_layout_callback(){
	global $wpdb;
	$tobecloned = $_POST["layoutid"];
	$select = "SELECT * FROM `".ULTIMATUM_TABLE_LAYOUT."` WHERE `id`='$tobecloned'";
	$sourcelayout = $wpdb->get_row($select,ARRAY_A);
	$title = $sourcelayout["title"].'(copy)';
	$cloneql = "INSERT INTO `".ULTIMATUM_TABLE_LAYOUT."` (`title`,`type`,`theme`) VALUES ('$title','".$sourcelayout["type"]."','".$sourcelayout["theme"]."')";
	$cloneql = $wpdb->query($cloneql);
	$cloneid = $wpdb->insert_id;
	ultimatum_clone_layout_part($sourcelayout["before"],'before',$tobecloned,$cloneid);
	ultimatum_clone_layout_part($sourcelayout["rows"],'rows',$tobecloned,$cloneid);
	ultimatum_clone_layout_part($sourcelayout["after"],'after',$tobecloned,$cloneid);
	$option = get_option(THEME_SLUG.'_'.$tobecloned.'_css');
	$newopt = update_option(THEME_SLUG.'_'.$cloneid.'_css', $option);
    /*
     * Clone the options
     */
    $options = get_option(THEME_SLUG.'_'.$tobecloned.'_options');
    $newopts = update_option(THEME_SLUG.'_'.$cloneid.'_options', $options);
	$custom_css = get_option(THEME_SLUG.'_custom_css_'.$tobecloned);
	if(strlen($custom_css)) update_option(THEME_SLUG.'_custom_css_'.$cloneid,$custom_css);
	unset($_POST);
	require_once (ULTIMATUM_ADMIN_HELPERS.DS.'class.css.saver.php');
	WonderWorksCSS::saveCSS($cloneid);
	}