-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathultratable.php
More file actions
238 lines (193 loc) · 9.6 KB
/
ultratable.php
File metadata and controls
238 lines (193 loc) · 9.6 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/**
* Plugin Name: AA UltraTable - WooCommerce Product Table
* Plugin URI: #
* Description: A Woocommerce Product Table for UltraTable
* Author: Saiful Islam
* Author URI: https://profiles.wordpress.org/codersaiful/#content-plugins
* Text Domain: ultratable
* Domain Path: /languages/
*
* Version: 1.0.0
* Requires at least: 4.0.0
* Tested up to: 5.4.2
* WC requires at least: 3.7
* WC tested up to: 4.2.2
*/
if ( !defined( 'ABSPATH' ) ) {
die();
}
if ( !defined( 'ULTRATABLE_VERSION' ) ) {
define( 'ULTRATABLE_VERSION', '1.0.0');
}
if( !defined( 'ULTRATABLE_CAPABILITY' ) ){
$wpt_capability = apply_filters( 'wpt_menu_capability', 'manage_woocommerce' );
define( 'ULTRATABLE_CAPABILITY', $wpt_capability );
}
if ( !defined( 'ULTRATABLE_NAME' ) ) {
define( 'ULTRATABLE_NAME', 'UltraTable - WooCommerce Product Table');
}
if ( !defined( 'ULTRATABLE_BASE_NAME' ) ) {
define( 'ULTRATABLE_BASE_NAME', plugin_basename( __FILE__ ) );
}
if ( !defined( 'ULTRATABLE_MENU_SLUG' ) ) {
define( 'ULTRATABLE_MENU_SLUG', 'ultratable' );
}
if( !defined( 'ULTRATABLE_PLUGIN' ) ){
define( 'ULTRATABLE_PLUGIN', 'ultratable/ultratable.php' );
}
if ( !defined( 'ULTRATABLE_BASE_URL' ) ) {
define( "ULTRATABLE_BASE_URL", plugins_url() . '/'. plugin_basename( dirname( __FILE__ ) ) . '/' );
}
if ( !defined( 'ULTRATABLE_BASE_DIR' ) ) {
define( "ULTRATABLE_BASE_DIR", str_replace( '\\', '/', dirname( __FILE__ ) ) );
}
//var_dump(ULTRATABLE_BASE_DIR);
if ( !defined( 'ULTRATABLE_TABLE_DIR' ) ) {
define( "ULTRATABLE_TABLE_DIR", ULTRATABLE_BASE_DIR . '/table' );
}
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
ULTRATABLE::getInstance();
class ULTRATABLE{
public static $own = array(
'plugin' => 'ultratable/ultratable.php',
'plugin_slug' => 'ultratable',
'type' => 'error',
'message' => 'Install To working',
'btn_text' => 'Install Now',
'name' => 'UltraTable',
'perpose' => 'install', //install,upgrade,activation
);
private static $_instance;
const MINIMUM_PHP_VERSION = '5.6';
public static function getInstance() {
if (!( self::$_instance instanceof self )) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
$installed_plugins = get_plugins();
if (!is_plugin_active('woocommerce/woocommerce.php')) {
add_action('admin_notices', [$this, 'admin_notice_missing_main_plugin']);
return;
}
//Qty Plus/Minus Button Plugin Compulsory for Our Product Table Plugin
$plugin = 'wc-quantity-plus-minus-button/init.php';
$link_text = '<strong><a href="' . esc_url( 'https://wordpress.org/plugins/wc-quantity-plus-minus-button/' ) . '" target="_blank">' . esc_html__( 'Quantity Plus/Minus Button for WooCommerce', 'wpt_pro' ) . '</a></strong>';
//Check Installation of Quantity Plus Minus Button Plugin
if( !isset( $installed_plugins[$plugin] ) ) {
self::$own['plugin'] = $plugin;
self::$own['plugin_slug'] = 'wc-quantity-plus-minus-button';
self::$own['type'] = 'warning';
self::$own['btn_text'] = 'Install Now';
$message = sprintf(
esc_html__( '"%1$s" requires "%2$s" to be Installed and Activated.', 'wpt_pro' ),
'<strong>' . esc_html__( 'Woo Product Table', 'wpt_pro' ) . '</strong>',
$link_text
);
self::$own['message'] = $message;//'You to activate your Plugin';
add_action( 'admin_notices', [ $this, 'admin_notice' ] );
}
//Check Activation Of that Plugin
if( isset( $installed_plugins[$plugin] ) && !is_plugin_active( $plugin ) ) {
self::$own['type'] = 'warning';
self::$own['perpose'] = 'activation';
self::$own['plugin'] = 'wc-quantity-plus-minus-button/init.php';
self::$own['btn_text'] = 'Activate Now';
$message = sprintf(
/* translators: 1: Plugin name 2: WooPrdouct Table */
esc_html__( '"%1$s" recomends "%2$s" to be activated.', 'wpt_pro' ),
'<strong>' . esc_html__( 'Woo Product Table', 'wpt_pro' ) . '</strong>',
$link_text
);
self::$own['message'] = $message;//'You to activate your Plugin';
add_action( 'admin_notices', [ $this, 'admin_notice' ] );
}
// Check for required PHP version
if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );
return;
}
add_action(
'plugins_loaded',
function () {
load_plugin_textdomain( 'ultratable', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
});
/**
* Including Files
*/
if( !class_exists( 'Mobile_Detect' ) ){
include_once ULTRATABLE_BASE_DIR . '/modules/Mobile_Detect.php';
}
//Load Script JS/CSS for both Admin/FrontEnd
include_once ULTRATABLE_BASE_DIR . '/includes/load-scripts.php';
include_once ULTRATABLE_BASE_DIR . '/includes/functions.php';
include_once ULTRATABLE_BASE_DIR . '/table/table.php';
//include_once ULTRATABLE_BASE_DIR . '/includes/aaaa.php';
//include_once $this->path('BASE_DIR','table/table.php');
//include_once ULTRATABLE_BASE_DIR . '/includes/action-hooks.php';
if( is_admin() ){
include_once ULTRATABLE_BASE_DIR . '/admin/functions.php';
include_once ULTRATABLE_BASE_DIR . '/admin/admin-menu.php';
include_once ULTRATABLE_BASE_DIR . '/admin/settings.php';
include_once ULTRATABLE_BASE_DIR . '/admin/ultratable-post.php';
include_once ULTRATABLE_BASE_DIR . '/admin/post_metabox.php';
}
}
public function admin_notice() {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
$plugin = isset( self::$own['plugin'] ) ? self::$own['plugin'] : '';
$type = isset( self::$own['type'] ) ? self::$own['type'] : false;
$plugin_slug = isset( self::$own['plugin_slug'] ) ? self::$own['plugin_slug'] : '';
$message = isset( self::$own['message'] ) ? self::$own['message'] : '';
$btn_text = isset( self::$own['btn_text'] ) ? self::$own['btn_text'] : '';
$name = isset( self::$own['name'] ) ? self::$own['name'] : false; //Mainly providing OUr pLugin Name
$perpose = isset( self::$own['perpose'] ) ? self::$own['perpose'] : 'install';
if( $perpose == 'activation' ){
$url = $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin );
}elseif( $perpose == 'upgrade' ){
$url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $plugin, 'upgrade-plugin_' . $plugin );
}elseif( $perpose == 'install' ){
//IF PERPOSE install or Upgrade Actually || $perpose == install only supported Here
$url = wp_nonce_url( self_admin_url( 'update.php?action=' . $perpose . '-plugin&plugin=' . $plugin_slug ), $perpose . '-plugin_' . $plugin_slug ); //$install_url =
}else{
$url = false;
}
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = '<p>' . $message . '</p>';
if( $url ){
$style = isset( $type ) && $type == 'error' ? 'style="background: #ff584c;border-color: #E91E63;"' : 'style="background: #ffb900;border-color: #c37400;"';
$message .= '<p>' . sprintf( '<a href="%s" class="button-primary" %s>%s</a>', $url,$style, $btn_text ) . '</p>';
}
printf( '<div class="notice notice-' . $type . ' is-dismissible"><p>%1$s</p></div>', $message );
}
public function admin_notice_missing_main_plugin() {
if (isset($_GET['activate']))
unset($_GET['activate']);
$message = sprintf(
esc_html__('"%1$s" requires "%2$s" to be installed and activated.', 'wqpmb'),
'<strong>' . ULTRATABLE_NAME . '</strong>',
'<strong><a href="' . esc_url('https://wordpress.org/plugins/woocommerce/') . '" target="_blank">' . esc_html__('WooCommerce', 'wqpmb') . '</a></strong>'
);
printf('<div class="notice notice-error is-dismissible"><p>%1$s</p></div>', $message);
}
public function admin_notice_minimum_php_version() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin name 2: PHP 3: Required PHP version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'wqpmb' ),
'<strong>' . ULTRATABLE_NAME . '</strong>',
'<strong>' . esc_html__( 'PHP', 'wqpmb' ) . '</strong>',
self::MINIMUM_PHP_VERSION
);
printf( '<div class="notice notice-error is-dismissible"><p>%1$s</p></div>', $message );
}
}
/**
* Plugin Install and Uninstall
*/
//register_activation_hook(__FILE__, array( 'ULTRATABLE','install' ) );
//register_deactivation_hook( __FILE__, array( 'ULTRATABLE','uninstall' ) );