'.__('Settings').''; array_unshift( $links, $settings_link ); } return $links; } add_action('admin_menu', 'announce_from_the_dashboard_add_menu'); // setting function announce_from_the_dashboard_setting() { $UPFN = 'sett'; $Msg = ''; // get type $Displaytype = announce_from_the_dashboard_typeload(); // get role $UserRole = announce_from_the_dashboard_roleload(); if(isset($_GET["delete"])) { // delete $id = $_GET["delete"]; $Data = get_option(ANNOUNCE_FROM_THE_DASHBOARD_RECORD_NAME); unset($Data[$id]); update_option(ANNOUNCE_FROM_THE_DASHBOARD_RECORD_NAME, $Data); echo '

'.__('Settings saved.').'

'; } else if(!empty($_POST[$UPFN])) { // update if($_POST[$UPFN] == 'Y') { unset($_POST[$UPFN]); $Update = array(); if(!empty($_POST["update"])) { foreach ($_POST["update"] as $key => $val) { $type = ''; if(!empty($val["type"])) { $type = strip_tags($val["type"]); } else { $type = $Displaytype[0]; } $role = array(); if(!empty($val["role"])) { foreach($val["role"] as $tmp) { $role[$tmp] = strip_tags($tmp); } } else { $role = $UserRole; } $Update[$key] = array( "title" => strip_tags($val["title"]), "content" => $val["content"], "type" => $type, "role" => $role ); } } if(!empty($_POST["create"]) && !empty($_POST["create"]["title"]) && !empty($_POST["create"]["content"])) { $type = ''; if(!empty($_POST["create"]["type"])) { $type = strip_tags($_POST["create"]["type"]); } else { $type = $Displaytype[0]; } $role = array(); if(!empty($_POST["create"]["role"])) { foreach($_POST["create"]["role"] as $val) { $role[$val] = strip_tags($val); } } else { $role = $UserRole; } $Update[] = array( "title" => strip_tags($_POST["create"]["title"]), "content" => $_POST["create"]["content"], "type" => $type, "role" => $role ); } if(!empty($Update)) { update_option(ANNOUNCE_FROM_THE_DASHBOARD_RECORD_NAME, $Update); $Msg = '

'.__('Settings saved.').'

'; } } } // get data $Data = get_option(ANNOUNCE_FROM_THE_DASHBOARD_RECORD_NAME); // include js css $ReadedJs = array('jquery', 'thickbox'); wp_enqueue_script('announce-from-the-dashboard', ANNOUNCE_FROM_THE_DASHBOARD_PLUGIN_DIR.dirname(plugin_basename(__FILE__)).'.js', $ReadedJs, ANNOUNCE_FROM_THE_DASHBOARD_VER); wp_enqueue_style('thickbox'); wp_enqueue_style('announce-from-the-dashboard', ANNOUNCE_FROM_THE_DASHBOARD_PLUGIN_DIR.dirname(plugin_basename(__FILE__)).'.css', array(), ANNOUNCE_FROM_THE_DASHBOARD_VER); ?>

 

*
* $mode.'[content]', 'media_buttons' => false)); ?>
$rolename) : ?>

$content) : ?> ">
/  
" name="[][title]"> ( ) $mode.'['.$key.'][content]', 'media_buttons' => false)); ?> $rolename) : ?>
    $tmp) : ?>
 | 

 

$details ) { $UserRole[$role] = translate_user_role($details['name'] ); } return $UserRole; } // get color function announce_from_the_dashboard_typecolor($type) { $color = ''; if($type == 'normal') { $color = __('gray', 'announce-from-the-dashboard'); } else if($type == 'updated') { $color = __('yellow', 'announce-from-the-dashboard'); } else if($type == 'error') { $color = __('red', 'announce-from-the-dashboard'); } else if($type == 'metabox') { $color = __('gray', 'announce-from-the-dashboard'); } echo $color; } // announce show function announce_from_the_dashboard_show() { $screen = get_current_screen(); if($screen->base == 'dashboard') { // get data $Data = get_option(ANNOUNCE_FROM_THE_DASHBOARD_RECORD_NAME); if(!empty($Data)) { // get type $Displaytype = announce_from_the_dashboard_typeload(); // get role $UserRole = announce_from_the_dashboard_roleload(); wp_enqueue_style('announce-from-the-dashboard', ANNOUNCE_FROM_THE_DASHBOARD_PLUGIN_DIR.dirname(plugin_basename(__FILE__)).'.css', array(), ANNOUNCE_FROM_THE_DASHBOARD_VER); $User = wp_get_current_user(); $Userroles = $User->roles[0]; $Msg = ''; foreach($Data as $key => $an) { $type = $an["type"]; if( !empty( $type ) && $type == 'updated' or $type == 'error' or $type == 'normal' ) { if(!empty($an["role"][$Userroles])) { $Msg .= '

'.strip_tags($an["title"]).''.apply_filters('the_content', stripslashes($an["content"])).'

'; } } } if(!empty($Msg)) { echo $Msg; } } } } add_filter('admin_notices', 'announce_from_the_dashboard_show', 99); // announce show metaxo function announce_from_the_dashboard_show_metabox() { // get data $Data = get_option(ANNOUNCE_FROM_THE_DASHBOARD_RECORD_NAME); if(!empty($Data)) { // get type $Displaytype = announce_from_the_dashboard_typeload(); // get role $UserRole = announce_from_the_dashboard_roleload(); $User = wp_get_current_user(); $Userroles = $User->roles[0]; foreach($Data as $key => $an) { $type = $an["type"]; if( !empty( $type ) && $type == 'metabox' ) { if(!empty($an["role"][$Userroles])) { add_meta_box( 'announce_from_the_dashboard-' . $key , strip_tags($an["title"]) , "nnounce_from_the_dashboard_callback" , 'dashboard' , 'normal' , '' , array( "announce" => $key ) ); } } } } } function nnounce_from_the_dashboard_callback( $post , $metabox ) { if( !empty( $metabox["args"]["announce"] ) ) { // get data $Data = get_option(ANNOUNCE_FROM_THE_DASHBOARD_RECORD_NAME); if( !empty( $Data[$metabox["args"]["announce"]] ) ) { echo apply_filters('the_content', stripslashes($Data[$metabox["args"]["announce"]]["content"])); } } } add_action('wp_dashboard_setup', 'announce_from_the_dashboard_show_metabox'); ?>