PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 2.2
Vimeography: Vimeo Video Gallery WordPress Plugin v2.2
2.4.9 2.4.8 trunk 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8 0.6.8.1 0.6.9 0.6.9.1 0.6.9.2 0.7 0.8 All 103 releases
vimeography / lib / admin / menu.php

menu.php in Vimeography: Vimeo Video Gallery WordPress Plugin 2.2, at lib/admin/menu.php

293 lines 8.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if (!defined('ABSPATH')) {
5 exit();
6 }
7
8 class Vimeography_Admin_Menu
9 {
10 protected $_mustache;
11 protected $_controller;
12 protected $_view;
13
14 public function __construct()
15 {
16 add_action('admin_menu', array($this, 'vimeography_add_menu'));
17 add_filter(
18 'set-screen-option',
19 array($this, 'set_galleries_per_page'),
20 10,
21 3
22 );
23
24 $this->_mustache = new Mustache_Engine(array(
25 'loader' => new Mustache_Loader_FilesystemLoader(
26 VIMEOGRAPHY_PATH . 'lib/admin/templates'
27 )
28 ));
29 }
30
31 /**
32 * Adds a new top level menu to the admin menu.
33 *
34 * @access public
35 * @return void
36 */
37 public function vimeography_add_menu()
38 {
39 global $submenu;
40 $hooks = array();
41
42 $capability = apply_filters(
43 'vimeography.capabilities.menu',
44 'manage_options'
45 );
46
47 add_menu_page(
48 'Vimeography Page Title',
49 'Vimeography',
50 $capability,
51 'vimeography-edit-galleries',
52 '',
53 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiAgIHZpZXdCb3g9IjAgMCA1NDAuOCA0MjAuOSIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTQwLjggNDIwLjk7IiB4bWw6c3BhY2U9InByZXNlcnZlIj48Zz4gIDxwYXRoIGZpbGw9IiMyQTJFMzUiIGQ9Ik01NDAuOCwzMDMuN0gwVjIxLjFDMCw5LjQsOS40LDAsMjEuMSwwaDQ5OC42YzExLjYsMCwyMS4xLDkuNCwyMS4xLDIxLjFWMzAzLjd6Ii8+ICA8cGF0aCBmaWxsPSIjMkEyRTM1IiBkPSJNMTYyLjgsNDIwLjlIMjEuMUM5LjQsNDIwLjksMCw0MTEuNSwwLDM5OS45di03MC4zaDE2Mi44VjQyMC45eiIvPiAgPHJlY3QgeD0iMTg5IiB5PSIzMjkuNSIgZmlsbD0iIzQxQjNDMCIgd2lkdGg9IjE2Mi44IiBoZWlnaHQ9IjkxLjQiLz4gIDxwYXRoIGZpbGw9IiMyQTJFMzUiIGQ9Ik01MTkuNyw0MjAuOUgzNzh2LTkxLjRoMTYyLjh2NzAuM0M1NDAuOCw0MTEuNSw1MzEuMyw0MjAuOSw1MTkuNyw0MjAuOXoiLz48L2c+PC9zdmc+'
54 );
55 $hooks['edit_galleries'] = add_submenu_page(
56 'vimeography-edit-galleries',
57 __('Edit Galleries', 'vimeography'),
58 __('Edit Galleries', 'vimeography'),
59 $capability,
60 'vimeography-edit-galleries',
61 array(&$this, 'vimeography_render_template')
62 );
63 $hooks['new_gallery'] = add_submenu_page(
64 'vimeography-edit-galleries',
65 __('New Gallery', 'vimeography'),
66 __('New Gallery', 'vimeography'),
67 $capability,
68 'vimeography-new-gallery',
69 array(&$this, 'vimeography_render_template')
70 );
71 $hooks['manage_licenses'] = add_submenu_page(
72 'vimeography-edit-galleries',
73 __('Manage Licenses', 'vimeography'),
74 __('Manage Licenses', 'vimeography'),
75 $capability,
76 'vimeography-manage-activations',
77 array(&$this, 'vimeography_render_template')
78 );
79 if (current_user_can($capability)) {
80 $submenu['vimeography-edit-galleries'][500] = array(
81 __('Preview Themes', 'vimeography'),
82 $capability,
83 'http://vimeography.com/themes'
84 );
85 }
86 $hooks['vimeography_pro'] = add_submenu_page(
87 'vimeography-edit-galleries',
88 'Vimeography Pro',
89 'Vimeography Pro',
90 $capability,
91 'vimeography-pro',
92 array(&$this, 'vimeography_render_template')
93 );
94 $hooks['vimeography_help'] = add_submenu_page(
95 'vimeography-edit-galleries',
96 __('Help', 'vimeography'),
97 __('Help', 'vimeography'),
98 $capability,
99 'vimeography-help',
100 array(&$this, 'vimeography_render_template')
101 );
102 $hooks['vimeography_welcome'] = add_submenu_page(
103 'options.php',
104 __('Welcome to Vimeography', 'vimeography'),
105 __('Welcome to Vimeography', 'vimeography'),
106 $capability,
107 'vimeography-welcome',
108 array(&$this, 'vimeography_render_template')
109 );
110
111 foreach ($hooks as $page => $hook) {
112 // Runs before any output
113 add_action('load-' . $hook, array($this, 'load_' . $page . '_page'));
114
115 // Render whatever you want at the bottom
116 // add_action( $hook, array($this, 'render_' . $page . '_page') );
117 }
118 }
119
120 /**
121 * [load_edit_galleries_page description]
122 * @return [type] [description]
123 */
124 public function load_edit_galleries_page()
125 {
126 if (isset($_GET['id'])) {
127 require_once VIMEOGRAPHY_PATH . 'lib/admin/controllers/gallery/edit.php';
128
129 if (is_plugin_active('vimeography-pro/vimeography-pro.php')) {
130 do_action('vimeography-pro/load-editor');
131 $this->_controller = new Vimeography_Pro_Gallery_Edit();
132 } else {
133 $this->_controller = new Vimeography_Gallery_Edit();
134 }
135
136 $this->_view = $this->_mustache->loadTemplate('gallery/edit/layout');
137 } else {
138 require_once VIMEOGRAPHY_PATH . 'lib/admin/controllers/gallery/list.php';
139 if (is_plugin_active('vimeography-pro/vimeography-pro.php')) {
140 do_action('vimeography-pro/load-list');
141 $this->_controller = new Vimeography_Pro_Gallery_List();
142 } else {
143 $this->_controller = new Vimeography_Gallery_List();
144 }
145 $this->_view = $this->_mustache->loadTemplate('gallery/list');
146 }
147 self::vimeography_process_actions();
148 }
149
150 /**
151 * [load_new_gallery_page description]
152 * @return [type] [description]
153 */
154 public function load_new_gallery_page()
155 {
156 require_once VIMEOGRAPHY_PATH . 'lib/admin/controllers/gallery/new.php';
157
158 if (is_plugin_active('vimeography-pro/vimeography-pro.php')) {
159 do_action('vimeography-pro/load-new');
160 $this->_controller = new Vimeography_Pro_Gallery_New();
161 } else {
162 $this->_controller = new Vimeography_Gallery_New();
163 }
164
165 $this->_view = $this->_mustache->loadTemplate('gallery/new');
166 self::vimeography_process_actions();
167 }
168
169 /**
170 * [load_manage_licenses_page description]
171 * @return [type] [description]
172 */
173 public function load_manage_licenses_page()
174 {
175 require_once VIMEOGRAPHY_PATH . 'lib/admin/controllers/theme/list.php';
176 $this->_controller = new Vimeography_Theme_List();
177 $this->_view = $this->_mustache->loadTemplate('theme/list');
178 self::vimeography_process_actions();
179 }
180
181 /**
182 * [load_vimeography_pro_page description]
183 * @return [type] [description]
184 */
185 public function load_vimeography_pro_page()
186 {
187 require_once VIMEOGRAPHY_PATH . 'lib/admin/controllers/vimeography/pro.php';
188 $this->_controller = new Vimeography_Pro_About();
189 $this->_view = $this->_mustache->loadTemplate('vimeography/pro');
190 self::vimeography_process_actions();
191 }
192
193 /**
194 * [load_vimeography_help_page description]
195 * @return [type] [description]
196 */
197 public function load_vimeography_help_page()
198 {
199 require_once VIMEOGRAPHY_PATH .
200 'lib/admin/controllers/vimeography/help.php';
201 $this->_controller = new Vimeography_Help();
202 $this->_view = $this->_mustache->loadTemplate('vimeography/help');
203 self::vimeography_process_actions();
204 }
205
206 /**
207 * [load_vimeography_welcome_page description]
208 * @return [type] [description]
209 */
210 public function load_vimeography_welcome_page()
211 {
212 require_once VIMEOGRAPHY_PATH .
213 'lib/admin/controllers/vimeography/welcome.php';
214 $this->_controller = new Vimeography_Welcome();
215
216 switch ($_GET['step']) {
217 case 2:
218 $step = 'welcome-step-2';
219 break;
220 case 3:
221 $step = 'welcome-step-3';
222 break;
223 default:
224 $step = 'welcome-step-1';
225 break;
226 }
227
228 $this->_controller->step = $this->_mustache
229 ->loadTemplate('vimeography/partials/' . $step)
230 ->render($this->_controller);
231
232 $this->_view = $this->_mustache->loadTemplate('vimeography/welcome');
233 self::vimeography_process_actions();
234 }
235
236 /**
237 * Renders the admin template for the current page.
238 *
239 * @access public
240 * @return void
241 */
242 public function vimeography_render_template()
243 {
244 $capability = apply_filters(
245 'vimeography.capabilities.menu',
246 'manage_options'
247 );
248
249 if (!current_user_can($capability)) {
250 wp_die(
251 __(
252 'You do not have sufficient permissions to access this page.',
253 'vimeography'
254 )
255 );
256 }
257
258 echo $this->_view->render($this->_controller);
259 }
260
261 /**
262 * Processes all Vimeography actions sent via POST and GET by looking for the 'vimeography-action'
263 * request and running do_action() to call the function
264 *
265 * @return void
266 */
267 public static function vimeography_process_actions()
268 {
269 if (isset($_POST['vimeography-action'])) {
270 do_action('vimeography_action_' . $_POST['vimeography-action'], $_POST);
271 }
272
273 if (isset($_GET['vimeography-action'])) {
274 do_action('vimeography_action_' . $_GET['vimeography-action'], $_GET);
275 }
276 }
277
278 /**
279 * Sets the galleries per page in the screen options on the gallery list page.
280 *
281 * @param [type] $status [description]
282 * @param [type] $option [description]
283 * @param [type] $value [description]
284 */
285 public function set_galleries_per_page($status, $option, $value)
286 {
287 if ('vimeography_galleries_per_page' == $option) {
288 return $value;
289 }
290 return $status;
291 }
292 }
293