user_login; $super_user = get_option( 'framework_woo_super_user' ); $themename = get_option( 'woo_themename' ); $shortname = get_option( 'woo_shortname' ); // Reset the settings, sanitizing the various requests made. // Use a SWITCH to determine which settings to update. /* Make sure we're making a request. ------------------------------------------------------------*/ if ( isset( $_REQUEST['page'] ) ) { // Sanitize page being requested. $_page = ''; $_page = mysql_real_escape_string( strtolower( trim( strip_tags( $_REQUEST['page'] ) ) ) ); // Sanitize action being requested. $_action = ''; if ( isset( $_REQUEST['woo_save'] ) ) { $_action = mysql_real_escape_string( strtolower( trim( strip_tags( $_REQUEST['woo_save'] ) ) ) ); } // End IF Statement // If the action is "reset", run the SWITCH. /* Perform settings reset. ------------------------------------------------------------*/ if ( $_action == 'reset' ) { // Add nonce security check. if ( function_exists( 'check_ajax_referer' ) ) { check_ajax_referer( 'wooframework-theme-options-reset', '_ajax_nonce' ); } // End IF Statement switch ( $_page ) { case 'woothemes': $options = get_option( 'woo_template' ); woo_reset_options($options,'woothemes' ); header( "Location: admin.php?page=woothemes&reset=true" ); die; break; case 'woothemes_framework_settings': $options = get_option( 'woo_framework_template' ); woo_reset_options($options); header( "Location: admin.php?page=woothemes_framework_settings&reset=true" ); die; break; case 'woothemes_seo': $options = get_option( 'woo_seo_template' ); woo_reset_options($options); header( "Location: admin.php?page=woothemes_seo&reset=true" ); die; break; case 'woothemes_sbm': delete_option( 'sbm_woo_sbm_options' ); header( "Location: admin.php?page=woothemes_sbm&reset=true" ); die; break; } // End SWITCH Statement } // End IF Statement } // End IF Statement // Check all the Options, then if the no options are created for a relative sub-page... it's not created. if(get_option( 'framework_woo_backend_icon')) { $icon = get_option( 'framework_woo_backend_icon' ); } else { $icon = get_template_directory_uri() . '/functions/images/woo-icon.png'; } if(function_exists( 'add_object_page')) { add_object_page ( 'Page Title', $themename, 'manage_options','woothemes', 'woothemes_options_page', $icon); } else { add_menu_page ( 'Page Title', $themename, 'manage_options','woothemes_home', 'woothemes_options_page', $icon); } $woopage = add_submenu_page( 'woothemes', $themename, 'Theme Options', 'manage_options', 'woothemes','woothemes_options_page' ); // Default // Framework Settings Menu Item $wooframeworksettings = ''; if($super_user == $current_user_id || empty($super_user)) { $wooframeworksettings = add_submenu_page( 'woothemes', 'Framework Settings', 'Framework Settings', 'manage_options', 'woothemes_framework_settings', 'woothemes_framework_settings_page' ); } // Add SEO Menu Item $wooseo = ''; if ( get_option( 'framework_woo_seo_disable') != 'true' ) $wooseo = add_submenu_page( 'woothemes', 'SEO', 'SEO', 'manage_options', 'woothemes_seo', 'woothemes_seo_page' ); // Add Sidebar Manager Menu Item $woosbm = ''; if ( get_option( 'framework_woo_sbm_disable') != 'true' ) $woosbm = add_submenu_page( 'woothemes', 'Sidebar Manager', 'Sidebar Manager', 'manage_options', 'woothemes_sbm', 'woothemes_sbm_page' ); // Woothemes Content Builder if (function_exists( 'woothemes_content_builder_menu')) { woothemes_content_builder_menu(); } // Custom Navigation Menu Item if (function_exists( 'woo_custom_navigation_menu')) { woo_custom_navigation_menu(); } // Update Framework Menu Item if($super_user == $current_user_id || empty($super_user)) { $woothemepage = add_submenu_page( 'woothemes', 'WooFramework Update', 'Update Framework', 'manage_options', 'woothemes_framework_update', 'woothemes_framework_update_page' ); } // Buy Themes Menu Item if(get_option( 'framework_woo_buy_themes_disable') != 'true') { $woothemepage = add_submenu_page( 'woothemes', 'Available WooThemes', 'Buy Themes', 'manage_options', 'woothemes_themes', 'woothemes_more_themes_page' ); add_action( "admin_print_scripts-$woothemepage", 'woo_load_only' ); } // Add framework functionaily to the head individually add_action( "admin_print_scripts-$woopage", 'woo_load_only' ); add_action( "admin_print_scripts-$wooframeworksettings", 'woo_load_only' ); add_action( "admin_print_scripts-$wooseo", 'woo_load_only' ); add_action( "admin_print_scripts-$woosbm", 'woo_load_only' ); } } add_action( 'admin_menu', 'woothemes_add_admin' ); /*-----------------------------------------------------------------------------------*/ /* WooThemes Reset Function - woo_reset_options */ /*-----------------------------------------------------------------------------------*/ if (!function_exists( 'woo_reset_options')) { function woo_reset_options($options,$page = ''){ $excludes = array( 'blogname' , 'blogdescription' ); foreach($options as $option){ if(isset($option['id'])){ $option_id = $option['id']; $option_type = $option['type']; //Skip assigned id's if(in_array($option_id,$excludes)) { continue; } if($option_type == 'multicheck'){ foreach($option['options'] as $option_key => $option_option){ $del = $option_id . "_" . $option_key; delete_option($del); } } else if(is_array($option_type)) { foreach($option_type as $inner_option){ $option_id = $inner_option['id']; $del = $option_id; delete_option($option_id); } } else { delete_option($option_id); } } } //When Theme Options page is reset - Add the woo_options option if($page == 'woothemes'){ delete_option( 'woo_options' ); } } } /*-----------------------------------------------------------------------------------*/ /* Framework options panel - woothemes_options_page */ /*-----------------------------------------------------------------------------------*/ if (!function_exists( 'woothemes_options_page')) { function woothemes_options_page(){ $options = get_option( 'woo_template' ); $themename = get_option( 'woo_themename' ); $shortname = get_option( 'woo_shortname' ); $manualurl = get_option( 'woo_manual' ); //Framework Version in Backend Header $woo_framework_version = get_option( 'woo_framework_version' ); //Version in Backend Header $theme_data = get_theme_data( get_template_directory() . '/style.css' ); $local_version = $theme_data['Version']; //GET themes update RSS feed and do magic include_once(ABSPATH . WPINC . '/feed.php' ); $pos = strpos($manualurl, 'documentation' ); $theme_slug = str_replace( "/", "", substr($manualurl, ($pos + 13))); //13 for the word documentation //add filter to make the rss read cache clear every 4 hours //add_filter( 'wp_feed_cache_transient_lifetime', create_function( '$a', 'return 14400;' ) ); //Check for latest version of the theme $update_message = ''; if(get_option( 'framework_woo_theme_version_checker') == 'true') { $update_message = woothemes_version_checker($local_version); } global $pagenow; ?>
Options Updated
Options Reset
'; echo '' // COLOR Picker ?> '; //print_r($new_import); //echo ''; if(!empty($new_import)) { foreach($new_import as $id2 => $value2){ if(is_serialized($value2)) { update_option($id2,unserialize($value2)); } else { update_option($id2,$value2); } } } } else { $type = $option_array['type']; if ( is_array($type)){ foreach($type as $array){ if($array['type'] == 'text'){ $id = $array['id']; $std = $array['std']; $new_value = $output[$id]; if($new_value == ''){ $new_value = $std; } update_option( $id, stripslashes($new_value)); } } } elseif ( $type == 'text' && $save_type == 'seo' ) { // Text Save $new_value = $output[$id]; if( $new_value == '' && $std != '' ){ $new_value = $std; } $new_value = stripslashes( stripslashes( $new_value ) ); update_option( $id, $new_value ); } elseif($new_value == '' && $type == 'checkbox'){ // Checkbox Save update_option($id,'false' ); } elseif ($new_value == 'true' && $type == 'checkbox'){ // Checkbox Save update_option($id,'true' ); } elseif($type == 'multicheck'){ // Multi Check Save $option_options = $option_array['options']; foreach ($option_options as $options_id => $options_value){ $multicheck_id = $id . "_" . $options_id; if(!isset($output[$multicheck_id])){ update_option($multicheck_id,'false' ); } else{ update_option($multicheck_id,'true' ); } } } elseif($type == 'typography'){ $typography_array = array(); $typography_array['size'] = $output[$option_array['id'] . '_size']; $typography_array['unit'] = $output[$option_array['id'] . '_unit']; $typography_array['face'] = stripslashes($output[$option_array['id'] . '_face']); $typography_array['style'] = $output[$option_array['id'] . '_style']; $typography_array['color'] = $output[$option_array['id'] . '_color']; update_option($id,$typography_array); } elseif($type == 'border'){ $border_array = array(); $border_array['width'] = $output[$option_array['id'] . '_width']; $border_array['style'] = $output[$option_array['id'] . '_style']; $border_array['color'] = $output[$option_array['id'] . '_color']; update_option($id,$border_array); } elseif($type != 'upload_min'){ update_option($id,stripslashes($new_value)); } } } } } if( $save_type == 'options' OR $save_type == 'framework' ){ /* Create, Encrypt and Update the Saved Settings */ $woo_options = array(); $data = array(); if($save_type == 'framework' ){ $options = get_option( 'woo_template' ); } foreach($options as $option){ if(isset($option['id'])){ $count++; $option_id = $option['id']; $option_type = $option['type']; if(is_array($option_type)) { $type_array_count = 0; foreach($option_type as $inner_option){ $option_id = $inner_option['id']; $data[$option_id] .= get_option($option_id); } } else { $data[$option_id] = get_option($option_id); } } } $output = ""; $output = base64_encode($output); update_option( 'woo_options',$woo_array); update_option( 'woo_settings_encode',$output); } die(); } } /*-----------------------------------------------------------------------------------*/ /* Generates The Options - woothemes_machine */ /*-----------------------------------------------------------------------------------*/ if (!function_exists( 'woothemes_machine')) { function woothemes_machine($options) { $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; //Start Heading if ( $value['type'] != "heading" ) { $class = ''; if(isset( $value['class'] )) { $class = $value['class']; } //$output .= '
'."\n".'
'."\n"; $output .= '
'."\n"; $output .= '

'. $value['name'] .'

'."\n"; $output .= '
'."\n" . '
'."\n"; } //End Heading $select_value = ''; switch ( $value['type'] ) { case 'text': $val = $value['std']; $std = get_option($value['id']); if ( $std != "") { $val = $std; } $val = stripslashes( $val ); // Strip out unwanted slashes. $output .= ''; break; case 'select': $output .= '
'; break; case 'select2': $output .= '
'; break; case 'calendar': $val = $value['std']; $std = get_option($value['id']); if ( $std != "") { $val = $std; } $output .= ''; break; case 'time': $val = $value['std']; $std = get_option($value['id']); if ( $std != "") { $val = $std; } $output .= ''; break; case 'textarea': $cols = '8'; $ta_value = ''; if(isset($value['std'])) { $ta_value = $value['std']; if(isset($value['options'])){ $ta_options = $value['options']; if(isset($ta_options['cols'])){ $cols = $ta_options['cols']; } else { $cols = '8'; } } } $std = get_option($value['id']); if( $std != "") { $ta_value = stripslashes( $std ); } $output .= ''; break; case "radio": $select_value = get_option( $value['id']); foreach ($value['options'] as $key => $option) { $checked = ''; if($select_value != '') { if ( $select_value == $key) { $checked = ' checked'; } } else { if ($value['std'] == $key) { $checked = ' checked'; } } $output .= '' . $option .'
'; } break; case "checkbox": $std = $value['std']; $saved_std = get_option($value['id']); $checked = ''; if(!empty($saved_std)) { if($saved_std == 'true') { $checked = 'checked="checked"'; } else{ $checked = ''; } } elseif( $std == 'true') { $checked = 'checked="checked"'; } else { $checked = ''; } $output .= ''; break; case "multicheck": $std = $value['std']; foreach ($value['options'] as $key => $option) { $woo_key = $value['id'] . '_' . $key; $saved_std = get_option($woo_key); if(!empty($saved_std)) { if($saved_std == 'true'){ $checked = 'checked="checked"'; } else{ $checked = ''; } } elseif( $std == $key) { $checked = 'checked="checked"'; } else { $checked = ''; } $output .= '
'; } break; case "multicheck2": $std = explode( ',',$value['std']); foreach ($value['options'] as $key => $option) { $woo_key = $value['id'] . '_' . $key; $saved_std = get_option($woo_key); if(!empty($saved_std)) { if($saved_std == 'true'){ $checked = 'checked="checked"'; } else{ $checked = ''; } } elseif( in_array($key,$std)) { $checked = 'checked="checked"'; } else { $checked = ''; } $output .= '
'; } break; case "upload": if ( function_exists( 'woothemes_medialibrary_uploader' ) ) { $output .= woothemes_medialibrary_uploader( $value['id'], $value['std'], null ); // New AJAX Uploader using Media Library } else { $output .= woothemes_uploader_function($value['id'],$value['std'],null); // Original AJAX Uploader } // End IF Statement break; case "upload_min": if ( function_exists( 'woothemes_medialibrary_uploader' ) ) { $output .= woothemes_medialibrary_uploader( $value['id'], $value['std'], 'min' ); // New AJAX Uploader using Media Library } else { $output .= woothemes_uploader_function($value['id'],$value['std'],'min' ); // Original AJAX Uploader } // End IF Statement // $output .= woothemes_uploader_function($value['id'],$value['std'],'min' ); break; case "color": $val = $value['std']; $stored = get_option( $value['id'] ); if ( $stored != "") { $val = $stored; } $output .= '
'; $output .= ''; break; case "typography": $default = $value['std']; $typography_stored = get_option($value['id']); /* Font Size */ $val = $default['size']; if ( $typography_stored['size'] != "") { $val = $typography_stored['size']; } if ( $typography_stored['unit'] == 'px'){ $show_px = ''; $show_em = ' style="display:none" '; $name_px = ' name="'. $value['id'].'_size" '; $name_em = ''; } else if ( $typography_stored['unit'] == 'em'){ $show_em = ''; $show_px = 'style="display:none"'; $name_em = ' name="'. $value['id'].'_size" '; $name_px = ''; } else { $show_px = ''; $show_em = ' style="display:none" '; $name_px = ' name="'. $value['id'].'_size" '; $name_em = ''; } $output .= ''; $output .= ''; /* Font Unit */ $val = $default['unit']; if ( $typography_stored['unit'] != "") { $val = $typography_stored['unit']; } $em = ''; $px = ''; if($val == 'em'){ $em = 'selected="selected"'; } if($val == 'px'){ $px = 'selected="selected"'; } $output .= ''; /* Font Face */ $val = $default['face']; if ( $typography_stored['face'] != "") $val = $typography_stored['face']; $font01 = ''; $font02 = ''; $font03 = ''; $font04 = ''; $font05 = ''; $font06 = ''; $font07 = ''; $font08 = ''; $font09 = ''; $font10 = ''; $font11 = ''; $font12 = ''; $font13 = ''; $font14 = ''; $font15 = ''; $font16 = ''; if (strpos($val, 'Arial, sans-serif') !== false){ $font01 = 'selected="selected"'; } if (strpos($val, 'Verdana, Geneva') !== false){ $font02 = 'selected="selected"'; } if (strpos($val, 'Trebuchet') !== false){ $font03 = 'selected="selected"'; } if (strpos($val, 'Georgia') !== false){ $font04 = 'selected="selected"'; } if (strpos($val, 'Times New Roman') !== false){ $font05 = 'selected="selected"'; } if (strpos($val, 'Tahoma, Geneva') !== false){ $font06 = 'selected="selected"'; } if (strpos($val, 'Palatino') !== false){ $font07 = 'selected="selected"'; } if (strpos($val, 'Helvetica') !== false){ $font08 = 'selected="selected"'; } if (strpos($val, 'Calibri') !== false){ $font09 = 'selected="selected"'; } if (strpos($val, 'Myriad') !== false){ $font10 = 'selected="selected"'; } if (strpos($val, 'Lucida') !== false){ $font11 = 'selected="selected"'; } if (strpos($val, 'Arial Black') !== false){ $font12 = 'selected="selected"'; } if (strpos($val, 'Gill') !== false){ $font13 = 'selected="selected"'; } if (strpos($val, 'Geneva, Tahoma') !== false){ $font14 = 'selected="selected"'; } if (strpos($val, 'Impact') !== false){ $font15 = 'selected="selected"'; } if (strpos($val, 'Courier') !== false){ $font16 = 'selected="selected"'; } $output .= ''; /* Font Weight */ $val = $default['style']; if ( $typography_stored['style'] != "") { $val = $typography_stored['style']; } $normal = ''; $italic = ''; $bold = ''; $bolditalic = ''; if($val == 'normal'){ $normal = 'selected="selected"'; } if($val == 'italic'){ $italic = 'selected="selected"'; } if($val == 'bold'){ $bold = 'selected="selected"'; } if($val == 'bold italic'){ $bolditalic = 'selected="selected"'; } $output .= ''; /* Font Color */ $val = $default['color']; if ( $typography_stored['color'] != "") { $val = $typography_stored['color']; } $output .= '
'; $output .= ''; break; case "border": $default = $value['std']; $border_stored = get_option( $value['id'] ); /* Border Width */ $val = $default['width']; if ( $border_stored['width'] != "") { $val = $border_stored['width']; } $output .= ''; /* Border Style */ $val = $default['style']; if ( $border_stored['style'] != "") { $val = $border_stored['style']; } $solid = ''; $dashed = ''; $dotted = ''; if($val == 'solid'){ $solid = 'selected="selected"'; } if($val == 'dashed'){ $dashed = 'selected="selected"'; } if($val == 'dotted'){ $dotted = 'selected="selected"'; } $output .= ''; /* Border Color */ $val = $default['color']; if ( $border_stored['color'] != "") { $val = $border_stored['color']; } $output .= '
'; $output .= ''; break; case "images": $i = 0; $select_value = get_option( $value['id']); foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if($select_value != '') { if ( $select_value == $key) { $checked = ' checked'; $selected = 'woo-radio-img-selected'; } } else { if ($value['std'] == $key) { $checked = ' checked'; $selected = 'woo-radio-img-selected'; } elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'woo-radio-img-selected'; } elseif ($i == 1 && $value['std'] == '') { $checked = ' checked'; $selected = 'woo-radio-img-selected'; } else { $checked = ''; } } $output .= ''; $output .= ''; $output .= '
'. $key .'
'; $output .= ''; $output .= '
'; } break; case "info": $default = $value['std']; $output .= $default; break; case "string_builder": $desc = $value['std']; $output .= '
'; $output .= 'Name'; $output .= 'Font Stack'; $output .= ''; $output .= '
'; $output .= '

'.$desc.'

'; $saved_data = get_option($value['id']); if(!empty($saved_data)){ foreach($saved_data as $name => $data){ $data = stripslashes($data); $output .= '
'.str_replace( '_',' ',$name) .': '. $data .'
'; } } $output .= ''; $output .= '
'; $output .= '
'; break; case "heading": if($counter >= 2){ $output .= '
'."\n"; } $jquery_click_hook = ereg_replace( "[^A-Za-z0-9]", "", strtolower($value['name']) ); $jquery_click_hook = "woo-option-" . $jquery_click_hook; // $jquery_click_hook = "woo-option-" . str_replace( "&","",str_replace( "/","",str_replace( ".","",str_replace( ")","",str_replace( "( ","",str_replace( " ","",strtolower($value['name']))))))); $menu .= '
  • '. $value['name'] .'
  • '; $output .= '

    '.$value['name'].'

    '."\n"; break; } // if TYPE is an array, formatted into smaller inputs... ie smaller values if ( is_array($value['type'])) { foreach($value['type'] as $array){ $id = $array['id']; $std = $array['std']; $saved_std = get_option($id); if($saved_std != $std){$std = $saved_std;} $meta = $array['meta']; if($array['type'] == 'text') { // Only text at this point $output .= ''; $output .= ''.$meta.''; } } } if ( $value['type'] != "heading" ) { if ( $value['type'] != "checkbox" ) { $output .= '
    '; } if(!isset($value['desc'])){ $explain_value = ''; } else{ $explain_value = $value['desc']; } $output .= '
    '. $explain_value .'
    '."\n"; $output .= '
    '."\n"; } } //Checks if is not the Content Builder page if ( isset($_REQUEST['page']) && $_REQUEST['page'] != 'woothemes_content_builder' ) { $output .= '
    '; } return array($output,$menu); } } /*-----------------------------------------------------------------------------------*/ /* WooThemes Uploader - woothemes_uploader_function */ /*-----------------------------------------------------------------------------------*/ if (!function_exists( 'woothemes_uploader_function')) { function woothemes_uploader_function($id,$std,$mod){ //$uploader .= ''; //$uploader .= ''; $uploader = ''; $upload = get_option($id); if($mod != 'min') { $val = $std; if ( get_option( $id ) != "") { $val = get_option($id); } $uploader .= ''; } $uploader .= '
    Upload Image'; if(!empty($upload)) {$hide = '';} else { $hide = 'hide';} $uploader .= 'Remove'; $uploader .='
    ' . "\n"; $uploader .= '
    ' . "\n"; if(!empty($upload)){ //$upload = cleanSource($upload); // Removed since V.2.3.7 it's not showing up $uploader .= ''; $uploader .= ''; $uploader .= ''; } $uploader .= '
    ' . "\n"; return $uploader; } } /*-----------------------------------------------------------------------------------*/ /* Woothemes Theme Version Checker - woothemes_version_checker */ /* @local_version is the installed theme version number */ /*-----------------------------------------------------------------------------------*/ if (!function_exists( 'woothemes_version_checker')) { function woothemes_version_checker ($local_version) { function do_not_cache_feeds(&$feed) { $feed->enable_cache(false); } add_action( 'wp_feed_options', 'do_not_cache_feeds' ); // Get a SimplePie feed object from the specified feed source. $theme_name = str_replace( "-","",strtolower(get_option( 'woo_themename'))); $feed_url = 'http://www.woothemes.com/?feed=updates&theme=' . $theme_name; $rss = fetch_feed($feed_url); // Of the RSS is failed somehow. if ( is_wp_error($rss) ) { /* $error = $rss->get_error_code(); $update_message = '
    Update notifier failed ('.$error.')
    '; return $update_message; */ // Return without notification return; } //Figure out how many total items there are, but limit it to 5. $maxitems = $rss->get_item_quantity(100); // Build an array of all the items, starting with element 0 (first element). $rss_items = $rss->get_items(0, $maxitems); if ($maxitems == 0) { $latest_version_via_rss = 0; } else { // Loop through each feed item and display each item as a hyperlink. foreach ( $rss_items as $item ) : $latest_version_via_rss = $item->get_title(); endforeach; } //Check if version is the latest - assume standard structure x.x.x $pieces_rss = explode( ".", $latest_version_via_rss); $pieces_local = explode( ".", $local_version); //account for null values in second position x.2.x if(isset($pieces_rss[0]) && $pieces_rss[0] != 0) { if (!isset($pieces_rss[1])) $pieces_rss[1] = '0'; if (!isset($pieces_local[1])) $pieces_local[1] = '0'; //account for null values in third position x.x.3 if (!isset($pieces_rss[2])) $pieces_rss[2] = '0'; if (!isset($pieces_local[2])) $pieces_local[2] = '0'; //do the comparisons $version_sentinel = false; if ($pieces_rss[0] > $pieces_local[0]) { $version_sentinel = true; } if (($pieces_rss[1] > $pieces_local[1]) AND ($version_sentinel == false) AND ($pieces_rss[0] == $pieces_local[0])) { $version_sentinel = true; } if (($pieces_rss[2] > $pieces_local[2]) AND ($version_sentinel == false) AND ($pieces_rss[0] == $pieces_local[0]) AND ($pieces_rss[1] == $pieces_local[1])) { $version_sentinel = true; } //set version checker message if ($version_sentinel == true) { $update_message = '
    Theme update is available (v.' . $latest_version_via_rss . ') - Get the new version.
    '; } else { $update_message = ''; } } else { $update_message = ''; } return $update_message; } } ?>