wp/wp-content/plugins/option-tree/includes/ot-functions-compat.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 11 bf1778c34b9a
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    73     $has_xml    = isset( $xml_file ) ? true : false;
    73     $has_xml    = isset( $xml_file ) ? true : false;
    74     $has_data   = isset( $data_file ) ? true : false;
    74     $has_data   = isset( $data_file ) ? true : false;
    75     $has_layout = isset( $layout_file ) ? true : false;
    75     $has_layout = isset( $layout_file ) ? true : false;
    76     
    76     
    77     /* auto import XML file */
    77     /* auto import XML file */
    78     if ( $has_xml == true && ! get_option( 'option_tree_settings' ) && class_exists( 'SimpleXMLElement' ) ) {
    78     if ( $has_xml == true && ! get_option( ot_settings_id() ) && class_exists( 'SimpleXMLElement' ) ) {
    79     
    79     
    80       $settings = ot_import_xml( $xml_file );
    80       $settings = ot_import_xml( $xml_file );
    81       
    81       
    82       if ( isset( $settings ) && ! empty( $settings ) ) {
    82       if ( isset( $settings ) && ! empty( $settings ) ) {
    83         
    83         
    84         update_option( 'option_tree_settings', $settings );
    84         update_option( ot_settings_id(), $settings );
    85         
    85         
    86       }
    86       }
    87       
    87       
    88     }
    88     }
    89     
    89     
    90     /* auto import Data file */
    90     /* auto import Data file */
    91     if ( $has_data == true && ! get_option( 'option_tree' ) ) {
    91     if ( $has_data == true && ! get_option( ot_options_id() ) ) {
    92       
    92       
    93       $get_data = wp_remote_get( $data_file );
    93       $get_data = wp_remote_get( $data_file );
    94       
    94       
    95       if ( is_wp_error( $get_data ) )
    95       if ( is_wp_error( $get_data ) )
    96         return false;
    96         return false;
    97         
    97         
    98       $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : '';
    98       $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : '';
    99       $options = unserialize( ot_decode( $rawdata ) );
    99       $options = unserialize( ot_decode( $rawdata ) );
   100       
   100       
   101       /* get settings array */
   101       /* get settings array */
   102       $settings = get_option( 'option_tree_settings' );
   102       $settings = get_option( ot_settings_id() );
   103       
   103       
   104       /* has options */
   104       /* has options */
   105       if ( is_array( $options ) ) {
   105       if ( is_array( $options ) ) {
   106         
   106         
   107         /* validate options */
   107         /* validate options */
   120           }
   120           }
   121         
   121         
   122         }
   122         }
   123         
   123         
   124         /* update the option tree array */
   124         /* update the option tree array */
   125         update_option( 'option_tree', $options );
   125         update_option( ot_options_id(), $options );
   126         
   126         
   127       }
   127       }
   128       
   128       
   129     }
   129     }
   130     
   130     
   131     /* auto import Layout file */
   131     /* auto import Layout file */
   132     if ( $has_layout == true && ! get_option( 'option_tree_layouts' ) ) {
   132     if ( $has_layout == true && ! get_option( ot_layouts_id() ) ) {
   133     
   133     
   134       $get_data = wp_remote_get( $layout_file );
   134       $get_data = wp_remote_get( $layout_file );
   135       
   135       
   136       if ( is_wp_error( $get_data ) )
   136       if ( is_wp_error( $get_data ) )
   137         return false;
   137         return false;
   138         
   138         
   139       $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : '';
   139       $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : '';
   140       $layouts = unserialize( ot_decode( $rawdata ) );
   140       $layouts = unserialize( ot_decode( $rawdata ) );
   141       
   141       
   142       /* get settings array */
   142       /* get settings array */
   143       $settings = get_option( 'option_tree_settings' );
   143       $settings = get_option( ot_settings_id() );
   144       
   144       
   145       /* has layouts */
   145       /* has layouts */
   146       if ( is_array( $layouts ) ) {
   146       if ( is_array( $layouts ) ) {
   147         
   147         
   148         /* validate options */
   148         /* validate options */
   174         }
   174         }
   175         
   175         
   176         /* update the option tree array */
   176         /* update the option tree array */
   177         if ( isset( $layouts['active_layout'] ) ) {
   177         if ( isset( $layouts['active_layout'] ) ) {
   178         
   178         
   179           update_option( 'option_tree', unserialize( ot_decode( $layouts[$layouts['active_layout']] ) ) );
   179           update_option( ot_options_id(), unserialize( ot_decode( $layouts[$layouts['active_layout']] ) ) );
   180           
   180           
   181         }
   181         }
   182         
   182         
   183         /* update the option tree layouts array */
   183         /* update the option tree layouts array */
   184         update_option( 'option_tree_layouts', $layouts );
   184         update_option( ot_layouts_id(), $layouts );
   185         
   185         
   186       }
   186       }
   187       
   187       
   188     }
   188     }
   189     
   189