'BottomBar-1',
'id' => 'BottomBar-1',
'before_title' => '
',
'after_title' => ' ',
));
}
function register_bottom_bar_b2()
{
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'BottomBar-2',
'id' => 'BottomBar-2',
'before_title' => '',
'after_title' => ' ',
));
}
function unregister_bottom_bar_b1()
{
if ( function_exists('unregister_sidebar') )
unregister_sidebar('BottomBar-1');
}
function unregister_bottom_bar_b2()
{
if ( function_exists('unregister_sidebar') )
unregister_sidebar('BottomBar-2');
}
////////////////////////////////////////////////////////////////////////////////
// register/unregister bottom tabs
////////////////////////////////////////////////////////////////////////////////
function register_b1_tabs()
{
$gn_theme_options = gn_get_theme_options();
$tab_count_b1 = $gn_theme_options['gn_tab_count_b1'];
if ( function_exists('register_sidebar') )
{
for ( $i = 1; $i <= $tab_count_b1; $i++ )
{
$name = 'BottomBar-1 Tab-' . $i;
register_sidebar(array(
'name' => $name,
'id' => $name,
'before_title' => '',
'after_title' => ' ',
));
}
}
}
function register_b2_tabs()
{
$gn_theme_options = gn_get_theme_options();
$tab_count_b2 = $gn_theme_options['gn_tab_count_b2'];
if ( function_exists('register_sidebar') )
{
for ( $i = 1; $i <= $tab_count_b2; $i++ )
{
$name = 'BottomBar-2 Tab-' . $i;
register_sidebar(array(
'name' => $name,
'id' => $name,
'before_title' => '',
'after_title' => ' ',
));
}
}
}
////////////////////////////////////////////////////////////////////////////////
// add tab titles options
////////////////////////////////////////////////////////////////////////////////
function add_tab_b1_titles()
{
$gn_theme_options = gn_get_theme_options();
$tab_count_b1 = $gn_theme_options['gn_tab_count_b1'];
if ( empty($gn_theme_options['gn_tab_b1_titles']) )
{
$def_titles = '';
for ( $i = 1; $i <= $tab_count_b1; $i++ )
{
$def_titles[ $i ] = 'Tab' . $i;
}
$gn_theme_options['gn_tab_b1_titles'] = $def_titles;
update_option( 'gn_theme_options', $gn_theme_options );
return $def_titles;
}
return $gn_theme_options['gn_tab_b1_titles'];
}
function add_tab_b2_titles()
{
$gn_theme_options = gn_get_theme_options();
$tab_count_b2 = $gn_theme_options['gn_tab_count_b2'];
if ( empty($gn_theme_options['gn_tab_b2_titles']) )
{
$def_titles = '';
for ( $i = 1; $i <= $tab_count_b2; $i++ )
{
$def_titles[ $i ] = 'Tab' . $i;
}
$gn_theme_options['gn_tab_b2_titles'] = $def_titles;
update_option( 'gn_theme_options', $gn_theme_options );
return $def_titles;
}
return $gn_theme_options['gn_tab_b2_titles'];
}
////////////////////////////////////////////////////////////////////////////////
// get titles
////////////////////////////////////////////////////////////////////////////////
function get_tab_b1_titles()
{
global $tab_b1_titles;
$gn_theme_options = gn_get_theme_options();
$tab_b1_titles = $gn_theme_options['gn_tab_b1_titles'];
return $tab_b1_titles;
}
function get_tab_b2_titles()
{
global $tab_b2_titles;
$gn_theme_options = gn_get_theme_options();
$tab_b2_titles = $gn_theme_options['gn_tab_b2_titles'];
return $tab_b2_titles;
}
////////////////////////////////////////////////////////////////////////////////
// load theme wp-admin css
////////////////////////////////////////////////////////////////////////////////
function gn_load_css()
{
$theme_option_css_url = get_template_directory_uri();
echo "\n\n";
echo '' . "\n";
echo '' . "\n";
echo ' ';
echo "\n\n";
}
function gn_header_style()
{
$gn_theme_options = gn_get_theme_options();
if ( $gn_theme_options['gn_wp_custom_header_feature'] == 'on' )
{
echo '
' . "\n";
}
}
// gets included in the admin header
function gn_admin_header_style()
{
echo
'
';
return;
}
////////////////////////////////////////////////////////////////////////////////
// get posts with most comments
////////////////////////////////////////////////////////////////////////////////
function gn_get_mostcommented($limit = 5)
{
global $wpdb, $post;
$mostcommenteds = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_date, COUNT($wpdb->comments.comment_post_ID) AS 'comment_total' FROM $wpdb->posts LEFT JOIN $wpdb->comments ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_date_gmt < '".gmdate("Y-m-d H:i:s")."' AND post_status = 'publish' AND post_password = '' GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_total DESC LIMIT $limit");
foreach ($mostcommenteds as $post)
{
$post_title = htmlspecialchars(stripslashes($post->post_title));
$comment_total = (int) $post->comment_total;
echo "$post_title ($comment_total) ";
}
}
////////////////////////////////////////////////////////////////////////////////
// check screen width
//
////////////////////////////////////////////////////////////////////////////////
function check_screen_width()
{
global $content_width;
global $screen_width;
$gn_theme_options = gn_get_theme_options();
$screen_width = $gn_theme_options['gn_screen_width'];
}
////////////////////////////////////////////////////////////////////////////////
// check tab feature
// if necessary register tabs
////////////////////////////////////////////////////////////////////////////////
function check_tab_feature()
{
$gn_theme_options = gn_get_theme_options();
$tab_feature_b1 = $gn_theme_options['gn_tab_feature_b1'];
$tab_feature_b2 = $gn_theme_options['gn_tab_feature_b2'];
$tab_count_b1 = $gn_theme_options['gn_tab_count_b1'];
$tab_count_b2 = $gn_theme_options['gn_tab_count_b2'];
if ( $tab_feature_b1 == 'off' )
{
register_bottom_bar_b1();
}
else
{
register_b1_tabs();
}
if ( $tab_feature_b2 == 'off' )
{
register_bottom_bar_b2();
}
else
{
register_b2_tabs();
}
$tab_b1_titles = add_tab_b1_titles();
$tab_b2_titles = add_tab_b2_titles();
}
////////////////////////////////////////////////////////////////////////////////
// write header css
////////////////////////////////////////////////////////////////////////////////
function write_body_css()
{
global $gn_body_color,
$gn_body_background,
$gn_wrapper_background;
global $wpdb;
$wpdb->flush();
$gn_theme_options = get_option('gn_theme_options');
$gn_body_color = $gn_theme_options['gn_body_color'];
$gn_body_background = $gn_theme_options['gn_body_background'];
$gn_wrapper_background = $gn_theme_options['gn_wrapper_background'];
return;
}
////////////////////////////////////////////////////////////////////////////////
// write header css
////////////////////////////////////////////////////////////////////////////////
function write_header_css()
{
global $gn_theme_url,
$gn_show_header,
$gn_header_img,
$gn_img_background;
global $wpdb;
$wpdb->flush();
$gn_theme_options = get_option('gn_theme_options');
$gn_show_header = $gn_theme_options['gn_show_header'];
$gn_header_img = $gn_theme_options['gn_header_img'];
$gn_img_background = $gn_theme_options['gn_img_background'];
$gn_theme_url = get_template_directory_uri();
return;
}
////////////////////////////////////////////////////////////////////////////////
// update theme options
////////////////////////////////////////////////////////////////////////////////
function update_gn_options()
{
$gn_theme_options = get_option('gn_theme_options');
$new_gn_tab_b1_titles = array();
$new_gn_tab_b2_titles = array();
// check if remove all widgets is set
if ( isset( $_POST['new_gn_rem_widgets'] ) )
{
gn_remove_all_widgets();
}
// check if screen width checkbox is set --> 800px
if (!isset( $_POST['new_gn_screen_width'] ))
{
$_POST['new_gn_screen_width'] = 'off';
$screen_width = 'off';
}
else
{
$_POST['new_gn_screen_width'] = 'on';
$screen_width = 'on';
}
// check if show header option checkbox is set
if (!isset( $_POST['new_gn_show_header'] ))
{
$_POST['new_gn_show_header'] = 'off';
$show_header = 'off';
}
else
{
$_POST['new_gn_show_header'] = 'on';
$show_header = 'on';
}
if ( !isset( $_POST['new_gn_facebook_btn'] ) )
{
$_POST['new_gn_facebook_btn'] = 'off';
$gn_facebook_btn = 'off';
}
else
{
$_POST['new_gn_facebook_btn'] = 'on';
$gn_facebook_btn = 'on';
}
if ( !isset($_POST['new_gn_menu_feature']) )
{
$_POST['new_gn_menu_feature'] = 'off';
$gn_menu_feature = 'off';
}
else
{
$_POST['new_gn_menu_feature'] = 'on';
$gn_menu_feature = 'on';
}
if ( !isset($_POST['new_gn_wp_custom_header_feature']) )
{
$_POST['new_gn_wp_custom_header_feature'] = 'off';
$gn_wp_custom_header_feature = 'off';
}
else
{
$_POST['new_gn_wp_custom_header_feature'] = 'on';
$gn_wp_custom_header_feature = 'on';
}
// check if Next Page String is set
if (!isset( $_POST['new_gn_next_page'] ))
{
$_POST['new_gn_next_page'] = 'off';
$next_page = 'off';
}
else
{
$_POST['new_gn_next_page'] = 'on';
$next_page = 'on';
}
// check which meta tags checkbox is active
if (!isset( $_POST['new_gn_seo_meta_tags'] ))
{
$_POST['new_gn_seo_meta_tags'] = 'off';
$seo_meta_tags = 'off';
}
else
{
$_POST['new_gn_seo_meta_tags'] = 'on';
$seo_meta_tags = 'on';
}
// check which meta tags checkbox is active
if (!isset( $_POST['new_gn_geourl_meta_tags'] ))
{
$_POST['new_gn_geourl_meta_tags'] = 'off';
$geourl_meta_tags = 'off';
}
else
{
$_POST['new_gn_geourl_meta_tags'] = 'on';
$geourl_meta_tags = 'on';
}
// check if tab feature has changed and
// register or unregister sidebars accordingly
if (!isset( $_POST['new_gn_tab_feature_b1'] ))
{
$_POST['new_gn_tab_feature_b1'] = 'off';
$tab_feature_b1 = 'off';
if ( $gn_theme_options['gn_tab_feature_b1'] == 'on' )
{
// unregister tabs
if ( function_exists('unregister_sidebar') )
{
$tab_b1_old_count = $gn_theme_options['gn_tab_count_b1'];
for ( $i = 1; $i <= $tab_b1_old_count; $i++ )
{
$name = 'BottomBar-1 Tab-' . $i;
unregister_sidebar($name);
}
}
// and register bottom_bar_b1
register_bottom_bar_b1();
}
else
{
// tab feature was off ==> nothing to do
}
// and set varaible to off
$tab_count_b1 = $gn_theme_options['gn_tab_count_b1'];
$tab_b1_titles = $gn_theme_options['gn_tab_b1_titles'];
}
else
{
$_POST['new_gn_tab_feature_b1'] = 'on';
$tab_feature_b1 = 'on';
if ( $gn_theme_options['gn_tab_feature_b1'] != 'on')
{
// first unregister bottom_menu_b1
unregister_bottom_bar_b1();
// and then register tabs
if ( function_exists('register_sidebar') )
{
$tab_count_b1 = (int)$gn_theme_options['gn_tab_count_b1'];
register_b1_tabs();
}
if ( empty($gn_theme_options['gn_tab_b1_titles']) )
$tab_b1_titles = add_tab_b1_titles();
else
$tab_b1_titles = $gn_theme_options['gn_tab_b1_titles'];
}
else
{
$tab_b1_old_count = $gn_theme_options['gn_tab_count_b1'];
$tab_b1_titles = $gn_theme_options['gn_tab_b1_titles'];
$tab_count_b1 = (int)$_POST['new_gn_tab_count_b1'];
if ( $tab_count_b1 )
{
// check if count has changed
if ( $tab_b1_old_count > $tab_count_b1 )
{
// unregister sidebars
for ( $i = $tab_count_b1 + 1; $i <= $tab_b1_old_count; $i++)
{
$name = 'BottomBar-1 Tab-' . $i;
if ( function_exists('unregister_sidebar') )
unregister_sidebar( $name );
}
// register sidebars
register_b1_tabs();
}
if ( $tab_b1_old_count < $tab_count_b1 )
{
// register sidebars
for ( $i = $tab_b1_old_count + 1; $i <= $tab_count_b1; $i++)
{
$name = 'BottomBar-1 Tab-' . $i;
if ( function_exists('register_sidebars') )
{
register_sidebar(array(
'name' => $name,
'id' => $name,
'before_title' => '',
'after_title' => ' ',
));
}
$_POST['new_gn_b1_tab_' . $i . '_title'] = 'Tab' . $i;
}
}
// set titles
for ( $i = 1; $i <= $tab_count_b1; $i++ )
$tab_b1_titles[$i] = $_POST['new_gn_b1_tab_' . $i . '_title'];
}
else
{
// take old count
if ($tab_b1_old_count)
{
$gn_theme_options['gn_tab_count_b1'] = $tab_b1_old_count;
$tab_count_b1 = $tab_b1_old_count;
update_option('gn_theme_options', $gn_theme_options);
if ( empty($tab_b1_titles) )
$tab_b1_titles = add_tab_b1_titles();
}
else
{
// set to default --> 3
$gn_theme_options['gn_tab_count_b1'] = 3;
update_option('gn_theme_options', $gn_theme_options);
$tab_b1_titles = add_tab_b1_titles();
$tab_count_b1 = 3;
}
}
}
}
if (!isset( $_POST['new_gn_tab_feature_b2'] ))
{
$_POST['new_gn_tab_feature_b2'] = 'off';
$tab_feature_b2 = 'off';
if ( $gn_theme_options['gn_tab_feature_b2'] == 'on' )
{
// unregister tabs
if ( function_exists('unregister_sidebar') )
{
$tab_b1_old_count = $gn_theme_options['gn_tab_count_b2'];
for ( $i = 1; $i <= $tab_b2_old_count; $i++ )
{
$name = 'BottomBar-2 Tab-' . $i;
unregister_sidebar($name);
}
}
// and register bottom_bar_b2
register_bottom_bar_b2();
}
else
{
// tab feature was off ==> nothing to do
}
// and set varaible to off
$tab_count_b2 = $gn_theme_options['gn_tab_count_b2'];
$tab_b2_titles = $gn_theme_options['gn_tab_b2_titles'];
}
else
{
$_POST['new_gn_tab_feature_b2'] = 'on';
$tab_feature_b2 = 'on';
if ( $gn_theme_options['gn_tab_feature_b2'] != 'on')
{
// first unregister bottom_menu_b2
unregister_bottom_bar_b2();
// and then register tabs
if ( function_exists('register_sidebar') )
{
$tab_count_b2 = (int)$gn_theme_options['gn_tab_count_b2'];
register_b2_tabs();
}
if ( empty($gn_theme_options['gn_tab_b2_titles']) )
$tab_b2_titles = add_tab_b2_titles();
else
$tab_b2_titles = $gn_theme_options['gn_tab_b2_titles'];
}
else
{
$tab_b2_old_count = $gn_theme_options['gn_tab_count_b2'];
$tab_b2_titles = $gn_theme_options['gn_tab_b2_titles'];
$tab_count_b2 = (int)$_POST['new_gn_tab_count_b2'];
if ( $tab_count_b2 )
{
// check if count has changed
if ( $tab_b2_old_count > $tab_count_b2 )
{
// unregister sidebars
for ( $i = $tab_count_b2 + 1; $i <= $tab_b2_old_count; $i++)
{
$name = 'BottomBar-2 Tab-' . $i;
if ( function_exists('unregister_sidebar') )
unregister_sidebar( $name );
}
// register sidebars
register_b2_tabs();
}
if ( $tab_b2_old_count < $tab_count_b2 )
{
// register sidebars
for ( $i = $tab_b2_old_count + 1; $i <= $tab_count_b2; $i++)
{
$name = 'BottomBar-2 Tab-' . $i;
if ( function_exists('register_sidebars') )
{
register_sidebar(array(
'name' => $name,
'id' => $name,
'before_title' => '',
'after_title' => ' ',
));
}
$_POST['new_gn_b2_tab_' . $i . '_title'] = 'Tab' . $i;
}
}
// set titles
for ( $i = 1; $i <= $tab_count_b2; $i++ )
$tab_b2_titles[$i] = $_POST['new_gn_b2_tab_' . $i . '_title'];
}
else
{
// take old count
if ($tab_b2_old_count)
{
$gn_theme_options['gn_tab_count_b2'] = $tab_b2_old_count;
$tab_count_b2 = $tab_b2_old_count;
update_option('gn_theme_options', $gn_theme_options);
if ( empty($tab_b2_titles) )
$tab_b2_titles = add_tab_b2_titles();
}
else
{
// set to default --> 3
$gn_theme_options['gn_tab_count_b2'] = 3;
update_option('gn_theme_options', $gn_theme_options);
$tab_b2_titles = add_tab_b2_titles();
$tab_count_b2 = 3;
}
}
}
}
// write body css class if changed
if ( ($_POST['new_gn_body_color'] != $gn_theme_options['gn_body_color'] ) OR
($_POST['new_gn_body_background'] != $gn_theme_options['gn_body_background'] ) OR
($_POST['new_gn_wrapper_background'] != $gn_theme_options['gn_wrapper_background'] ) )
{
$gn_body_color = $_POST['new_gn_body_color'];
$gn_body_background = $_POST['new_gn_body_background'];
$gn_wrapper_background = $_POST['new_gn_wrapper_background'];
write_body_css();
}
$gn_theme_options = array(
'gn_left_img' => $_POST['new_gn_left_img'],
'gn_right_img' => $_POST['new_gn_right_img'],
'gn_left_img_atxt' => $_POST['new_gn_left_img_atxt'],
'gn_right_img_atxt' => $_POST['new_gn_right_img_atxt'],
'gn_left_img_lnk' => $_POST['new_gn_left_img_lnk'],
'gn_right_img_lnk' => $_POST['new_gn_right_img_lnk'],
'gn_header_img' => $_POST['new_gn_header_img'],
'gn_show_header' => $show_header,
'gn_img_background' => $_POST['new_gn_img_background'],
'gn_wrapper_background' => $_POST['new_gn_wrapper_background'],
'gn_body_background' => $_POST['new_gn_body_background'],
'gn_body_color' => $_POST['new_gn_body_color'],
'gn_screen_width' => $screen_width,
'gn_next_page' => $next_page,
'gn_next_page_txt' => $_POST['new_gn_next_page_txt'],
'gn_page_exclude' => $_POST['new_gn_page_exclude'],
'gn_seo_meta_tags' => $seo_meta_tags,
'gn_seo_meta_author' => $_POST['new_gn_seo_meta_author'],
'gn_seo_meta_desc' => $_POST['new_gn_seo_meta_desc'],
'gn_seo_meta_keyw' => $_POST['new_gn_seo_meta_keyw'],
'gn_geourl_meta_tags' => $geourl_meta_tags,
'gn_geourl_loc' => $_POST['new_gn_geourl_loc'],
'gn_geourl_title' => $_POST['new_gn_geourl_title'],
'gn_theme_sidebars' => $_POST['new_gn_theme_sidebars'],
'gn_facebook_btn' => $gn_facebook_btn,
'gn_menu_feature' => $gn_menu_feature,
'gn_wp_custom_header_feature' => $gn_wp_custom_header_feature,
'gn_tab_feature_b1' => $tab_feature_b1,
'gn_tab_feature_b2' => $tab_feature_b2,
'gn_tab_count_b1' => $tab_count_b1,
'gn_tab_count_b2' => $tab_count_b2,
'gn_tab_b1_titles' => $tab_b1_titles,
'gn_tab_b2_titles' => $tab_b2_titles
);
update_option('gn_theme_options', $gn_theme_options);
echo " " . "\n";
echo "
Options updated!
" . "\n";
echo "
" . "\n\n";
// print info in status bar
echo '' . "\n";
if ( isset( $_POST['new_gn_rem_widgets'] ) )
{
_e("
All registered widgets deleted !!!
\n");
}
// write the header.css file new
write_header_css();
return;
}
////////////////////////////////////////////////////////////////////////////////
// remove all widgets from all sidebars
////////////////////////////////////////////////////////////////////////////////
function gn_remove_all_widgets()
{
global $wpdb;
$sql_stmt = "DELETE FROM $wpdb->options WHERE option_name = 'sidebars_widgets'";
$sql_rc = $wpdb->query( $sql_stmt );
return;
}
?>