$val ) {
$the_opt[$key] = $the_coa[$key]['default'];
}
$the_opt['version'] = ''; //null value to keep admin notice alive and invite user to discover theme options
update_option( 'boozurk_options' , $the_opt );
} else if ( !isset( $the_opt['version'] ) || $the_opt['version'] < boozurk_get_info( 'version' ) ) {
// check for unset values and set them to default value -> when updated to new version
foreach ( $the_coa as $key => $val ) {
if ( !isset( $the_opt[$key] ) ) $the_opt[$key] = $the_coa[$key]['default'];
}
$the_opt['version'] = ''; //null value to keep admin notice alive and invite user to discover theme options
update_option( 'boozurk_options' , $the_opt );
}
}
// print a reminder message for set the options after the theme is installed or updated
function boozurk_setopt_admin_notice() {
if ( current_user_can( 'manage_options' ) && ( boozurk_get_opt( 'version' ) < boozurk_get_info( 'version' ) ) )
echo '
' . sprintf( __( "%s theme says: \"Dont forget to set my options!\"", 'boozurk' ), 'Boozurk', get_admin_url() . 'themes.php?page=boozurk_functions' ) . '
';
}
//add js script to the options page
function boozurk_theme_admin_scripts() {
wp_enqueue_media();
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_script( 'boozurk-options-script', get_template_directory_uri().'/js/options.dev.js', array( 'jquery', 'farbtastic', 'thickbox' ), boozurk_get_info( 'version' ), true ); //thebird js
$data = array(
'confirm_to_defaults' => __( 'Are you really sure you want to set all the options to their default values?', 'boozurk' )
);
wp_localize_script( 'boozurk-options-script', 'boozurk_options_l10n', $data );
}
//add custom stylesheet
function boozurk_widgets_style() {
wp_enqueue_style( 'boozurk-widgets-style', get_template_directory_uri() . '/css/widgets.css', false, '', 'screen' );
}
//add js script to the widgets page
function boozurk_widgets_scripts() {
wp_enqueue_script( 'boozurk-widgets-scripts', get_template_directory_uri() . '/js/widgets.dev.js', array('jquery'), boozurk_get_info( 'version' ), true );
}
// the custon header page style
function boozurk_theme_admin_styles() {
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style( 'boozurk-options-style', get_template_directory_uri() . '/css/options.css', array('farbtastic','thickbox'), '', 'screen' );
}
// sanitize options value
if ( !function_exists( 'boozurk_sanitize_options' ) ) {
function boozurk_sanitize_options($input) {
$the_coa = boozurk_get_coa();
foreach ( $the_coa as $key => $val ) {
if( $the_coa[$key]['type'] == 'chk' ) { //CHK
if( !isset( $input[$key] ) ) {
$input[$key] = 0;
} else {
$input[$key] = ( $input[$key] == 1 ? 1 : 0 );
}
} elseif( $the_coa[$key]['type'] == 'sel' ) { //SEL
if ( !in_array( $input[$key], $the_coa[$key]['options'] ) )
$input[$key] = $the_coa[$key]['default'];
} elseif( $the_coa[$key]['type'] == 'opt' ) { //OPT
if ( !in_array( $input[$key], $the_coa[$key]['options'] ) )
$input[$key] = $the_coa[$key]['default'];
} elseif( $the_coa[$key]['type'] == 'col' ) { //COL
$color = str_replace( '#' , '' , $input[$key] );
$color = preg_replace( '/[^0-9a-fA-F]/' , '' , $color );
$input[$key] = '#' . $color;
} elseif( $the_coa[$key]['type'] == 'url' ) { //URL
$input[$key] = esc_url( trim( strip_tags( $input[$key] ) ) );
} elseif( $the_coa[$key]['type'] == 'txt' ) { //TXT
if( !isset( $input[$key] ) ) {
$input[$key] = '';
} else {
$input[$key] = trim( strip_tags( $input[$key] ) );
}
} elseif( $the_coa[$key]['type'] == 'int' ) { //INT
if( !isset( $input[$key] ) ) {
$input[$key] = $the_coa[$key]['default'];
} else {
$input[$key] = (int) $input[$key] ;
}
} elseif( $the_coa[$key]['type'] == 'txtarea' ) { //TXTAREA
if( !isset( $input[$key] ) ) {
$input[$key] = '';
} else {
$input[$key] = trim( strip_tags( $input[$key] ) );
}
}
}
foreach ( $input['boozurk_cat_colors'] as $key => $val ) { //CATCOL
$color = str_replace( '#' , '' , $input['boozurk_cat_colors'][$key] );
$color = preg_replace( '/[^0-9a-fA-F]/' , '' , $color );
$input['boozurk_cat_colors'][$key] = '#' . $color;
}
// check for required options
foreach ( $the_coa as $key => $val ) {
if ( $the_coa[$key]['req'] != '' ) { if ( $input[$the_coa[$key]['req']] == ( 0 || '') ) $input[$key] = 0; }
}
$input['version'] = boozurk_get_info( 'version' ); // keep version number
return $input;
}
}
// the theme option page
if ( !function_exists( 'boozurk_edit_options' ) ) {
function boozurk_edit_options() {
if ( !current_user_can( 'edit_theme_options' ) ) wp_die( 'You do not have sufficient permissions to access this page.' );
global $boozurk_opt;
$the_coa = boozurk_get_coa();
$the_groups = boozurk_get_coa( 'groups' );
$the_option_name = 'boozurk_options';
if ( isset( $_GET['erase'] ) ) {
$_SERVER['REQUEST_URI'] = remove_query_arg( 'erase', $_SERVER['REQUEST_URI'] );
delete_option( $the_option_name );
boozurk_default_options();
$boozurk_opt = get_option( $the_option_name );
}
// update version value when admin visit options page
if ( $boozurk_opt['version'] < boozurk_get_info( 'version' ) ) {
$boozurk_opt['version'] = boozurk_get_info( 'version' );
update_option( $the_option_name , $boozurk_opt );
}
$the_opt = $boozurk_opt;
// options have been updated
if ( isset( $_REQUEST['settings-updated'] ) ) {
//return options save message
echo '' . __( 'Options saved.','boozurk' ) . '
';
}
// options to defaults done
if ( isset( $_GET['erase'] ) ) {
echo '' . __( 'Defaults values loaded.', 'boozurk' ) . '
';
}
?>
Support the theme in your language, provide a translation.