PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.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
← All changes | inc/class-merchant-loader.php +187 -0 1.10.52.3.2 View file →
@@ -32,8 +32,10 @@
32 32 public function __construct() {
33 33 // Includes.
34 34 $this->includes();
35 35
36 + add_action( 'plugins_loaded', array( $this, 'maybe_define_awl_constant' ), 5 );
37 +
36 38 // Register scripts.
37 39 add_action( 'wp_enqueue_scripts', array( $this, 'register_global_js_and_css' ) );
38 40
39 41 // Enqueue scripts.
@@ -40,8 +42,17 @@
40 42 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
41 43
42 44 // Add identifier to body class.
43 45 add_filter( 'body_class', array( $this, 'add_body_class' ) );
46 +
47 + // Add row meta to the plugin screen.
48 + add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
49 +
50 + // Add settings link to the plugin screen.
51 + add_filter( 'plugin_action_links_' . plugin_basename( MERCHANT_DIR . 'merchant.php' ), array( $this, 'settings_link' ) );
52 +
53 + // WP Abilities API integration.
54 + add_action( 'plugins_loaded', array( $this, 'load_abilities_bootstrap' ), 20 );
44 55 }
45 56
46 57 /**
47 58 * Include required classes.
@@ -46,8 +57,9 @@
46 57 /**
47 58 * Include required classes.
48 59 */
49 60 public function includes() {
61 +
50 62 // Essential functions.
51 63 require_once MERCHANT_DIR . 'inc/functions.php';
52 64
53 65 // Helpers.
@@ -67,8 +79,10 @@
67 79 require_once MERCHANT_DIR . 'inc/classes/class-merchant-option.php';
68 80 require_once MERCHANT_DIR . 'inc/classes/class-merchant-modules.php';
69 81 require_once MERCHANT_DIR . 'inc/classes/class-merchant-custom-css.php';
70 82 require_once MERCHANT_DIR . 'inc/classes/class-merchant-svg-icons.php';
83 + require_once MERCHANT_DIR . 'inc/classes/class-merchant-db-tables.php';
84 + require_once MERCHANT_DIR . 'inc/classes/class-merchant-general-hooks.php';
71 85
72 86 // Metabox
73 87 require_once MERCHANT_DIR . 'inc/classes/class-merchant-metabox.php';
74 88
@@ -77,8 +91,39 @@
77 91
78 92 // Modules global settings.
79 93 require_once MERCHANT_DIR . 'inc/modules/global-settings/global-settings.php';
80 94
95 + // Modules analytics
96 + require_once MERCHANT_DIR . 'inc/analytics/class-merchant-analytics-db-orm.php';
97 + require_once MERCHANT_DIR . 'inc/analytics/class-merchant-analytics-logger.php';
98 + require_once MERCHANT_DIR . 'inc/analytics/class-merchant-analytics-data-provider.php';
99 + require_once MERCHANT_DIR . 'inc/analytics/class-merchant-analytics-data-reports.php';
100 + require_once MERCHANT_DIR . 'inc/analytics/class-merchant-analytics-data-ajax.php';
101 + require_once MERCHANT_DIR . 'inc/analytics/class-merchant-analytics-data-hooks.php';
102 +
103 + // Usage Tracking.
104 + require_once MERCHANT_DIR . 'inc/usage-tracking/class-merchant-usage-tracking.php';
105 + require_once MERCHANT_DIR . 'inc/usage-tracking/class-merchant-send-usage-task.php';
106 +
107 + /*
108 + * Action Scheduler requires a special loading procedure.
109 + * Load on plugins_loaded to ensure it's available before init.
110 + *
111 + * @since {VERSION}
112 + */
113 + add_action(
114 + 'plugins_loaded',
115 + static function() {
116 +
117 + //Check if Action Scheduler is already loaded.
118 + if ( function_exists( 'as_schedule_recurring_action' ) ) {
119 + return;
120 + }
121 +
122 + require_once MERCHANT_DIR . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
123 + },
124 + );
125 +
81 126 // Modules (free and pro).
82 127 foreach ( Merchant_Admin_Modules::$modules_data as $module_id => $module_data ) {
83 128 if (
84 129 defined( 'MERCHANT_PRO_VERSION' )
@@ -103,8 +148,11 @@
103 148 require_once MERCHANT_DIR . 'inc/compatibility/class-merchant-flatsome-theme.php';
104 149 require_once MERCHANT_DIR . 'inc/compatibility/class-merchant-breakdance-builder.php';
105 150 require_once MERCHANT_DIR . 'inc/compatibility/class-merchant-elementor-builder.php';
106 151 require_once MERCHANT_DIR . 'inc/compatibility/class-merchant-bricks-builder.php';
152 + require_once MERCHANT_DIR . 'inc/compatibility/class-merchant-woo-payments-plugin.php';
153 + require_once MERCHANT_DIR . 'inc/compatibility/class-merchant-ohio-theme.php';
154 + require_once MERCHANT_DIR . 'inc/compatibility/class-merchant-woo-multi-currency.php';
107 155
108 156 /**
109 157 * Hook 'merchant_admin_after_include_modules_classes'.
110 158 *
@@ -113,8 +161,23 @@
113 161 do_action( 'merchant_admin_after_include_modules_classes' );
114 162 }
115 163
116 164 /**
165 + * Define MERCHANT_AWL_ACTIVE when White Label is applied.
166 + *
167 + * @return void
168 + */
169 + public function maybe_define_awl_constant() {
170 + if ( defined( 'MERCHANT_AWL_ACTIVE' ) ) {
171 + return;
172 + }
173 +
174 + if ( merchant_white_label_is_applied() ) {
175 + define( 'MERCHANT_AWL_ACTIVE', true );
176 + }
177 + }
178 +
179 + /**
117 180 * Add to body class.
118 181 */
119 182 public function add_body_class( $classes ) {
120 183 $theme = wp_get_theme();
@@ -123,8 +186,132 @@
123 186
124 187 $classes[] = 'merchant-theme-' . strtolower( esc_attr( $theme_name ) );
125 188
126 189 return $classes;
190 + }
191 +
192 + /**
193 + * Bootstrap the WP Abilities API integration.
194 + *
195 + * Only loads on WordPress 6.9+ where the Abilities API exists.
196 + * Zero overhead on older WordPress versions.
197 + *
198 + * @since 2.3.0
199 + */
200 + public function load_abilities_bootstrap() {
201 + if ( ! function_exists( 'wp_register_ability' ) ) {
202 + return;
203 + }
204 +
205 + require_once MERCHANT_DIR . 'inc/abilities/class-merchant-abilities-bootstrap.php';
206 + Merchant_Abilities_Bootstrap::init();
207 + }
208 +
209 + /**
210 + * Show row meta on the plugin screen.
211 + *
212 + * @param mixed $links Plugin Row Meta.
213 + * @param mixed $file Plugin Base file.
214 + *
215 + * @since 2.1.2
216 + *
217 + * @return array
218 + */
219 + public function plugin_row_meta($links, $file) {
220 + if ( plugin_basename( MERCHANT_FILE ) !== $file ) {
221 + return $links;
222 + }
223 +
224 + /**
225 + * The Merchant documentation URL.
226 + *
227 + * @since 2.1.2
228 + */
229 + $docs_url = apply_filters( 'merchant_docs_url', 'https://docs.athemes.com/documentation/merchant/' );
230 +
231 + /**
232 + * The Merchant landing page URL.
233 + *
234 + * @since 2.1.2
235 + */
236 + $plugin_site = apply_filters( 'merchant_plugin_site_url', 'https://athemes.com/merchant/' );
237 +
238 + /**
239 + * The Merchant changelog URL.
240 + *
241 + * @since 2.1.2
242 + */
243 + $changelog = apply_filters( 'merchant_changelog_url', 'https://athemes.com/changelog/merchant/' );
244 +
245 + $row_meta = array(
246 + 'docs' => '<a href="' . esc_url( $docs_url ) . '" aria-label="' . esc_attr__( 'View Merchant documentation', 'merchant' ) . '" target="_blank">' . esc_html__(
247 + 'Docs',
248 + 'merchant'
249 + ) . '</a>',
250 + 'apidocs' => '<a href="' . esc_url( $plugin_site ) . '" aria-label="' . esc_attr__( 'View Merchant plugin site', 'merchant' ) . '" target="_blank">' . esc_html__(
251 + 'Visit plugin site',
252 + 'merchant' ) . '</a>',
253 + 'support' => '<a href="' . esc_url( $changelog ) . '" aria-label="' . esc_attr__( 'View Merchant changelog', 'merchant' ) . '" target="_blank">' . esc_html__( 'Changelog',
254 + 'merchant' ) . '</a>',
255 + );
256 +
257 + /**
258 + * Filter the plugin row meta links.
259 + *
260 + * @since 2.1.2
261 + *
262 + * @param array $row_meta The plugin row meta links.
263 + * @param string $file The plugin file.
264 + */
265 + $row_meta = apply_filters( 'merchant_plugin_row_meta', $row_meta, $file );
266 +
267 + return array_merge( $links, $row_meta );
268 + }
269 +
270 + /**
271 + * Add settings link to the Plugins page.
272 + *
273 + * @since 2.1.2
274 + *
275 + * @param array $links Plugin row links.
276 + *
277 + * @return array $links
278 + */
279 + public function settings_link( $links ) {
280 + if ( ! merchant_pro_is_active() ) {
281 + $url = merchant_admin_upgrade_link(
282 + 'https://athemes.com/merchant/#pricing',
283 + array(),
284 + 'plugins-page-upgrade-link'
285 + );
286 + $links['merchant-pro'] = sprintf(
287 + '<a href="%1$s" aria-label="%2$s" target="_blank" rel="noopener noreferrer"
288 + style="color: #00a32a; font-weight: 700;"
289 + onmouseover="this.style.color=\'#008a20\';"
290 + onmouseout="this.style.color=\'#00a32a\';"
291 + >%3$s</a>',
292 + esc_url( $url ),
293 + esc_attr__( 'Upgrade to Merchant Pro', 'merchant' ),
294 + esc_html__( 'Get Merchant Pro', 'merchant' )
295 + );
296 + }
297 +
298 + $custom['merchant-settings'] = sprintf(
299 + '<a href="%s" aria-label="%s">%s</a>',
300 + esc_url(
301 + add_query_arg(
302 + array(
303 + 'page' => 'merchant',
304 + 'section' => 'settings',
305 + ),
306 + admin_url( 'admin.php' )
307 + )
308 + ),
309 + esc_attr__( 'Go to Merchant Settings page', 'merchant' ),
310 + esc_html__( 'Settings', 'merchant' )
311 + );
312 +
313 + return array_merge( $custom, (array) $links );
127 314 }
128 315
129 316 /**
130 317 * Register scripts.