function wppb_get_options_for_storing($wppb_options, $css = '')
{
    // Setting CSS
    $wppb_options['css'] = $css;
    // Add support for sidebars
    if (!isset($wppb_options['sidebar_positions'])) {
        $wppb_options['sidebar_positions'] = '';
    }
    $sidebar_positions = str_replace('layout-', '', $wppb_options['sidebar_positions']);
    $sidebar_positions = explode(',', $sidebar_positions);
    foreach ($sidebar_positions as $block) {
        $count = 0;
        while ($count < 2) {
            $count++;
            $wppb_options['show_widget' . $count] = '';
            $wppb_options['name_widget' . $count] = '';
            $wppb_options['before_widget' . $count] = '';
            $wppb_options['after_widget' . $count] = '';
            $wppb_options['before_title' . $count] = '';
            $wppb_options['after_title' . $count] = '';
            if ('sidebar' . $count == $block) {
                $wppb_options['show_widget' . $count] = 'on';
                $wppb_options['name_widget' . $count] = 'Sidebar ' . $count;
                $wppb_options['before_widget' . $count] = '<div id="%1$s" class="widget %2$s">';
                $wppb_options['after_widget' . $count] = '</div>';
                $wppb_options['before_title' . $count] = '<h3>';
                $wppb_options['after_title' . $count] = '</h3>';
            }
        }
    }
    // This section only used when saving
    if (isset($wppb_options['positions'])) {
        // Set header and footer templates
        $positions = explode(',', $wppb_options['positions']);
        $section = 'header';
        // Load header first
        $wppb_options['header'] = '';
        // Resetting header
        $wppb_options['footer'] = '';
        // Resetting footer
        foreach ($positions as $pos) {
            foreach (wppb_page_chunks() as $chunk => $test) {
                $chunk = strtolower($chunk);
                // Convert to lowercase
                $chunk = str_replace(' ', '', $chunk);
                // Strip spaces
                if ('layout-' . $chunk == $pos) {
                    $chunk = '[wppb_' . strtolower($chunk) . ']';
                    // Convert to lowercase
                    if ('footer' == $section) {
                        $wppb_options['footer'] .= do_shortcode($chunk);
                    }
                    if ('[wppb_content]' == $chunk) {
                        $section = 'footer';
                    }
                    if ('header' == $section) {
                        $wppb_options['header'] .= do_shortcode($chunk);
                    }
                }
            }
        }
    }
    // Add support for menus
    $positions = explode(',', $wppb_options['positions']);
    foreach ($positions as $pos) {
        foreach (wppb_page_chunks() as $chunk => $test) {
            $chunk = strtolower($chunk);
            // Convert to lowercase
            $chunk = str_replace(' ', '', $chunk);
            // Strip spaces
            if ('layout-' . $chunk == $pos) {
                if ('menu' == $chunk) {
                    $wppb_options['support_primarymenu'] = 'on';
                }
            }
        }
    }
    // Set main templates
    //$wppb_options['front_page'] = '';
    $wppb_options['front_page'] = "[get_header]\n\n" . do_shortcode('[wppb_content_front]') . "\n\n[get_footer]";
    $wppb_options['home'] = "[get_header]\n\n" . do_shortcode('[wppb_content_home]') . "\n\n[get_footer]";
    $wppb_options['archive'] = "[get_header]\n\n" . do_shortcode('[wppb_content_home]') . "\n\n[get_footer]";
    $wppb_options['index'] = "[get_header]\n\n" . do_shortcode('[wppb_content_home]') . "\n\n[get_footer]";
    $wppb_options['page'] = "[get_header]\n\n" . do_shortcode('[wppb_content_page]') . "\n\n[get_footer]";
    $wppb_options['single'] = "[get_header]\n\n" . do_shortcode('[wppb_content_single]') . "\n\n[get_footer]";
    // Correct URLs
    $wppb_options['css'] = str_replace('http: //', 'http://', $wppb_options['css']);
    // Filter for plugins to modify data before storage
    $wppb_options = apply_filters('wppb_storage_options_filter', $wppb_options);
    return $wppb_options;
}
Exemple #2
0
function wppb_designs_editor_tab()
{
    $wppb_design_settings = get_option(WPPB_DESIGNER_SETTINGS);
    // Add HTML
    ?>
<div class="tab-block" id="content_options">
	<div id="blocks_options" class="wide">
		<?php 
    /*
    		<div class="section-layout">
    			<h2><?php _e( 'Choose design', 'wppb_lang' ); ?></h2>
    			<p><?php _e( 'You can select a default design to start from. We will be adding more designs to this area over time.', 'wppb_lang' ); ?></p>
    			<br />
    			<div class="floating-spacer-block"> </div>
    			<div id="wppb-ajax"></div><?php  
    				foreach( wppb_available_themes() as $count=>$design ) { 
    				?>
    				<div class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-hover" role="button" aria-disabled="false">
    					<input id="myform<?php echo $design['Folder']; ?>" type="button" name="button" value="<?php echo $design['Name']; ?>" />
    			</div><?php
    			}
    			?>		
    			<br /><br /><br />
    		</div>
    */
    ?>
		<div class="section-layout">
			<h2><?php 
    _e('Layout', 'wppb_lang');
    ?>
</h2>
			<p><?php 
    _e('You can modify your layout by dragging content boxes around.', 'wppb_lang');
    ?>
</p>
			<div id="layout-editor-opener"><?php 
    _e('Open layout editor', 'wppb_lang');
    ?>
</div>					
			<div id="layout-editor-dialog">
				<p>
					<strong><?php 
    _e('Drag content across</strong> and arrange it on your template', 'wppb_lang');
    ?>
 <img src="<?php 
    echo WPPB_URL;
    ?>
/images/arrow.png" alt="" />
				</p>
				<div class="layout-editor-background">
					<div class="current-blocks layout-blocks">
						<ul id="layout-sortable" class="blocks-sortable-connect">
							<?php 
    // Generating string which loads the content box in the layout editor
    $content = '<li id="layout-content" class="ui-state-default"><ul id="sidebar-layout-sortable" class="sidebar-sortable-connect">';
    $sidebar_positions = explode(',', $wppb_design_settings['sidebar_positions']);
    foreach ($sidebar_positions as $block) {
        if ('layout-sidebar1' == $block) {
            $name = 'S1';
        } elseif ('layout-sidebar2' == $block) {
            $name = 'S2';
        } elseif ('layout-maincontent' == $block) {
            $name = 'Content';
        }
        $content .= '<li id="' . $block . '" class="ui-state-default">' . $name . '</li>';
    }
    $content .= '</ul></li>';
    // Processor for loading chunks into layout editor
    $positions = explode(',', $wppb_design_settings['positions']);
    foreach ($positions as $pos) {
        foreach (wppb_page_chunks() as $chunk => $test) {
            $id = strtolower($chunk);
            // Convert to lowercase
            $id = str_replace(' ', '', $id);
            // Strip spaces
            $id = 'layout-' . $id;
            // Prepend ID prefix
            if ('layout-content' == $id && 'layout-content' == $pos) {
                echo $content;
            } elseif ($pos == $id) {
                echo '<li id="' . $id . '" class="ui-state-default">' . $chunk . '</li>';
            }
        }
    }
    ?>
						</ul>
						<input type="hidden" name="positions" class="positions" id="positions" value="<?php 
    echo $wppb_design_settings['positions'];
    ?>
" />
						<input type="hidden" name="sidebar_positions" class="sidebar_positions" id="sidebar_positions" value="<?php 
    echo $wppb_design_settings['sidebar_positions'];
    ?>
" />
					</div>
					<div class="section-layout section-available">
						<h2><?php 
    _e('Content blocks', 'wppb_lang');
    ?>
</h2>
						<div class="layout-blocks">
							<ul id="blocks-sortable" class="blocks-sortable blocks-sortable-connect">
								<?php 
    // Processor for loading chunks into available content
    foreach (wppb_page_chunks() as $chunk => $test) {
        $id = strtolower($chunk);
        // Convert to lowercase
        $id = str_replace(' ', '', $id);
        // Strip spaces
        $id = 'layout-' . $id;
        // Prepend ID prefix
        foreach ($positions as $pos) {
            if ($pos == $id) {
                $exists = 'yes';
            }
        }
        if ('yes' != $exists && 'layout-content' == $id) {
            echo $content;
        } elseif ('yes' != $exists) {
            echo '<li id="' . $id . '" class="ui-state-default">' . $chunk . '</li>';
        }
        $exists = '';
    }
    ?>
							</ul>
						</div>
						<h2><?php 
    _e('Sidebar blocks', 'wppb_lang');
    ?>
</h2>
						<div class="layout-blocks">
							<ul id="sidebar-blocks-sortable" class="blocks-sortable sidebar-sortable-connect">
							<?php 
    // Unused sidebar chunks
    $sidebar_remainging = wppb_sidebar_chunks();
    foreach (wppb_sidebar_chunks() as $name => $block) {
        foreach ($sidebar_positions as $current) {
            if ($block == $current) {
                $sidebar_remainging[$name] = '';
            }
        }
    }
    foreach ($sidebar_remainging as $name => $block) {
        if ('' != $sidebar_remainging[$name]) {
            echo '<li id="' . $block . '" class="ui-state-default">' . $name . '</li>';
        }
    }
    ?>
							</ul>
						</div>
					</div>
				</div>
			</div>					
		</div>
	</div>
</div>
<?php 
}