. */ $agca = new AGCA(); class AGCA{ private $colorizer=""; private $active_plugin; private $agca_version; private $agca_debug = false; private $admin_capabilities; private $context = ""; private $saveAfterImport = false; private $templateCustomizations = ""; private $templates_ep = "http://wordpressadminpanel.com/configuration.php"; public function __construct() { $this->reloadScript(); $this->checkPOST(); $this->checkGET(); if(function_exists("add_filter")){ 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_init', array(&$this,'agca_init_session')); 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')); add_action( 'wp_before_admin_bar_render', array(&$this,'admin_bar_changes') ); register_deactivation_hook(__FILE__, array(&$this,'agca_deactivate')); add_action( 'customize_controls_enqueue_scripts', array(&$this,'agca_customizer_php') ); /*Initialize properties*/ $this->colorizer = $this->jsonMenuArray(get_option('ag_colorizer_json'),'colorizer'); $this->agca_version = "1.5.4.3"; //TODO:upload images programmaticaly } // Add donate and support information function jk_filter_plugin_links($links, $file) { if ( $file == plugin_basename(__FILE__) ) { if(!is_network_admin()){ $links[] = '' . __('Settings') . ''; $links[] = '' . __('Admin Themes') . ''; } $links[] = '' . __('Support') . ''; $links[] = '' . __('Upgrade') . ''; $links[] = '' . __('Donate') . ''; } return $links; } function change_admin_color(){ return 'default'; } function agca_customizer_php(){ $this->agca_get_includes(); } function agca_init_session(){ if (!session_id()) session_start(); } function checkGET(){ if(isset($_GET['agca_action'])){ if($_GET['agca_action'] =="remove_templates"){ $this->delete_template_images_all(); update_option('agca_templates', ""); update_option('agca_selected_template', ""); } } if(isset($_GET['agca_debug'])){ if($_GET['agca_debug'] =="true"){ $this->agca_debug = true; }else{ $this->agca_debug = false; } } } function checkPOST(){ if(isset($_POST['_agca_save_template'])){ $this->verifyPostRequest(); //print_r($_POST); $data = $_POST['templates_data']; $parts = explode("|||",$data); $common_data = $parts [0]; $admin_js = $parts [1]; $admin_css = $parts [2]; $login_js = $parts [3]; $login_css = $parts [4]; $settings = $parts [5]; $images = $parts [6]; $template_name = $_POST['templates_name']; update_option('agca_selected_template', $template_name); $templates = get_option( 'agca_templates' ); if($templates == ""){ $templates = array(); } $templates[$template_name] = array( 'common'=>$common_data, 'admin'=>"", 'adminjs'=>$admin_js, 'admincss'=>$admin_css, 'login'=>"", 'loginjs'=>$login_js, 'logincss'=>$login_css, 'images'=>$images, 'settings'=>$settings ); update_option('agca_templates', $templates); $_POST = array(); }else if(isset($_POST['_agca_templates_session'])){ $this->verifyPostRequest(); $this->agcaAdminSession(); if($_POST['template'] !="") $_SESSION["AGCA"]["Templates"][$_POST['template']] = array("license"=>$_POST['license']); print_r($_SESSION); echo "_agca_templates_session:OK"; exit; }else if(isset($_POST['_agca_templates_session_remove_license'])){ $this->verifyPostRequest(); $this->agcaAdminSession(); if($_POST['template'] !="") $_SESSION["AGCA"]["Templates"][$_POST['template']] = null; print_r($_SESSION); echo "_agca_templates_session_remove_license:OK"; exit; }else if(isset($_POST['_agca_get_templates'])){ $this->verifyPostRequest(); $templates = get_option( 'agca_templates' ); if($templates == "") $templates = array(); $results = array(); foreach($templates as $key=>$val){ $results[]=$key; } echo json_encode($results); exit; }else if(isset($_POST['_agca_activate_template'])){ $this->verifyPostRequest(); update_option('agca_selected_template', $_POST['_agca_activate_template']); $_POST = array(); //unset($_POST); exit; }else if(isset($_POST['_agca_template_settings'])){ $this->verifyPostRequest(); $settings = $_POST['_agca_template_settings']; $templates = get_option( 'agca_templates' ); if($templates == ""){ $templates = array(); } $template_name = $_POST["_agca_current_template"]; $templates[$template_name]["settings"] = $settings; update_option('agca_templates', $templates); $_POST = array(); //print_r($templates); exit; }else if(isset($_POST['_agca_upload_image'])){ $this->verifyPostRequest(); function my_sideload_image() { $remoteurl = $_POST['_agca_upload_image']; $file = media_sideload_image( $remoteurl, 0 ,"AG Custom Admin Template Image (do not delete)"); $fileparts = explode("src='",$file); $url=explode("'",$fileparts[1]); echo $url[0]; exit; } add_action( 'admin_init', 'my_sideload_image' ); }else if(isset($_POST['_agca_remove_template_images'])){ $this->verifyPostRequest(); $this->delete_template_images($_POST['_agca_remove_template_images']); exit; } } function verifyPostRequest(){ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if(!is_admin()){ exit; } include_once(ABSPATH . 'wp-includes/pluggable.php'); if(!is_user_logged_in() || !current_user_can( 'manage_options' )){ exit; } if(!wp_verify_nonce($_POST['_agca_token'],'agca_form')){ exit; } } } function admin_bar_changes(){ if( current_user_can( 'manage_options' )){ global $wp_admin_bar; if(!is_network_admin()){ $wp_admin_bar->add_menu( array( 'id' => 'agca-admin-themes', 'title' => ''.__( 'Admin Themes', 'agca-admin-themes' ), 'href' => 'tools.php?page=ag-custom-admin/plugin.php#ag-templates' )); } } } function delete_template_images_all(){ $templates = get_option('agca_templates'); if($templates != null && $templates != ""){ foreach($templates as $template){ if($template != null && $template['images'] != null && $template['images'] != ""){ //print_r($template['images']); $imgs = explode(',',$template['images']); foreach($imgs as $imageSrc){ $this->delete_attachment_by_src($imageSrc); } //print_r($imgs); } } } //print_r($templates); } function delete_template_images($template_name){ $templates = get_option('agca_templates'); if($templates != null && $templates != ""){ $template = $templates[$template_name]; if($template != null && $template['images'] != null && $template['images'] != ""){ //print_r($template['images']); exit; $imgs = explode(',',$template['images']); foreach($imgs as $imageSrc){ $this->delete_attachment_by_src($imageSrc); } //print_r($imgs); } } //print_r($templates); } function delete_attachment_by_src ($image_src) { global $wpdb; $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'"; $id = $wpdb->get_var($query); wp_delete_attachment( $id, $true ); } function get_installed_agca_templates(){ $templates = get_option( 'agca_templates' ); if($templates == "")return '[]'; $results = array(); foreach($templates as $key=>$val){ $results[]=$key; } return json_encode($results); } 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() { ?> " /> context == "login"){ ?> templateCustomizations; if(!((get_option('agca_role_allbutadmin')==true) and (current_user_can($this->admin_capability())))){ ?> verifyPostRequest(); if(isset($_FILES) && isset($_FILES['settings_import_file']) ){ if($_FILES["settings_import_file"]["error"] > 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->verifyPostRequest(); $this->exportSettings(); } } if(isset($_GET['agca_action'])){ if($_GET['agca_action'] == "disablewarning"){ update_option('agca_disablewarning', true); } } } 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_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_activity', '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_admin_bar_admin_themes', 'agca_remove_top_bar_dropdowns', 'agca_admin_menu_turnonoff', 'agca_admin_menu_agca_button_only', 'agca_admin_menu_separators', '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_autofold', 'agca_admin_menu_collapse_button', 'ag_edit_adminmenu_json', 'ag_edit_adminmenu_json_new', 'ag_add_adminmenu_json', 'ag_colorizer_json', 'agca_colorizer_turnonof', 'agca_custom_js', 'agca_custom_css', 'agca_colorizer_turnonoff', 'agca_disablewarning', 'agca_selected_template', 'agca_templates', ); } function getTextEditor($name){ $settings = array( 'textarea_name' => $name, 'media_buttons' => true, 'tinymce' => array( 'theme_advanced_buttons1' => 'formatselect,|,bold,italic,underline,|,' . 'bullist,blockquote,|,justifyleft,justifycenter' . ',justifyright,justifyfull,|,link,unlink,|' . ',spellchecker,wp_fullscreen,wp_adv' ) ); wp_editor( get_option($name), $name, $settings ); } 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" || "ag_edit_adminmenu_json_new"|| $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() { add_management_page( 'AG Custom Admin', 'AG Custom Admin', 'administrator', __FILE__, array(&$this,'agca_admin_page') ); } function agca_create_admin_button($name,$arr) { $href = $arr["value"]; $target =$arr["target"]; $button ="

  • $name
  • "; return $button; } function agca_decode($code){ $code = str_replace("{","",$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.='  '; } } }else{ if(isset($arr[$type])){ $elements = $this->agca_decode($arr[$type]); } if($elements !=""){ foreach($elements as $element){ if(!$first){ $array .=","; } $parts = explode(" : ",$element); if(isset($parts[0]) && isset($parts[1])){ $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 print_page() { if($this->isGuest() && get_option('agca_admin_bar_frontend_hide')){ return false; } if(!$this->isGuest()){ ?> context = "page"; $wpversion = $this->get_wp_version(); ?> 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',''); jQuery(".new_content_header_submenu").hide(); 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("ul#wp-admin-bar-root-default li#wp-admin-bar-agca-admin-themes").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"); var img_url = ''; advanced_url = img_url; image = jQuery("").attr("src",advanced_url); jQuery(image).load(function() { jQuery("#wpbody-content").prepend(image); }); 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:before").attr('title',''); jQuery('body #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon').attr('class','ab-icon2'); jQuery("#wp-admin-bar-wp-logo").show(); jQuery("#wp-admin-bar-site-name").css("display","none"); 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('

    '); 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"); jQuery("#wpbody-content").prepend(''); 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+""); change_title', 10, 2); } ?> jQuery("ul#wp-admin-bar-user-actions li#wp-admin-bar-logout a").text(""); 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','#'); var logout_content = jQuery("li#wp-admin-bar-logout").html(); jQuery("ul#wp-admin-bar-top-secondary").html('
  • '+ logout_content +'
  • '); jQuery("#wp-admin-bar-logout a").css('padding','0 8px'); 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"; } /*echo $selectedValue; die;*/ ksort($capabs); foreach($capabs as $k=>$v){ $selected = ""; if($this->startsWith($k, 'level_')) continue; if($selectedValue == $k){ $selected = " selected=\"selected\" "; } //TODO:Find out why this does not work //$capabilitySelector .="\n"; $capabilitySelector .="\n"; } $this->admin_capabilities = ""; } function admin_capability(){ $selectedValue = get_option('agca_admin_capability'); if($selectedValue == ""){ $selectedValue = "edit_dashboard"; } return $selectedValue; } function JSPrintAGCATemplateSettingsVar($settings){ echo "\n#is', '', $settings).";\n"; //TODO: think about this echo ""; } function appendSettingsToAGCATemplateCustomizations($customizations, $settings){ $template_settings = json_decode($settings); //print_r($template_settings); foreach($template_settings as $sett){ $key = $sett->code; //use default value if user's value is not set $value=""; if($sett->value != ""){ $value = $sett->value; }else{ $value = $sett->default_value; } //Prepare settings if($sett->type == 6){ if($value !== null && (strtolower($value) == "on" || $value == "1")){ $value = "true"; }else{ $value = "false"; } } $customizations = str_replace("%".$key."%",$value, $customizations); } return $customizations; } function enableSpecificWPVersionCustomizations($customizations){ /*enable special CSS for this WP version*/ $ver = $this->get_wp_version(); $customizations = str_replace("/*".$ver," ", $customizations); $customizations = str_replace($ver."*/"," ", $customizations); return $customizations; } function removeCSSComments($customizations){ $customizations = preg_replace('#/\*.*?\*/#si','',$customizations); return $customizations; } function prepareAGCAAdminTemplates(){ if(get_option( 'agca_templates' ) != ""){ //print_r(get_option( 'agca_templates' )); $themes = get_option( 'agca_templates' ); $selectedTheme = get_option('agca_selected_template'); if(isset($themes[$selectedTheme])){ $theme = $themes[$selectedTheme]; add_filter('get_user_option_admin_color', array(&$this,'change_admin_color')); echo (stripslashes($theme['common'])); echo ""; //KEEP THIS FOR MIGRATION PURPOSE FOR SOME TIME if(!((get_option('agca_role_allbutadmin')==true) and (current_user_can($this->admin_capability())))){ if($theme['settings'] == "" || $theme['settings'] == " ") $theme['settings'] = "{}"; //print_r($templdata); $this->JSPrintAGCATemplateSettingsVar($theme['settings']); $admindata = $this->appendSettingsToAGCATemplateCustomizations(stripslashes($theme['admin']), $theme['settings']); $admindata = $this->enableSpecificWPVersionCustomizations($admindata); $admindata = $this->removeCSSComments($admindata); //echo $admindata; //REPLACE TAGS WITH CUSTOM TEMPLATE SETTINGS $this->templateCustomizations = $admindata; } //KEEP THIS FOR MIGRATION PURPOSE FOR SOME TIME } } } function agcaAdminSession(){ $agcaTemplatesSession = array(); //session_destroy(); //session_unset(); /*if(!session_id()){ session_start(); }*/ if(!isset($_SESSION["AGCA"])){ $_SESSION["AGCA"] = array(); $_SESSION["AGCA"]["Templates"] = array(); } //print_r($_SESSION); if(isset($_SESSION["AGCA"])){ if(isset($_SESSION["AGCA"]["Templates"])){ //print_r($_SESSION["AGCA"]["Templates"]); $agcaTemplatesSession = json_encode($_SESSION["AGCA"]["Templates"]); } } if($agcaTemplatesSession == '""' || $agcaTemplatesSession == '"[]"'){ $agcaTemplatesSession = array(); } return $agcaTemplatesSession; } function getAGCAColor($name){ if(isset($this->colorizer[$name])){ echo htmlspecialchars($this->colorizer[$name]); } } function prepareAGCALoginTemplates(){ if(get_option( 'agca_templates' ) != ""){ //print_r(get_option( 'agca_templates' )); $templates = get_option( 'agca_templates' ); foreach($templates as $templname=>$templdata){ if($templname == get_option('agca_selected_template')){ echo (stripslashes($templdata['common'])); if($templdata['settings'] == "" || $templdata['settings'] == " ") $templdata['settings'] = "{}"; $this->JSPrintAGCATemplateSettingsVar($templdata['settings']); $logindata = $this->appendSettingsToAGCATemplateCustomizations(stripslashes($templdata['login']), $templdata['settings']); $logindata = $this->enableSpecificWPVersionCustomizations($logindata); $logindata = $this->removeCSSComments($logindata); echo($logindata); break; } } } } function agca_error_check(){ ?> menu_item_cleartext($name); //apply previous submenu customizations if($customizationsSet){ $pc = $previousCustomizations[$url]; } //get submenu $s = array(); if(isset($submenu[$url])){ $sitems = $submenu[$url]; foreach($sitems as $key=>$sub){ $nameSub = $sub[0]; $urlSub = $sub[2]; $removeSub = false; $nameSub = $this->menu_item_cleartext($nameSub); $s[$key]=array( 'name'=>$nameSub, 'new'=>'', 'remove'=>$removeSub, 'url'=>$urlSub ); if(isset($pc) && isset($pc['submenus'])){ $s[$key]['new'] = $pc['submenus'][$key]['new']; $s[$key]['remove'] = $pc['submenus'][$key]['remove']; if($s[$key]['new'] == null){ $s[$key]['new'] = ''; } if($s[$key]['remove'] == null){ $s[$key]['remove'] = false; } } } } $m[$url]=array( 'name'=>$name, 'remove'=>$remove, 'new'=>'', 'url'=>$url, 'cls'=>$cls, 'submenus'=>$s ); //apply previous top menu customizations if($customizationsSet){ $pc = $previousCustomizations[$url]; if(isset($pc)){ $m[$url]['remove'] = $pc['remove']; $m[$url]['new'] = $pc['new']; } } } return $m; } /** * Applies customizations to admin menu */ function customized_menu(){ $customizations = $this->get_menu_customizations(); global $menu; global $submenu; //print_r($submenu);die; //apply customizations to original admin menu foreach($menu as $key=>$top){ $url = $top[2]; if(isset($customizations[$url])){ $topCustomized = $customizations[$url]; if($topCustomized['new']) { $menu[$key][0] = $topCustomized['new']; } if($topCustomized['remove']){ unset($menu[$key]); } } } foreach($submenu as $topkey=>$subs){ foreach($subs as $subkey=>$sub){ if(isset($customizations[$topkey]['submenus'][$subkey])){ $cs = $customizations[$topkey]['submenus'][$subkey]; if($cs['new']) { $submenu[$topkey][$subkey][0] = preg_replace("/".$cs['name']."/",$cs['new'], $submenu[$topkey][$subkey][0],1); } if($cs['remove']){ unset($submenu[$topkey][$subkey]); } } } } } /** * Used only for removing admin menu customizations to AGCA 1.5 version or later * @param $checkboxes * @param $textboxes */ function migrate_menu_customizations($checkboxes, $textboxes){ $customizations = $this->get_menu_customizations(); global $menu; /*print_r($menu); print_r($customizations); print_r($textboxes);*/ $oldTopValue = ""; //Migrate checkboxes foreach($checkboxes as $key=>$value){ $isTop = false; $oldSubValue = ""; if (strpos($key,'<-TOP->') !== false) { $oldTopValue = str_replace('<-TOP->','',$key); $isTop = true; }else{ $oldSubValue = $key; } if($value == 'checked'){ $topIndex = ""; foreach($customizations as $k=>$c){ if($c['cls'] == $oldTopValue){ $topIndex = $k; break; } } if($topIndex == "") continue; if($isTop){ $customizations[$topIndex]['remove'] = true; }else{ if(is_array($customizations[$topIndex]['submenus'])){ foreach($customizations[$topIndex]['submenus'] as $skey=>$sval){ if($sval['name'] == $oldSubValue){ $customizations[$topIndex]['submenus'][$skey]['remove'] = true; } } } } } } //Migrate textboxes foreach($textboxes as $key=>$value){ $isTop = false; $oldSubValue = ""; if (strpos($key,'<-TOP->') !== false) { $oldTopValue = str_replace('<-TOP->','',$key); $isTop = true; }else{ $oldSubValue = $key; } if($value != ''){ $topIndex = ""; foreach($customizations as $k=>$c){ if($c['cls'] == $oldTopValue){ $topIndex = $k; break; } } if($topIndex == "") continue; if($isTop){ $customizations[$topIndex]['new'] = $value; }else{ if(is_array($customizations[$topIndex]['submenus'])){ foreach($customizations[$topIndex]['submenus'] as $skey=>$sval){ if($sval['name'] == $oldSubValue){ if($customizations[$topIndex]['submenus'][$skey]['name'] != $value){ $customizations[$topIndex]['submenus'][$skey]['new'] = $value; } } } } } } } update_option('ag_edit_adminmenu_json','');//remove previous admin menu configuration update_option('ag_edit_adminmenu_json_new',json_encode($customizations)); } function print_admin_css() { $agcaTemplateSession = $this->agcaAdminSession(); $wpversion = $this->get_wp_version(); $this->context = "admin"; $this->error_check(); $currentScreen = get_current_screen(); ?> prepareAGCAAdminTemplates(); $this->agca_get_includes(); $this->admin_capabilities(); get_currentuserinfo() ; ?> admin_capability())){ ?> id == 'tools_page_ag-custom-admin/plugin'){ ?>
    context = "login"; $this->error_check(); $wpversion = $this->get_wp_version(); ?> prepareAGCALoginTemplates(); $this->agca_get_includes(); ?> get_wp_version(); $this->agca_error_check(); ?>

    AG Custom Admin Settings (vagca_version; ?>)

     

    Your feedback:

    Admin Bar Settings

    print_checkbox(array( 'attributes'=>array( 'class'=>'ag_table_major_options', ), 'hide'=>true, 'title'=>'Hides admin bar completely from the admin panel', 'name'=>'agca_header', 'label'=>'Admin bar', 'input-attributes'=>'data-dependant="#agca_header_show_logout_content"', 'input-class'=>'has-dependant', )); $this->print_checkbox(array( 'attributes'=>array( 'class'=>'ag_table_major_options', 'style'=> ((get_option('agca_header')!='true')?'display:none':''), 'id'=>'agca_header_show_logout_content', ), 'title'=>'Check this if you want to show Log Out button in top right corner of the admin page', 'name'=>'agca_header_show_logout', 'checked'=> ((get_option('agca_header')==true) && (get_option('agca_header_show_logout')==true)), 'label'=>'(but show Log Out button)' )); $this->print_checkbox(array( 'title'=>'Removes admin bar customizations for authenticated users on site pages.
    This option can be useful if you want to remove AGCA scripts (styles, JavaScript) on your website for any reason.', 'name'=>'agca_admin_bar_frontend', 'hide'=>true, 'label'=>'Site pages: Admin bar customizations' )); $this->print_checkbox(array( 'title'=>'Hides admin bar completely for authenticated users on site pages.', 'name'=>'agca_admin_bar_frontend_hide', 'hide'=>true, 'label'=>'Site pages: Admin bar' )); $this->print_options_h3('Left Side'); $this->print_input(array( 'title'=>'Change default WordPress logo with custom image.', 'name'=>'agca_wp_logo_custom', 'label'=>'Admin bar logo', 'hint' =>'Image URL (maximum height is 28px)' )); $this->print_input(array( 'title'=>'Custom link on admin bar logo.

    Use:
    %BLOG% - for blog URL
    %SWITCH% - to switch betweent admin and site area', 'name'=>'agca_wp_logo_custom_link', 'label'=>'Admin bar logo link', 'hint' =>'Link' )); $this->print_input(array( 'title'=>'Customize WordPress title using custom title template.

    Examples:
    %BLOG% -- %PAGE% (will be) My Blog -- Add New Post
    %BLOG% (will be) My Blog
    My Company > %BLOG% > %PAGE% (will be) My Company > My Blog > Tools', 'name'=>'agca_custom_title', 'label'=>'Page title template', 'hint' =>'Please use %BLOG% and %PAGE% in your title template.' )); $this->print_input(array( 'title'=>'Add custom image on the top of the admin content.', 'name'=>'agca_header_logo_custom', 'label'=>'Header image', 'hint' =>'Image URL' )); $this->print_checkbox(array( 'hide'=>true, 'title'=>'Hides small Wordpress logo from the admin bar', 'name'=>'agca_header_logo', 'label'=>'WordPress logo' )); $this->print_checkbox(array( 'hide'=>true, 'title'=>'Hides WordPress context menu on WordPress logo icon from admin bar', 'name'=>'agca_remove_top_bar_dropdowns', 'label'=>'WordPress logo context menu' )); $this->print_checkbox(array( 'hide'=>true, 'title'=>'Hides site name link from the admin bar', 'name'=>'agca_remove_site_link', 'label'=>'Site name' )); $this->print_checkbox(array( 'hide'=>true, 'title'=>'Hides update notifications from admin bar', 'name'=>'agca_admin_bar_update_notifications', 'label'=>'Update notifications' )); $this->print_checkbox(array( 'hide'=>true, 'title'=>'Hides comments block from admin bar', 'name'=>'agca_admin_bar_comments', 'label'=>'"Comments" block' )); $this->print_checkbox(array( 'hide'=>true, 'attributes'=>array( 'style'=>'margin-top:20px;' ), 'title'=>'Hides "+ New" block and its context menu from admin bar', 'name'=>'agca_admin_bar_new_content', 'label'=>'"+ New" block', 'input-attributes'=>'data-dependant=".new_content_header_submenu"', 'input-class'=>'has-dependant dependant-opposite' )); $this->print_checkbox(array( 'hide'=>true, 'attributes'=>array( 'class'=>'new_content_header_submenu' ), 'title'=>'Hides "Post" sub-menu from "+ New" block on admin bar', 'name'=>'agca_admin_bar_new_content_post', 'label'=>'      "+ New" -> Post sub-menu' )); $this->print_checkbox(array( 'hide'=>true, 'attributes'=>array( 'class'=>'new_content_header_submenu' ), 'title'=>'Hides "Link" sub-menu from "+ New" block on admin bar', 'name'=>'agca_admin_bar_new_content_link', 'label'=>'      "+ New" -> Link sub-menu' )); $this->print_checkbox(array( 'hide'=>true, 'attributes'=>array( 'class'=>'new_content_header_submenu' ), 'title'=>'Hides "Page" sub-menu from "+ New" block on admin bar', 'name'=>'agca_admin_bar_new_content_page', 'label'=>'      "+ New" -> Page sub-menu' )); $this->print_checkbox(array( 'hide'=>true, 'attributes'=>array( 'class'=>'new_content_header_submenu' ), 'title'=>'Hides "User" sub-menu from "+ New" block on admin bar', 'name'=>'agca_admin_bar_new_content_user', 'label'=>'      "+ New" -> User sub-menu' )); $this->print_checkbox(array( 'hide'=>true, 'attributes'=>array( 'class'=>'new_content_header_submenu' ), 'title'=>'Hides "Media" sub-menu from "+ New" block on admin bar', 'name'=>'agca_admin_bar_new_content_media', 'label'=>'      "+ New" -> Media sub-menu' )); $this->print_checkbox(array( 'hide'=>true, 'title'=>'Hides "Admin themes" from admin bar', 'name'=>'agca_admin_bar_admin_themes', 'label'=>'"Admin themes"' )); $this->print_textarea(array( 'title'=>'Adds custom text in admin top bar.', 'name'=>'agca_custom_site_heading', 'label'=>'Custom blog heading', 'hint'=>"Tip: You can use HTML tags like <h1> or <a>" )); $this->print_checkbox(array( 'hide'=>true, 'title'=>'Hides yellow bar with information about new WordPress release', 'name'=>'agca_update_bar', 'label'=>'Update WordPress notification' )); $this->print_options_h3('Right Side'); $this->print_input(array( 'name'=>'agca_howdy', 'label'=>'Change Howdy text', )); $this->print_input(array( 'title'=>'Put \'Exit\', for example', 'name'=>'agca_logout', 'label'=>'Change Log out text', )); $this->print_checkbox(array( 'hide'=>true, 'name'=>'agca_remove_your_profile', 'label'=>'"Edit My Profile" option from dropdown menu' )); $this->print_checkbox(array( 'title'=>'If selected, hides all elements in top right corner, except Log Out button', 'name'=>'agca_logout_only', 'label'=>'Log out only' )); ?>

    $val){ $strAttributes.=' '.$key.'="'.$val.'"'; } } if(isset($data['input-class'])){ $strInputClass = $data['input-class']; } if(isset($data['hide'])){ $strInputClass .= " visibility"; } if(isset($data['input-attributes'])){ $strInputAttributes = $data['input-attributes']; } if(isset($data['onchange'])){ $strOnchange = $data['onchange']; } if(!isset($data['title'])){ $data['title'] = $data['label']; } if(isset($data['checked'])){ $isChecked = $data['checked']; }else{ //use default check with the option $isChecked = get_option($data['name'])==true; } ?> > title='Toggle on/off' name="" value="true" /> '.$data['hint'].'

    '; } if(!isset($data['title'])){ $data['title'] = $data['label']; } if(isset($data['suffix'])){ $suffix = $data['suffix']; } if(isset($data['attributes'])){ foreach($data['attributes'] as $key=>$val){ $strAttributes.=' '.$key.'="'.$val.'"'; } } ?> > '.$data['hint'].'.

    '; } if(!isset($data['title'])){ $data['title'] = $data['label']; } ?>