PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 1.8.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v1.8.2
2.3.2 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 All 60 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.8.2, at admin/class-merchant-admin-loader.php

161 lines 5.6 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 * Include admin classes.
44 */
45 public function includes() {
46
47 // Notices.
48 require_once MERCHANT_DIR . 'admin/notices/class-merchant-notice.php';
49 require_once MERCHANT_DIR . 'admin/notices/class-merchant-notice-review.php';
50 require_once MERCHANT_DIR . 'admin/notices/class-merchant-notice-upsell.php';
51
52 require_once MERCHANT_DIR . 'inc/classes/class-merchant-svg-icons.php';
53 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-menu.php';
54 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-modules.php';
55 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-options.php';
56 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-utils.php';
57 require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-preview.php';
58 }
59
60 /**
61 * Enqueue admin styles and scripts.
62 */
63 public function enqueue_styles_scripts() {
64
65 $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
66
67 wp_register_script( 'merchant-select2', MERCHANT_URI . 'assets/vendor/select2/select2.full.min.js', array( 'jquery' ), '4.0.13', true );
68
69 wp_register_style( 'merchant-select2', MERCHANT_URI . 'assets/vendor/select2/select2.min.css', array(), '4.0.13' );
70
71 if ( ! empty( $page ) && false !== strpos( $page, 'merchant' ) ) {
72
73 wp_enqueue_media();
74
75 wp_enqueue_style( 'merchant-admin', MERCHANT_URI . 'assets/css/admin/admin.min.css', array(), MERCHANT_VERSION );
76
77 wp_enqueue_script( 'merchant-jquery-form', MERCHANT_URI . 'assets/vendor/jquery-form/jquery.form.min.js', array( 'jquery' ), '4.3.0', true );
78
79 wp_enqueue_script( 'merchant-pickr', MERCHANT_URI . 'assets/vendor/pickr/pickr.min.js', array( 'jquery' ), '1.8.2', true );
80
81 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 );
82
83 wp_localize_script( 'merchant-admin', 'merchant', array(
84 'nonce' => wp_create_nonce( 'merchant' ),
85 'ajax_url' => admin_url( 'admin-ajax.php' ),
86 ) );
87
88 $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
89
90 if( !empty($module) ) {
91 wp_enqueue_script( 'merchant-admin-preview', MERCHANT_URI . 'assets/js/admin/merchant-preview.min.js', array( 'jquery' ), MERCHANT_VERSION, true );
92 }
93 }
94 }
95
96 /**
97 * Add plugin settings link on the plugin page.
98 */
99 public function action_links( $links ) {
100
101 $page_url = add_query_arg( array( 'page' => 'merchant' ), admin_url( 'themes.php' ) );
102
103 $action_links = array(
104 'settings' => '<a href="' . esc_url( $page_url ) . '">' . esc_html__( 'Settings', 'merchant' ) . '</a>',
105 );
106
107 return array_merge( $action_links, $links );
108 }
109
110 /**
111 * Add plugin settings link on the plugin page.
112 */
113 public function add_admin_footer_text( $text ) {
114 $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
115 $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
116
117 if ( ! empty( $page ) && false !== strpos( $page, 'merchant' ) ) {
118
119 $text = '';
120
121 if ( empty( $module ) ) {
122
123 $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' ) );
124 $text .= esc_html__( 'to discuss about the product and ask for support or help the community.', 'merchant' );
125
126 }
127
128 }
129
130 return $text;
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 Merchant_Admin_Loader::instance();
159
160 }
161