| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: SupportCandy |
| 4 |
* Plugin URI: https://wordpress.org/plugins/supportcandy/ |
| 5 |
* Description: Easy & Powerful support ticket system for WordPress |
| 6 |
* Version: 2.3.1 |
| 7 |
* Author: SupportCandy Team |
| 8 |
* Author URI: https://supportcandy.net/ |
| 9 |
* Requires at least: 4.4 |
| 10 |
* Tested up to: 6.0 |
| 11 |
* Text Domain: supportcandy |
| 12 |
* Domain Path: /lang |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; // Exit if accessed directly |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! class_exists( 'Support_Candy' ) ) : |
| 20 |
|
| 21 |
final class Support_Candy { |
| 22 |
|
| 23 |
public $version = '2.3.1'; |
| 24 |
public $db_version = '2.0'; |
| 25 |
|
| 26 |
public function __construct() { |
| 27 |
|
| 28 |
// define global constants |
| 29 |
$this->define_constants(); |
| 30 |
|
| 31 |
// Include required files and classes |
| 32 |
$this->includes(); |
| 33 |
|
| 34 |
add_action( 'init', array($this,'load_textdomain') ); |
| 35 |
|
| 36 |
/* |
| 37 |
* Cron setup |
| 38 |
*/ |
| 39 |
add_filter('cron_schedules',array( $this, 'wpsc_cron_schedule')); |
| 40 |
add_action( 'wpsc_cron_job_schedules', array( $this, 'wpsc_cron_job')); |
| 41 |
if (!wp_next_scheduled('wpsc_cron_job_schedules')) { |
| 42 |
wp_schedule_event(time(), 'wpsc5min', 'wpsc_cron_job_schedules'); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Attachment restructure |
| 47 |
*/ |
| 48 |
$restuct_attach = get_option('wpsc_restructured_attach_completed', 0); |
| 49 |
if( !$restuct_attach ){ |
| 50 |
if (! wp_next_scheduled ( 'wpsc_attachment_restructure')) { |
| 51 |
wp_schedule_event( time(), 'hourly', 'wpsc_attachment_restructure'); |
| 52 |
} |
| 53 |
include( WPSC_ABSPATH.'includes/class-wpsc-attachment-restructure.php' ); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
function define_constants() { |
| 58 |
$this->define('WPSC_STORE_URL', 'https://supportcandy.net'); |
| 59 |
$this->define('WPSC_PLUGIN_FILE', __FILE__); |
| 60 |
$this->define('WPSC_ABSPATH', dirname(__FILE__) . '/'); |
| 61 |
$this->define('WPSC_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 62 |
$this->define('WPSC_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
| 63 |
$this->define('WPSC_VERSION', $this->version); |
| 64 |
$this->define('WPSC_DB_VERSION', $this->db_version); |
| 65 |
} |
| 66 |
|
| 67 |
function load_textdomain(){ |
| 68 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'supportcandy' ); |
| 69 |
load_textdomain( 'supportcandy', WP_LANG_DIR . '/supportcandy/supportcandy-' . $locale . '.mo' ); |
| 70 |
load_plugin_textdomain( 'supportcandy', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' ); |
| 71 |
} |
| 72 |
|
| 73 |
public function includes() { |
| 74 |
include_once( WPSC_ABSPATH . 'includes/class-wpsc-install.php' ); |
| 75 |
include_once( WPSC_ABSPATH . 'includes/class-wpsc-ajax.php' ); |
| 76 |
include_once( WPSC_ABSPATH . 'includes/class-wpsc-functions.php' ); |
| 77 |
include_once( WPSC_ABSPATH . 'includes/class-wpsc-actions.php' ); |
| 78 |
include_once( WPSC_ABSPATH . 'includes/rest_api/class-rest-child.php' ); |
| 79 |
include_once( WPSC_ABSPATH . 'includes/rest_api/v1/class-rest-v1-helper.php' ); |
| 80 |
if ($this->is_request('admin')) { |
| 81 |
include_once( WPSC_ABSPATH . 'includes/class-wpsc-admin.php' ); |
| 82 |
} |
| 83 |
if ($this->is_request('frontend')) { |
| 84 |
include_once( WPSC_ABSPATH . 'includes/class-wpsc-frontend.php' ); |
| 85 |
} |
| 86 |
if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
| 87 |
include_once( WPSC_ABSPATH . 'includes/EDD_SL_Plugin_Updater.php' ); |
| 88 |
} |
| 89 |
if( get_option('wpsc_rest_api') ) { |
| 90 |
include_once( WPSC_ABSPATH . 'includes/rest_api/class-wpsc-rest-api-v1.php' ); |
| 91 |
} |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
private function define($name, $value) { |
| 96 |
if (!defined($name)) { |
| 97 |
define($name, $value); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
private function is_request($type) { |
| 102 |
switch ($type) { |
| 103 |
case 'admin' : |
| 104 |
return is_admin(); |
| 105 |
case 'frontend' : |
| 106 |
return (!is_admin() || defined('DOING_AJAX') ) && !defined('DOING_CRON'); |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
function wpsc_cron_schedule($schedules){ |
| 111 |
if(!isset($schedules["wpsc5min"])){ |
| 112 |
$schedules["wpsc5min"] = array( |
| 113 |
'interval' => 5*60, |
| 114 |
'display' => 'Once every 5 minute', |
| 115 |
); |
| 116 |
} |
| 117 |
return $schedules; |
| 118 |
} |
| 119 |
|
| 120 |
function wpsc_cron_job() { |
| 121 |
|
| 122 |
do_action('wpsc_cron'); |
| 123 |
} |
| 124 |
|
| 125 |
} |
| 126 |
|
| 127 |
endif; |
| 128 |
|
| 129 |
new Support_Candy(); |
| 130 |
|