themename = AKYUZ_THEMENAME;
// This will keep track of the checkbox options for the validate_settings function.
$this->akyuz_checkboxes = array();
$this->akyuz_settings = array();
$this->akyuz_get_setting();
$this->akyuz_sections[AKYUZ_SHORTNAME.'_tab_social_networks'] = __( 'Social Networks' , AKYUZ_TEXT_DOMAIN);
$this->akyuz_sections[AKYUZ_SHORTNAME.'_tab_footer'] = __( 'Footer' , AKYUZ_TEXT_DOMAIN);
$this->akyuz_sections[AKYUZ_SHORTNAME.'_tab_tracking'] = __( 'Tracking Settings' , AKYUZ_TEXT_DOMAIN);
$this->akyuz_sections[AKYUZ_SHORTNAME.'_tab_advertising'] = __( 'Advertising' , AKYUZ_TEXT_DOMAIN);
$this->akyuz_sections[AKYUZ_SHORTNAME.'_tab_about'] = __( 'About' , AKYUZ_TEXT_DOMAIN);
$this->akyuz_sections[AKYUZ_SHORTNAME.'_tab_reset'] = __( 'Reset Options' , AKYUZ_TEXT_DOMAIN);
add_action( 'admin_menu', array( &$this, 'akyuz_add_pages' ) );
add_action( 'admin_init', array( &$this, 'register_settings' ) );
if ( ! get_option( 'akyuz_options' ) )
$this->initialize_settings();
}
/**
* Add options page
*
* @since 1.0
*/
public function akyuz_add_pages() {
$admin_page = add_theme_page( __( 'Theme Options', AKYUZ_TEXT_DOMAIN ), __( 'Akyuz Theme Options', AKYUZ_TEXT_DOMAIN ), 'manage_options', AKYUZ_OPTIONSPAGENAME, array( &$this, 'akyuz_display_page' ) );
add_action( 'admin_print_scripts-' . $admin_page, array( &$this, 'scripts' ) );
add_action( 'admin_print_styles-' . $admin_page, array( &$this, 'styles' ) );
}
/**
* Create settings field
*
* @since 1.0
*/
public function akyuz_create_setting( $args = array() ) {
$defaults = array(
'id' => 'default_field',
'title' => __( 'Default Field', AKYUZ_TEXT_DOMAIN ),
'desc' => __( 'This is a default description.', AKYUZ_TEXT_DOMAIN ),
'std' => '',
'type' => 'text',
'section' => 'general',
'choices' => array(),
'class' => ''
);
extract( wp_parse_args( $args, $defaults ) );
$field_args = array(
'type' => $type,
'id' => $id,
'desc' => $desc,
'std' => $std,
'choices' => $choices,
'label_for' => $id,
'class' => $class
);
if ( $type == 'checkbox' )
$this->akyuz_checkboxes[] = $id;
add_settings_field( $id, $title, array( $this, 'display_setting' ), AKYUZ_OPTIONSPAGENAME, $section, $field_args );
}
/**
* Display options page
*
* @since 1.0
*/
public function akyuz_display_page() {
?>
' . $desc . ' ';
break;
case 'checkbox':
echo ' ' . $desc . ' ';
break;
case 'select':
echo '';
foreach ( $choices as $value => $label )
echo '' . $label . ' ';
echo ' ';
if ( $desc != '' )
echo '' . $desc . ' ';
break;
case 'radio':
$i = 0;
foreach ( $choices as $value => $label ) {
echo ' ' . $label . ' ';
if ( $i < count( $options ) - 1 )
echo ' ';
$i++;
}
if ( $desc != '' )
echo '' . $desc . ' ';
break;
case 'textarea':
echo '';
if ( $desc != '' )
echo '' . $desc . ' ';
break;
case 'password':
echo ' ';
if ( $desc != '' )
echo '' . $desc . ' ';
break;
case 'text':
echo ' ';
break;
default:
echo ' ';
if ( $desc != '' )
echo '' . $desc . ' ';
break;
}
}
/**
* Settings and defaults
*
* @since 1.0
*/
public function akyuz_get_setting() {
/* Social Networking Settings
===========================================*/
$this->akyuz_settings[AKYUZ_SHORTNAME.'_social_enable'] = array(
'title' => __( 'Enable Social Network', AKYUZ_TEXT_DOMAIN ),
'desc' => __( '', AKYUZ_TEXT_DOMAIN ),
'std' => '',
'type' => 'checkbox',
'section' => AKYUZ_SHORTNAME.'_tab_social_networks'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_social_facebook_url'] = array(
'title' => __( 'Facebook URL' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Enter your Facebook URL.', AKYUZ_TEXT_DOMAIN ),
'std' => 'http://',
'type' => 'text',
'section' => AKYUZ_SHORTNAME.'_tab_social_networks'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_social_twitter_url'] = array(
'title' => __( 'Twitter URL', AKYUZ_TEXT_DOMAIN ),
'desc' => __( 'Enter your Twitter URL.', AKYUZ_TEXT_DOMAIN ),
'std' => 'http://',
'type' => 'text',
'section' => AKYUZ_SHORTNAME.'_tab_social_networks'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_social_youtube_url'] = array(
'title' => __( 'YouTube URL', AKYUZ_TEXT_DOMAIN ),
'desc' => __( 'Enter your YouTube URL.', AKYUZ_TEXT_DOMAIN ),
'std' => 'http://',
'type' => 'text',
'section' => AKYUZ_SHORTNAME.'_tab_social_networks'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_social_flickr_url'] = array(
'title' => __( 'Flickr URL', AKYUZ_TEXT_DOMAIN ),
'desc' => __( 'Enter your Flickr URL.', AKYUZ_TEXT_DOMAIN ),
'std' => 'http://',
'type' => 'text',
'section' => AKYUZ_SHORTNAME.'_tab_social_networks'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_social_linkedin_url'] = array(
'title' => __( 'LinkedIn URL' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Enter your LinkedIn URL.', AKYUZ_TEXT_DOMAIN ),
'std' => 'http://',
'type' => 'text',
'section' => AKYUZ_SHORTNAME.'_tab_social_networks'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_social_delicious_url'] = array(
'title' => __( 'Delicious URL' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Enter your Delicious URL.', AKYUZ_TEXT_DOMAIN ),
'std' => 'http://',
'type' => 'text',
'section' => AKYUZ_SHORTNAME.'_tab_social_networks'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_social_rss_url'] = array(
'title' => __( 'Feedburner URL' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Feedburner URL' , AKYUZ_TEXT_DOMAIN),
'std' => get_bloginfo('rss2_url'),
'type' => 'text',
'section' => AKYUZ_SHORTNAME.'_tab_social_networks'
);
/* Advertising
===========================================*/
$this->akyuz_settings[AKYUZ_SHORTNAME.'_advertising_ads_top'] = array(
'title' => __( 'Top Advertising' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Top advertising space.', AKYUZ_TEXT_DOMAIN ),
'std' => '',
'type' => 'textarea',
'section' => AKYUZ_SHORTNAME.'_tab_advertising'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_advertising_ads_sidebar_1'] = array(
'title' => __( 'Sidebar Advertising-1' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Sidebar advertising space.', AKYUZ_TEXT_DOMAIN ),
'std' => '',
'type' => 'textarea',
'section' => AKYUZ_SHORTNAME.'_tab_advertising'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_advertising_ads_sidebar_2'] = array(
'title' => __( 'Sidebar Advertising-2' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Sidebar advertising space.', AKYUZ_TEXT_DOMAIN ),
'std' => '',
'type' => 'textarea',
'section' => AKYUZ_SHORTNAME.'_tab_advertising'
);
/* Tracking
===========================================*/
$this->akyuz_settings[AKYUZ_SHORTNAME.'_tracking_header'] = array(
'title' => __( 'Header Tracking' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Enter your tracking code to insert it in the head tag of your site.', AKYUZ_TEXT_DOMAIN ),
'std' => '',
'type' => 'textarea',
'section' => AKYUZ_SHORTNAME.'_tab_tracking'
);
$this->akyuz_settings[AKYUZ_SHORTNAME.'_tracking_footer'] = array(
'title' => __( 'Footer Tracking' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Enter your tracking code to insert it in the footer tag of your site.', AKYUZ_TEXT_DOMAIN ),
'std' => '',
'type' => 'textarea',
'section' => AKYUZ_SHORTNAME.'_tab_tracking'
);
/* Footer
===========================================*/
$this->akyuz_settings[AKYUZ_SHORTNAME.'_footer_left'] = array(
'title' => __( 'Footer Copy Right Text' , AKYUZ_TEXT_DOMAIN),
'desc' => __( 'Enter text used in the left side of the footer. It can be HTML.' , AKYUZ_TEXT_DOMAIN),
'std' => 'Copyright © 2008-2012 Selim AKYUZ . All rights reserved.',
'type' => 'textarea',
'section' => AKYUZ_SHORTNAME.'_tab_footer',
'class' => 'code'
);
/* Reset
===========================================*/
$this->akyuz_settings['reset_theme'] = array(
'section' => AKYUZ_SHORTNAME.'_tab_reset',
'title' => __( 'Reset theme' , AKYUZ_TEXT_DOMAIN),
'type' => 'checkbox',
'std' => 0,
'class' => 'warning', // Custom class for CSS
'desc' => __( 'Check this box and click "Save Changes" below to reset theme options to their defaults.' , AKYUZ_TEXT_DOMAIN)
);
}
/**
* Initialize settings to their default values
*
* @since 1.0
*/
public function initialize_settings() {
$default_settings = array();
foreach ( $this->akyuz_settings as $id => $setting ) {
if ( $setting['type'] != 'heading' )
$default_settings[$id] = $setting['std'];
}
update_option( 'akyuz_options', $default_settings );
}
/**
* Register settings
*
* @since 1.0
*/
public function register_settings() {
register_setting( 'akyuz_options', 'akyuz_options', array ( &$this, 'validate_settings' ) );
foreach ( $this->akyuz_sections as $slug => $title ) {
add_settings_section( $slug, $title, array( &$this, 'display_section_'.$slug ), AKYUZ_OPTIONSPAGENAME );
}
$this->akyuz_get_setting();
foreach ( $this->akyuz_settings as $id => $setting ) {
$setting['id'] = $id;
$this->akyuz_create_setting( $setting );
}
}
/**
* Styling for the theme options page
*
* @since 1.0
*/
public function styles() {
wp_register_style( 'akyuz-admin', get_stylesheet_directory_uri() . '/functions/akyuz-options.css' );
wp_enqueue_style( 'akyuz-admin' );
wp_enqueue_script( 'akyuz-theme-options', get_template_directory_uri() . '/functions/akyuz-options.js', false, '2011-06-10' );
}
/**
* Validate settings
*
* @since 1.0
*/
public function validate_settings( $input ) {
if ( ! isset( $input['reset_theme'] ) ) {
$options = get_option( 'akyuz_options' );
foreach ( $this->akyuz_checkboxes as $id ) {
if ( isset( $options[$id] ) && ! isset( $input[$id] ) )
unset( $options[$id] );
}
return $input;
}
return false;
}
}
$akyuz_theme_options = new Akyuz_Theme_Administration_Options();
function mytheme_option( $option ) {
$options = get_option( 'akyuz_options' );
if ( isset( $options[$option] ) )
return $options[$option];
else
return false;
}
/*
* Add Options Menu Item to the WordPress Admin Bar
*/
function akyuz_admin_bar()
{
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'parent' => 'appearance',
'id' => 'akyuz_theme_admin_options',
'title' => __( 'Akyuz Options',AKYUZ_TEXT_DOMAIN ),
'href' => admin_url( 'themes.php?page='.AKYUZ_OPTIONSPAGENAME )
));
}
add_action( 'wp_before_admin_bar_render', 'akyuz_admin_bar' );
/*
* Short Code for the theme Link
*/
function akyuz_theme_url()
{
$themelink = "Akyuz Wordpress Theme ";
return $themelink;
}
add_shortcode( 'theme-url', 'akyuz_theme_url' );
?>