PluginProbe ʕ •ᴥ•ʔ
Download Manager / trunk
Download Manager vtrunk
3.3.61 3.3.60 3.3.59 3.3.58 3.3.57 3.3.56 trunk 2.1.3 2.3.0 2.5.96 2.5.97 2.6.2 2.6.96 2.8.3 2.9.99 3.0.4 3.1.05 3.1.07 3.1.08 3.1.11 3.1.12 3.1.14 3.1.17 3.1.18 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.2.04 3.2.13 3.2.14 3.2.16 3.2.18 3.2.19 3.2.21 3.2.22 3.2.23 3.2.24 3.2.25 3.2.27 3.2.28 3.2.29 3.2.30 3.2.31 3.2.32 3.2.33 3.2.34 3.2.35 3.2.37 3.2.38 3.2.39 3.2.40 3.2.41 3.2.42 3.2.43 3.2.44 3.2.45 3.2.46 3.2.47 3.2.48 3.2.49 3.2.50 3.2.51 3.2.52 3.2.53 3.2.54 3.2.55 3.2.56 3.2.57 3.2.58 3.2.59 3.2.60 3.2.61 3.2.63 3.2.64 3.2.65 3.2.66 3.2.67 3.2.68 3.2.69 3.2.70 3.2.71 3.2.72 3.2.73 3.2.74 3.2.75 3.2.76 3.2.77 3.2.78 3.2.79 3.2.80 3.2.81 3.2.82 3.2.83 3.2.84 3.2.85 3.2.86 3.2.87 3.2.88 3.2.89 3.2.90 3.2.91 3.2.92 3.2.93 3.2.94 3.2.95 3.2.96 3.2.97 3.2.98 3.2.99 3.3.00 3.3.01 3.3.02 3.3.03 3.3.04 3.3.05 3.3.06 3.3.07 3.3.08 3.3.09 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 3.3.16 3.3.17 3.3.18 3.3.19 3.3.20 3.3.21 3.3.22 3.3.23 3.3.24 3.3.25 3.3.26 3.3.27 3.3.28 3.3.29 3.3.30 3.3.31 3.3.32 3.3.33 3.3.34 3.3.35 3.3.36 3.3.37 3.3.38 3.3.39 3.3.40 3.3.41 3.3.42 3.3.43 3.3.44 3.3.45 3.3.46 3.3.47 3.3.48 3.3.49 3.3.50 3.3.51 3.3.52 3.3.53 3.3.54 3.3.55
download-manager / src / Admin / AdminController.php
download-manager / src / Admin Last commit date
Menu 4 days ago views 3 days ago AdminController.php 3 days ago DashboardWidgets.php 6 months ago PackageTemplate.php 4 years ago
AdminController.php
243 lines
1 <?php
2
3 namespace WPDM\Admin;
4
5 use WPDM\__\__;
6 use WPDM\__\Email;
7 use WPDM\__\Installer;
8 use WPDM\Admin\Menu\AddOns;
9 use WPDM\Admin\Menu\Categories;
10 use WPDM\Admin\Menu\Packages;
11 use WPDM\Admin\Menu\Settings;
12 use WPDM\Admin\Menu\Stats;
13 use WPDM\Admin\Menu\Templates;
14 use WPDM\Admin\Menu\Welcome;
15
16 class AdminController {
17
18 function __construct() {
19 new Welcome();
20 new Packages();
21 new Categories();
22 new Templates();
23 new AddOns();
24 new Stats();
25 new Settings();
26 new DashboardWidgets();
27 $this->actions();
28 $this->filters();
29 }
30
31 function actions() {
32 add_action('init', array($this, 'registerScripts'), 1);
33 add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'), 1);
34 add_action('admin_init', array($this, 'metaBoxes'), 0);
35 add_action('admin_init', array(new Email(), 'preview'));
36 add_action('admin_head', array($this, 'adminHead'));
37 add_action('admin_footer', array($this, 'adminFooter'));
38
39 add_action("admin_notices", [$this, 'notices']);
40 add_action("wp_ajax_wpdm_remove_admin_notice", [$this, 'removeNotices']);
41 add_action("wp_ajax_hide_wpdmpro_notice", [$this, 'hideProNotice']);
42 add_action("wp_ajax_wpdm_iconFinder", [$this, 'iconFinder']);
43
44 add_filter("user_row_actions", [$this, 'usersRowAction'], 10, 2);
45
46
47 }
48
49 function filters(){
50 add_filter("plugin_row_meta", [$this, 'pluginRowMeta'], 10, 4);
51 }
52
53 function pluginRowMeta($plugin_meta, $plugin_file, $plugin_data, $status){
54 if($plugin_file === 'download-manager/download-manager.php') {
55 $plugin_meta[] = "<strong><a href='https://wordpress.org/plugins/download-manager/#developers' target='_blank'>" . __("Changelog", "download-manager") . "</a></strong>";
56 $plugin_meta[] = "<a href='https://www.wpdownloadmanager.com/docs/' target='_blank'>" . __("Docs", "download-manager") . "</a>";
57 $plugin_meta[] = "<a href='https://www.wpdownloadmanager.com/support/' target='_blank'>" . __("Support Forum", "download-manager") . "</a>";
58 }
59 return $plugin_meta;
60 }
61
62 function registerScripts(){
63 wp_register_script('wpdm-admin-js', WPDM_BASE_URL.'assets/js/wpdm.min.js', array('jquery'));
64 wp_register_style('wpdm-admin-base', WPDM_BASE_URL.'assets/adminui/css/base.css');
65 wp_register_style('wpdm-font-awesome', WPDM_FONTAWESOME_URL);
66 }
67
68 /**
69 * Enqueue admin scripts & styles
70 */
71 function enqueueScripts() {
72
73 global $pagenow;
74 $allow_bscss = array('profile.php', 'user-edit.php', 'upload.php');
75 $wpdm_pages = array( 'wpdm-settings', 'emails', 'wpdm-stats', 'templates', 'importable-files', 'wpdm-addons', 'orders', 'pp-license', 'wpdm-asset-manager');
76 if (wpdm_query_var('post_type') === 'wpdmpro' || get_post_type() === 'wpdmpro' || in_array(wpdm_query_var('page'), $wpdm_pages) || ($pagenow == 'index.php' && wpdm_query_var('page') == '') || in_array($pagenow, $allow_bscss)) {
77 //wpdmdd("OK");
78 wp_enqueue_script('jquery');
79 wp_enqueue_script('jquery-form');
80 wp_enqueue_script('jquery-ui-core');
81 //wp_enqueue_script('jquery-ui-dialog');
82 wp_enqueue_script('jquery-ui-tabs');
83 wp_enqueue_script('jquery-ui-datepicker');
84 wp_enqueue_script('jquery-ui-slider');
85 wp_enqueue_script('jquery-ui-sortable');
86 wp_enqueue_script('jquery-ui-timepicker', WPDM_BASE_URL . 'assets/js/jquery-ui-timepicker-addon.js', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-slider'));
87 wp_enqueue_script('thickbox');
88 wp_enqueue_style('thickbox');
89 wp_enqueue_script('media-upload');
90 wp_enqueue_media();
91
92 wp_enqueue_script('select2', WPDM_BASE_URL.'assets/select2/js/select2.min.js', array('jquery'));
93 wp_enqueue_style('select2-css', WPDM_BASE_URL.'assets/select2/css/select2.min.css');
94 wp_enqueue_style('jqui-css', WPDM_BASE_URL.'assets/jqui/theme/jquery-ui.css');
95
96 wp_enqueue_script('wpdm-admin-js' );
97
98 if(in_array(wpdm_query_var('page'), $wpdm_pages))
99 wp_enqueue_script('wpdm-vue', WPDM_BASE_URL.'assets/js/vue.min.js');
100
101 wp_enqueue_script('wpdm-admin', WPDM_BASE_URL.'assets/js/wpdm-admin.js', array('jquery'));
102
103
104 wp_enqueue_style( 'wpdm-font-awesome' );
105 wp_enqueue_style( 'wpdm-admin-base' );
106
107 //wp_enqueue_style('wpdm-bootstrap-theme', plugins_url('/download-manager/assets/css/front.css'));
108 wp_enqueue_style('wpdm-admin-styles', WPDM_BASE_URL.'assets/css/admin-styles.css', 9999);
109
110 wp_enqueue_style('wpdm-lock-options', WPDM_BASE_URL.'assets/css/wpdm-lock-options.css', [], WPDM_VERSION);
111
112 wp_enqueue_style( 'wp-color-picker' );
113 wp_enqueue_script( 'wp-color-picker' );
114
115 wp_enqueue_script('wpdm-modal');
116 wp_enqueue_style('wpdm-modal');
117
118
119 }
120
121 wp_enqueue_style('wpdm-gutenberg-styles',WPDM_BASE_URL.'assets/css/gutenberg-styles.css', 9999);
122 }
123
124 function pageHeader($title, $icon, $menus = [], $actions = [], $params = [])
125 {
126 include wpdm_admin_tpl_path("page-header.php", __DIR__.'/views');
127 }
128
129
130 function usersRowAction($actions, $user)
131 {
132 $actions[] = "<a href='edit.php?post_type=wpdmpro&page=wpdm-stats&type=history&filter=1&user_ids[0]={$user->ID}'>".__( 'Download History', 'download-manager' )."</a>";
133 return $actions;
134 }
135
136 function notices()
137 {
138 $class = '';
139 if(!(int)get_option('__wpdm_hide_admin_notice', 0)) {
140 $message = '<b>Congratulation! You are using Download Manager ' . WPDM_VERSION . '</b><br/>This is a major update. You must update all Download Manager add-ons too, to keep them compatible with Download Manager ' . WPDM_VERSION;
141 printf('<div id="wpdmvnotice" class="notice notice-success is-dismissible"><p>%1$s</p></div>', $message);
142 }
143 if (is_admin() && current_user_can('manage_options') && Installer::dbUpdateRequired()) {
144 $message = sprintf(__('A database update is required for <strong>WordPress Download Manager %s</strong>. Please click the button on the right to update your database now.', WPDM_TEXT_DOMAIN), WPDM_VERSION);
145 printf('<div id="wpdmvnotice" class="notice notice-warning is-dismissible w3eden"><div style="padding: 20px;line-height: 22px;display:flex"><div style="width:9999px" >%1$s</div><div style="white-space: nowrap"><a class="btn btn-primary btn-sm" href="%2$s">Update Database</a></div></div></div>', $message, admin_url('edit.php?post_type=wpdmpro&page=wpdm-settings'));
146 }
147 }
148
149 function removeNotices()
150 {
151 __::isAuthentic('__rnnonce', WPDM_PUB_NONCE, WPDM_ADMIN_CAP);
152 update_option('__wpdm_hide_admin_notice', 1, false);
153 wp_send_json(['success' => true]);
154 }
155
156
157 function adminHead() {
158 remove_submenu_page('index.php', 'wpdm-welcome');
159
160 include_once wpdm_admin_tpl_path("admin-head.php");
161
162 }
163
164
165 function metaBoxes() {
166 global $ServerDirBrowser;
167 if(get_post_type(wpdm_query_var('post')) != 'wpdmpro' && wpdm_query_var('post_type') != 'wpdmpro') return;
168
169 if(current_user_can('upload_files')) {
170 $meta_boxes = array(
171 'wpdm-settings' => array(
172 'title' => __( "Package Settings", "download-manager" ),
173 'callback' => array( $this, 'packageSettings' ),
174 'position' => 'normal',
175 'priority' => 'low'
176 ),
177 'wpdm-upload-file' => array( 'title' => __( "Attach File", "download-manager" ),
178 'callback' => array( $this, 'uploadFiles' ),
179 'position' => 'side',
180 'priority' => 'core'
181 ),
182 'wpdm-changelog' => array(
183 "title" => __("Changelog", WPDM_TEXT_DOMAIN),
184 "callback" => array( $this, 'changelog' ),
185 "position" => "normal",
186 "priority" => "default"
187 ),
188 );
189 } else
190 $meta_boxes = [];
191
192
193 $meta_boxes = apply_filters("wpdm_meta_box", $meta_boxes);
194 foreach ($meta_boxes as $id => $meta_box) {
195 extract($meta_box);
196 if (!isset($position))
197 $position = 'normal';
198 if (!isset($priority))
199 $priority = 'core';
200 add_meta_box($id, $title, $callback, 'wpdmpro', $position, $priority);
201 }
202 }
203
204
205 function packageSettings($post) {
206 include wpdm_admin_tpl_path("metaboxes/package-settings.php" );
207 }
208
209 function uploadFiles($post) {
210 include wpdm_admin_tpl_path("metaboxes/attach-file.php" );
211 }
212
213 function changelog($post)
214 {
215 include wpdm_admin_tpl_path("metaboxes/changelog.php" );
216 }
217
218 function hideProNotice()
219 {
220 __::isAuthentic('__wpnnonce', WPDM_PUB_NONCE, WPDM_ADMIN_CAP);
221 update_option("__hide_wpdmpro_notice", strtotime('+15 days'));
222 die();
223 }
224
225 function adminFooter()
226 {
227 $noticeresume = (int)get_option('__hide_wpdmpro_notice');
228 if ($noticeresume < time()) {
229 include_once wpdm_admin_tpl_path("admin-footer.php");
230 }
231 }
232
233 function iconFinder() {
234 //__::isAuthentic('__icononce', WPDM_PUB_NONCE, WPDM_ADMIN_CAP);
235
236 include_once wpdm_admin_tpl_path("iconfinder.php");
237
238 die();
239
240 }
241
242 }
243