plugin_url = plugins_url('',__FILE__).'/'; $this->plugin_path = plugin_dir_path( __FILE__ ); } // add plugin to settings menu function add_menu() { //print_r(get_option( $this->settings_name )); $active = true; if ( is_multisite() ) { $this->settings = get_blog_option(1, $this->settings_name ); if(get_current_blog_id() != 1){ if($this->get_setting('network') == true){ $active = false; }else{ $this->settings = get_option( $this->settings_name ); } } }else{ $this->settings = get_option( $this->settings_name ); } if($active){ $page = add_submenu_page( 'options-general.php', $this->page_name, $this->page_name, 'manage_options', 'tema-admin', array( $this, 'settings' ) ); add_action('load-'.$page, array( $this, 'admin_help' )); } } // register function register_settings() { register_setting( 'tema-admin-group', $this->settings_name ); add_filter( 'pre_update_option_'.$this->settings_name, array($this, 'update_variables'), 10, 2 ); } // get setting function get_setting($arg){ $ptr = $this->settings; foreach (func_get_args() as $arg) { if (!is_array($ptr) || !is_scalar($arg) || !isset($ptr[$arg])) { return NULL; } $ptr = $ptr[$arg]; } return $ptr; } // settings function settings() { global $nav; global $subnav; ?>

page_name; ?>

Colors

Default colors

Global

Menu

Bar

Others

Login page, footer and others

Login page

Footer

Network

Custom css

Custom js

Bar

Change the admin bar on the top

Logo & name

Quick links



Menu

Change the menu on the left.

menus as $k=>$v){ $id = $this->get_slug($v); if($id[0] != NULL){ $title = isset( $nav[$id[0]]['title'] ) && $nav[$id[0]]['title'] != '' ? $nav[$id[0]]['title'] : NULL; $icon = isset( $nav[$id[0]]['icon'] ) && $nav[$id[0]]['icon'] != '' ? $nav[$id[0]]['icon'] : NULL; $hide = isset( $nav[$id[0]]['hide'] ) && $nav[$id[0]]['hide'] != '' ? $nav[$id[0]]['hide'] : NULL; $index = isset( $nav[$id[0]]['index'] ) && $nav[$id[0]]['index'] != '' ? $nav[$id[0]]['index'] : $v[10]; ?>

>

submenus[$v[2]])){ ?>

Submenu

submenus[$v[2]]) ? $this->submenus[$v[2]] : array() ; foreach ($sub as $k){ $sid = $this->get_slug($k); if($sid[0] != NULL){ $title = isset( $subnav[$sid[0]]['title'] ) && $subnav[$sid[0]]['title'] != '' ? $subnav[$sid[0]]['title'] : NULL; $hide = isset( $subnav[$sid[0]]['hide'] ) && $subnav[$sid[0]]['hide'] != '' ? TRUE : FALSE; $index = isset( $subnav[$sid[0]]['index'] ) && $subnav[$sid[0]]['index'] != '' ? $subnav[$sid[0]]['index'] : $v[10]; ?>

plugin_url.( "js/dropdown.js" ), array()); wp_register_style( 'glyphicons', $this->plugin_url.( "css/glyphicons.css" ), array()); wp_enqueue_style( 'glyphicons' ); wp_register_style( 'admin', $this->plugin_url.( "scss/scss.php/admin.scss" ), array()); wp_enqueue_style( 'admin' ); wp_register_style( 'font', $this->plugin_url.( "css/font.css" ), array()); wp_enqueue_style( 'font' ); wp_register_style( 'style', $this->plugin_url.( "scss/scss.php/admin.scss" ), array()); wp_enqueue_style( 'style' ); wp_register_style( 'menu', $this->plugin_url.( "scss/scss.php/_admin_menu.scss" ), array()); wp_enqueue_style( 'menu' ); wp_register_style( 'bar', $this->plugin_url.( "scss/scss.php/_admin_bar.scss" ), array()); wp_enqueue_style( 'bar' ); } // admin menu function admin_menu() { global $menu; global $submenu; global $nav; global $subnav; $nav = $this->get_setting('menu'); $subnav = $this->get_setting('submenu'); $i = 0; foreach ($menu as $k=>&$v){ $i++; $v[10] = $i; } foreach ($submenu as $k=>&$v){ $i = 0; foreach ($v as $key=>&$val){ $i++; $val[10] = $i; } usort($v, array($this, 'sort_submenu')); } usort($menu, array($this, 'sort_menu')); $this->menus = array_merge(array(), $menu === NULL ? array() : $menu); $this->submenus = array_merge(array(), $submenu === NULL ? array() : $submenu); // update menu end( $menu ); foreach ($menu as $k=>&$v){ $id = $this->get_slug($v); if($id[0] != NULL && isset( $nav[$id[0]] )){ // hide if( isset($nav[$id[0]]['hide']) && $nav[$id[0]]['hide'] ){ unset($menu[$k]); }else{ // title if( isset($nav[$id[0]]['title']) && $nav[$id[0]]['title'] != ''){ $v[0] = $nav[$id[0]]['title']. ( isset($id[2]) ? ' &$val){ $sid = $this->get_slug($val); if($sid[0] != NULL && isset( $subnav[$sid[0]]['title'] ) && $subnav[$sid[0]]['title'] !=''){ $val[0] = $subnav[$sid[0]]['title']. ( isset($sid[2]) ? ' get_slug($a)[0]]['index'] ) && $nav[$this->get_slug($a)[0]]['index'] != '' ? $nav[$this->get_slug($a)[0]]['index'] : $a[10]; $j = isset( $nav[$this->get_slug($b)[0]]['index'] ) && $nav[$this->get_slug($b)[0]]['index'] != '' ? $nav[$this->get_slug($b)[0]]['index'] : $b[10]; if ($i == $j) { return 0; } return ($i < $j) ? -1 : 1; } // sort submenu function sort_submenu($a, $b) { global $subnav; $i = isset( $subnav[$this->get_slug($a)[0]]['index'] ) && $subnav[$this->get_slug($a)[0]]['index'] != '' ? $subnav[$this->get_slug($a)[0]]['index'] : $a[10]; $j = isset( $subnav[$this->get_slug($b)[0]]['index'] ) && $subnav[$this->get_slug($b)[0]]['index'] != '' ? $subnav[$this->get_slug($b)[0]]['index'] : $b[10]; if ($i == $j) { return 0; } return ($i < $j) ? -1 : 1; } // get id function get_slug($s){ $c = explode(' get_nodes(); $site = array(); foreach ( $all_toolbar_nodes as $key=>$node ) { $args = $node; if($args->id == "site-name"){ $logo = $this->get_setting('bar_logo') ? sprintf('', $this->get_setting('bar_logo')) : ''; $hide = $this->get_setting('bar_name_hide') ? "hide" : ""; $name = $this->get_setting('bar_name') ? $this->get_setting('bar_name') : $args->title; $args->title = sprintf('%s %s', $logo, $hide, $name); $this->get_setting('bar_name_link') && ($args->href = $this->get_setting('bar_name_link')); } if($args->id == "my-sites"){ $site = $node; } // update the Toolbar node $wp_admin_bar->add_node( $args ); } // remove the wordpress logo $wp_admin_bar->remove_node( 'wp-logo' ); $wp_admin_bar->remove_node( 'view-site' ); $wp_admin_bar->remove_node( 'my-sites' ); $wp_admin_bar->add_node( $site ); if($this->get_setting('bar_updates_hide')){ $wp_admin_bar->remove_node('updates'); } if($this->get_setting('bar_comments_hide')){ $wp_admin_bar->remove_node('comments'); } if($this->get_setting('bar_new_hide')){ $wp_admin_bar->remove_node('new-content'); } if($this->get_setting('bar_new_hide')){ $wp_admin_bar->remove_node('new-content'); } } // admin footer function admin_footer( $default ){ if( strpos($default, 'wordpress') === false ){ if( $this->get_setting('footer_version_hide') ){ return ''; } if( $this->get_setting('footer_version') ){ return $this->get_setting('footer_version'); } }else{ if( $this->get_setting('footer_text_hide') ){ return ''; } if( $this->get_setting('footer_text') ){ return $this->get_setting('footer_text'); } } return $default; } // menu folder function admin_footer_scripts() { if( $this->get_setting('menu_collapse') ) { ?> get_setting('menu_collapse_hide') ) { ?> '.$this->get_setting('admin_js').''; echo ''; } // save to variables function update_variables( $new_value, $old_value ) { $file = $this->plugin_path.'/scss/scss/_variables_menu.scss'; $file_ = $this->plugin_path.'/scss/scss/_variables_bar.scss'; if( isset($new_value['use-default-color']) ){ $file__ = $this->plugin_path.'/scss/scss/_variables_menu_'.$new_value['default-color'].'.scss'; $file___ = $this->plugin_path.'/scss/scss/_variables_bar_white.scss'; if(file_exists($file__)){ file_put_contents($file, file_get_contents($file__), FILE_TEXT ); } if(file_exists($file___)){ file_put_contents($file_, file_get_contents($file___), FILE_TEXT ); } }else{ // menu $output = ""; foreach ( $new_value['color'] as $variable => $vvalue ) { if($vvalue != ''){ $output .= '$' . $variable . ': ' . $vvalue . ';' . PHP_EOL; } } file_put_contents($file, $output, FILE_TEXT ); // bar $output = ""; foreach ( $new_value['bar'] as $variable => $vvalue ) { if($vvalue != ''){ $output .= '$' . $variable . ': ' . $vvalue . ';' . PHP_EOL; } } file_put_contents($file_, $output, FILE_TEXT ); } return $new_value; } // login function login_style() { add_filter( 'login_headerurl', array( $this, 'login_headerurl' ) ); add_filter( 'login_headertitle', array( $this, 'login_headertitle' ) ); $this->settings = get_option( $this->settings_name ); ?> plugin_url.( "js/form.js" ), array('jquery')); } function login_headerurl() { return esc_url( trailingslashit( get_bloginfo( 'url' ) ) ); } function login_headertitle() { return esc_attr( get_bloginfo( 'name' ) ); } // disable the google webfonts api function disable_open_sans( $translations, $text, $context, $domain ) { if ( 'Open Sans font: on or off' == $context && 'on' == $text ) { $translations = 'off'; } return $translations; } // deactivation function deactivation() { delete_option( $this->settings_name ); } /** * Process a settings export to a json file */ function process_settings_export() { if( empty( $_POST['setting_action'] ) || 'export_settings' != $_POST['setting_action'] ) return; if( ! wp_verify_nonce( $_POST['setting_export_nonce'], 'setting_export_nonce' ) ) return; if( ! current_user_can( 'manage_options' ) ) return; $settings = get_option( $this->settings_name ); ignore_user_abort( true ); nocache_headers(); header( 'Content-Type: application/json; charset=utf-8' ); header( 'Content-Disposition: attachment; filename=tema-admin-settings-export-' . date( 'm-d-Y' ) . '.json' ); header( "Expires: 0" ); echo json_encode( $settings ); exit; } /** * Process a settings import from a json file */ function process_settings_import() { if( empty( $_POST['setting_action'] ) || 'import_settings' != $_POST['setting_action'] ) return; if( ! wp_verify_nonce( $_POST['setting_import_nonce'], 'setting_import_nonce' ) ) return; if( ! current_user_can( 'manage_options' ) ) return; $import_file = $_FILES['import_file']['tmp_name']; if( empty( $import_file ) ) { wp_die( __( 'Please upload a file to import' ) ); } // Retrieve the settings from the file and convert the json object to an array. $settings = (array) json_decode( file_get_contents( $import_file ) ); update_option( $this->settings_name, $settings ); wp_safe_redirect( admin_url( 'options-general.php?page=tema-admin' ) ); exit; } // help function admin_help() { $current_screen = get_current_screen(); // Overview $current_screen->add_help_tab( array( 'id' => 'overview', 'title' => __( 'Overview', 'AT' ), 'content' => '

' . __( 'Admin Theme by flatfull.com', 'AT' ) . '

' . '

' . __( 'Admin Theme changes your wordpress admin appearance', 'AT' ) . '

' . '

' . __( 'Have fun.', 'AT' ) . '

', ) ); // Help Sidebar $current_screen->set_help_sidebar( '

' . __( 'For more information:', 'AT' ) . '

' . '

' . __( 'FAQ', 'AT' ) . '

' . '

' ); } } new tema;