123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?php
- if (!class_exists("plug_admin_bar")) {
- class plug_admin_bar {
- function plug_admin_bar($ns) {
- $this->title = __("Admin bar","dagsopt");
- $this->pluginname = $ns->pluginname;
- $this->file = $ns->file;
- $this->ns = $ns;
- }
- function start(){
- add_action( 'admin_bar_menu' , array(&$this,'bu_admin_link_first'), 1 );
- add_action( 'admin_bar_menu' , array(&$this,'bu_admin_link_last'), 200 );
- if(get_option( $this->pluginname."_admin_bar".'_remove_comments' ,false)){
- add_action( 'wp_before_admin_bar_render' , array(&$this,'bu_admin_link_remove_comments'), 210 );
- }
- if(!function_exists('wp_get_current_user')) {
- include(ABSPATH . "wp-includes/pluggable.php");
- }
- // remove_submenu_page('index.php','update-core.php');
- $current_user = wp_get_current_user();
- if( current_user_can( 'manage_options' ) && $current_user->user_login == "admin") {
- add_action( 'admin_menu' , array(&$this,'setup_menus'), 220 );
- } else {
- add_action( 'admin_menu' , array(&$this,'remove_menus'), 220 );
- add_action( 'wp_before_admin_bar_render' , array(&$this,'remove_menus2'), 210 );
- }
- }
- function remove_menus2() {
- global $wp_admin_bar;
- if(get_option( $this->pluginname."_admin_bar".'_remove_new-post' ,false)){
- $wp_admin_bar->remove_menu("new-post");
- }
- if(get_option( $this->pluginname."_admin_bar".'_remove_new-link' ,false)){
- $wp_admin_bar->remove_menu("new-link");
- }
- if(get_option( $this->pluginname."_admin_bar".'_remove_new-page' ,false)){
- $wp_admin_bar->remove_menu("new-page");
- }
- if(get_option( $this->pluginname."_admin_bar".'_remove_new-media' ,false)){
- $wp_admin_bar->remove_menu("new-media");
- }
- if(get_option( $this->pluginname."_admin_bar".'_remove_new-user' ,false)){
- $wp_admin_bar->remove_menu("new-user");
- }
- }
- function setup_menus () {
- global $menu;
- $this->gmenu = $menu;
- }
- function remove_menus () {
- global $menu;
- $this->setup_menus();
- $rr = array();
- foreach($this->gmenu as $id => $mm){
- if(get_option($this->pluginname."_admin_bar".'_remove_'.$mm[5],false)){
- array_push($rr,$mm[5]);
- }
- }
- foreach($menu as $id => $menupoint){
- if(isset($menupoint[5]) && in_array($menupoint[5],$rr)){
- unset($menu[$id]);
- }
- }
- remove_submenu_page('index.php','update-core.php');
- remove_submenu_page('themes.php','update');
- remove_submenu_page('themes.php','checkupdate');
- remove_submenu_page('themes.php','custom-header');
- remove_submenu_page('themes.php','custom-background');
- remove_submenu_page('themes.php','theme-editor.php');
- remove_submenu_page('themes.php','themes.php');
- //add_submenu_page( 'themes.php', "Customize", "Customize", "", "customize.php", "");
- }
- function bu_admin_link_first() {
- global $wp_admin_bar;
- if(get_option( $this->pluginname."_admin_bar".'_dags_logo' ,true)){
- $wp_admin_bar->add_menu( array('id' => 'dags-logo', 'title' => '<img src="/wp-content/plugins/dagsplug/logo.png" style="margin-top: 4px;">', 'href' => 'https://dags.dk/' , 'meta' => array('title' => __('Dags dk','dagsopt'), ), ) );
- }
- }
- function bu_admin_link_remove_comments() {
- global $wp_admin_bar;
- $wp_admin_bar->remove_menu('comments');
- }
-
-
- function bu_admin_link_last() {
- global $wp_admin_bar;
- if(get_option( $this->pluginname."_admin_bar".'_dags_logo' ,true)){
- $wp_admin_bar->remove_node("wp-logo");
- }
- if(get_option( $this->pluginname."_admin_bar".'_show_ip' ,true)){
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'IP', 'title' => 'IP: '.$_SERVER['SERVER_ADDR'], 'href' => admin_url( 'admin.php?page='.$this->pluginname.'-options' ) ) );
- }
- if ( current_user_can( 'manage_options' ) && get_option( $this->pluginname."_admin_bar_live_url" )) {
- if(get_option( $this->pluginname."_admin_bar".'_show_switcher' ,true)){
- if($_SERVER['HTTP_HOST']==get_option( $this->pluginname."_admin_bar_live_url" )){
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_live', 'title' => get_option( $this->pluginname."_admin_bar_live_title" ), 'href' => get_option( $this->pluginname."_admin_bar_live_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> 'active') ) );
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_stage', 'title' => get_option( $this->pluginname."_admin_bar_stage_title" ), 'href' => get_option( $this->pluginname."_admin_bar_stage_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> '') ) );
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_local', 'title' => get_option( $this->pluginname."_admin_bar_local_title" ), 'href' => get_option( $this->pluginname."_admin_bar_local_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> '') ) );
- }else if($_SERVER['HTTP_HOST']==get_option( $this->pluginname."_admin_bar_stage_url" )){
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_live', 'title' => get_option( $this->pluginname."_admin_bar_live_title" ), 'href' => get_option( $this->pluginname."_admin_bar_live_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> '') ) );
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_stage', 'title' => get_option( $this->pluginname."_admin_bar_stage_title" ), 'href' => get_option( $this->pluginname."_admin_bar_stage_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> 'active') ) );
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_local', 'title' => get_option( $this->pluginname."_admin_bar_local_title" ), 'href' => get_option( $this->pluginname."_admin_bar_local_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> '') ) );
- }else{
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_live', 'title' => get_option( $this->pluginname."_admin_bar_live_title" ), 'href' => get_option( $this->pluginname."_admin_bar_live_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> '') ) );
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_stage', 'title' => get_option( $this->pluginname."_admin_bar_stage_title" ), 'href' => get_option( $this->pluginname."_admin_bar_stage_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> '') ) );
- $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', 'id' => 'DEV_local', 'title' => get_option( $this->pluginname."_admin_bar_local_title" ), 'href' => get_option( $this->pluginname."_admin_bar_local_url" ).$_SERVER['REQUEST_URI'], 'meta'=>array('class'=> 'active') ) );
- }
- }
- } else {
- }
- }
- function help(){
- ?>
- <?php echo(__("Server switcher : local > stage > live","dagsopt")) ?><br>
- <?php echo(__("Swap WP for dags logo","dagsopt")) ?><br>
- <?php echo(__("Show server ip","dagsopt")) ?><br>
- <?php
- }
- function Option($pre){
- update_option ( $pre.'_show_switcher', $_POST [ $pre.'_show_switcher' ] );
- if(!empty($_POST [ $pre.'_live_url' ])){
- update_option ( $pre.'_live_url', $_POST [ $pre.'_live_url' ] );
- }
- if(!empty($_POST [ $pre.'_live_title' ])){
- update_option ( $pre.'_live_title', $_POST [ $pre.'_live_title' ] );
- }
- if(!empty($_POST [ $pre.'_stage_url' ])){
- update_option ( $pre.'_stage_url', $_POST [ $pre.'_stage_url' ] );
- }
- if(!empty($_POST [ $pre.'_stage_title' ])){
- update_option ( $pre.'_stage_title', $_POST [ $pre.'_stage_title' ] );
- }
- if(!empty($_POST [ $pre.'_local_url' ])){
- update_option ( $pre.'_local_url', $_POST [ $pre.'_local_url' ] );
- }
- if(!empty($_POST [ $pre.'_local_title' ])){
- update_option ( $pre.'_local_title', $_POST [ $pre.'_local_title' ] );
- }
- update_option ( $pre.'_dags_logo', $_POST [ $pre.'_dags_logo' ] );
- update_option ( $pre.'_show_ip', $_POST [ $pre.'_show_ip' ] );
- update_option ( $pre.'_remove_comments', $_POST [ $pre.'_remove_comments' ] );
- update_option ( $pre.'_remove_new-post', $_POST [ $pre.'_remove_new-post' ] );
- update_option ( $pre.'_remove_new-link', $_POST [ $pre.'_remove_new-link' ] );
- update_option ( $pre.'_remove_new-media', $_POST [ $pre.'_remove_new-media' ] );
- update_option ( $pre.'_remove_new-page', $_POST [ $pre.'_remove_new-page' ] );
- update_option ( $pre.'_remove_new-user', $_POST [ $pre.'_remove_new-user' ] );
-
- foreach($this->gmenu as $id => $mm){
- update_option ( $pre.'_remove_'.$mm[5], $_POST [ $pre.'_remove_'.$mm[5] ] );
- }
- }
- function admin_line($pre){
- ?>
- <table>
- <tr><td ><?php echo(__("Server switcher","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_show_switcher' ); ?>" type="checkbox" id="<?php echo( $pre.'_show_switcher' ); ?>" <?php if(get_option( $pre.'_show_switcher' ,true)) echo 'checked'; ?> />
- <?php if(get_option( $pre.'_show_switcher' ,true)){
- ?>
- <table>
- <tr><td ><input type="text" name="<?php echo( $pre.'_live_title' ); ?>" value="<?php echo( get_option( $pre.'_live_title','live' ) ); ?>"></td><td><input type="text" name="<?php echo( $pre.'_live_url' ); ?>" value="<?php echo( get_option( $pre.'_live_url' ) ); ?>"></td></tr>
- <tr><td><input type="text" name="<?php echo( $pre.'_stage_title' ); ?>" value="<?php echo( get_option( $pre.'_stage_title','stage' ) ); ?>"></td><td><input type="text" name="<?php echo( $pre.'_stage_url' ); ?>" value="<?php echo( get_option( $pre.'_stage_url' ) ); ?>"></td></tr>
- <tr><td><input type="text" name="<?php echo( $pre.'_local_title' ); ?>" value="<?php echo( get_option( $pre.'_local_title','local' ) ); ?>"></td><td><input type="text" name="<?php echo( $pre.'_local_url' ); ?>" value="<?php echo( get_option( $pre.'_local_url' ) ); ?>"></td></tr>
- </table>
- <?php
- } ?>
- </td></tr>
- <tr><td ><?php echo(__("Dags logo","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_dags_logo' ); ?>" type="checkbox" id="<?php echo( $pre.'_dags_logo' ); ?>" <?php if(get_option( $pre.'_dags_logo' ,true)) echo 'checked'; ?> /></td></tr>
- <tr><td ><?php echo(__("Show IP","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_show_ip' ); ?>" type="checkbox" id="<?php echo( $pre.'_show_ip' ); ?>" <?php if(get_option( $pre.'_show_ip' ,true)) echo 'checked'; ?> /></td></tr>
- <tr><td colspan="2"><a href="javascript:$('#dags_tools_menus').toggle();">Remove Menus</a></td></tr>
- <tr><td ></td><td>
- <table id="dags_tools_menus" style="display: none;">
- <tr><td colspan="2">Remove Admin Top Bar</td></tr>
- <tr><td ><?php echo(__("Comments","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_remove_comments' ); ?>" type="checkbox" id="<?php echo( $pre.'_remove_comments' ); ?>" <?php if(get_option( $pre.'_remove_comments' ,false)) echo 'checked'; ?> /></td></tr>
- <tr><td ><?php echo(__("New Post","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_remove_new-post' ); ?>" type="checkbox" id="<?php echo( $pre.'_remove_new-post' ); ?>" <?php if(get_option( $pre.'_remove_new-post' ,false)) echo 'checked'; ?> /></td></tr>
- <tr><td ><?php echo(__("New Link","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_remove_new-link' ); ?>" type="checkbox" id="<?php echo( $pre.'_remove_new-link' ); ?>" <?php if(get_option( $pre.'_remove_new-link' ,false)) echo 'checked'; ?> /></td></tr>
- <tr><td ><?php echo(__("New Media","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_remove_new-media' ); ?>" type="checkbox" id="<?php echo( $pre.'_remove_new-media' ); ?>" <?php if(get_option( $pre.'_remove_new-media' ,false)) echo 'checked'; ?> /></td></tr>
- <tr><td ><?php echo(__("New Page","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_remove_new-page' ); ?>" type="checkbox" id="<?php echo( $pre.'_remove_new-page' ); ?>" <?php if(get_option( $pre.'_remove_new-page' ,false)) echo 'checked'; ?> /></td></tr>
- <tr><td ><?php echo(__("New User","dagsopt")) ?></td><td><input name="<?php echo( $pre.'_remove_new-user' ); ?>" type="checkbox" id="<?php echo( $pre.'_remove_new-user' ); ?>" <?php if(get_option( $pre.'_remove_new-user' ,false)) echo 'checked'; ?> /></td></tr>
- <tr><td colspan="2">Remove Admin Mode Bar</td></tr>
-
- <?php
- foreach($this->gmenu as $id => $mm){
- if(strstr($mm[2],"separator")){
- continue;
- }
- ?>
- <tr><td ><?php echo($mm[0]) ?> </td><td><input name="<?php echo( $pre.'_remove_'.$mm[5] ); ?>" type="checkbox" id="<?php echo( $pre.'_remove_'.$mm[5] ); ?>" <?php if(get_option( $pre.'_remove_'.$mm[5] ,false)) echo 'checked'; ?> /> <?php echo($mm[5]); ?></td></tr>
-
- <?php
- }
-
- ?>
- </table>
- </td></tr>
- </table>
- <?php
- }
- }
- global $plug_admin_bar;
- $plug_admin_bar = new plug_admin_bar($this);
- $this->dagsopt['plug_admin_bar'] = $plug_admin_bar;
- }
|