. */ //require_once('/../../../../../FirePHPCore/lib/FirePHPCore/fb.php'); //fb($_POST); $agca = new AGCA(); class AGCA{ private $colorizer=""; private $active_plugin; private $agca_version; private $admin_capabilities; private $context = ""; private $saveAfterImport = false; public function __construct() { $this->reloadScript(); add_filter('admin_title', array(&$this,'change_title'), 10, 2); add_filter('plugin_row_meta', array(&$this,'jk_filter_plugin_links'), 10, 2); add_action('admin_init', array(&$this,'agca_register_settings')); add_action('admin_head', array(&$this,'print_admin_css')); add_action('login_head', array(&$this,'print_login_head')); add_action('admin_menu', array(&$this,'agca_create_menu')); add_action('wp_head', array(&$this,'print_page')); register_deactivation_hook(__FILE__, array(&$this,'agca_deactivate')); /*Initialize properties*/ $this->colorizer = $this->jsonMenuArray(get_option('ag_colorizer_json'),'colorizer'); //fb($this->colorizer); $this->agca_version = "1.2.7.1"; } // Add donate and support information function jk_filter_plugin_links($links, $file) { if ( $file == plugin_basename(__FILE__) ) { $links[] = '' . __('Settings') . ''; $links[] = '' . __('Support') . ''; $links[] = '' . __('Donate') . ''; } return $links; } function isGuest(){ global $user_login; if($user_login) { return false; }else{ return true; } } function check_active_plugin(){ $ozh = false; if (is_plugin_active('ozh-admin-drop-down-menu/wp_ozh_adminmenu.php')) { $ozh = true; } $this->active_plugin = array( "ozh" => $ozh ); } function change_title($admin_title, $title){ //return get_bloginfo('name').' - '.$title; if(get_option('agca_custom_title')!=""){ $blog = get_bloginfo('name'); $page = $title; $customTitle = get_option('agca_custom_title'); $customTitle = str_replace('%BLOG%',$blog,$customTitle); $customTitle = str_replace('%PAGE%',$page,$customTitle); return $customTitle; }else{ return $admin_title; } } function agca_get_includes() { ?> admin_capability())))){ ?> 0){ }else{ $file = $_FILES['settings_import_file']; if($this->startsWith($file['name'],'AGCA_Settings')){ if (file_exists($file['tmp_name'])) { $fh = fopen($file['tmp_name'], 'r'); $theData = ""; if(filesize($file['tmp_name']) > 0){ $theData = fread($fh,filesize($file['tmp_name'])); } fclose($fh); $this->importSettings($theData); } } } } }else if(isset($_POST['_agca_export_settings']) && $_POST['_agca_export_settings']=="true"){ $this->exportSettings(); }else{ } } } function agca_deactivate() { } function getOptions(){ return Array( 'agca_role_allbutadmin', 'agca_admin_bar_frontend', 'agca_admin_bar_frontend_hide', 'agca_login_register_remove', 'agca_login_register_href', 'agca_login_lostpassword_remove', 'agca_admin_capability', 'agca_screen_options_menu', 'agca_help_menu', 'agca_logout', 'agca_remove_your_profile', 'agca_logout_only', 'agca_options_menu', 'agca_custom_title', 'agca_howdy', 'agca_header', 'agca_header_show_logout', 'agca_footer', 'agca_privacy_options', 'agca_header_logo', 'agca_header_logo_custom', 'agca_remove_site_link', 'agca_wp_logo_custom', 'agca_wp_logo_custom_link', 'agca_site_heading', 'agca_custom_site_heading', 'agca_update_bar', 'agca_footer_left', 'agca_footer_left_hide', 'agca_footer_right', 'agca_footer_right_hide', 'agca_login_banner', 'agca_login_banner_text', 'agca_login_photo_remove', 'agca_login_photo_url', 'agca_login_photo_href', 'agca_login_round_box', 'agca_login_round_box_size', 'agca_dashboard_icon', 'agca_dashboard_text', 'agca_dashboard_text_paragraph', 'agca_dashboard_widget_welcome', 'agca_dashboard_widget_rc', 'agca_dashboard_widget_il', 'agca_dashboard_widget_plugins', 'agca_dashboard_widget_qp', 'agca_dashboard_widget_rn', 'agca_dashboard_widget_rd', 'agca_dashboard_widget_primary', 'agca_dashboard_widget_secondary', 'agca_admin_bar_comments', 'agca_admin_bar_new_content', 'agca_admin_bar_new_content_post', 'agca_admin_bar_new_content_link', 'agca_admin_bar_new_content_page', 'agca_admin_bar_new_content_user', 'agca_admin_bar_new_content_media', 'agca_admin_bar_update_notifications', 'agca_remove_top_bar_dropdowns', 'agca_admin_menu_turnonoff', 'agca_admin_menu_agca_button_only', 'agca_admin_menu_separator_first', 'agca_admin_menu_separator_second', 'agca_admin_menu_icons', 'agca_admin_menu_arrow', 'agca_admin_menu_submenu_round', 'agca_admin_menu_submenu_round_size', 'agca_admin_menu_brand', 'agca_admin_menu_brand_link', 'agca_admin_menu_collapse_button', 'ag_edit_adminmenu_json', 'ag_add_adminmenu_json', 'ag_colorizer_json', 'agca_colorizer_turnonof', 'agca_custom_js', 'agca_custom_css', 'agca_colorizer_turnonoff', ); } function importSettings($settings){ $exploaded = explode("|^|^|", $settings); // $str = "EEE: "; $savedOptions = array(); foreach ($exploaded as $setting){ $key = current(explode(':', $setting)); $value = substr($setting, strlen($key)+1); $cleanedValue = str_replace('|^|^|','',$value); $savedOptions[$key] = $cleanedValue; } // print_r($savedOptions); $optionNames = $this->getOptions(); foreach ($optionNames as $optionName){ $optionValue = ""; $optionValue = $savedOptions[$optionName]; if($optionName == "ag_edit_adminmenu_json" || $optionName == "ag_add_adminmenu_json" ||$optionName == "ag_colorizer_json"){ $optionValue = str_replace("\\\"", "\"", $optionValue); $optionValue = str_replace("\\\'", "\'", $optionValue); }else if($optionName == "agca_custom_js" || $optionName == "agca_custom_css"){ //fb($optionValue); $optionValue = htmlspecialchars_decode($optionValue); $optionValue = str_replace("\'", '"', $optionValue); $optionValue = str_replace('\"', "'", $optionValue); //fb($optionValue); }else{ } update_option($optionName, $optionValue); $str.="/".$optionName."/".$optionValue."\n"; } //Migration from 1.2.6. to 1.2.5.1 - remove in later versions //agca_script_css // // fb($savedOptions); if($savedOptions['agca_script_css'] != null){ $optionValue = ""; $optionValue = str_replace("\'", '"', $savedOptions['agca_script_css']); $optionValue = str_replace('\"', "'", $optionValue); update_option('agca_custom_css', $optionValue); } if($savedOptions['agca_script_js'] != null){ $optionValue = ""; $optionValue = str_replace("\'", '"', $savedOptions['agca_script_js']); $optionValue = str_replace('\"', "'", $optionValue); update_option('agca_custom_js', $optionValue); } //echo $str; //save imported settings $this->saveAfterImport = true; } function exportSettings(){ $str = ""; $include_menu_settings = false; if(isset($_POST['export_settings_include_admin_menu'])){ if($_POST['export_settings_include_admin_menu'] == 'on'){ $include_menu_settings = true; } } foreach ($_POST as $key => $value) { if ($this->startsWith($key,'ag')||$this->startsWith($key,'color')) { if($this->startsWith($key,'ag_edit_adminmenu')){ if($include_menu_settings) $str .=$key. ":".$value."|^|^|"; }else{ $str .=$key. ":".$value."|^|^|"; } } } $filename = 'AGCA_Settings_'.date("Y-M-d_H-i-s").'.agca'; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$filename"); header("Content-Type: text/plain; "); header("Content-Transfer-Encoding: binary"); echo $str; die(); } function startsWith($haystack, $needle) { $length = strlen($needle); return (substr($haystack, 0, $length) === $needle); } function agca_create_menu() { //create new top-level menu add_management_page( 'AG Custom Admin', 'AG Custom Admin', 'administrator', __FILE__, array(&$this,'agca_admin_page') ); } function agca_create_admin_button($name,$arr) { $class=""; $wpversion = $this->get_wp_version(); $href = $arr["value"]; $target =$arr["target"];; if($name == 'AG Custom Admin'){ $class="agca_button_only"; $target = "_self"; $href = $arr; } $button =""; if($wpversion >=3.5 ){ $button .= ''; }else{ $button .= ''; } return $button; } function agca_decode($code){ $code = str_replace("{","",$code); $code = str_replace("}","",$code); $elements = explode(", ",$code); return $elements; } function jsonMenuArray($json,$type){ $arr = explode("|",$json); $elements = ""; $array =""; $first = true; //print_r($json); if($type == "colorizer"){ $elements = json_decode($arr[0],true); if($elements !=""){ return $elements; } }else if($type == "buttons"){ $elements = json_decode($arr[0],true); if($elements !=""){ foreach($elements as $k => $v){ $array.=$this->agca_create_admin_button($k,$v); } } }else if($type == "buttonsJq"){ $elements = json_decode($arr[0],true); if($elements !=""){ foreach($elements as $k => $v){ $array.=' (edit) (remove)'; } } }else{ //$elements = json_decode($arr[$type],true); $elements = $this->agca_decode($arr[$type]); if($elements !=""){ foreach($elements as $element){ if(!$first){ $array .=","; } $parts = explode(" : ",$element); $array.="[".$parts[0].", ".$parts[1]."]"; $first=false; } } } return $array; } function remove_dashboard_widget($widget,$side) { //side can be 'normal' or 'side' global $wp_meta_boxes; remove_meta_box($widget, 'dashboard', $side); } function get_wp_version(){ global $wp_version; $array = explode('-', $wp_version); $version = $array[0]; return $version; } function finalErrorCheck(){ ?> function AGCAErrorPage(){ if(document.getElementsByTagName('html')[0].style.visibility == ""){ var txt = ""; txt += 'AG Custom Admin Error\n\n\n'; txt += 'AG Custom Admin is unable to correctly process this page. Probably there are some errors thrown from some of the installed plugins or templates.\n\n\n'; txt += 'To resolve this issue please:\n\n'; txt += '* Check browser\'s console for errors. Analyse .js script location which throws the error. Location of the script can give you more information about where is the source of the problem. Usualy it is a location of a plugin or a template. If there are more than one error, usualy the first one is the one which caused this problem.\n\n'; txt += '* If you can\'t access your login page, please disable JavaScript in your browser. After you log in, you can remove or fix problematic plugin, and re-enable JavaScript again.\n\n'; txt += '* If you can\'t find the source of the problem by yourself, please post this error to AGCA WordPress.org support page(http://wordpress.org/extend/plugins/ag-custom-admin/) or to AGCA support page(http://agca.argonius.com/ag-custom-admin/)'; txt += '\n\nThank you.'; alert(txt); } } window.setTimeout(AGCAErrorPage,4000); isGuest()){ return false; } if(get_option('agca_admin_bar_frontend_hide')==true){ add_filter( 'show_admin_bar', '__return_false' ); ?> context = "page"; $wpversion = $this->get_wp_version(); ?> if(isWPHigherOrEqualThan("3.3")){ //remove on site page jQuery("#wpadminbar #wp-admin-bar-root-default > #wp-admin-bar-wp-logo .ab-sub-wrapper").hide(); jQuery("#wpadminbar #wp-admin-bar-root-default > #wp-admin-bar-site-name .ab-sub-wrapper").hide(); jQuery("#wpadminbar #wp-admin-bar-root-default > #wp-admin-bar-wp-logo .ab-item").attr('title',''); var abitemSelector = "#wpadminbar .ab-top-menu > li.menupop > .ab-item"; var originalBkg = jQuery(abitemSelector).css('background'); var originalColor = jQuery(abitemSelector).css('color'); jQuery(abitemSelector).mouseover(function(){ jQuery(this).css({'background':'#222222','color':'#fafafa'}); }).mouseout(function(){ jQuery(this).css({'background':originalBkg,'color':originalColor}); }); jQuery(".new_content_header_submenu").hide(); } if(isWPHigherOrEqualThan("3.3")){ jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-comments").css("display","none"); jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-new-content").css("display","none"); jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-new-content li#wp-admin-bar-new-post").css("display","none"); jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-new-content li#wp-admin-bar-new-link").css("display","none"); jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-new-content li#wp-admin-bar-new-page").css("display","none"); jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-new-content li#wp-admin-bar-new-user").css("display","none"); jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-new-content li#wp-admin-bar-new-media").css("display","none"); jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-updates").css("display","none"); } jQuery("#wphead #header-logo").css("display","none"); jQuery("ul#wp-admin-bar-root-default li#wp-admin-bar-wp-logo").css("display","none"); if(isWPHigherOrEqualThan("3.3")){ var img_url = ''; advanced_url = img_url; image = jQuery("").attr("src",advanced_url); jQuery(image).load(function() { jQuery("#wpbody-content").prepend(image); }); }else{ jQuery("#wphead img#header-logo").attr('src',''); jQuery("#wphead img#header-logo").hide(); var img_url = ''; advanced_url = img_url+ "?" + new Date().getTime(); image = jQuery("").attr("src",advanced_url); jQuery(image).load(function() { jQuery("#wphead img#header-logo").attr('src', advanced_url); jQuery("#wphead img#header-logo").attr('width',this.width); jQuery("#wphead img#header-logo").attr('height',this.height); jQuery("#wphead").css('height', (14 + this.height)+'px'); jQuery("#wphead img#header-logo").show(); }); } if(isWPHigherOrEqualThan("3.3")){ jQuery("li#wp-admin-bar-wp-logo a.ab-item span.ab-icon").html("\" />"); jQuery("li#wp-admin-bar-wp-logo a.ab-item span.ab-icon").css('background-image','none'); jQuery("li#wp-admin-bar-wp-logo a.ab-item span.ab-icon").css('width','auto'); jQuery("li#wp-admin-bar-wp-logo a.ab-item").attr('href',""); jQuery("#wpadminbar #wp-admin-bar-root-default > #wp-admin-bar-wp-logo .ab-item").attr('title',''); } jQuery("#wp-admin-bar-site-name").css("display","none"); if(isWPHigherOrEqualThan("3.3")){ var href = ""; href = href.replace("%BLOG%", ""); if(href == "%SWITCH%"){ href = ""; context == "page"){ ?>href+="/wp-admin"; } jQuery("li#wp-admin-bar-wp-logo a.ab-item").attr('href',href); } jQuery("#wphead #site-heading").css("display","none"); jQuery("#wphead #site-heading").after('

'); //3.3FIX if(isWPHigherOrEqualThan("3.3")){ jQuery("#wp-admin-bar-site-name a:first").html(''); } context =='admin'){ ?> jQuery("#wpadminbar").css("display","none"); jQuery("body.admin-bar").css("padding-top","0"); jQuery("#wphead").css("display","none"); jQuery('html.wp-toolbar').css("padding-top","0"); if(isWPHigherOrEqualThan("3.3")){ jQuery("#wpbody-content").prepend('Log Out'); }else{ var clon =""; jQuery("div#user_info a").each(function(){ if(jQuery(this).text() =="Log Out"){ clon = jQuery(this).clone(); } }); if(clon !=""){ jQuery(clon).attr('style','float:right;padding:15px'); jQuery(clon).html(''); } jQuery("#wphead").after(clon); } if(isWPHigherOrEqualThan("3.5")){ var alltext=""; alltext=""; jQuery('li#wp-admin-bar-my-account').css('cursor','default'); alltext = jQuery('li#wp-admin-bar-my-account').html(); if(alltext!=null){ var parts = alltext.split(','); alltext = "" + ", " + parts[1]; } jQuery("li#wp-admin-bar-my-account").html(""+alltext+""); }else if(isWPHigherOrEqualThan("3.3")){ var alltext=""; alltext=""; jQuery('li#wp-admin-bar-my-account').css('cursor','default'); alltext = jQuery('li#wp-admin-bar-my-account').html(); if(alltext!=null){ var parts = alltext.split(','); alltext = "" + ", " + parts[1]; } jQuery("li#wp-admin-bar-my-account").html(alltext); }else if(isWPHigherOrEqualThan("3.2")){ var alltext=""; alltext=""; alltext = jQuery('#user_info div.hide-if-no-js').html(); if(alltext!=null){ var parts = alltext.split(','); alltext = "" + ", " + parts[1]; } jQuery("#user_info div.hide-if-no-js").html(alltext); }else{ var howdyText = jQuery("#user_info").html(); if(howdyText !=null){ jQuery("#user_info").html("

"+""+howdyText.substr(9)); } } if(isWPHigherOrEqualThan("3.5")){ //jQuery("#wp-admin-bar-my-account").css("padding-left","10px"); //jQuery("#wp-admin-bar-my-account").css("padding-right","10px"); //jQuery("#wp-admin-bar-my-account img").css({"margin-left":"5px","margin-bottom":"-4px"}); } change_title', 10, 2); } ?> if(isWPHigherOrEqualThan("3.3")){ jQuery("ul#wp-admin-bar-user-actions li#wp-admin-bar-logout a").text(""); }else if(isWPHigherOrEqualThan("3.2")){ jQuery("#user_info #user_info_links a:eq(1)").text(""); }else{ jQuery("#user_info a:eq(1)").text(""); } if(isWPHigherOrEqualThan("3.3")){ jQuery("ul#wp-admin-bar-user-actions li#wp-admin-bar-edit-profile").css("visibility","hidden"); jQuery("ul#wp-admin-bar-user-actions li#wp-admin-bar-edit-profile").css("height","10px"); jQuery('#wpadminbar #wp-admin-bar-top-secondary > #wp-admin-bar-my-account > a').attr('href','#'); jQuery('#wpadminbar #wp-admin-bar-top-secondary #wp-admin-bar-user-info > a').attr('href','#'); jQuery('#wpadminbar #wp-admin-bar-top-secondary #wp-admin-bar-edit-profile > a').attr('href','#'); }else if(isWPHigherOrEqualThan("3.2")){ jQuery("#user_info #user_info_links li:eq(0)").remove(); } if(isWPHigherOrEqualThan("3.3")){ var logout_content = jQuery("li#wp-admin-bar-logout").html(); jQuery("ul#wp-admin-bar-top-secondary").html('

  • '+ logout_content +'
  • '); }else if(isWPHigherOrEqualThan("3.2")){ var logoutText = jQuery("#user_info a:nth-child(2)").text(); logoutText = ""; var logoutLink = jQuery("#user_info a:nth-child(2)").attr("href"); jQuery("#user_info").html(""+logoutText+""); }else{ var logoutText = jQuery("#user_info a:nth-child(2)").text(); var logoutLink = jQuery("#user_info a:nth-child(2)").attr("href"); jQuery("#user_info").html(""+logoutText+""); } function updateAllColors(){ colorizer as $k => $v){ if(($k !="") and ($v !="")){ ?> updateTargetColor("",""); jQuery('.color_picker').each(function(){ updateColor(jQuery(this).attr('id'),jQuery(this).val()) }); jQuery('label,h1,h2,h3,h4,h5,h6,a,p,.form-table th,.form-wrap label').css('text-shadow','none'); jQuery('#adminmenu li.wp-menu-open').css('border','none'); jQuery('#adminmenu li.wp-menu-open .wp-submenu').css({'border':'none','margin':'0px','border-radius':'0px'}); }roles['administrator']['capabilities']; $capabilitySelector = ""; $selectedValue = get_option('agca_admin_capability'); if($selectedValue == ""){ $selectedValue = "edit_dashboard"; } foreach($capabs as $k=>$v){ $selected = ""; if($selectedValue == $k){ $selected = " selected=\"selected\" "; } $capabilitySelector .="\n"; } $this->admin_capabilities = ""; } function admin_capability(){ $selectedValue = get_option('agca_admin_capability'); if($selectedValue == ""){ $selectedValue = "edit_dashboard"; } return $selectedValue; } function print_admin_css() { $this->agca_get_includes(); $this->admin_capabilities(); $this->context = "admin"; get_currentuserinfo() ; $wpversion = $this->get_wp_version(); ?> admin_capability())){ ?> context = "login"; $this->agca_get_includes(); $wpversion = $this->get_wp_version(); ?> get_wp_version(); ?>

    AG Custom Admin Settings (vagca_version; ?>)

     

    />
    Your feedback:

    Admin Bar Settings Page


    Info: Roll over option labels for more information about option.


    > =3.3){?> = 3.2){ ?> = 3.3){ $profile_text = 'Remove "Edit My Profile" option from dropdown menu'; } ?>
    />
    />
    />
    />

    Elements on Left

    />
     

    Put here an URL of the new top bar image ( maximum height = 28px).

     

    Put here a link for admin bar logo .

     

    Please use %BLOG% and %PAGE% in your title template.

     

    Add custom header image.

    />
    />
    />
    />
    />
    />
    />
    />
    />
    />
    />

    Info: You can use HTML tags like 'h1' and/or 'a' tag

    />
    />

    Elements on Right

    />
    />
    />
    />
    />