PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.3.46
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.3.46
1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 1.3.47 1.3.46 All 178 releases
disco / backend / Settings_Page.php

Settings_Page.php in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.3.46, at backend/Settings_Page.php

285 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Disco
5 *
6 * @package Disco
7 * @author Ohidul Islam <wahid0003@gmail.com>
8 * @link http://domain.tld
9 * @license GPL 2.0+
10 * @copyright 2022 WebAppick
11 */
12
13 namespace Disco\Backend;
14
15 use Disco\App\Disco;
16 use Disco\Engine\Base;
17
18 /**
19 * Create the settings page in the backend
20 */
21 class Settings_Page extends Base {
22
23 /**
24 * Initialize the class.
25 *
26 * @return void|bool
27 */
28 public function initialize() {
29 if ( ! parent::initialize() ) {
30 return;
31 }
32
33 // Add the options page and menu item.
34 \add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
35
36 $realpath = (string) \realpath( __DIR__ );
37 $plugin_basename = \plugin_basename( \plugin_dir_path( $realpath ) . DISCO_TEXTDOMAIN . '.php' );
38
39 add_filter( "plugin_action_links_{$plugin_basename}", array( $this, 'disco_add_action_plugin_links' ) );
40 }
41
42 /**
43 * Add settings link on plugin page
44 *
45 * @param array $links links.
46 * @return array
47 */
48 public function disco_add_action_plugin_links( $links ) {
49
50 $is_pro_active = class_exists( '\Disco_Pro' );
51
52 $custom_links = [
53 [
54 'label' => __( 'Settings', 'disco' ),
55 'url' => admin_url( 'admin.php?page=disco-create-discount' ),
56 'class' => 'disco-settings-link',
57 ],
58 [
59 'label' => __( 'Get Pro', 'disco' ),
60 'url' => 'https://discoplugin.com/pricing/?utm_source=plugin_dashboard&utm_medium=free-to-pro&utm_campaign=free-to-pro&utm_id=1',
61 'class' => 'disco-custom-pro-link',
62 ],
63 [
64 'label' => __( 'Docs', 'disco' ),
65 'url' => 'https://discoplugin.com/docs/',
66 'class' => 'disco-custom-docs-link',
67 ],
68 ];
69
70 if ( $is_pro_active ) {
71 array_splice( $custom_links, 1, 1 );
72 }
73
74 $built_links = array();
75
76 foreach ( $custom_links as $item ) {
77 $built_links[] = sprintf(
78 '<a href="%s" class="%s" target="_blank" rel="noopener">%s</a>',
79 esc_url( $item['url'] ),
80 esc_attr( $item['class'] ),
81 esc_html( $item['label'] )
82 );
83 }
84
85 $new_links = array();
86
87 foreach ( $links as $link ) {
88 $new_links[] = $link;
89
90 // Insert after Deactivate
91 if ( strpos( $link, 'deactivate' ) !== false ) {
92 foreach ( $built_links as $custom_link ) {
93 $new_links[] = $custom_link;
94 }
95 }
96 }
97
98 return $new_links;
99 }
100
101 /**
102 * Register the administration menu for this plugin into the WordPress Dashboard menu.
103 *
104 * @return void
105 * @since 1.0.0
106 */
107 public function add_plugin_admin_menu() {
108 /*
109 * Add a settings page for this plugin to the Settings menu
110 *
111 *
112 *
113 * - Change 'manage_options' to the capability you see fit
114 * For reference: http://codex.wordpress.org/Roles_and_Capabilities
115
116 add_options_page( __( 'Page Title', DISCO_TEXTDOMAIN ), DISCO_NAME, 'manage_options', DISCO_TEXTDOMAIN, array( $this, 'display_plugin_admin_page' ) );
117 *
118 */
119 /*
120 * Add a settings page for this plugin to the main menu
121 *
122 */
123 add_menu_page(
124 'Disco',
125 DISCO_NAME,
126 'manage_woocommerce',
127 'disco-create-discount',
128 array(
129 $this,
130 'display_plugin_admin_page_create_discount',
131 ),
132 plugins_url( 'disco/assets/img/disco-menu-icon.png' ),
133 10
134 );
135 add_submenu_page(
136 'disco-create-discount',
137 __( 'Campaigns', 'disco' ),
138 __( 'Campaigns', 'disco' ),
139 'manage_woocommerce',
140 'disco-create-discount',
141 array(
142 $this,
143 'display_plugin_admin_page_create_discount',
144 )
145 );
146 add_submenu_page(
147 'disco-create-discount',
148 __( 'Create Campaign', 'disco' ),
149 __( 'Create Campaign', 'disco' ),
150 'manage_woocommerce',
151 'disco-create-campaign',
152 array(
153 $this,
154 'disco_display_plugin_admin_page_create_campaign',
155 )
156 );
157 add_submenu_page(
158 'disco-create-discount',
159 __( 'Settings', 'disco' ),
160 __( 'Settings', 'disco' ),
161 'manage_woocommerce',
162 'disco-settings',
163 array(
164 $this,
165 'disco_display_plugin_admin_page_settings',
166 )
167 );
168 add_submenu_page(
169 'disco-create-discount',
170 __( 'Compatibles', 'disco' ),
171 __( 'Compatibles', 'disco' ),
172 'manage_woocommerce',
173 'compatible-plugin-list',
174 array(
175 $this,
176 'disco_display_plugin_admin_page_compatible_plugin_list',
177 )
178 );
179 add_submenu_page(
180 'disco-create-discount',
181 __( 'Help & Docs', 'disco' ),
182 __( 'Help & Docs', 'disco' ),
183 'manage_woocommerce',
184 'help-and-docs',
185 array(
186 $this,
187 'disco_display_plugin_admin_page_help_and_docs',
188 )
189 );
190 if ( ! Disco::is_pro() ) {
191 add_submenu_page(
192 'disco-create-discount',
193 __( 'Pro Plan', 'disco' ),
194 __( 'Pro Plan', 'disco' ),
195 'manage_woocommerce',
196 'pro-plan',
197 array(
198 $this,
199 'disco_display_plugin_admin_page_pro_plan',
200 )
201 );
202 }
203
204 if ( ! Disco::is_pro() ) {
205 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
206 $GLOBALS['submenu']['disco-create-discount'][] = array(
207 '<span class="disco-pro-submenu-badge">
208 <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 15 15" fill="none">
209 <path fill-rule="evenodd" clip-rule="evenodd" d="M11.2814 5.98453H5.72436V4.1044C5.72436 3.12776 6.52343 2.32872 7.50004 2.32872C8.30225 2.32872 8.98463 2.86784 9.2028 3.60167C9.37029 4.16505 10.1124 4.2808 10.4549 3.82187C10.592 3.6382 10.6307 3.42103 10.5655 3.20133C10.1734 1.87951 8.94467 0.908203 7.50004 0.908203C5.74211 0.908203 4.30381 2.3465 4.30381 4.10443V5.98453H3.71872C3.0734 5.98453 2.54541 6.51252 2.54541 7.15784V12.9185C2.54541 13.5638 3.0734 14.0918 3.71872 14.0918H11.2814C11.9267 14.0918 12.4547 13.5638 12.4547 12.9185V7.15784C12.4547 6.51252 11.9267 5.98453 11.2814 5.98453ZM7.93952 10.0434V11.5296C7.93952 11.7723 7.74276 11.969 7.50007 11.969C7.25737 11.969 7.06062 11.7723 7.06062 11.5296V10.0434C6.71849 9.87938 6.48224 9.52983 6.48224 9.1251C6.48224 8.56298 6.93792 8.10727 7.50007 8.10727C8.06222 8.10727 8.5179 8.56298 8.5179 9.1251C8.5179 9.52986 8.28165 9.8794 7.93952 10.0434Z" fill="white"/>
210 </svg> ' . esc_html__( 'Unlock Pro', 'disco' ) .
211 '</span>',
212 'manage_woocommerce',
213 admin_url( 'admin.php?page=pro-plan' ),
214 esc_html__( 'Unlock Pro', 'disco' ),
215 );
216 }
217 }
218
219 /**
220 * Render the create discount page for this plugin.
221 *
222 * @return void
223 * @since 1.0.0
224 */
225 public function display_plugin_admin_page_create_discount() {
226 // Create a nonce
227 wp_create_nonce( 'disco_create_discount' );
228
229 include_once DISCO_PLUGIN_ROOT . 'backend/views/create_discount.php';
230 }
231
232 /**
233 * Render the create campaign page for this plugin.
234 *
235 * @return void
236 */
237 public function disco_display_plugin_admin_page_create_campaign() {
238 wp_create_nonce( 'disco_create_discount' );
239 echo '<script>window.location.hash="#/disco";</script>';
240 include_once DISCO_PLUGIN_ROOT . 'backend/views/create_discount.php';
241 }
242
243 /**
244 * Render the settings page for this plugin.
245 *
246 * @return void
247 */
248 public function disco_display_plugin_admin_page_settings() {
249 wp_create_nonce( 'disco_create_discount' );
250 echo '<script>window.location.hash="#/settings";</script>';
251 include_once DISCO_PLUGIN_ROOT . 'backend/views/create_discount.php';
252 }
253
254 /**
255 * Render the help and docs page for this plugin.
256 *
257 * @return void
258 * @since 1.0.0
259 */
260 public function disco_display_plugin_admin_page_help_and_docs() {
261 include_once DISCO_PLUGIN_ROOT . 'backend/views/help_and_docs.php';
262 }
263
264 /**
265 * Render the pro plan page for this plugin.
266 *
267 * @return void
268 * @since 1.0.0
269 */
270 public function disco_display_plugin_admin_page_pro_plan() {
271 include_once DISCO_PLUGIN_ROOT . 'backend/views/pro_plan.php';
272 }
273
274 /**
275 * Render the compatible plugin list page for this plugin.
276 *
277 * @return void
278 * @since 1.0.0
279 */
280 public function disco_display_plugin_admin_page_compatible_plugin_list() {
281 include_once DISCO_PLUGIN_ROOT . 'backend/views/compatible_plugin_list.php';
282 }
283
284 }
285