PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 1.7
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v1.7
2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 All 59 releases
merchant / admin / class-merchant-admin-loader.php

class-merchant-admin-loader.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 1.7, at admin/class-merchant-admin-loader.php

163 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Merchant_Admin_Loader Class.
4 */
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 if ( ! class_exists( 'Merchant_Admin_Loader' ) ) {
11
12 class Merchant_Admin_Loader {
13
14 /**
15 * The single class instance.
16 */
17 private static $instance = null;
18
19 /**
20 * Instance.
21 */
22 public static function instance() {
23 if ( is_null( self::$instance ) ) {
24 self::$instance = new self();
25 }
26 return self::$instance;
27 }
28
29 /**
30 * Constructor.
31 */
32 public function __construct() {
33
34 add_action( 'init', array( $this, 'includes' ) );
35
36 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
37 add_action( 'plugin_action_links_' . MERCHANT_BASE, array( $this, 'action_links' ) );
38 add_filter( 'admin_footer_text', array( $this, 'add_admin_footer_text' ), 999 );
39 add_filter( 'admin_body_class', array( $this, 'add_admin_body_class' ), 999 );
40
41 }
42
43 /**
44 * Include admin classes.
45 */
46 public function includes() {
47
48 require_once MERCHANT_DIR . 'inc/classes/class-merchant-svg-icons.php';
49 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-menu.php';
50 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-modules.php';
51 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-options.php';
52 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-utils.php';
53 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-preview.php';
54
55 }
56
57 /**
58 * Enqueue admin styles and scripts.
59 */
60 public function enqueue_styles_scripts() {
61
62 $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
63
64 wp_register_script( 'merchant-select2', MERCHANT_URI . 'assets/vendor/select2/select2.full.min.js', array( 'jquery' ), '4.0.13', true );
65
66 wp_register_style( 'merchant-select2', MERCHANT_URI . 'assets/vendor/select2/select2.min.css', array(), '4.0.13' );
67
68 if ( ! empty( $page ) && false !== strpos( $page, 'merchant' ) ) {
69
70 wp_enqueue_media();
71
72 wp_enqueue_style( 'merchant-admin', MERCHANT_URI . 'assets/css/admin/admin.min.css', array(), MERCHANT_VERSION );
73
74 wp_enqueue_script( 'merchant-jquery-form', MERCHANT_URI . 'assets/vendor/jquery-form/jquery.form.min.js', array( 'jquery' ), '4.3.0', true );
75
76 wp_enqueue_script( 'merchant-pickr', MERCHANT_URI . 'assets/vendor/pickr/pickr.min.js', array( 'jquery' ), '1.8.2', true );
77
78 wp_enqueue_script( 'merchant-admin', MERCHANT_URI . 'assets/js/admin/admin.min.js', array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-core', 'wp-util' ), MERCHANT_VERSION, true );
79
80 wp_localize_script( 'merchant-admin', 'merchant', array(
81 'nonce' => wp_create_nonce( 'merchant' ),
82 'ajax_url' => admin_url( 'admin-ajax.php' ),
83 ) );
84
85 $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
86
87 if( !empty($module) ) {
88 wp_enqueue_script( 'merchant-admin-preview', MERCHANT_URI . 'assets/js/admin/merchant-preview.min.js', array( 'jquery' ), MERCHANT_VERSION, true );
89 }
90 }
91
92 }
93
94 /**
95 * Add plugin settings link on the plugin page.
96 */
97 public function action_links( $links ) {
98
99 $page_url = add_query_arg( array( 'page' => 'merchant' ), admin_url( 'themes.php' ) );
100
101 $action_links = array(
102 'settings' => '<a href="' . esc_url( $page_url ) . '">' . esc_html__( 'Settings', 'merchant' ) . '</a>',
103 );
104
105 return array_merge( $action_links, $links );
106
107 }
108
109 /**
110 * Add plugin settings link on the plugin page.
111 */
112 public function add_admin_footer_text( $text ) {
113 $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
114 $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
115
116 if ( ! empty( $page ) && false !== strpos( $page, 'merchant' ) ) {
117
118 $text = '';
119
120 if ( empty( $module ) ) {
121
122 $text .= sprintf( '<a href="https://www.facebook.com/groups/245922400035997" target="_blank" class="merchant-admin-footer-text-link">%s</a>', esc_html__( 'Join our community', 'merchant' ) );
123 $text .= esc_html__( 'to discuss about the product and ask for support or help the community.', 'merchant' );
124
125 }
126
127 }
128
129 return $text;
130
131 }
132
133 /**
134 * Add admin body class.
135 */
136 public function add_admin_body_class( $classes ) {
137 $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
138 $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
139
140 if ( ! empty( $page ) && false !== strpos( $page, 'merchant' ) ) {
141
142 if ( ! empty( $module ) ) {
143
144 $classes .= ' merchant-admin-page-module';
145
146 } else {
147
148 $classes .= ' merchant-admin-page';
149
150 }
151
152 }
153
154 return $classes;
155
156 }
157
158 }
159
160 Merchant_Admin_Loader::instance();
161
162 }
163