ID ); if( ! $user_id ) { return false; } $user = new WP_User( $user_id ); $roles = $user->roles; foreach($roles as $role) { return strtolower($role); } } function nb_check_access() { global $current_user; get_currentuserinfo(); $user_id = intval( $current_user->ID ); if( ! $user_id ) { return false; } $user = new WP_User( $user_id ); $roles = $user->roles; $access = false; $abroles = get_option('pd_nb_roles'); if(empty($abroles)){ $access = true; } foreach($roles as $role) { if($abroles[$role] == 'true') { $access = true; } } return $access; } function nb_redirect($url){ @header('Location: ' . $url); exit; } function nb_get_roles() { global $wp_roles; $roles = $wp_roles->get_names(); return $roles; } function nb_notice($messages,$options){ $dismissbeta = '' . __('Stop bugging me','attention-bar') . ''; $dismissversion = '' . __('Stop bugging me','attention-bar') . ''; if(is_array($messages)){ foreach ($messages as $message) { $mescombined .= '

* ' . $message . '

'; } $message = $mescombined; } else { $message = '

' . $messages . '

'; } switch($options['type']){ case 'error': $type = '
'; break; default: $type = '
'; break; } $message = 'ATTENTION-BAR: ' . $message; switch ($options['dismiss']) { case 'version': $notice = $type . $dismissversion . $message; break; case 'beta': $notice = $type . $dismissbeta . $message; break; } $notice .= '

'; echo $notice; } function nb_admin_notices() { global $wp_version; if(get_option('pd_nb_installnotification') != NB_VERSION) { switch (NB_VERSION) { case '0.7.1.1': if (get_option('pd_nb_db_convertepoch') == 'true'){ nb_notice( __('All your existing time schedules have been converted to epoch timing, check your schedules asap!','attention-bar'),array('type'=>'notice','dismiss'=>'version')); } break; } } if (version_compare($wp_version,"3.3",">") && version_compare(get_option('pd_nb_betanotification'),NB_VERSION,"<")){ if($_REQUEST['versioncheck'] != true) { nb_notice( __('You are using a beta version of WordPress: ','attention-bar') . $wp_version . __(' it is possible that there are problems with Attention bar in combination with this WordPress version!','attention-bar'), array('type'=>'error','dismiss'=>'beta')); } } } function nb_get_time($request) { $time = date(get_option('date_format') . ' ' . get_option('time_format'),(int)$request); return $time; } function nb_get_current_time() { return date('Y-m-d H:i:s',time()); } function nb_get_tztime($request) { if (function_exists('date_default_timezone_set')) { $timezone = date_default_timezone_get(); date_default_timezone_set(get_option('timezone_string')); $time = date(get_option('date_format') . ' ' . get_option('time_format'),(int)$request); date_default_timezone_set($timezone); } else { $time = date(get_option('date_format') . ' ' . get_option('time_format'),(int)$request); } return($time); } function nb_get_edit_time($request) { if (!empty($request)) { return date('Y-m-d H:i:s',(int)$request); } } function nb_get_tzepoch_time($request) { if (function_exists('date_default_timezone_set')) { $timezone = date_default_timezone_get(); date_default_timezone_set(get_option('timezone_string')); $phptime = date('Y-m-d H:i:s',(int)$request); date_default_timezone_set($timezone); } else { $phptime = date('Y-m-d H:i:s',(int)$request); } return strtotime($phptime); } function nb_get_info_box() { $info = '

' . __('Information','attention-bar') . '

'; return $info; } ?>