/var/www/html_us/wp-content/plugins/dream-team/admin/dreamteam-base.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
if (!class_exists('DreamTeam_Base')) {
    class 
DreamTeam_Base {
        public 
$plugin_file;
        public 
$plugin_path;
        public 
$tab_info;
        public 
$sub_tabs;
        
        public function 
__construct() {
            if (isset(
$this->tab_info) && !empty($this->tab_info['slug'])) {
                if (!empty(
$this->plugin_file)) {
                    
add_filter'plugin_action_links_' $this->plugin_file, array($this'action_links'), 101);
                }

                if (!empty(
$this->tab_info['heading'])) {
                    
$priority = !empty($this->tab_info['priority']) ? $this->tab_info['priority'] : 10;
                    
add_filter('dreamteam_dashboard_heading_tabs', array($this'tab_heading'), $priority);
                    
add_action('dreamteam_admin_tab_content_wrap', array($this'tab_content'));
                }
            }
        }

        public function 
action_links($actions) {
            
$settings = array(
                
'settings' => sprintf('<a href="%s">%s</a>'admin_url('admin.php?page=dreamteam&tab=' $this->tab_info['slug']), 'Settings')
            );
            
            return 
array_merge($settings$actions);
        }

        public function 
tab_heading($tabs) {
            
$k $this->tab_info['slug'];
            
$tabs[$k] = $this->tab_info['heading'];
            return 
$tabs;
        }

        public function 
tab_content() {
            
$_tab = !empty($_GET['tab']) ? $_GET['tab'] : '';
            if (
$_tab !== $this->tab_info['slug']) {
                return 
'';
            }

            if (!empty(
$this->sub_tabs)) {
                
$_subTab = !empty($_GET['sub']) ? $_GET['sub'] : false;
                
$_i 0;

                echo 
'<ul class="dreamteam-subtab-nav subsubsub">';
                foreach ( 
$this->sub_tabs as $slug => $label ) {
                    
$class 'sub-tab';
                    if (
$_subTab == $slug || (!$_subTab && $_i == 0)) {
                        
$class .= ' current';
                        
$_subTab $slug;
                    }
                    
$liStr '<li><a class="%s" href="%s">%s</a>%s</li>';
                    
printf$liStr
                        
$class,
                        
admin_url('admin.php?page=dreamteam&tab=' $this->tab_info['slug'] . '&sub='.$slug),
                        
esc_attr($label),
                        
$_i < (count($this->sub_tabs) - 1)? '&nbsp;|&nbsp;' ''
                    
);
                    
$_i++;
                }
                echo 
'</ul><br class="clear">';

                
$subtab_template $this->plugin_path 'templates/admin-subtab-' $_subTab '-content.php';
                if (
file_exists($subtab_template)) {
                    include_once 
$subtab_template;
                } else {
                    echo 
'Please create template file: ' .$subtab_template;
                }

            } else {
                include_once 
$this->plugin_path 'templates/admin-tab-content.php';
            }
        }
    }
}