This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
dokan.php
710 lines (593 loc) · 23.5 KB
/
dokan.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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
<?php
/*
Plugin Name: Dokan (Lite) - Multi-vendor Marketplace
Plugin URI: https://wordpress.org/plugins/dokan-lite/
Description: An e-commerce marketplace plugin for WordPress. Powered by WooCommerce and weDevs.
Version: 2.4.8
Author: weDevs
Author URI: http://wedevs.com/
License: GPL2
*/
/**
* Copyright (c) 2015 weDevs (email: info@wedevs.com). All rights reserved.
*
* Released under the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This is an add-on for WordPress
* http://wordpress.org/
*
* **********************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* **********************************************************************
*/
// don't call the file directly
if ( ! defined( 'ABSPATH' ) ) exit;
// Backwards compatibility for older than PHP 5.3.0
if ( !defined( '__DIR__' ) ) {
define( '__DIR__', dirname( __FILE__ ) );
}
define( 'DOKAN_PLUGIN_VERSION', '2.4.8' );
define( 'DOKAN_FILE', __FILE__ );
define( 'DOKAN_DIR', __DIR__ );
define( 'DOKAN_INC_DIR', __DIR__ . '/includes' );
define( 'DOKAN_LIB_DIR', __DIR__ . '/lib' );
define( 'DOKAN_PLUGIN_ASSEST', plugins_url( 'assets', __FILE__ ) );
// give a way to turn off loading styles and scripts from parent theme
if ( !defined( 'DOKAN_LOAD_STYLE' ) ) {
define( 'DOKAN_LOAD_STYLE', true );
}
if ( !defined( 'DOKAN_LOAD_SCRIPTS' ) ) {
define( 'DOKAN_LOAD_SCRIPTS', true );
}
/**
* Autoload class files on demand
*
* `Dokan_Installer` becomes => installer.php
* `Dokan_Template_Report` becomes => template-report.php
*
* @since 1.0
*
* @param string $class requested class name
*/
function dokan_autoload( $class ) {
if ( stripos( $class, 'Dokan_' ) !== false ) {
$class_name = str_replace( array( 'Dokan_', '_' ), array( '', '-' ), $class );
$file_path = __DIR__ . '/classes/' . strtolower( $class_name ) . '.php';
if ( file_exists( $file_path ) ) {
require_once $file_path;
}
}
}
spl_autoload_register( 'dokan_autoload' );
/**
* WeDevs_Dokan class
*
* @class WeDevs_Dokan The class that holds the entire WeDevs_Dokan plugin
*/
final class WeDevs_Dokan {
private $is_pro = false;
/**
* Constructor for the WeDevs_Dokan class
*
* Sets up all the appropriate hooks and actions
* within our plugin.
*
* @uses register_activation_hook()
* @uses register_deactivation_hook()
* @uses is_admin()
* @uses add_action()
*/
public function __construct() {
if ( ! function_exists( 'WC' ) ) {
add_action( 'admin_notices', array( $this, 'add_woocommerce_activation_notice' ) );
return;
}
global $wpdb;
$wpdb->dokan_withdraw = $wpdb->prefix . 'dokan_withdraw';
$wpdb->dokan_orders = $wpdb->prefix . 'dokan_orders';
//includes file
$this->includes();
// init actions and filter
$this->init_filters();
$this->init_actions();
// initialize classes
$this->init_classes();
//for reviews ajax request
$this->init_ajax();
do_action( 'dokan_loaded' );
}
/**
* Show wordpress error notice if Woocommerce not found
*
* @since 2.4.4
*
*/
function add_woocommerce_activation_notice() {
echo '<div class="error"><p>' . sprintf( __( '<b>Dokan</b> requires %sWoocommerce%s to be installed & activated!', 'dokan' ), '<a target="_blank" href="https://wordpress.org/plugins/woocommerce/">', '</a>' ) . '</p></div>';
}
/**
* Initializes the WeDevs_Dokan() class
*
* Checks for an existing WeDevs_WeDevs_Dokan() instance
* and if it doesn't find one, creates it.
*/
public static function init() {
static $instance = false;
if ( ! $instance ) {
$instance = new WeDevs_Dokan();
}
return $instance;
}
/**
* Get the plugin path.
*
* @return string
*/
public function plugin_path() {
return untrailingslashit( plugin_dir_path( __FILE__ ) );
}
/**
* Get the template path.
*
* @return string
*/
public function template_path() {
return apply_filters( 'dokan_template_path', 'dokan/' );
}
/**
* Placeholder for activation function
*
* Nothing being called here yet.
*/
public static function activate() {
global $wpdb;
$wpdb->dokan_withdraw = $wpdb->prefix . 'dokan_withdraw';
$wpdb->dokan_orders = $wpdb->prefix . 'dokan_orders';
$wpdb->dokan_announcement = $wpdb->prefix . 'dokan_announcement';
require_once __DIR__ . '/includes/functions.php';
$installer = new Dokan_Installer();
$installer->do_install();
}
/**
* Placeholder for deactivation function
*
* Nothing being called here yet.
*/
public static function deactivate() {
}
/**
* Initialize plugin for localization
*
* @uses load_plugin_textdomain()
*/
public function localization_setup() {
load_plugin_textdomain( 'dokan', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
function init_actions() {
// Localize our plugin
add_action( 'admin_init', array( $this, 'load_table_prifix' ) );
add_action( 'init', array( $this, 'localization_setup' ) );
add_action( 'init', array( $this, 'register_scripts' ) );
add_action( 'template_redirect', array( $this, 'redirect_if_not_logged_seller' ), 11 );
add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'login_enqueue_scripts', array( $this, 'login_scripts') );
// add_action( 'admin_init', array( $this, 'install_theme' ) );
add_action( 'admin_init', array( $this, 'block_admin_access' ) );
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'plugin_action_links' ) );
}
public function register_scripts() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
// register styles
wp_register_style( 'jquery-ui', plugins_url( 'assets/css/jquery-ui-1.10.0.custom.css', __FILE__ ), false, null );
wp_register_style( 'fontawesome', plugins_url( 'assets/css/font-awesome.min.css', __FILE__ ), false, null );
wp_register_style( 'dokan-extra', plugins_url( 'assets/css/dokan-extra.css', __FILE__ ), false, null );
wp_register_style( 'dokan-style', plugins_url( 'assets/css/style.css', __FILE__ ), false, null );
wp_register_style( 'dokan-chosen-style', plugins_url( 'assets/css/chosen.min.css', __FILE__ ), false, null );
wp_register_style( 'dokan-magnific-popup', plugins_url( 'assets/css/magnific-popup.css', __FILE__ ), false, null );
// register scripts
wp_register_script( 'jquery-flot', plugins_url( 'assets/js/flot-all.min.js', __FILE__ ), false, null, true );
wp_register_script( 'jquery-chart', plugins_url( 'assets/js/Chart.min.js', __FILE__ ), false, null, true );
wp_register_script( 'dokan-tabs-scripts', plugins_url( 'assets/js/jquery.easytabs.min.js', __FILE__ ), false, null, true );
wp_register_script( 'dokan-hashchange-scripts', plugins_url( 'assets/js/jquery.hashchange.min.js', __FILE__ ), false, null, true );
wp_register_script( 'dokan-tag-it', plugins_url( 'assets/js/tag-it.min.js', __FILE__ ), array( 'jquery' ), null, true );
wp_register_script( 'chosen', plugins_url( 'assets/js/chosen.jquery.min.js', __FILE__ ), array( 'jquery' ), null, true );
wp_register_script( 'dokan-popup', plugins_url( 'assets/js/jquery.magnific-popup.min.js', __FILE__ ), array( 'jquery' ), null, true );
wp_register_script( 'bootstrap-tooltip', plugins_url( 'assets/js/bootstrap-tooltips.js', __FILE__ ), false, null, true );
wp_register_script( 'form-validate', plugins_url( 'assets/js/form-validate.js', __FILE__ ), array( 'jquery' ), null, true );
wp_register_script( 'dokan-script', plugins_url( 'assets/js/all.js', __FILE__ ), false, null, true );
wp_register_script( 'dokan-product-shipping', plugins_url( 'assets/js/single-product-shipping.js', __FILE__ ), false, null, true );
}
/**
* Enqueue admin scripts
*
* Allows plugin assets to be loaded.
*
* @uses wp_enqueue_script()
* @uses wp_localize_script()
* @uses wp_enqueue_style
*/
public function scripts() {
if ( is_singular( 'product' ) && !get_query_var( 'edit' ) ) {
wp_enqueue_script( 'dokan-product-shipping' );
$localize_script = array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'dokan_reviews' ),
'ajax_loader' => plugins_url( 'assets/images/ajax-loader.gif', __FILE__ ),
'seller' => array(
'available' => __( 'Available', 'dokan' ),
'notAvailable' => __( 'Not Available', 'dokan' )
),
'delete_confirm' => __('Are you sure?', 'dokan' ),
'wrong_message' => __('Something went wrong. Please try again.', 'dokan' ),
);
wp_localize_script( 'jquery', 'dokan', $localize_script );
}
$page_id = dokan_get_option( 'dashboard', 'dokan_pages' );
// bailout if not dashboard
if ( ! $page_id ) {
return;
}
if ( ! function_exists( 'WC' ) ) {
return;
}
$localize_script = array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'dokan_reviews' ),
'ajax_loader' => plugins_url( 'assets/images/ajax-loader.gif', __FILE__ ),
'seller' => array(
'available' => __( 'Available', 'dokan' ),
'notAvailable' => __( 'Not Available', 'dokan' )
),
'delete_confirm' => __('Are you sure?', 'dokan' ),
'wrong_message' => __('Something is wrong, Please try again.', 'dokan' ),
'duplicates_attribute_messg' => __( 'Sorry, this attribute option already exists, Try a different one.', 'dokan' ),
'variation_unset_warning' => __( 'Warning! This product will not have any variations if this option is not checked.', 'dokan' ),
);
$form_validate_messages = array(
'required' => __( "This field is required", 'dokan' ),
'remote' => __( "Please fix this field.", 'dokan' ),
'email' => __( "Please enter a valid email address." , 'dokan' ),
'url' => __( "Please enter a valid URL." , 'dokan' ),
'date' => __( "Please enter a valid date." , 'dokan' ),
'dateISO' => __( "Please enter a valid date (ISO)." , 'dokan' ),
'number' => __( "Please enter a valid number." , 'dokan' ),
'digits' => __( "Please enter only digits." , 'dokan' ),
'creditcard' => __( "Please enter a valid credit card number." , 'dokan' ),
'equalTo' => __( "Please enter the same value again." , 'dokan' ),
'maxlength_msg' => __( "Please enter no more than {0} characters." , 'dokan' ),
'minlength_msg' => __( "Please enter at least {0} characters." , 'dokan' ),
'rangelength_msg' => __( "Please enter a value between {0} and {1} characters long." , 'dokan' ),
'range_msg' => __( "Please enter a value between {0} and {1}." , 'dokan' ),
'max_msg' => __( "Please enter a value less than or equal to {0}." , 'dokan' ),
'min_msg' => __( "Please enter a value greater than or equal to {0}." , 'dokan' ),
);
wp_localize_script( 'form-validate', 'DokanValidateMsg', $form_validate_messages );
// load only in dokan dashboard and edit page
if ( is_page( $page_id ) || ( get_query_var( 'edit' ) && is_singular( 'product' ) ) ) {
if ( DOKAN_LOAD_STYLE ) {
wp_enqueue_style( 'jquery-ui' );
wp_enqueue_style( 'fontawesome' );
wp_enqueue_style( 'dokan-extra' );
wp_enqueue_style( 'dokan-style' );
wp_enqueue_style( 'dokan-magnific-popup' );
}
if ( DOKAN_LOAD_SCRIPTS ) {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_script( 'underscore' );
wp_enqueue_script( 'post' );
wp_enqueue_script( 'dokan-tag-it' );
wp_enqueue_script( 'bootstrap-tooltip' );
wp_enqueue_script( 'form-validate' );
wp_enqueue_script( 'dokan-tabs-scripts' );
wp_enqueue_script( 'jquery-chart' );
wp_enqueue_script( 'jquery-flot' );
wp_enqueue_script( 'chosen' );
wp_enqueue_media();
wp_enqueue_script( 'dokan-popup' );
wp_enqueue_script( 'dokan-script' );
wp_localize_script( 'jquery', 'dokan', $localize_script );
}
}
// store and my account page
$custom_store_url = dokan_get_option( 'custom_store_url', 'dokan_general', 'store' );
if ( get_query_var( $custom_store_url ) || get_query_var( 'store_review' ) || is_account_page() ) {
if ( DOKAN_LOAD_STYLE ) {
wp_enqueue_style( 'fontawesome' );
wp_enqueue_style( 'dokan-style' );
}
if ( DOKAN_LOAD_SCRIPTS ) {
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_script( 'bootstrap-tooltip' );
wp_enqueue_script( 'chosen' );
wp_enqueue_script( 'form-validate' );
wp_enqueue_script( 'dokan-script' );
wp_localize_script( 'jquery', 'dokan', $localize_script );
}
}
// load dokan style on every pages. requires for shortcodes in other pages
if ( DOKAN_LOAD_STYLE ) {
wp_enqueue_style( 'dokan-style' );
wp_enqueue_style( 'fontawesome' );
}
//load country select js in seller settings store template
global $wp;
if ( isset( $wp->query_vars['settings'] ) == 'store' ) {
wp_enqueue_script( 'wc-country-select' );
}
do_action( 'dokan_after_load_script' );
}
/**
* Include all the required files
*
* @return void
*/
function includes() {
$lib_dir = __DIR__ . '/lib/';
$inc_dir = __DIR__ . '/includes/';
$classes_dir = __DIR__ . '/classes/';
require_once $inc_dir . 'functions.php';
require_once $inc_dir . 'widgets/menu-category.php';
require_once $inc_dir . 'widgets/store-menu-category.php';
require_once $inc_dir . 'widgets/bestselling-product.php';
require_once $inc_dir . 'widgets/top-rated-product.php';
require_once $inc_dir . 'widgets/store-menu.php';
require_once $inc_dir . 'wc-functions.php';
// Load free or pro moduels
if ( file_exists( DOKAN_INC_DIR . '/pro/dokan-pro-loader.php' ) ) {
include_once DOKAN_INC_DIR . '/pro/dokan-pro-loader.php';
$this->is_pro = true;
}
else if ( file_exists( DOKAN_INC_DIR . '/free/dokan-free-loader.php' ) ) {
include_once DOKAN_INC_DIR . '/free/dokan-free-loader.php';
}
if ( is_admin() ) {
require_once $inc_dir . 'admin/admin.php';
require_once $inc_dir . 'admin/ajax.php';
require_once $inc_dir . 'admin-functions.php';
} else {
require_once $inc_dir . 'wc-template.php';
require_once $inc_dir . 'template-tags.php';
}
}
/**
* Initialize filters
*
* @return void
*/
function init_filters() {
add_filter( 'posts_where', array( $this, 'hide_others_uploads' ) );
add_filter( 'body_class', array( $this, 'add_dashboard_template_class' ), 99 );
add_filter( 'wp_title', array( $this, 'wp_title' ), 20, 2 );
}
/**
* Hide other users uploads for `seller` users
*
* Hide media uploads in page "upload.php" and "media-upload.php" for
* sellers. They can see only thier uploads.
*
* FIXME: fix the upload counts
*
* @global string $pagenow
* @global object $wpdb
*
* @param string $where
*
* @return string
*/
function hide_others_uploads( $where ) {
global $pagenow, $wpdb;
if ( ( $pagenow == 'upload.php' || $pagenow == 'media-upload.php' ) && current_user_can( 'dokandar' ) ) {
$user_id = get_current_user_id();
$where .= " AND $wpdb->posts.post_author = $user_id";
}
return $where;
}
/**
* Init ajax classes
*
* @return void
*/
function init_ajax() {
$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
if ( $doing_ajax ) {
Dokan_Ajax::init()->init_ajax();
new Dokan_Pageviews();
}
}
/**
* Init all the classes
*
* @return void
*/
function init_classes() {
if ( is_admin() ) {
new Dokan_Admin_User_Profile();
Dokan_Admin_Ajax::init();
new Dokan_Upgrade();
} else {
new Dokan_Pageviews();
}
new Dokan_Rewrites();
Dokan_Email::init();
if ( is_user_logged_in() ) {
Dokan_Template_Main::init();
Dokan_Template_Dashboard::init();
Dokan_Template_Products::init();
Dokan_Template_Orders::init();
Dokan_Template_Withdraw::init();
Dokan_Template_Shortcodes::init();
Dokan_Template_Settings::init();
}
}
/**
* Redirect if not logged Seller
*
* @since 2.4
*
* @return void [redirection]
*/
function redirect_if_not_logged_seller() {
global $post;
$page_id = dokan_get_option( 'dashboard', 'dokan_pages' );
if ( ! $page_id ) {
return;
}
if ( is_page( $page_id ) ) {
dokan_redirect_login();
dokan_redirect_if_not_seller();
}
}
/**
* Block user access to admin panel for specific roles
*
* @global string $pagenow
*/
function block_admin_access() {
global $pagenow, $current_user;
// bail out if we are from WP Cli
if ( defined( 'WP_CLI' ) ) {
return;
}
$no_access = dokan_get_option( 'admin_access', 'dokan_general', 'on' );
$valid_pages = array( 'admin-ajax.php', 'admin-post.php', 'async-upload.php', 'media-upload.php' );
$user_role = reset( $current_user->roles );
if ( ( $no_access == 'on' ) && ( !in_array( $pagenow, $valid_pages ) ) && in_array( $user_role, array( 'seller', 'customer' ) ) ) {
wp_redirect( home_url() );
exit;
}
}
/**
* Load jquery in login page
*
* @since 2.4
*
* @return void
*/
function login_scripts() {
wp_enqueue_script( 'jquery' );
}
/**
* Scripts and styles for admin panel
*/
function admin_enqueue_scripts() {
wp_enqueue_script( 'dokan_slider_admin', DOKAN_PLUGIN_ASSEST.'/js/admin.js', array( 'jquery' ) );
}
/**
* Load table prefix for withdraw and orders table
*
* @since 1.0
*
* @return void
*/
function load_table_prifix() {
global $wpdb;
$wpdb->dokan_withdraw = $wpdb->prefix . 'dokan_withdraw';
$wpdb->dokan_orders = $wpdb->prefix . 'dokan_orders';
}
/**
* Add body class for dokan-dashboard
*
* @param array $classes
*/
function add_dashboard_template_class( $classes ) {
$page_id = dokan_get_option( 'dashboard', 'dokan_pages' );
if ( ! $page_id ) {
return $classes;
}
if ( is_page( $page_id ) || ( get_query_var( 'edit' ) && is_singular( 'product' ) ) ) {
$classes[] = 'dokan-dashboard';
}
if ( dokan_is_store_page () ) {
$classes[] = 'dokan-store';
}
$classes[] = 'dokan-theme-' . get_option( 'template' );
return $classes;
}
/**
* Create a nicely formatted and more specific title element text for output
* in head of document, based on current view.
*
* @since Dokan 1.0.4
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
*
* @return string The filtered title.
*/
function wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() ) {
return $title;
}
if ( dokan_is_store_page() ) {
$site_title = get_bloginfo( 'name' );
$store_user = get_userdata( get_query_var( 'author' ) );
$store_info = dokan_get_store_info( $store_user->ID );
$store_name = esc_html( $store_info['store_name'] );
$title = "$store_name $sep $site_title";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 ) {
$title = "$title $sep " . sprintf( __( 'Page %s', 'dokan' ), max( $paged, $page ) );
}
return $title;
}
return $title;
}
/**
* Returns if the plugin is in PRO version
*
* @since 2.4
*
* @return boolean
*/
public function is_pro() {
return $this->is_pro;
}
/**
* Plugin action links
*
* @param array $links
*
* @since 2.4
*
* @return array
*/
function plugin_action_links( $links ) {
if ( ! $this->is_pro() ) {
$links[] = '<a href="https://wedevs.com/products/plugins/dokan/" target="_blank">' . __( 'Get PRO', 'dokan' ) . '</a>';
}
$links[] = '<a href="' . admin_url( 'admin.php?page=dokan-settings' ) . '">' . __( 'Settings', 'dokan' ) . '</a>';
$links[] = '<a href="http://docs.wedevs.com/category/plugins/dokan-plugins/" target="_blank">' . __( 'Documentation', 'dokan' ) . '</a>';
return $links;
}
} // WeDevs_Dokan
/**
* Load Dokan Plugin when all plugins loaded
*
* @return void
*/
function dokan_load_plugin() {
$dokan = WeDevs_Dokan::init();
}
add_action( 'plugins_loaded', 'dokan_load_plugin', 5 );
register_activation_hook( __FILE__, array( 'WeDevs_Dokan', 'activate' ) );
register_deactivation_hook( __FILE__, array( 'WeDevs_Dokan', 'deactivate' ) );
add_action( 'activated_plugin', array( 'Dokan_Installer', 'welcome_page_redirect' ) );