__( 'Settings saved.', 'boldr' ), 'reset_confirm' => __( 'Are you sure you want to reset ALL settings for this theme to default values?', 'boldr' ), ); wp_localize_script( 'boldr_admin_js', 'boldr_js_strings', $boldr_translation_array ); wp_enqueue_script( 'boldr_admin_js' ); } // Generates the settings panel's menu function boldr_settings_machine_menu($options) { $output = ""; foreach ($options as $arg) { if ( $arg['type'] == "start_menu" ) { $output .= '
  • '.$arg['name'].'
  • '."\n"; } } return $output; } // Generate the settings panel's content function boldr_settings_machine($options) { global $boldr_settings_slug; $boldr_settings = get_option($boldr_settings_slug); $output = ""; foreach ($options as $arg) { if ( is_array($arg) && is_array($boldr_settings) ) { if ( array_key_exists('id', $arg) ) { if ( array_key_exists($arg['id'], $boldr_settings) ) $val = stripslashes($boldr_settings[$arg['id']]); else $val = ""; } else { $val = ""; } } else { $val = ""; } if ( $arg['type'] == "start_menu" ) { $output .= '
    '; } elseif ( $arg['type'] == "radio" ) { $output .= '

    '. $arg['name'] .'

    '."\n"; if ( $val == "" && $arg['default'] != "") $boldr_settings[$arg['id']] = $val = $arg['default']; $values = $arg['values']; $output .= '
    '; foreach ($values as $value) { $output .= ''.$value['display'].'
    '; } $output .= '
    '; $output .= '
    '."\n"; } elseif ( $arg['type'] == "image" ) { $output .= '

    '. $arg['name'] .'

    '."\n"; if ( $val == "" && $arg['default'] != "") $boldr_settings[$arg['id']] = $val = $arg['default']; $output .= ''."\n"; $output .= '

    '."\n"; $output .= ''."\n"; $output .= '
    '."\n"; $output .= '
    '."\n"; } elseif ( $arg['type'] == "gopro" ) { $output .= '

    '. $arg['name'] .'

    '."\n"; $output .= sprintf( __('

    Unleash the full potential of BoldR by upgrading to BoldR Pro!

    The Pro version comes with a great set of awesome features:

    Learn More and Upgrade Now!', 'boldr'), 'http://www.iceablethemes.com/shop/boldr-pro/?utm_source=lite_theme&utm_medium=go_pro&utm_campaign=boldr_lite'); } elseif ( $arg['type'] == "support_feedback" ) { $output .= '

    '.__('Get Support','boldr').'

    '."\n"; $output .= '

    '.__('Have a question? Need help?', 'boldr').'

    '; $output .= '

    '.__('Visit the free BoldR Lite support forums','boldr').'

    '; $output .= '

    '.__('Give Feedback', 'boldr').'

    '."\n"; $output .= '

    '.__('Like this theme? We\'d love to hear your feedback!','boldr').'

    '; $output .= '

    '.__('Rate and review BoldR Lite at WordPress.org','boldr').'

    '; $output .= '

    '.__('Get social!', 'boldr').'

    '."\n"; $output .= '

    '.__('Follow and like IceableThemes!','boldr').'

    '; $output .= '

    '; } elseif ( $arg['type'] == "end_menu" ) { $output .= '
    '; } } return $output; } // AJAX callback function for the "reset" button (resets settings to default) function boldr_settings_reset_ajax_callback() { if ( ! current_user_can('edit_theme_options') ) wp_die(__('You do not have permission to edit theme options.', 'boldr')); global $boldr_settings_slug; // Get settings from the database $boldr_settings = get_option($boldr_settings_slug); // Get the settings template $options = boldr_settings_template(); // Revert all settings to default value foreach($options as $arg){ if ($arg['type'] != 'start_menu' && $arg['type'] != 'end_menu' && isset($arg['default'])) { $boldr_settings[$arg['id']] = $arg['default']; } } // Updates settings in the database update_option($boldr_settings_slug,$boldr_settings); } add_action('wp_ajax_boldr_settings_reset_ajax_post_action', 'boldr_settings_reset_ajax_callback'); // AJAX callback function for the "Save changes" button (updates user's settings in the database) function boldr_settings_ajax_callback() { if ( ! current_user_can('edit_theme_options') ) wp_die(__('You do not have permission to edit theme options.', 'boldr')); global $boldr_settings_slug; // Check nonce check_ajax_referer('boldr_settings_ajax_post_action','boldr_settings_nonce'); // Get POST data $data = $_POST['data']; parse_str($data,$input); // Get current settings from the database $boldr_settings = get_option($boldr_settings_slug); // Get the settings template $options = boldr_settings_template(); // Validate input and update all settings according to POST data foreach($options as $option_array){ if (isset($option_array['id']) && $option_array['type'] != 'start_menu' && $option_array['type'] != 'end_menu') { $id = $option_array['id']; if ($option_array['type'] == "radio" ) { $allowed_values = array(); foreach ($option_array['values'] as $value): $allowed_values[] = $value['value']; endforeach; if ( in_array( $input[$option_array['id']], $allowed_values) ) { $new_value = $input[$option_array['id']]; } else { $new_value = $option_array['default']; } } elseif ($option_array['type'] == "image") { $new_value = esc_url_raw($input[$option_array['id']]); } $boldr_settings[$id] = stripslashes($new_value); } } // Updates settings in the database update_option($boldr_settings_slug,$boldr_settings); } add_action('wp_ajax_boldr_settings_ajax_post_action', 'boldr_settings_ajax_callback'); // NOJS fallback for the "Save changes" button function boldr_settings_save_nojs() { if ( ! current_user_can('edit_theme_options') ) wp_die(__('You do not have permission to edit theme options.', 'boldr')); global $boldr_settings_slug; // Get POST data // parse_str($_POST,$output); // Get current settings from the database $boldr_settings = get_option($boldr_settings_slug); // Get the settings template $options = boldr_settings_template(); // Updates all settings according to POST data foreach($options as $option_array){ if ( isset($option_array['id']) && $option_array['type'] != 'start_menu' && $option_array['type'] != 'end_menu' ) { $id = $option_array['id']; if ($option_array['type'] == "radio" ) { if ( in_array( $_POST[$option_array['id']], $option_array['values']) ) { $new_value = $_POST[$option_array['id']]; } else { $new_value = $option_array['default']; } } elseif ($option_array['type'] == "image") { $new_value = esc_url_raw($_POST[$option_array['id']]); } $boldr_settings[$id] = stripslashes($new_value); } } // Updates settings in the database update_option($boldr_settings_slug,$boldr_settings); } // Outputs the settings panel function boldr_settings_page(){ wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); global $boldr_settings_slug; global $boldr_settings_name; if (isset( $_POST['reset-no-js'] ) && $_POST['reset-no-js']) { boldr_settings_reset_ajax_callback(); echo '

    '.__('Settings were reset to default.', 'boldr').'

    '; } if (isset( $_POST['save-no-js'] ) && $_POST['save-no-js']) { boldr_settings_save_nojs(); echo '

    '.__('Settings updated.', 'boldr').'

    '; } ?>

    ' . sprintf( __('BoldR Lite Notice: you have not set your primary menu yet, and your site is currently using a fallback menu which is not responsive. Please take a minute to set your menu now!','boldr'), admin_url('nav-menus.php') ) . '

    '; endif; ?>