Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

flexlayout.php

By: a guest on Jan 5th, 2013  |  syntax: None  |  size: 6.75 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. add_action( 'ithemes_init', 'ithemes_flexx_layout_loader' );
  3.  
  4. function ithemes_flexx_layout_loader() {
  5.         global $wp_theme_options, $container_width, $content_width, $feature_top_width, $feature_bottom_width;
  6.        
  7.         foreach ( (array) $wp_theme_options['flexx'] as $name => $val )
  8.                 $GLOBALS[$name] = $val;
  9.        
  10.         extract( (array) $wp_theme_options['flexx'] );
  11.        
  12.         //How wide should the container be?
  13.         if(preg_match('/^(2_right|2_left|split)$/', $sidebars)) $container_width = 960;
  14.         else $container_width = 780;
  15.         $container_width = intval( $container_width ); //just in case something screws up
  16.        
  17.         //How wide should the content be?
  18.         $content_width = ($sidebars != 'none') ? 600 : 780;
  19.        
  20.         //How wide should each of the boxes in
  21.         //the feature_top/feature_bottom sections be?
  22.         if ( ! empty( $feature_top ) && ( $feature_top != 'none' ) )
  23.                 $feature_top_width = ( $container_width / $feature_top );
  24.         if ( ! empty( $feature_bottom ) && ( $feature_bottom != 'none' ) )
  25.                 $feature_bottom_width = ( $container_width / $feature_bottom );
  26.        
  27.         //The container width
  28.         add_action( 'container_style', 'flexx_container_style' );
  29.         function flexx_container_style() {
  30.                 global $container_width;
  31.                 echo 'c' . $container_width . ' center wrap';
  32.         }
  33.        
  34.         //The content width
  35.         add_action('content_style', 'flexx_content_style');
  36.         function flexx_content_style() {
  37.                 global $content_width;
  38.                 echo 'w'.$content_width.'-';
  39.         }
  40.        
  41.         //What menu goes above the header (if any)
  42.         add_action('above_header', 'flexx_menu_above_header');
  43.         function flexx_menu_above_header() {
  44.                 global $above_header;
  45.                 if($above_header != 'none') echo '<div id="above-header">';
  46.                 if($above_header == 'pages') { get_template_file('menu-pages.php'); }
  47.                 if($above_header == 'categories') { get_template_file('menu-cats.php'); }
  48.                 if($above_header == 'pages_categories') { get_template_file('menu-pages.php'); get_template_file('menu-cats.php'); }
  49.                 if($above_header == 'categories_pages') { get_template_file('menu-cats.php'); get_template_file('menu-pages.php'); }
  50.                 if($above_header != 'none') echo '</div>';
  51.         }
  52.        
  53.         //What menu goes below the header (if any)
  54.         add_action('below_header', 'flexx_menu_below_header');
  55.         function flexx_menu_below_header() {
  56.                 global $below_header;
  57.                 if($below_header != 'none') echo '<div id="below-header">';
  58.                 if($below_header == 'pages') { get_template_file('menu-pages.php'); }
  59.                 if($below_header == 'categories') { get_template_file('menu-cats.php'); }
  60.                 if($below_header == 'pages_categories') { get_template_file('menu-pages.php'); get_template_file('menu-cats.php'); }
  61.                 if($below_header == 'categories_pages') { get_template_file('menu-cats.php'); get_template_file('menu-pages.php'); }
  62.                 if($below_header != 'none') echo '</div>';
  63.         }
  64.        
  65.         //Feature Top
  66.         add_action('below_header', 'flexx_feature_top', 11);
  67.         function flexx_feature_top() {
  68.                 global $feature_top;
  69.                 if ( ! empty( $feature_top ) && ( $feature_top != 'none' ) ) {
  70.                         get_template_file('feature-top.php'); } else { return; }
  71.         }
  72.         //Feature Top Style
  73.         add_action('feature_top_style','flexx_feature_top_style');
  74.         function flexx_feature_top_style() {
  75.                 global $feature_top_width;
  76.                 if($feature_top_width) echo 'w'.$feature_top_width.'-';
  77.         }
  78.        
  79.         //Feature Bottom
  80.         add_action('above_footer', 'flexx_feature_bottom');
  81.         function flexx_feature_bottom() {
  82.                 global $feature_bottom;
  83.                 if ( ! empty( $feature_bottom ) && ( $feature_bottom != 'none' ) ) {
  84.                         get_template_file('feature-bottom.php'); } else { return; }
  85.         }
  86.         //Feature Bottom Style
  87.         add_action('feature_bottom_style','flexx_feature_bottom_style');
  88.         function flexx_feature_bottom_style() {
  89.                 global $feature_bottom_width;
  90.                 if($feature_bottom_width) echo 'w'.$feature_bottom_width.'-';
  91.         }
  92.        
  93.         //Sidebars
  94.         add_action('before_content','flexx_before_content');
  95.         function flexx_before_content() {
  96.                 global $sidebars;
  97.                 if($sidebars == '2_left') get_sidebar();
  98.                 if(preg_match('/^(1_left|split)$/', $sidebars)) get_sidebar('left');
  99.         }
  100.         add_action('after_content','flexx_after_content');
  101.         function flexx_after_content() {
  102.                 global $sidebars;
  103.                 if($sidebars == '2_right') get_sidebar();
  104.                 if(preg_match('/^(1_right|split)$/', $sidebars)) get_sidebar('right');
  105.         }
  106.        
  107.         //Register Widget Areas (conditionally)
  108.         if ( function_exists('register_sidebar') ) {
  109.                 if(preg_match('/^(1_left|2_right|2_left|split)$/', $sidebars)) {
  110.                 register_sidebar(array('name'=>'Skinny Left Sidebar','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  111.                
  112.                 if(preg_match('/^(1_right|2_right|2_left|split)$/', $sidebars)) {
  113.                 register_sidebar(array('name'=>'Skinny Right Sidebar','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  114.                
  115.                 if(preg_match('/^(2_right|2_left)$/', $sidebars)) {
  116.                 register_sidebar(array('name'=>'Wide Sidebar Bottom','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',));
  117.                 register_sidebar(array('name'=>'Wide Sidebar Top','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  118.                
  119.                 if(preg_match('/^(2|3)$/', $feature_top)) {
  120.                 register_sidebar(array('name'=>'Feature Top Left','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',));
  121.                 if($feature_top == 3) {
  122.                 register_sidebar(array('name'=>'Feature Top Middle','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  123.                 register_sidebar(array('name'=>'Feature Top Right','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  124.                 if($feature_top == 1) {
  125.                 register_sidebar(array('name'=>'Feature Top','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  126.                
  127.                 if(preg_match('/^(2|3)$/', $feature_bottom)) {
  128.                 register_sidebar(array('name'=>'Feature Bottom Left','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',));
  129.                 if($feature_bottom == 3) {
  130.                 register_sidebar(array('name'=>'Feature Bottom Middle','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  131.                 register_sidebar(array('name'=>'Feature Bottom Right','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  132.                 if($feature_bottom == 1) {
  133.                 register_sidebar(array('name'=>'Feature Bottom','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',)); }
  134.         }
  135. }
  136. ?>