Current Path : /storage/v11800/andslite-new/public_html/wp-content/plugins/commercegurus-commercekit/ |
Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64
|
Current File : /storage/v11800/andslite-new/public_html/wp-content/plugins/commercegurus-commercekit/commercegurus-commercekit.php |
<?php
/**
* CommerceGurus Commercekit
*
* @link https://www.commercegurus.com
* @since 1.1.0
* @package CommerceGurus_Commercekit
*
* @wordpress-plugin
* Plugin Name: CommerceGurus Commercekit
* Plugin URI: https://www.commercegurus.com
* Description: CommerceGurus Commercekit
* Version: 1.1.0
* Author: CommerceGurus
* Author URI: https://www.commercegurus.com
* Requires at least: 4.9.7
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: commercegurus-commercekit
* Domain Path: /languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly....
}
/**
* Required minimums and constants
*/
define( 'CGKIT_MIN_WC_VER', '4.0' );
define( 'CGKIT_CSS_JS_VER', '1.1.0' );
define( 'CGKIT_BASE_PATH', plugin_dir_path( __FILE__ ) );
if ( ! defined( 'CKIT_URI' ) ) {
define( 'CKIT_URI', plugin_dir_url( __FILE__ ) );
}
global $commercekit_db_version;
$commercekit_db_version = '1.1.0';
require_once dirname( __FILE__ ) . '/includes/class-commercegurus-commercekit.php';
require_once dirname( __FILE__ ) . '/includes/admin-settings.php';
require_once dirname( __FILE__ ) . '/includes/modules.php';
/**
* Add site CSS and JS scripts
*/
function commercekit_scripts() {
global $post;
$commercekit_options = get_option( 'commercekit', array() );
if ( isset( $commercekit_options['wishlist'] ) && 1 === (int) $commercekit_options['wishlist'] ) {
wp_enqueue_style( 'commercekit-wishlist-css', plugins_url( 'assets/css/wishlist.css', __FILE__ ), array(), CGKIT_CSS_JS_VER );
wp_enqueue_script( 'commercekit-wishlist', plugins_url( 'assets/js/wishlist.js', __FILE__ ), array(), CGKIT_CSS_JS_VER, true );
}
if ( isset( $commercekit_options['ajax_search'] ) && 1 === (int) $commercekit_options['ajax_search'] ) {
wp_enqueue_style( 'commercekit-ajax-search-css', plugins_url( 'assets/css/ajax-search.css', __FILE__ ), array(), CGKIT_CSS_JS_VER );
wp_enqueue_script( 'commercekit-ajax-search', plugins_url( 'assets/js/ajax-search.js', __FILE__ ), array(), CGKIT_CSS_JS_VER, true );
}
}
add_action( 'wp_enqueue_scripts', 'commercekit_scripts' );
/**
* Commercekit js variables
*/
function commercekit_js_variables() {
$commercekit_ajs = array( 'ajax_url' => admin_url( 'admin-ajax.php' ) );
if ( function_exists( 'commercekit_ajs_options' ) ) {
$commercekit_ajs = commercekit_ajs_options();
}
wp_localize_script( 'commercekit-script', 'commercekit_ajs', $commercekit_ajs );
?>
<script type="text/javascript">
var commercekit_ajs = <?php echo wp_json_encode( $commercekit_ajs ); ?>
</script>
<?php
}
add_action( 'wp_head', 'commercekit_js_variables' );
/**
* Add admin CSS and JS scripts
*/
function commercekit_admin_scripts() {
$screen = get_current_screen();
if ( 'toplevel_page_commercekit' === $screen->base ) {
wp_enqueue_style( 'commercekit-select2-style', plugins_url( 'assets/css/select2.css', __FILE__ ), array(), CGKIT_CSS_JS_VER );
wp_enqueue_style( 'commercekit-admin-style', plugins_url( 'assets/css/admin.css', __FILE__ ), array(), CGKIT_CSS_JS_VER );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'commercekit-select2-script', plugins_url( 'assets/js/select2.js', __FILE__ ), array(), CGKIT_CSS_JS_VER, true );
wp_enqueue_script( 'commercekit-admin-script', plugins_url( 'assets/js/admin.js', __FILE__ ), array(), CGKIT_CSS_JS_VER, true );
}
}
add_action( 'admin_enqueue_scripts', 'commercekit_admin_scripts' );
/**
* Commercekit create plugin tables
*/
function commercekit_create_plugin_tables() {
global $wpdb, $commercekit_db_version;
$installed_version = (string) get_option( 'commercekit_db_version' );
if ( $installed_version === $commercekit_db_version ) {
return;
}
$table_name = 'commercekit_waitlist';
$cgw_table = $wpdb->prefix . $table_name;
$get_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $cgw_table ) ); // db call ok; no-cache ok.
if ( $cgw_table !== $get_table ) {
$sql = 'CREATE TABLE IF NOT EXISTS `' . $cgw_table . '` ( ';
$sql .= '`id` INT(11) NOT NULL AUTO_INCREMENT, ';
$sql .= '`email` VARCHAR(255) NOT NULL, ';
$sql .= '`product_id` INT(11) NOT NULL, ';
$sql .= '`created` BIGINT(20) NOT NULL, ';
$sql .= 'PRIMARY KEY (`id`) ';
$sql .= '); ';
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
dbDelta( $sql ); // db call ok; no-cache ok.
}
$table_name = 'commercekit_wishlist';
$cgw_table = $wpdb->prefix . $table_name;
$get_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $cgw_table ) ); // db call ok; no-cache ok.
if ( $cgw_table !== $get_table ) {
$sql = 'CREATE TABLE IF NOT EXISTS `' . $cgw_table . '` ( ';
$sql .= '`id` INT(11) NOT NULL AUTO_INCREMENT, ';
$sql .= '`session_key` VARCHAR(100) NOT NULL, ';
$sql .= 'PRIMARY KEY (`id`) ';
$sql .= '); ';
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
dbDelta( $sql ); // db call ok; no-cache ok.
}
$table_name = 'commercekit_wishlist_items';
$cgw_table = $wpdb->prefix . $table_name;
$get_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $cgw_table ) ); // db call ok; no-cache ok.
if ( $cgw_table !== $get_table ) {
$sql = 'CREATE TABLE IF NOT EXISTS `' . $cgw_table . '` ( ';
$sql .= '`id` INT(11) NOT NULL AUTO_INCREMENT, ';
$sql .= '`user_id` INT(11) NOT NULL, ';
$sql .= '`list_id` INT(11) NOT NULL, ';
$sql .= '`product_id` INT(11) NOT NULL, ';
$sql .= '`created` BIGINT(20) NOT NULL, ';
$sql .= 'PRIMARY KEY (`id`) ';
$sql .= '); ';
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
dbDelta( $sql ); // db call ok; no-cache ok.
}
update_option( 'commercekit_db_version', $commercekit_db_version );
}
register_activation_hook( __FILE__, 'commercekit_create_plugin_tables' );
/**
* Commercekit update db check
*/
function commercekit_update_db_check() {
global $commercekit_db_version;
if ( (string) get_option( 'commercekit_db_version' ) !== $commercekit_db_version ) {
commercekit_create_plugin_tables();
}
}
add_action( 'plugins_loaded', 'commercekit_update_db_check' );
/**
* Commercekit admin notices
*/
function commercekit_admin_notices() {
global $commerce_gurus_commercekit;
$commerce_gurus_commercekit->check_environment();
$commerce_gurus_commercekit->admin_notices();
}
add_action( 'admin_notices', 'commercekit_admin_notices' );