PluginProbe
Groups – Memberships and Access Control / 1.1.4
Groups – Memberships and Access Control v1.1.4
4.7.1 4.7.0 4.6.0 4.5.0 4.4.0 4.3.0 trunk 1.0.0-beta-1 1.0.0-beta-2 1.0.0-beta-3 1.0.0-beta-3b 1.0.0-beta-3c 1.0.0-beta-3d 1.1.4 1.1.5 1.10.0 1.10.1 1.10.2 1.10.3 1.11.0 1.11.1 1.11.2 1.11.3 1.12.0 1.13.0 All 131 releases
groups / lib / admin / class-groups-admin.php

class-groups-admin.php in Groups – Memberships and Access Control 1.1.4, at lib/admin/class-groups-admin.php

164 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * class-groups-admin.php
4 *
5 * Copyright (c) 2011 "kento" Karim Rahimpur www.itthinx.com
6 *
7 * This code is released under the GNU General Public License.
8 * See COPYRIGHT.txt and LICENSE.txt.
9 *
10 * This code is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * This header and all notices must be kept intact.
16 *
17 * @author Karim Rahimpur
18 * @package groups
19 * @since groups 1.0.0
20 */
21 class Groups_Admin {
22 public static function init() {
23 add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
24 add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
25 add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
26 add_action( 'network_admin_menu', array( __CLASS__, 'network_admin_menu' ) );
27 }
28
29 /**
30 * Hooks into admin_init.
31 * @see Groups_Admin::admin_menu()
32 * @see Groups_Admin::admin_print_styles()
33 * @link http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Load_scripts_only_on_plugin_pages
34 */
35 public static function admin_init() {
36 global $groups_version;
37 wp_register_style( 'groups_admin', GROUPS_PLUGIN_URL . 'css/groups_admin.css', array(), $groups_version );
38 }
39
40 /**
41 * Loads styles for the Groups admin section.
42 *
43 * @see Groups_Admin::admin_menu()
44 */
45 public static function admin_print_styles() {
46 wp_enqueue_style( 'groups_admin' );
47 }
48
49 /**
50 * Loads scripts.
51 */
52 public static function admin_print_scripts() {
53 global $groups_version;
54 wp_enqueue_script( 'groups', GROUPS_PLUGIN_URL . 'js/groups_admin.js', array( ), $groups_version );
55 }
56
57 /**
58 * Prints admin notices.
59 */
60 public static function admin_notices() {
61 global $groups_admin_messages;
62 if ( !empty( $groups_admin_messages ) ) {
63 foreach ( $groups_admin_messages as $msg ) {
64 echo $msg;
65 }
66 }
67 }
68
69 /**
70 * Admin menu.
71 */
72 public static function admin_menu() {
73
74 include_once( GROUPS_ADMIN_LIB . '/groups-admin-groups.php');
75 include_once( GROUPS_ADMIN_LIB . '/groups-admin-capabilities.php');
76 include_once( GROUPS_ADMIN_LIB . '/groups-admin-options.php');
77
78 $pages = array();
79
80 // main
81 $page = add_menu_page(
82 __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
83 __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
84 GROUPS_ADMINISTER_GROUPS,
85 'groups-admin',
86 apply_filters( 'groups_add_menu_page_function', 'groups_admin_groups' ),
87 GROUPS_PLUGIN_URL . '/images/groups.png'
88 );
89 $pages[] = $page;
90 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
91 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
92
93 $show_tree_view = Groups_Options::get_option( GROUPS_SHOW_TREE_VIEW, GROUPS_SHOW_TREE_VIEW_DEFAULT );
94 if ( $show_tree_view ) {
95 include_once( GROUPS_ADMIN_LIB . '/groups-admin-tree-view.php');
96 $page = add_submenu_page(
97 'groups-admin',
98 __( 'Tree', GROUPS_PLUGIN_DOMAIN ),
99 __( 'Tree', GROUPS_PLUGIN_DOMAIN ),
100 GROUPS_ACCESS_GROUPS,
101 'groups-admin-tree-view',
102 apply_filters( 'groups_add_submenu_page_function', 'groups_admin_tree_view' )
103 );
104 $pages[] = $page;
105 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
106 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
107 }
108
109 // capabilities
110 $page = add_submenu_page(
111 'groups-admin',
112 __( 'Groups Capabilities', GROUPS_PLUGIN_DOMAIN ),
113 __( 'Capabilities', GROUPS_PLUGIN_DOMAIN ),
114 GROUPS_ADMINISTER_GROUPS,
115 'groups-admin-capabilities',
116 apply_filters( 'groups_add_submenu_page_function', 'groups_admin_capabilities' )
117 );
118 $pages[] = $page;
119 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
120 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
121
122 // options
123 $page = add_submenu_page(
124 'groups-admin',
125 __( 'Groups options', GROUPS_PLUGIN_DOMAIN ),
126 __( 'Options', GROUPS_PLUGIN_DOMAIN ),
127 GROUPS_ADMINISTER_OPTIONS,
128 'groups-admin-options',
129 apply_filters( 'groups_add_submenu_page_function', 'groups_admin_options' )
130 );
131 $pages[] = $page;
132 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
133 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
134
135 do_action( 'groups_admin_menu', $pages );
136 }
137
138 /**
139 * Network admin menu.
140 */
141 public static function network_admin_menu() {
142
143 include_once( GROUPS_ADMIN_LIB . '/groups-admin-options.php');
144
145 $pages = array();
146
147 // main
148 $page = add_menu_page(
149 __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
150 __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
151 GROUPS_ADMINISTER_GROUPS,
152 'groups-network-admin',
153 apply_filters( 'groups_add_menu_page_function', 'groups_network_admin_options' ),
154 GROUPS_PLUGIN_URL . '/images/groups.png'
155 );
156 $pages[] = $page;
157 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
158 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
159
160 do_action( 'groups_network_admin_menu', $pages );
161 }
162 }
163 Groups_Admin::init();
164