chaty
Last commit date
admin
6 years ago
assets
6 years ago
frontend
6 years ago
icon
6 years ago
includes
6 years ago
views
6 years ago
cht-icons.php
6 years ago
readme.txt
6 years ago
cht-icons.php
157 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: Chaty |
| 4 | Contributors: galdub, tomeraharon |
| 5 | Description: Chat with your website visitors via their favorite channels. Show a chat icon on the bottom of your site and communicate with your customers. |
| 6 | Author: Premio |
| 7 | Author URI: https://premio.io/downloads/chaty/ |
| 8 | Version: 2.4.2 |
| 9 | License: GPL2 |
| 10 | */ |
| 11 | |
| 12 | if (!defined('ABSPATH')) { |
| 13 | wp_die(); // don't access directly |
| 14 | }; |
| 15 | |
| 16 | |
| 17 | define('CHT_FILE', __FILE__); // this file |
| 18 | define('CHT_OPT', 'chaty'); |
| 19 | define('CHT_DIR', dirname(CHT_FILE)); // our directory |
| 20 | define('CHT_ADMIN_INC', CHT_DIR . '/admin'); |
| 21 | define('CHT_FRONT_INC', CHT_DIR . '/frontend'); |
| 22 | define('CHT_INC', CHT_DIR . '/includes'); |
| 23 | define('CHT_PRO_URL', admin_url("admin.php?page=chaty-app-upgrade")); |
| 24 | define('CHT_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 25 | define('CHT_PLUGIN_BASE', plugin_basename(CHT_FILE)); |
| 26 | define('CHT_VERSION', "2.4.2"); |
| 27 | |
| 28 | if (!function_exists('wp_doing_ajax')) { |
| 29 | function wp_doing_ajax() |
| 30 | { |
| 31 | /** |
| 32 | * Filters whether the current request is a WordPress Ajax request. |
| 33 | * |
| 34 | * @since 4.7.0 |
| 35 | * |
| 36 | * @param bool $wp_doing_ajax Whether the current request is a WordPress Ajax request. |
| 37 | */ |
| 38 | return apply_filters('wp_doing_ajax', defined('DOING_AJAX') && DOING_AJAX); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | if(!function_exists("cht_clear_all_caches")) { |
| 43 | function cht_clear_all_caches() |
| 44 | { |
| 45 | try { |
| 46 | global $wp_fastest_cache; |
| 47 | // if W3 Total Cache is being used, clear the cache |
| 48 | if (function_exists('w3tc_flush_all')) { |
| 49 | w3tc_flush_all(); |
| 50 | /* if WP Super Cache is being used, clear the cache */ |
| 51 | } else if (function_exists('wp_cache_clean_cache')) { |
| 52 | global $file_prefix, $supercachedir; |
| 53 | if (empty($supercachedir) && function_exists('get_supercache_dir')) { |
| 54 | $supercachedir = get_supercache_dir(); |
| 55 | } |
| 56 | wp_cache_clean_cache($file_prefix); |
| 57 | } else if (class_exists('WpeCommon')) { |
| 58 | //be extra careful, just in case 3rd party changes things on us |
| 59 | if (method_exists('WpeCommon', 'purge_memcached')) { |
| 60 | //WpeCommon::purge_memcached(); |
| 61 | } |
| 62 | if (method_exists('WpeCommon', 'clear_maxcdn_cache')) { |
| 63 | //WpeCommon::clear_maxcdn_cache(); |
| 64 | } |
| 65 | if (method_exists('WpeCommon', 'purge_varnish_cache')) { |
| 66 | //WpeCommon::purge_varnish_cache(); |
| 67 | } |
| 68 | } else if (method_exists('WpFastestCache', 'deleteCache') && !empty($wp_fastest_cache)) { |
| 69 | $wp_fastest_cache->deleteCache(); |
| 70 | } else if (function_exists('rocket_clean_domain')) { |
| 71 | rocket_clean_domain(); |
| 72 | // Preload cache. |
| 73 | if (function_exists('run_rocket_sitemap_preload')) { |
| 74 | run_rocket_sitemap_preload(); |
| 75 | } |
| 76 | } else if (class_exists("autoptimizeCache") && method_exists("autoptimizeCache", "clearall")) { |
| 77 | autoptimizeCache::clearall(); |
| 78 | } else if (class_exists("LiteSpeed_Cache_API") && method_exists("autoptimizeCache", "purge_all")) { |
| 79 | LiteSpeed_Cache_API::purge_all(); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | if (class_exists( '\Hummingbird\Core\Utils' ) ) { |
| 84 | $modules = \Hummingbird\Core\Utils::get_active_cache_modules(); |
| 85 | foreach ( $modules as $module => $name ) { |
| 86 | $mod = \Hummingbird\Core\Utils::get_module( $module ); |
| 87 | if ( $mod->is_active() ) { |
| 88 | if ( 'minify' === $module ) { |
| 89 | $mod->clear_files(); |
| 90 | } else { |
| 91 | $mod->clear_cache(); |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } catch (Exception $e) { |
| 97 | return 1; |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | if(is_admin()) { |
| 103 | require_once CHT_INC . '/class-review-box.php'; |
| 104 | } |
| 105 | |
| 106 | require_once CHT_INC . '/class-cht-icons.php'; |
| 107 | require_once CHT_FRONT_INC . '/class-frontend.php'; |
| 108 | |
| 109 | require_once CHT_INC . '/class-affiliate.php'; |
| 110 | |
| 111 | |
| 112 | |
| 113 | add_action('activated_plugin', 'cht_activation_redirect'); |
| 114 | |
| 115 | register_activation_hook(CHT_FILE, 'cht_install', 10); |
| 116 | |
| 117 | function cht_install() |
| 118 | { |
| 119 | $widgetSize = get_option('cht_numb_slug'); |
| 120 | $cht_devices = get_option('cht_devices'); |
| 121 | |
| 122 | if (empty($widgetSize) && empty($cht_devices)) { |
| 123 | $options = array( |
| 124 | 'mobile' => '1', |
| 125 | 'desktop' => '1', |
| 126 | ); |
| 127 | |
| 128 | update_option('cht_devices', $options); |
| 129 | update_option('cht_active', '1'); |
| 130 | update_option('cht_position', 'right'); |
| 131 | update_option('cht_cta', 'Contact us'); |
| 132 | update_option('cht_numb_slug', ',Phone,Whatsapp'); |
| 133 | update_option('cht_social_whatsapp', ''); |
| 134 | update_option('cht_social_phone', ''); |
| 135 | update_option('cht_widget_size', '54'); |
| 136 | update_option('widget_icon', 'chat-base'); |
| 137 | update_option('cht_widget_img', ''); |
| 138 | update_option('cht_color', '#A886CD'); |
| 139 | } |
| 140 | |
| 141 | $option = get_option("Chaty_show_affiliate_box_after"); |
| 142 | if($option === false || empty($option)) { |
| 143 | $date = date("Y-m-d", strtotime("+5 days")); |
| 144 | add_option("Chaty_show_affiliate_box_after", $date); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | function cht_activation_redirect($plugin) |
| 149 | { |
| 150 | if ($plugin == plugin_basename(__FILE__)) { |
| 151 | $admin_url = esc_url(admin_url('admin.php?page=chaty-app')); |
| 152 | wp_redirect($admin_url); |
| 153 | exit; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 |