Ver = '1.2'; $this->Name = 'Announce from the Dashboard'; $this->Url = WP_PLUGIN_URL . '/' . dirname( plugin_basename( __FILE__ ) ) . '/'; $this->ltd = 'afd'; $this->ltd_p = $this->ltd . '_plugin'; $this->Slug = 'announce_from_the_dashboard'; $this->RecordName = 'announce_from_the_dashboard'; $this->UPFN = 'Y'; $this->DonateKey = 'd77aec9bc89d445fd54b4c988d090f03'; $this->Msg = ''; $this->PluginSetup(); add_action( 'load-index.php' , array( $this , 'FilterStart' ) ); } // PluginSetup function PluginSetup() { // load text domain load_plugin_textdomain( $this->ltd , false , basename( dirname( __FILE__ ) ) . '/languages' ); load_plugin_textdomain( $this->ltd_p , false , basename( dirname( __FILE__ ) ) . '/languages' ); // plugin links add_filter( 'plugin_action_links' , array( $this , 'plugin_action_links' ) , 10 , 2 ); // add menu add_action( 'admin_menu' , array( $this , 'admin_menu' ) ); // get donation toggle add_action( 'wp_ajax_afd_get_donation_toggle' , array( $this , 'wp_ajax_afd_get_donation_toggle' ) ); // set donation toggle add_action( 'wp_ajax_afd_set_donation_toggle' , array( $this , 'wp_ajax_afd_set_donation_toggle' ) ); } // Translation File Check function TransFileCk() { $file = false; $moFile = WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) . '/languages/' . $this->ltd . '-' . get_locale() . '.mo'; if( file_exists( $moFile ) ) { $file = true; } return $file; } // PluginSetup function plugin_action_links( $links , $file ) { if( plugin_basename(__FILE__) == $file ) { $mofile = $this->TransFileCk(); if( $mofile == false ) { $translation_link = 'Please translation'; array_unshift( $links, $translation_link ); } $support_link = '' . __( 'Support Forums' ) . ''; array_unshift( $links, $support_link ); array_unshift( $links, '' . __('Settings') . '' ); } return $links; } // PluginSetup function admin_menu() { add_options_page( $this->Name , __( 'Announcement settings for Dashboard' , $this->ltd ), 'administrator' , $this->Slug , array( $this , 'setting' ) ); } // SettingPage function setting() { add_filter( 'admin_footer_text' , array( $this , 'layout_footer' ) ); $this->DisplayDonation(); include_once 'inc/setting.php'; } // SetList function wp_ajax_afd_get_donation_toggle() { echo get_option( $this->ltd . '_donate_width' ); die(); } // SetList function wp_ajax_afd_set_donation_toggle() { update_option( $this->ltd . '_donate_width' , strip_tags( $_POST["f"] ) ); die(); } // SetList function AllTypes() { $Displaytype = array( 'normal' , 'updated' , 'error' , 'metabox' , 'nonstyle' ); return $Displaytype; } // SetList function get_color( $type ) { $color = ''; if($type == 'normal') { $color = __( 'gray' , $this->ltd ); } else if($type == 'updated') { $color = __( 'yellow' , $this->ltd ); } else if($type == 'error') { $color = __( 'red' , $this->ltd ); } else if($type == 'metabox') { $color = __( 'gray' , $this->ltd ); } return $color; } // SetList function get_user_role() { $editable_roles = get_editable_roles(); foreach ( $editable_roles as $role => $details ) { $UserRole[$role] = translate_user_role( $details['name'] ); } return $UserRole; } // GetData function get_data( $user = false ) { $GetData = get_option( $this->RecordName ); $Data = array(); if( !empty( $GetData ) ) { if( !empty( $user ) ) { $SettData = array(); foreach( $GetData as $k => $sett ) { if( array_key_exists( $user , $sett["role"] ) ) { $SettData[] = $sett; } } $Data = $SettData; } else { $Data = $GetData; } } return $Data; } // DataUpdate function DonatingCheck() { $Update = $this->update_validate(); if( !empty( $Update ) ) { if( !empty( $_POST["donate_key"] ) ) { $SubmitKey = md5( strip_tags( $_POST["donate_key"] ) ); if( $this->DonateKey == $SubmitKey ) { update_option( $this->ltd . '_donated' , $SubmitKey ); $this->Msg .= '

' . __( 'Thank you for your donation.' , $this->ltd_p ) . '

'; } } } } // DataUpdate function update_validate() { $Update = array(); if( !empty( $_POST[$this->UPFN] ) ) { $UPFN = strip_tags( $_POST[$this->UPFN] ); if( $UPFN == $this->UPFN ) { $Update["UPFN"] = strip_tags( $_POST[$this->UPFN] ); } } return $Update; } // DataUpdate function update() { $Update = $this->update_validate(); if( !empty( $Update ) ) { if( !empty( $_POST["data"]["create"] ) ) { $Create = $_POST["data"]["create"]; if( !empty( $Create["title"] ) && !empty( $Create["content"] ) ) { $title = strip_tags ( $Create["title"] ); $Content = $Create["content"]; if( !empty( $Create["type"] ) ) { $Type = $Create["type"]; } else { $Type = 'normal'; } $Roles = array(); if( !empty( $Create["role"] ) ) { foreach( $Create["role"] as $name => $val ) { $Roles[strip_tags( $name )] = intval( $val ); } } $Update = $this->get_data(); $Update[] = array( "title" => $title , "content" => $Content , "type" => $Type , "role" => $Roles ); } } elseif( !empty( $_POST["data"]["update"] ) ) { foreach( $_POST["data"]["update"] as $key => $Announce ) { $title = strip_tags ( $Announce["title"] ); $Content = $Announce["content"]; if( !empty( $Announce["type"] ) ) { $Type = $Announce["type"]; } else { $Type = 'normal'; } $Roles = array(); if( !empty( $Announce["role"] ) ) { foreach( $Announce["role"] as $name => $val ) { $Roles[strip_tags( $name )] = intval( $val ); } } $Update[$key] = array( "title" => $title , "content" => $Content , "type" => $Type , "role" => $Roles ); } } if( !empty( $Update ) ) { unset( $Update["UPFN"] ); update_option( $this->RecordName , $Update ); $Msg = '

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

'; } } } // DataUpdate function update_delete() { $Update = $this->get_data(); $del = false; if( !empty( $_POST["action"] ) or !empty( $_POST["action2"] ) ) { if( $_POST["action"] == 'delete' or $_POST["action2"] == 'delete' ) { if( !empty( $_POST["data"]["delete"] ) ) { foreach( $_POST["data"]["delete"] as $ID ) { $DeleteID = intval( $ID["id"] ); unset( $Update[$DeleteID] ); } $del = true; } } } if( $del ) { update_option( $this->RecordName , $Update ); $this->Msg = '

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

'; } } // FilterStart function FilterStart() { if ( is_admin() ) { // notice add_filter( 'admin_notices' , array( $this , 'admin_notices' ) , 99 ); // metabox add_action( 'wp_dashboard_setup' , array( $this , 'wp_dashboard_setup' ) ); } } // FilterStart function admin_notices() { $User = wp_get_current_user(); $Userrole = $User->roles[0]; $Data = $this->get_data( $Userrole ); if( !empty( $Data ) ) { wp_enqueue_style( $this->Slug , $this->Url . dirname( plugin_basename( __FILE__ ) ) . '.css' , array() , $this->Ver ); foreach( $Data as $key => $sett ) { $type = $sett["type"]; if( !empty( $type ) && $type == 'updated' or $type == 'error' or $type == 'normal' or $type == 'nonstyle' ) { $class = 'announce updated ' . $type; echo sprintf( '

%2$s%3$s

' , $class , strip_tags( $sett["title"] ) , apply_filters( 'the_content' , stripslashes( $sett["content"] ) ) ); } } } } // FilterStart function wp_dashboard_setup() { $User = wp_get_current_user(); $Userrole = $User->roles[0]; $Data = $this->get_data( $Userrole ); if( !empty( $Data ) ) { foreach( $Data as $key => $sett ) { $type = $sett["type"]; if( !empty( $type ) && $type == 'metabox' ) { add_meta_box( $this->Slug . '-' . $key , strip_tags( $sett["title"] ) , array( $this , 'dashboard_do_metabox' ) , 'dashboard' , 'normal' , '' , array( "announce" => $key ) ); } } } } // FilterStart function dashboard_do_metabox( $post , $metabox ) { if( isset( $metabox["args"]["announce"] ) ) { $User = wp_get_current_user(); $Userrole = $User->roles[0]; $Data = $this->get_data( $Userrole ); if( !empty( $Data[$metabox["args"]["announce"]] ) ) { echo apply_filters( 'the_content' , stripslashes( $Data[$metabox["args"]["announce"]]["content"] ) ); } } } // FilterStart function layout_footer( $text ) { $text = ' Plugin developer : gqevu6bsiz'; return $text; } // FilterStart function DisplayDonation() { $donation = get_option( $this->ltd . '_donated' ); if( $this->DonateKey != $donation ) { $this->Msg .= '

' . __( 'Please consider a donation if you are satisfied with this plugin.' , $this->ltd_p ) . ' ' . __( 'Please donation.' , $this->ltd_p ) . '

'; } } } if( class_exists( 'Afd' ) ) { $Afd = new Afd(); } ?>