Example #1
0
function wppb_convert_urls_in_css($css)
{
    // Iterate available themes to convert their image URLs (since images used in those themes aren't stored in the uploads folder)
    foreach (wppb_available_themes() as $count => $theme) {
        if ('Internal' == $theme['Type']) {
            $css = str_replace("url('" . $theme['Folder'], "url('" . get_template_directory_uri() . '/designs/' . $theme['Folder'] . '/images/', $css);
        } elseif ('Child' == $theme['Type']) {
            $css = str_replace("url('" . $theme['Folder'], "url('" . get_theme_root_uri() . '/' . $theme['Folder'] . '/images/', $css);
        }
        // Fixing CSS URLs
    }
    return $css;
}
Example #2
0
function wppb_inline_scripts()
{
    $wppb_design_settings = get_option(WPPB_DESIGNER_SETTINGS);
    // Setting potentially empty variable
    if (empty($wppb_design_settings['design'])) {
        $wppb_design_settings['design'] = '';
    } else {
        $wppb_design_settings['design'] = sanitize_title($wppb_design_settings['design']);
    }
    // Bug fix for existing poorly labelled designs
    ?>
<script type="text/javascript">
<?php 
    do_action('wppb_inline_scripts_hook');
    ?>

// Setting WP Paintbrush JS variables
var storage_folder = '<?php 
    echo wppb_storage_folder('images', 'url');
    ?>
';
var design_folder = '<?php 
    echo get_template_directory_uri();
    ?>
/designs/<?php 
    echo $wppb_design_settings['design'];
    ?>
/images/';
var design_name = '<?php 
    echo $wppb_design_settings['design'];
    ?>
';
var nonce_link = '<?php 
    echo wp_nonce_url(home_url(), 'wppb_editor');
    ?>
';
var admin_url = '<?php 
    echo home_url();
    ?>
/wp-admin/';
var home_url = '<?php 
    echo home_url();
    ?>
';

jQuery(function($){
	// AJAX form submission
	function change_design(button) {
		$.ajax({
			type: 'POST',
			url: home_url+'/?change_theme='+button,
			data: {
				'wppb_nonce' : $("#wppb_nonce").val(),
			},
			success: function(data, textStatus) {
				$( "#wppb-page-reload" ).dialog({width:250,minWidth:250,maxWidth:250,modal:true,autoOpen:true,});
				$(location).attr('href',home_url);
			},
			error: function(jqXHR, textStatus, errorThrown) {
				$( "#wppb-external-connection-failure" ).dialog({width:250,minWidth:250,maxWidth:250,modal:true,autoOpen:true,});
			},
			dataType: 'html'
		});

	}<?php 
    // Output list of available designs
    foreach (wppb_available_themes() as $count => $design) {
        echo "\$('#myform" . $design['Folder'] . "').click(function() {change_design( '" . $design['Folder'] . "' );});\n";
    }
    ?>
	// AJAX form submission
	function option_get(button) {
		$("#wppb-css2").html('<div style="text-indent:0;"><img style="" src="'+admin_url+'images/wpspin_light.gif" /></div>');
		$.ajax({
			type: 'POST',
			url: home_url+'/?generator-css='+button,
			data: {
				'wppb_nonce':$("#wppb_nonce").val(),<?php 
    // Set all AJAX options
    foreach (wppb_ajax_option_get() as $option) {
        echo '\'' . $option . '\':$("#' . $option . '").val(),' . "\n";
    }
    ?>
			},
			success: function(data, textStatus) {
				switch(data) {
					case "Error: Couldn't connect to server":
					$( "#wppb-external-connection-failure" ).dialog({width:250,minWidth:250,maxWidth:250,modal:true,autoOpen:true,});
					$('#wppb-css3').html("Error: Couldn't connect to server");
					break;
					default:
					$('#wppb-css').html(data);
					$('#wppb-css3').html(data);
					break;
				}
				$('#wppb-css2').html('');
			},
			error: function(jqXHR, textStatus, errorThrown) {
				$( "#wppb-external-connection-failure" ).dialog({width:250,minWidth:250,maxWidth:250,modal:true,autoOpen:true,});
			},
			dataType: 'html'
		});
	}
	$('#myformButton').click(function() {option_get( 'process' );});
	$('.myformSaver').click(function() {option_get( 'save' );});
	$('#myformPublish').click(function() {option_get( 'publish' );});
	$('#myformExport').click(function() {option_get( 'export' );});
	$('#ChangeHomeLayoutMagazine').click(function() {option_get( 'Magazine' );});
	$('#ChangeHomeLayoutNormal').click(function() {option_get( 'Normal' );});

	$("#sidebar-layout-sortable, #sidebar-blocks-sortable").sortable({
		connectWith: ".sidebar-sortable-connect",
		update: function(){
			var pos = [];
			$('#sidebar-layout-sortable > li').each(function(i){
				pos[i] = $(this).attr('id');
			});
			$('#sidebar_positions').val(pos.toString());
			option_get( 'process' );
		}
	});

	// Image picker
	var $button,
	$ele = $('#wppb-image-uploads').dialog({
		width: 530,
		minWidth: 530,
		maxWidth: 530,
		title: 'Image picker',
		modal: false,
		autoOpen: false,
		open : function(event, ui){
			$('img.uploaded-image',ui.dialog).each(function(){
				var image = $(this);
				image.click(function(){
					$button.parent().find('.image-picker').val(image.attr('alt'));
					$button.removeClass('ICopen').val('pick');
<?php 
    $images = array('sidebar_background_image' => '.wrapper', 'footer_background_image' => 'footer div.footer', 'background_image' => 'body', 'maincontent_background_image' => '.wrapper #content', 'header_background_image' => 'header div.header', 'header_fullwidth_background_image' => 'header', 'header_searchbox_background_image' => 'header #search', 'header_logo_background_image' => 'header #logo', 'banner_image' => '#banner div.banner-image', 'menu1_hover_background_image' => 'nav#nav li:hover a', 'menu1_background_image' => 'nav#nav ul', 'menu1_fullwidth_background_image' => 'nav#nav', 'menu1_items_background_image' => 'nav#nav li', 'header_searchbox_text_background_image' => 'header #search input[type=text]', 'header_searchsubmit_text_background_image' => 'header #search input[type=submit]', 'footer_fullwidth_background_image' => 'footer');
    foreach ($images as $theid => $selector) {
        echo "\n\t\t\t\t\tvar filename=\$('#" . $theid, "').val().split('/');\n\t\t\t\t\tif('stored'==filename[0]){\n\t\t\t\t\t\t\$('" . $selector . "').css({'background-image':'url('+storage_folder+'/'+filename[1]+')'});\n\t\t\t\t\t}\n\t\t\t\t\tif(design_name==filename[0]){\n\t\t\t\t\t\t\$('" . $selector . "').css({'background-image':'url('+design_folder+'/'+filename[1]+')'});\n\t\t\t\t\t}";
    }
    ?>
					$ele.dialog('close');
				});
			});
		},
		beforeClose: function(event,ui){
			$('img',ui.dialog).unbind();
		}
	});
	$('.imagepickerbutton').click(function(){$button = $(this);$ele.dialog('open');});
});
</script><?php 
}
Example #3
0
function wppb_editor_content()
{
    // Bail out now if user not supposed to see admin panel
    if (!current_user_can('manage_options') || 'on' != get_option('wppb_designer_pane')) {
        return;
    }
    // Setting defaults for "content_layout"
    $wppb_designer_settings = get_option(WPPB_DESIGNER_SETTINGS);
    ?>
<div id="dialog" title="Theme Creator">
	<div id="loading-text">
		<img style="" src="<?php 
    echo WPPB_URL;
    ?>
images/load.gif" alt="<?php 
    _e('Loading', 'wppb_lang');
    ?>
" />
		<br />
		<h3><?php 
    _e('One moment please. The WP Paintbrush editor is loading.', 'wppb_lang');
    ?>
</h3>
	</div>
<div id="tab_wrapper">
<form id="wppb-editor-form" method="post" action="" enctype="multipart/form-data">
	<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
	<input type="hidden" id="copyright" name="copyright" value='<?php 
    echo $wppb_designer_settings['copyright'];
    ?>
' />
	<input type="hidden" id="design" name="design" value='<?php 
    echo $wppb_designer_settings['design'];
    ?>
' />
	<?php 
    wp_nonce_field('wppb_upload_image', 'image');
    ?>
	<?php 
    wp_nonce_field('wppb_nonce', 'wppb_nonce');
    ?>
	<div id="tabs" class="maintabber">
		<div id="tabs-navigation-wrapper">
			<ul>
				<?php 
    // Hook for adding new link
    do_action('wppb_add_editor_links');
    ?>
 
			</ul>
		</div>

		<?php 
    // Hook for adding new tabs
    do_action('wppb_add_editor_tabs');
    ?>
	</div>

<!-- Farbtastic colour picker -->
<div id="farbtastic" title="Colour picker"><?php 
    _e('Colour picker', 'wppb_lang');
    ?>
</div>

<!-- Image picker -->
<div id="wppb-image-uploads">
	<div id="wppb-images">
		<table>
		<?php 
    wppb_list_images(wppb_storage_folder('images'), wppb_storage_folder('images', 'url'), 'display', 'stored');
    echo '<tr><td><h2 style="margin:20px 0 6px 0;">' . __(' Design images', 'wppb_lang') . '</h2></td></tr>';
    foreach (wppb_available_themes() as $count => $theme) {
        if ($theme['Folder'] == $wppb_designer_settings['design']) {
            if ('Internal' == $theme['Type']) {
                wppb_list_images(get_template_directory() . '/designs/' . $theme['Folder'] . '/images/', get_template_directory_uri() . '/designs/' . $theme['Folder'] . '/images/', '', $theme['Folder']);
            }
        }
    }
    ?>
		</table>
	</div>
	<h2><?php 
    _e('Image uploads', 'wppb_lang');
    ?>
</h2>
	<!--
	--><?php 
    // If using WP 3.3 then make use of plup uploader (note use of query var to force major CSS changes in iframe)
    global $wp_version;
    if ($wp_version >= 3.3) {
        echo '<iframe src="' . admin_url() . '/media-new.php?wppb_frontenduploader=css" width="525" height="215"></iframe>';
    } else {
        echo '<p>' . __('Visit the <a href="http://localhost/wp/testing/wp-admin/themes.php?page=upload_images">image uploads page</a> to upload new images.', 'wppb_lang') . '</p>';
    }
    ?>
</div>

</form>

<!-- Connection failure dialog -->
<div id="wppb-external-connection-failure" title="<?php 
    _e('Dangit, we got an error!', 'wppb_lang');
    ?>
">
	<p><?php 
    _e('Sorry, the server is having difficulties connecting to the CSS generator. Please try again.', 'wppb_lang');
    ?>
</p>
</div>

<div id="wppb-page-reload" title="Page reloading!">
	<p><?php 
    _e('We need to reload the page to show the changes you just selected. One moment please ...', 'wppb_lang');
    ?>
</p>
</div>

</div>
</div>

<?php 
}