View difference between Paste ID: 9QAG1jFU and
SHOW: | | - or go back to the newest paste.
1-
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
?>