SHARE
TWEET

Code in iThemes Builder that makes all module outer wrappers full width

a guest Oct 17th, 2012 29 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Making all module outer wrappers full width
  2. function it_set_full_width_container( $width ) {
  3.         remove_filter( 'builder_get_container_width', 'it_set_full_width_container' );
  4.  
  5.         return '';
  6. }
  7. add_filter( 'builder_get_container_width', 'it_set_full_width_container' );
  8.  
  9. function it_set_full_width_module( $fields ) {
  10.  
  11.         global $it_original_module_width;
  12.  
  13.         $it_original_module_width = '';
  14.  
  15.         foreach ( (array) $fields['attributes']['style'] as $index => $value ) {
  16.                 if ( preg_match( '/^(width:.+)/i', $value, $matches ) ) {
  17.                         $it_original_module_width = $matches[1];
  18.                         unset( $fields['attributes']['style'][$index] );
  19.                 }
  20.                 if ( preg_match( '/^overflow:/', $value ) ) {
  21.                         unset( $fields['attributes']['style'][$index] );
  22.                         $fields['attributes']['style'][] = 'overflow:visible;';
  23.                 }
  24.         }
  25.         add_filter( 'builder_module_filter_inner_wrapper_attributes', 'it_constrain_full_width_module_inner_wrapper' );
  26.  
  27.         return $fields;
  28. }
  29. add_filter( 'builder_module_filter_outer_wrapper_attributes', 'it_set_full_width_module' );
  30.  
  31. function it_constrain_full_width_module_inner_wrapper( $fields ) {
  32.         global $it_original_module_width;
  33.  
  34.         remove_filter( 'builder_module_filter_inner_wrapper_attributes', 'it_constrain_full_width_module_inner_wrapper' );
  35.  
  36.         $fields['attributes']['style'][] = $it_original_module_width;
  37.         $fields['attributes']['style'][] = 'margin:0 auto;';
  38.  
  39.         $it_original_module_width = '';
  40.  
  41.         return $fields;
  42. }
RAW Paste Data
Top