PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.3.16
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.3.16
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.16, at backend/Settings_Page.php

161 lines 3.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\Engine\Base;
16
17 /**
18 * Create the settings page in the backend
19 */
20 class Settings_Page extends Base {
21
22 /**
23 * Initialize the class.
24 *
25 * @return void|bool
26 */
27 public function initialize() {
28 if ( ! parent::initialize() ) {
29 return;
30 }
31
32 // Add the options page and menu item.
33 \add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
34
35 $realpath = (string) \realpath( __DIR__ );
36 $plugin_basename = \plugin_basename( \plugin_dir_path( $realpath ) . DISCO_TEXTDOMAIN . '.php' );
37
38 add_filter( "plugin_action_links_{$plugin_basename}", array( $this, 'disco_add_action_plugin_links' ) );
39 }
40
41 /**
42 * Add settings link on plugin page
43 *
44 * @param array $links links.
45 * @return array
46 */
47 public function disco_add_action_plugin_links( $links ) {
48
49 $is_pro_active = class_exists( '\Disco_Pro' );
50
51 $custom_links = [
52 [
53 'label' => __( 'Settings', 'disco' ),
54 'url' => admin_url( 'admin.php?page=disco-create-discount' ),
55 'class' => 'disco-settings-link',
56 ],
57 [
58 'label' => __( 'Get Pro', 'disco' ),
59 'url' => 'https://discoplugin.com/pricing/?utm_source=plugin_dashboard&utm_medium=free-to-pro&utm_campaign=free-to-pro&utm_id=1',
60 'class' => 'disco-custom-pro-link',
61 ],
62 [
63 'label' => __( 'Docs', 'disco' ),
64 'url' => 'https://discoplugin.com/docs/',
65 'class' => 'disco-custom-docs-link',
66 ],
67 ];
68
69 if ( $is_pro_active ) {
70 array_splice( $custom_links, 1, 1 );
71 }
72
73 $built_links = array();
74
75 foreach ( $custom_links as $item ) {
76 $built_links[] = sprintf(
77 '<a href="%s" class="%s" target="_blank" rel="noopener">%s</a>',
78 esc_url( $item['url'] ),
79 esc_attr( $item['class'] ),
80 esc_html( $item['label'] )
81 );
82 }
83
84 $new_links = array();
85
86 foreach ( $links as $link ) {
87 $new_links[] = $link;
88
89 // Insert after Deactivate
90 if ( strpos( $link, 'deactivate' ) !== false ) {
91 foreach ( $built_links as $custom_link ) {
92 $new_links[] = $custom_link;
93 }
94 }
95 }
96
97 return $new_links;
98 }
99
100 /**
101 * Register the administration menu for this plugin into the WordPress Dashboard menu.
102 *
103 * @return void
104 * @since 1.0.0
105 */
106 public function add_plugin_admin_menu() {
107 /*
108 * Add a settings page for this plugin to the Settings menu
109 *
110 *
111 *
112 * - Change 'manage_options' to the capability you see fit
113 * For reference: http://codex.wordpress.org/Roles_and_Capabilities
114
115 add_options_page( __( 'Page Title', DISCO_TEXTDOMAIN ), DISCO_NAME, 'manage_options', DISCO_TEXTDOMAIN, array( $this, 'display_plugin_admin_page' ) );
116 *
117 */
118 /*
119 * Add a settings page for this plugin to the main menu
120 *
121 */
122 add_menu_page(
123 'Disco',
124 DISCO_NAME,
125 'manage_woocommerce',
126 'disco-create-discount',
127 array(
128 $this,
129 'display_plugin_admin_page_create_discount',
130 ),
131 plugins_url( 'disco/assets/img/disco-menu-icon.png' ),
132 10
133 );
134 add_submenu_page(
135 DISCO_TEXTDOMAIN,
136 __( 'Create a Discount', 'disco' ),
137 __( 'Create a Discount', 'disco' ),
138 'manage_woocommerce',
139 'create-discount',
140 array(
141 $this,
142 'display_plugin_admin_page_create_discount',
143 )
144 );
145 }
146
147 /**
148 * Render the create discount page for this plugin.
149 *
150 * @return void
151 * @since 1.0.0
152 */
153 public function display_plugin_admin_page_create_discount() {
154 // Create a nonce
155 wp_create_nonce( 'disco_create_discount' );
156
157 include_once DISCO_PLUGIN_ROOT . 'backend/views/create_discount.php';
158 }
159
160 }
161