PluginProbe ʕ •ᴥ•ʔ
External Links – nofollow, noopener & new window / 2.48
External Links – nofollow, noopener & new window v2.48
2.66 0.31 0.32 0.33 0.34 0.35 1.01 1.02 1.03 1.10 1.20 1.21 1.30 1.31 1.40 1.41 1.50 1.51 1.52 1.53 1.54 1.55 1.56 1.60 1.61 1.62 1.70 1.80 1.81 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 2.3 2.32 2.35 2.40 2.42 2.43 2.45 2.46 2.47 2.48 2.50 2.51 2.55 2.56 2.57 2.58 2.59 2.60 2.61 2.62 2.63 2.64 2.65 trunk 0.10 0.11 0.12 0.20 0.21 0.30
wp-external-links / includes / admin / class-wpel-network-page.php
wp-external-links / includes / admin Last commit date
network-fields 7 years ago settings-fields 6 years ago class-wpel-network-page.php 6 years ago class-wpel-settings-page.php 5 years ago
class-wpel-network-page.php
186 lines
1 <?php
2 /**
3 * Class WPEL_Network_Page
4 *
5 * @package WPEL
6 * @category WordPress Plugin
7 * @version 2.3
8 * @link https://www.webfactoryltd.com/
9 * @license Dual licensed under the MIT and GPLv2+ licenses
10 */
11 final class WPEL_Network_Page extends WPRun_Base_1x0x0
12 {
13
14 /**
15 * @var string
16 */
17 private $menu_slug = 'wpel-network-settings-page';
18
19 /**
20 * @var string
21 */
22 private $current_tab = null;
23
24 /**
25 * @var array
26 */
27 private $tabs = array();
28
29 /**
30 * Initialize
31 */
32 protected function init( array $fields_objects )
33 {
34 $this->tabs = array(
35 'network-settings' => array(
36 'title' => __( 'Multi Site Settings', 'wp-external-links' ),
37 'icon' => '<i class="fa fa-sitemap" aria-hidden="true"></i>',
38 'fields' => $fields_objects[ 'network-settings' ],
39 ),
40 'network-admin-settings' => array(
41 'title' => __( 'Admin Settings', 'wp-external-links' ),
42 'icon' => '<i class="fa fa-cogs" aria-hidden="true"></i>',
43 'fields' => $fields_objects[ 'network-admin-settings' ],
44 ),
45 'support' => array(
46 'title' => __( 'Support', 'wp-external-links' ),
47 'icon' => '<i class="fa fa-question" aria-hidden="true"></i>',
48 ),
49 );
50
51 // get current tab
52 $this->current_tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_STRING );
53
54 // set default tab
55 if ( ! key_exists( $this->current_tab, $this->tabs ) ) {
56 reset( $this->tabs );
57 $this->current_tab = key( $this->tabs );
58 }
59 }
60
61 /**
62 * Get option value
63 * @param string $key
64 * @param string $type
65 * @return string
66 * @triggers E_USER_NOTICE Option value cannot be found
67 */
68 public function get_option_value( $key, $type = null )
69 {
70 if ( null === $type ) {
71 foreach ( $this->tabs as $tab_key => $values ) {
72 if ( ! isset( $values[ 'fields' ] ) ) {
73 continue;
74 }
75
76 $option_values = $values[ 'fields' ]->get_option_values();
77
78 if ( ! isset( $option_values[ $key ] ) ) {
79 continue;
80 }
81
82 return $option_values[ $key ];
83 }
84 } else if ( isset( $this->tabs[ $type ][ 'fields' ] ) ) {
85 $option_values = $this->tabs[ $type ][ 'fields' ]->get_option_values();
86 return $option_values[ $key ];
87 }
88
89 trigger_error( 'Option value "'. $key .'" cannot be found.' );
90 }
91
92 /**
93 * Action for "network_admin_menu"
94 */
95 protected function action_network_admin_menu()
96 {
97 $own_admin_menu = $this->get_option_value( 'own_admin_menu' );
98
99 if ( '1' === $own_admin_menu ) {
100 $this->page_hook = add_menu_page(
101 __( 'WP External Links' , 'wp-external-links' ) // page title
102 , __( 'External Links' , 'wp-external-links' ) // menu title
103 , 'manage_network' // capability
104 , $this->menu_slug // menu slug
105 , $this->get_callback( 'show_network_page' ) // callback
106 , 'none' // icon
107 , null // position
108 );
109 } else {
110 $this->page_hook = add_submenu_page(
111 'settings.php' // parent slug
112 , __( 'WP External Links' , 'wp-external-links' ) // page title
113 , __( 'External Links' , 'wp-external-links' ) // menu title
114 , 'manage_options' // capability
115 , $this->menu_slug // menu slug
116 , $this->get_callback( 'show_network_page' ) // callback
117 );
118 }
119
120 add_action( 'load-'. $this->page_hook, $this->get_callback( 'add_help_tabs' ) );
121 }
122
123 /**
124 * Action for "admin_enqueue_scripts"
125 */
126 protected function action_admin_enqueue_scripts()
127 {
128 $current_screen = get_current_screen();
129
130 if($current_screen->id == 'toplevel_page_wpel-network-settings-page-network' || $current_screen->id == 'settings_page_wpel-network-settings-page-network'){
131 wp_enqueue_style( 'font-awesome' );
132 wp_enqueue_style( 'wpel-admin-style' );
133 wp_enqueue_script( 'wpel-admin-script' );
134 }
135
136 wp_enqueue_style( 'wpel-admin-global-style' );
137 }
138
139 /**
140 * Show Admin Page
141 */
142 protected function show_network_page()
143 {
144 $template_file = WPEL_Plugin::get_plugin_dir( '/templates/network-page/main.php' );
145 $page = $this->get_option_value( 'own_admin_menu' ) ? 'admin.php' : 'settings.php';
146 $page_url = network_admin_url() . $page .'?page='. $this->menu_slug;
147
148 $template_vars = array(
149 'tabs' => $this->tabs,
150 'current_tab' => $this->current_tab,
151 'page_url' => $page_url,
152 'menu_slug' => $this->menu_slug,
153 'own_admin_menu' => $this->get_option_value( 'own_admin_menu' ),
154 );
155
156 $this->show_template( $template_file, $template_vars );
157 }
158
159 /**
160 * Add help tabs
161 */
162 protected function add_help_tabs()
163 {
164 $screen = get_current_screen();
165
166 $screen->add_help_tab( array(
167 'id' => 'under-construction',
168 'title' => __( 'Under Construction', 'wp-external-links' ),
169 'callback' => $this->get_callback( 'show_help_tab' ),
170 ) );
171 }
172
173 /**
174 * @param WP_Screen $screen
175 * @param array $args
176 */
177 protected function show_help_tab( $screen, array $args )
178 {
179 $template_file = WPEL_Plugin::get_plugin_dir( '/templates/network-page/help-tabs/'. $args[ 'id' ] .'.php' );
180 $this->show_template( $template_file );
181 }
182
183 }
184
185 /*?>*/
186