getWPTBPluginOptions();
}
//Returns an array of admin options
function getWPTBPluginOptions() {
$wptbAdminOptions = array(
'enable_topbar' => 'false',
'text_color' => '#000000',
'bar_color' => '#ffffff',
'bottom_color' => '#f90000',
'link_color' => '#c00000',
'bottom_border_height' => '3',
'include_pages' => '0',
'delay_time' => '5000',
'slide_time' => '2000',
'font_size' => '14',
'padding_top' => '8',
'padding_bottom' => '8',
'bar_link' => 'http://wordpress.org',
'bar_text' => 'Text Message: ',
'bar_link_text' => 'Link Text');
$wptbOptions = get_option($this->adminOptionsName);
if (!empty($wptbOptions)) {
foreach ($wptbOptions as $key => $option)
$wptbAdminOptions[$key] = $option;
}
update_option($this->adminOptionsName, $wptbAdminOptions);
return $wptbAdminOptions;
}
//Puts the Top Bar above the Header
function wptb_addHeaderCode() {
global $wp_query;
$wptbOptions = $this->getWPTBPluginOptions();
if ($wptbOptions['enable_topbar'] == "false") { return; }
$thePostID = $wp_query->post->ID;
if ( ! in_array( $thePostID, explode( ',', $wptbOptions['include_pages'] ) ) && ! in_array( 0, explode( ',', $wptbOptions['include_pages'] ) ) )
{ return; }
?>
getWPTBPluginOptions();
if (isset($_POST['update_wptbSettings'])) {
if (isset($_POST['wptbenabletopbar'])) {
$wptbOptions['enable_topbar'] = $_POST['wptbenabletopbar'];
}
if (isset($_POST['wptbtextcolor'])) {
$wptbOptions['text_color'] = $_POST['wptbtextcolor'];
}
if (isset($_POST['wptbbarcolor'])) {
$wptbOptions['bar_color'] = $_POST['wptbbarcolor'];
}
if (isset($_POST['wptbbottomcolor'])) {
$wptbOptions['bottom_color'] = $_POST['wptbbottomcolor'];
}
if (isset($_POST['wptblinkcolor'])) {
$wptbOptions['link_color'] = $_POST['wptblinkcolor'];
}
if (isset($_POST['wptbincludepages'])) {
$wptbOptions['include_pages'] = $_POST['wptbincludepages'];
}
if (isset($_POST['wptbbottomborderheight'])) {
if (!is_numeric($_POST['wptbbottomborderheight'])) {
echo 'Bottom border height is not numeric. Resetting to 3px.
';
$wptbOptions['bottom_border_height'] = 3;
}
else
$wptbOptions['bottom_border_height'] = $_POST['wptbbottomborderheight']+0;
}
if (isset($_POST['wptbdelayintime'])) {
if (!is_numeric($_POST['wptbdelayintime'])) {
echo 'Delay time is not numeric. Resetting to zero.
';
$wptbOptions['delay_time'] = 0;
}
else
$wptbOptions['delay_time'] = $_POST['wptbdelayintime']+0;
}
if (isset($_POST['wptbslidetime'])) {
if (!is_numeric($_POST['wptbslidetime'])) {
echo 'Slide time is not numeric. Resetting to zero.
';
$wptbOptions['slide_time'] = 0;
}
else
$wptbOptions['slide_time'] = $_POST['wptbslidetime']+0;
}
if (isset($_POST['wptbfontsize'])) {
if (!is_numeric($_POST['wptbfontsize'])) {
echo 'Top padding is not numeric. Resetting to 8px.
';
$wptbOptions['font_size'] = 0;
}
else
$wptbOptions['font_size'] = $_POST['wptbfontsize']+0;
}
if (isset($_POST['wptbpaddingtop'])) {
if (!is_numeric($_POST['wptbpaddingtop'])) {
echo 'Top padding is not numeric. Resetting to 8px.
';
$wptbOptions['padding_top'] = 0;
}
else
$wptbOptions['padding_top'] = $_POST['wptbpaddingtop']+0;
}
if (isset($_POST['wptbpaddingbottom'])) {
if (!is_numeric($_POST['wptbpaddingbottom'])) {
echo 'Bottom padding is not numeric. Resetting to 8px.
';
$wptbOptions['padding_bottom'] = 0;
}
else
$wptbOptions['padding_bottom'] = $_POST['wptbpaddingbottom']+0;
}
if (isset($_POST['wptblink'])) {
$wptbOptions['bar_link'] = $_POST['wptblink'];
}
if (isset($_POST['wptbbartext'])) {
$wptbOptions['bar_text'] = $_POST['wptbbartext'];
}
if (isset($_POST['wptbbartext'])) {
$wptbOptions['bar_link_text'] = $_POST['wptblinktext'];
}
update_option($this->adminOptionsName, $wptbOptions);
?>
adminOptionsName);
$wptbOptions = array(
'enable_topbar' => 'false',
'text_color' => '#000000',
'bar_color' => '#ffffff',
'bottom_color' => '#f90000',
'link_color' => '#c00000',
'bottom_border_height' => '3',
'include_pages' => '0',
'delay_time' => '5000',
'slide_time' => '2000',
'font_size' => '14',
'padding_top' => '8',
'padding_bottom' => '8',
'bar_link' => 'http://wordpress.org',
'bar_text' => 'Text Message: ',
'bar_link_text' => 'Link Text');
?>
%s', admin_url( 'admin.php?page=wp-topbar.php' ), __('Settings') );
array_unshift($links, $wptb_settings_link);
return $links;
}
//Actions and Filters
if (isset($wtpb_plugin)) {
//Actions
add_action('admin_menu', 'wptb_options_panel');
add_action('wp_head', array(&$wtpb_plugin, 'wptb_addHeaderCode'), 1);
add_action('activate_wptb-plugin-series/wptb-plugin-series.php', array(&$wtpb_plugin, 'init'));
add_action('init', 'wptb_enqueue_scripts');
add_action('wp_footer', 'wptb_style', 15);
//Filters
add_filter('plugin_action_links_' . plugin_basename(__FILE__) , 'wptb_plugin_action_links');
}
?>