PluginProbe
SweepPress: Website Cleanup and Optimization / 3.2
SweepPress: Website Cleanup and Optimization v3.2
trunk 1.1 1.2 1.3 1.4 1.4.1 1.5 1.6 1.7 1.8 2.0 2.1 2.1.1 2.2 2.3 2.3.1 2.4 2.4.1 2.4.2 2.5 2.6 3.0 3.1 3.1.1 3.2 All 39 releases
sweeppress / core / admin / Plugin.php

Plugin.php in SweepPress: Website Cleanup and Optimization 3.2, at core/admin/Plugin.php

223 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dev4Press\Plugin\SweepPress\Admin;
4
5 use Dev4Press\Plugin\SweepPress\Basic\Plugin as CorePlugin;
6 use Dev4Press\Plugin\SweepPress\Basic\Settings as CoreSettings;
7 use Dev4Press\v49\Core\Admin\Menu\Plugin as BasePlugin;
8 use Dev4Press\v49\Core\Quick\URL;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 class Plugin extends BasePlugin {
15 public $plugin = 'sweeppress';
16 public $plugin_prefix = 'sweeppress';
17 public $plugin_menu = 'SweepPress';
18 public $plugin_title = 'SweepPress';
19
20 public $has_metabox = true;
21 public $auto_mod_interface_colors = true;
22
23 public $enqueue_wp = array(
24 'dialog' => true,
25 );
26 public $per_page_options = array(
27 'sweeppress_options_rows_per_page',
28 );
29
30 public function constructor() {
31 $this->url = SWEEPPRESS_URL;
32 $this->path = SWEEPPRESS_PATH;
33
34 add_action( 'sweeppress_plugin_core_ready', array( $this, 'ready' ) );
35 }
36
37 public function settings() : CoreSettings {
38 return sweeppress_settings();
39 }
40
41 public function plugin() : CorePlugin {
42 return CorePlugin::instance();
43 }
44
45 public function settings_definitions() : Settings {
46 return Settings::instance();
47 }
48
49 public function ready() {
50 }
51
52 public function admin_menu_items() {
53 $this->setup_items = array(
54 'install' => array(
55 'title' => __( 'Install', 'sweeppress' ),
56 'icon' => 'ui-traffic',
57 'type' => 'setup',
58 'info' => __( 'Before you continue, make sure plugin installation was successful.', 'sweeppress' ),
59 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Install',
60 ),
61 'update' => array(
62 'title' => __( 'Update', 'sweeppress' ),
63 'icon' => 'ui-traffic',
64 'type' => 'setup',
65 'info' => __( 'Before you continue, make sure plugin was successfully updated.', 'sweeppress' ),
66 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Update',
67 ),
68 );
69
70 $this->menu_items = array(
71 'dashboard' => array(
72 'title' => __( 'Overview', 'sweeppress' ),
73 'icon' => 'ui-home',
74 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Dashboard',
75 ),
76 'about' => array(
77 'title' => __( 'About', 'sweeppress' ),
78 'icon' => 'ui-info',
79 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\About',
80 ),
81 'settings' => array(
82 'title' => __( 'Settings', 'sweeppress' ),
83 'icon' => 'ui-cog',
84 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Settings',
85 'kb' => array(
86 'url' => 'https://support.dev4press.com/kb/article/sweeppress-panel-settings/',
87 ),
88 ),
89 'sweep' => array(
90 'title' => __( 'Sweep', 'sweeppress' ),
91 'icon' => 'plugin-sweeppress',
92 'info' => __( 'Detailed view for all the available Sweeper tools with additional information about each tool.', 'sweeppress' ),
93 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Sweep',
94 'kb' => array(
95 'url' => 'https://support.dev4press.com/kb/article/sweeppress-panel-sweep/',
96 ),
97 ),
98 'options' => array(
99 'title' => __( 'Manage Options', 'sweeppress' ),
100 'icon' => 'ui-sliders-base',
101 'info' => __( 'Review all the records in the WordPress options table with ability to remove them.', 'sweeppress' ),
102 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Options',
103 'kb' => array(
104 'url' => 'https://support.dev4press.com/kb/article/sweeppress-panel-metadata/',
105 ),
106 ),
107 'sweepers' => array(
108 'title' => __( 'Sweepers List', 'sweeppress' ),
109 'icon' => 'ui-list',
110 'info' => __( 'List of all current sweepers, and where they can be used from.', 'sweeppress' ),
111 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Sweepers',
112 'kb' => array(
113 'url' => 'https://support.dev4press.com/kb/article/sweeppress-panel-sweepers-list/',
114 ),
115 ),
116 'statistics' => array(
117 'title' => __( 'Statistics', 'sweeppress' ),
118 'icon' => 'ui-chart-area',
119 'info' => __( 'Overview of the statistics gathered by the plugin with all time and monthly statistics.', 'sweeppress' ),
120 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Statistics',
121 'kb' => array(
122 'url' => 'https://support.dev4press.com/kb/article/sweeppress-panel-statistics/',
123 ),
124 ),
125 'tools' => array(
126 'title' => __( 'Tools', 'sweeppress' ),
127 'icon' => 'ui-wrench',
128 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Tools',
129 ),
130 'jobs' => array(
131 'title' => __( 'Upgrade', 'sweeppress' ) . ' <span style="color: #FFF; background: red; padding: 1px 5px 3px; border-radius: 3px; margin-left: 5px;">Pro</span>',
132 'icon' => 'ui-clock',
133 'info' => __( 'Get more features with the SweepPress Pro version.', 'sweeppress' ),
134 'class' => '\\Dev4Press\\Plugin\\SweepPress\\Admin\\Panel\\Jobs',
135 'kb' => array(
136 'url' => URL::add_campaign_tracking( 'https://plugins.dev4press.com/sweeppress/lite-vs-pro/', 'sweeppress-upgrade-to-pro' ),
137 'label' => 'Compare Lite vs Pro',
138 ),
139 ),
140 );
141 }
142
143 public function action_url( $action, $nonce, $args = '', $panel = '', $subpanel = '', $network = null ) : string {
144 $base = empty( $panel ) ? $this->current_url() : $this->panel_url( $panel, $subpanel, $network );
145 $base = add_query_arg(
146 array(
147 $this->v() => 'getback',
148 'single-action' => $action,
149 '_wpnonce' => wp_create_nonce( $nonce ),
150 ),
151 $base
152 );
153
154 if ( ! empty( $args ) ) {
155 $base .= '&' . trim( $args, '&' );
156 }
157
158 return $base;
159 }
160
161 public function svg_icon() : string {
162 return sweeppress()->svg_icon;
163 }
164
165 public function run_getback() {
166 new GetBack( $this );
167 }
168
169 public function run_postback() {
170 new PostBack( $this );
171 }
172
173 public function message_process( $code, $msg ) {
174 switch ( $code ) {
175 case 'option-deleted':
176 $records = isset( $_GET['records'] ) ? absint( $_GET['records'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification
177 $msg['message'] = sprintf( __( 'The deletion has been completed. Records removed in the process: %s.', 'sweeppress' ), $records );
178 break;
179 }
180
181 return $msg;
182 }
183
184 public function register_scripts_and_styles() {
185 $this->enqueue->register( 'css', 'sweeppress-admin',
186 array(
187 'path' => 'css/',
188 'file' => 'admin',
189 'ext' => 'css',
190 'min' => true,
191 'ver' => sweeppress_settings()->file_version(),
192 'src' => 'plugin',
193 'int' => array( 'ctrl' ),
194 ) )->register( 'js', 'sweeppress-admin',
195 array(
196 'path' => 'js/',
197 'file' => 'admin',
198 'ext' => 'js',
199 'min' => true,
200 'ver' => sweeppress_settings()->file_version(),
201 'src' => 'plugin',
202 'int' => array( 'ctrl' ),
203 'req' => array( 'jquery', 'jquery-form' ),
204 ) );
205 }
206
207 public function help_tab_getting_help() {
208 if ( ! empty( $this->panel ) ) {
209 Help::instance();
210 }
211
212 parent::help_tab_getting_help();
213 }
214
215 protected function extra_enqueue_scripts_plugin() {
216 $this->enqueue->css( 'sweeppress-admin' )->js( 'sweeppress-admin' );
217 }
218
219 public function wizard() {
220 return null;
221 }
222 }
223