PluginProbe
Groups – Memberships and Access Control / 1.1.5
Groups – Memberships and Access Control v1.1.5
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.5, at lib/admin/class-groups-admin.php

168 lines 5.2 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
22 /**
23 * Groups admin sections initialization.
24 */
25 class Groups_Admin {
26 public static function init() {
27 add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
28 add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
29 add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
30 add_action( 'network_admin_menu', array( __CLASS__, 'network_admin_menu' ) );
31 }
32
33 /**
34 * Hooks into admin_init.
35 * @see Groups_Admin::admin_menu()
36 * @see Groups_Admin::admin_print_styles()
37 * @link http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Load_scripts_only_on_plugin_pages
38 */
39 public static function admin_init() {
40 global $groups_version;
41 wp_register_style( 'groups_admin', GROUPS_PLUGIN_URL . 'css/groups_admin.css', array(), $groups_version );
42 }
43
44 /**
45 * Loads styles for the Groups admin section.
46 *
47 * @see Groups_Admin::admin_menu()
48 */
49 public static function admin_print_styles() {
50 wp_enqueue_style( 'groups_admin' );
51 }
52
53 /**
54 * Loads scripts.
55 */
56 public static function admin_print_scripts() {
57 global $groups_version;
58 wp_enqueue_script( 'groups', GROUPS_PLUGIN_URL . 'js/groups_admin.js', array( ), $groups_version );
59 }
60
61 /**
62 * Prints admin notices.
63 */
64 public static function admin_notices() {
65 global $groups_admin_messages;
66 if ( !empty( $groups_admin_messages ) ) {
67 foreach ( $groups_admin_messages as $msg ) {
68 echo $msg;
69 }
70 }
71 }
72
73 /**
74 * Admin menu.
75 */
76 public static function admin_menu() {
77
78 include_once( GROUPS_ADMIN_LIB . '/groups-admin-groups.php');
79 include_once( GROUPS_ADMIN_LIB . '/groups-admin-capabilities.php');
80 include_once( GROUPS_ADMIN_LIB . '/groups-admin-options.php');
81
82 $pages = array();
83
84 // main
85 $page = add_menu_page(
86 __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
87 __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
88 GROUPS_ADMINISTER_GROUPS,
89 'groups-admin',
90 apply_filters( 'groups_add_menu_page_function', 'groups_admin_groups' ),
91 GROUPS_PLUGIN_URL . '/images/groups.png'
92 );
93 $pages[] = $page;
94 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
95 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
96
97 $show_tree_view = Groups_Options::get_option( GROUPS_SHOW_TREE_VIEW, GROUPS_SHOW_TREE_VIEW_DEFAULT );
98 if ( $show_tree_view ) {
99 include_once( GROUPS_ADMIN_LIB . '/groups-admin-tree-view.php');
100 $page = add_submenu_page(
101 'groups-admin',
102 __( 'Tree', GROUPS_PLUGIN_DOMAIN ),
103 __( 'Tree', GROUPS_PLUGIN_DOMAIN ),
104 GROUPS_ACCESS_GROUPS,
105 'groups-admin-tree-view',
106 apply_filters( 'groups_add_submenu_page_function', 'groups_admin_tree_view' )
107 );
108 $pages[] = $page;
109 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
110 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
111 }
112
113 // capabilities
114 $page = add_submenu_page(
115 'groups-admin',
116 __( 'Groups Capabilities', GROUPS_PLUGIN_DOMAIN ),
117 __( 'Capabilities', GROUPS_PLUGIN_DOMAIN ),
118 GROUPS_ADMINISTER_GROUPS,
119 'groups-admin-capabilities',
120 apply_filters( 'groups_add_submenu_page_function', 'groups_admin_capabilities' )
121 );
122 $pages[] = $page;
123 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
124 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
125
126 // options
127 $page = add_submenu_page(
128 'groups-admin',
129 __( 'Groups options', GROUPS_PLUGIN_DOMAIN ),
130 __( 'Options', GROUPS_PLUGIN_DOMAIN ),
131 GROUPS_ADMINISTER_OPTIONS,
132 'groups-admin-options',
133 apply_filters( 'groups_add_submenu_page_function', 'groups_admin_options' )
134 );
135 $pages[] = $page;
136 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
137 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
138
139 do_action( 'groups_admin_menu', $pages );
140 }
141
142 /**
143 * Network admin menu.
144 */
145 public static function network_admin_menu() {
146
147 include_once( GROUPS_ADMIN_LIB . '/groups-admin-options.php');
148
149 $pages = array();
150
151 // main
152 $page = add_menu_page(
153 __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
154 __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
155 GROUPS_ADMINISTER_GROUPS,
156 'groups-network-admin',
157 apply_filters( 'groups_add_menu_page_function', 'groups_network_admin_options' ),
158 GROUPS_PLUGIN_URL . '/images/groups.png'
159 );
160 $pages[] = $page;
161 add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'admin_print_styles' ) );
162 add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'admin_print_scripts' ) );
163
164 do_action( 'groups_network_admin_menu', $pages );
165 }
166 }
167 Groups_Admin::init();
168