Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Get options from inactive layouts <OptionTree:Wordpress>

By: josenetome on Jan 3rd, 2013  |  syntax: PHP  |  size: 1.06 KB  |  hits: 59  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3.  
  4.         @autor: José Neto <josenetome@gmail.com>
  5.         @description: Get options from inactive layouts <OptionTree:Wordpress>
  6.         @usage: ot_get_option_by_layout($field, $layout, $default)
  7.        
  8. */
  9. if ( ! function_exists( 'ot_get_option_by_layout' ) ) {
  10.  
  11.   function ot_get_option_by_layout( $option_id, $layout, $default = '' ) {
  12.    
  13.     /* get the saved options */
  14.     $layouts = get_option( 'option_tree_layouts' );
  15.    
  16.     /* get options by layout */
  17.     foreach ( $layouts as $layout_name => $fields ) {
  18.    
  19.         if ( $layout_name == 'active_layout') continue;
  20.        
  21.         /* check if layout exists */
  22.                 if ( $layout_name == $layout ) {
  23.                        
  24.                         /* get fields of this layout */
  25.                         $fields = unserialize ( base64_decode ( $fields ) );
  26.                        
  27.                         /* fields loop */
  28.                         foreach ( $fields as $option_name => $value) {
  29.                                
  30.                                 /* look for the saved value */
  31.                                 if ( $option_name == $option_id && $value != NULL ) {
  32.                                
  33.                                         return $value;
  34.                                        
  35.                                 }
  36.                                
  37.                         } /* end fields loop */
  38.                        
  39.                 }
  40.    
  41.         }  
  42.  
  43.   return $default;  
  44.  
  45.   }
  46.  
  47. }
  48. ?>