-
Notifications
You must be signed in to change notification settings - Fork 15
/
dc_product_vendor.php
107 lines (100 loc) · 3.91 KB
/
dc_product_vendor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* Plugin Name: MultiVendorX
* Plugin URI: https://multivendorx.com/
* Description: A Free Extension That Transforms Your WooCommerce Site into a Marketplace.
* Author: MultiVendorX
* Version: 4.2.6
* Author URI: https://multivendorx.com/
* Requires at least: 5.4
* Tested up to: 6.6.2
* WC requires at least: 8.2.2
* WC tested up to: 9.3.3
*
* Text Domain: multivendorx
* Requires Plugins: woocommerce
* Domain Path: /languages/
*/
if (!class_exists('WC_Dependencies_Product_Vendor')) {
require_once 'includes/class-mvx-dependencies.php';
}
require_once 'includes/mvx-core-functions.php';
require_once 'mvx-config.php';
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
if (!defined('MVX_PLUGIN_TOKEN')) {
exit;
}
/* Check whether another multi vendor plugin exist */
register_activation_hook(__FILE__, 'mvx_check_if_another_vendor_plugin_exits');
/* Plugin activation hook */
register_activation_hook(__FILE__, 'activate_mvx_plugin');
/* Plugin deactivation hook */
register_deactivation_hook(__FILE__, 'deactivate_mvx_plugin');
/* Remove rewrite rules and then recreate rewrite rules. */
register_activation_hook(__FILE__, 'flush_rewrite_rules');
add_action('init', 'mvx_plugin_init');
add_action('admin_init', 'mvx_delete_woocomerce_transient_redirect_to_mvx_setup', 5);
/**
* Load setup class
*/
function mvx_plugin_init() {
$current_page = filter_input(INPUT_GET, 'page');
if ($current_page && $current_page == 'mvx-setup') {
include_once(dirname( __FILE__ ) . '/admin/class-mvx-admin-setup-wizard.php');
}
}
/**
* Delete WooCommerce activation redirect transient
*/
function mvx_delete_woocomerce_transient_redirect_to_mvx_setup(){
if ( get_transient( '_wc_activation_redirect' ) ) {
delete_transient( '_wc_activation_redirect' );
return;
}
if ( get_transient( '_mvx_activation_redirect' ) ) {
delete_transient( '_mvx_activation_redirect' );
if ( ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'mvx-setup' ) ) ) || is_network_admin() || isset( $_GET['activate-multi'] ) || apply_filters( 'mvx_prevent_automatic_wizard_redirect', false ) ) {
return;
}
wp_safe_redirect( admin_url( 'index.php?page=mvx-setup' ) );
exit;
}
}
$permalink_structure = get_option('permalink_structure');
if (!class_exists('MVX') && WC_Dependencies_Product_Vendor::is_woocommerce_active() && !empty($permalink_structure)) {
global $MVX;
require_once( 'classes/class-mvx.php' );
/* recheck plugin install */
add_action('plugins_loaded', 'activate_mvx_plugin');
/* Initiate plugin main class */
$MVX = new MVX(__FILE__);
$GLOBALS['MVX'] = $MVX;
if (is_admin() && !defined('DOING_AJAX')) {
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'mvx_action_links');
}
} else {
add_action('admin_notices', 'mvx_admin_notice');
function mvx_admin_notice() {
?>
<div class="error">
<p><?php _e('MultiVendorX plugin requires <a href="https://wordpress.org/plugins/woocommerce/">WooCommerce</a> plugins to be active! and <a href='. admin_url('options-permalink.php') .'>permalink</a> structure should be configured', 'multivendorx'); ?></p>
</div>
<?php
}
}
function mvx_namespace_approve( $value ) {
$rest_prefix = trailingslashit( rest_get_url_prefix() );
// Allow third party plugins use our authentication methods.
$mvx_support = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'mvx' ) );
if($value || $mvx_support) $return = true;
else $return = false;
return $return;
}
add_action ( 'before_woocommerce_init', function () {
if ( class_exists ( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility ( 'custom_order_tables', WP_CONTENT_DIR.'/plugins/dc-woocommerce-multi-vendor/dc_product_vendor.php', true );
}
});