Changeset 2785528
- Timestamp:
- 09/15/2022 06:48:05 PM (4 years ago)
- Location:
- staffing-engine-chatbot
- Files:
-
- 6 added
- 4 deleted
- 12 edited
- 1 copied
-
tags/0.2.0 (copied) (copied from staffing-engine-chatbot/trunk)
-
tags/0.2.0/index.php (modified) (1 diff)
-
tags/0.2.0/readme.txt (modified) (2 diffs)
-
tags/0.2.0/src/includes/admin (deleted)
-
tags/0.2.0/src/includes/admin.php (added)
-
tags/0.2.0/src/includes/chatbot-embed.php (deleted)
-
tags/0.2.0/src/includes/embed.php (added)
-
tags/0.2.0/src/includes/plugin.php (modified) (9 diffs)
-
tags/0.2.0/src/includes/utils.php (added)
-
tags/0.2.0/src/public/css/se-chatbot.css (modified) (1 diff)
-
tags/0.2.0/src/public/js/se-chatbot.js (modified) (2 diffs)
-
tags/0.2.0/staffing-engine-chatbot.php (modified) (4 diffs)
-
trunk/index.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/includes/admin (deleted)
-
trunk/src/includes/admin.php (added)
-
trunk/src/includes/chatbot-embed.php (deleted)
-
trunk/src/includes/embed.php (added)
-
trunk/src/includes/plugin.php (modified) (9 diffs)
-
trunk/src/includes/utils.php (added)
-
trunk/src/public/css/se-chatbot.css (modified) (1 diff)
-
trunk/src/public/js/se-chatbot.js (modified) (2 diffs)
-
trunk/staffing-engine-chatbot.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
staffing-engine-chatbot/tags/0.2.0/index.php
r2784220 r2785528 1 <?php // Silence is golden.1 <?php // Silence is golden. -
staffing-engine-chatbot/tags/0.2.0/readme.txt
r2784220 r2785528 4 4 - Donate Link: https://staffingengine.ai/ 5 5 - Tags: chatbot, live chat, AI, staffing, recruiting 6 - Stable tag: 0. 1.06 - Stable tag: 0.2.0 7 7 - Requires at least: 5.5 8 8 - Tested up to: 6.0.1 … … 35 35 == Changelog == 36 36 37 = 0. 9.0 : 2022-09-12 =37 = 0.1.0 : 2022-09-12 = 38 38 39 39 Initial release candidate 40 40 41 = 0.2.0 : 2022-09-15 = 42 43 Bug fixes and better guards for overzealous wordpress theme styles 44 -
staffing-engine-chatbot/tags/0.2.0/src/includes/plugin.php
r2784220 r2785528 1 1 <?php 2 2 /** 3 * Staffing Engine - Chatbot 3 * Staffing Engine - Chatbot - Plugin class 4 4 * 5 5 * @link https://staffingengine.ai/ … … 7 7 * 8 8 * @package Staffing Engine - Chatbot 9 * @author Staffing Engine , Paul Bearnee9 * @author Staffing Enginee 10 10 * @copyright (c) 2022 staffing Engine 11 11 * … … 20 20 21 21 /** 22 * C lass Extension22 * Core plugin instance 23 23 * 24 24 * @final … … 27 27 final class Plugin { 28 28 /** 29 * Name 29 * Slug 30 * 31 * The plugin's slug 30 32 * 31 * @since 0. 1.033 * @since 0.2.0 32 34 * 33 35 * @var string 34 36 */ 35 const NAME= 'staffing-engine-chatbot';37 const SLUG = 'staffing-engine-chatbot'; 36 38 37 39 /** 38 * Constant Version 40 * Name 41 * 42 * The plugin's name, for rendering 39 43 * 40 * @since 0. 1.044 * @since 0.2.0 41 45 * 42 46 * @var string 43 47 */ 44 const VERSION = '0.1.0'; 48 const NAME = 'Staffing Engine - Chatbot'; 49 50 /** 51 * Plugin version 52 * 53 * @since 0.2.0 54 * 55 * @var string 56 */ 57 public static $version = ''; 58 59 /** 60 * Minimum supported php version 61 * 62 * @since 0.2.0 63 * 64 * @var string 65 */ 66 public static $min_supported_php = ''; 67 45 68 46 69 /** … … 60 83 * @var object 61 84 */ 62 pr ivate static $instance;85 protected static $instance = null; 63 86 64 87 /** … … 68 91 */ 69 92 function __construct() { 70 } 93 self::$version = SE_CHAT_VERSION; 94 self::$min_supported_php = SE_CHAT_MIN_PHP; 95 self::$directory = SE_CHAT_DIR; 71 96 72 /** 73 * Throw error on object clone. 74 * 75 * Singleton design pattern means is that there is a single object, 76 * and therefore, we don't want or allow the object to be cloned. 77 * 78 * @since 0.1.0 79 */ 80 public function __clone() { 81 _doing_it_wrong( __FUNCTION__, esc_html__( 'No can do! You may not clone an instance of the plugin.', self::NAME ), esc_attr( self::VERSION ) ); 82 } 97 Utils\start_debug_log(); 83 98 84 /** 85 * Disable unserializing of the class. 86 * 87 * Unserializing of the class is also forbidden in the singleton pattern. 88 * 89 * @since 0.1.0 90 */ 91 public function __wakeup() { 92 _doing_it_wrong( __FUNCTION__, esc_html__( 'No can do! You may not unserialize an instance of the plugin.', self::NAME ), esc_attr( self::VERSION ) ); 99 /** 100 * Staffing Engine Extension [Extension] Initialized 101 * 102 * Action to run immediately after a Staffing Engine Extension's Initialization Code Runs 103 * 104 * @since 0.1.0 105 */ 106 do_action( self::SLUG . '-initialized' ); 107 108 /** 109 * Staffing Engine Extension [Extension] Loaded 110 * 111 * Action to run immediately after a Staffing Engine Extension's Loading Code Runs (during WordPress's 112 * plugins_loaded action). 113 * 114 * @since 0.1.0 115 */ 116 do_action( self::SLUG . '-loaded' ); 93 117 } 94 118 … … 102 126 * @return object 103 127 */ 104 public static function instance() {128 public static function get_instance() { 105 129 if ( ! isset( self::$instance ) ) { 106 107 $instance = new self(); 108 109 $instance->properties(); 110 111 $instance->initialize(); 112 113 /** 114 * Staffing Engine Extension [Extension] Initialized 115 * 116 * Action to run immediately after a Staffing Engine Extension's Initialization Code Runs 117 * 118 * @since 0.1.0 119 */ 120 do_action( self::NAME . '-initialized' ); 121 122 add_action( 'plugins_loaded', [ $instance, 'textdomain' ] ); 123 124 self::load(); 125 126 /** 127 * Staffing Engine Extension [Extension] Loaded 128 * 129 * Action to run immediately after a Staffing Engine Extension's Loading Code Runs (during WordPress's 130 * plugins_loaded action). 131 * 132 * @since 0.1.0 133 */ 134 do_action( self::NAME . '-loaded' ); 135 136 self::$instance = $instance; 130 self::$instance = new self(); 137 131 } 138 132 … … 140 134 } 141 135 142 136 /** 137 * Fired when the plugin is activated. 138 * 139 * @since 1.0.0 140 */ 141 public static function activate() {} 143 142 144 143 /** 145 * Properties 144 * Fired when the plugin is deactivated. 145 * 146 * @since 1.0.0 147 */ 148 public static function deactivate() {} 149 150 /** 151 * Load the i18n text domain for the plugin 146 152 * 147 153 * @since 0.1.0 … … 149 155 * @return void 150 156 */ 151 protected function properties() : void { 152 self::$directory = SE_CHAT_DIR; 157 public static function load_textdomain() { 158 load_plugin_textdomain( self::SLUG, false, SE_CHAT_DIR_LANGUAGES ); 159 } 160 161 /** 162 * Throw error on object clone. 163 * 164 * Singleton design pattern means is that there is a single object, 165 * and therefore, we don't want or allow the object to be cloned. 166 * 167 * @since 0.1.0 168 */ 169 public function __clone() { 170 _doing_it_wrong( __FUNCTION__, esc_html__( 'No can do! You may not clone an instance of the plugin.', self::SLUG ), esc_attr( self::$version ) ); 153 171 } 154 172 155 173 /** 156 * Load Plugin174 * Disable unserializing of the class. 157 175 * 158 * @since 0.1.0 159 * 160 * @return void 161 */ 162 public static function load() : void { 163 164 if ( is_admin() ) { 165 new Admin\Settings(); 166 } 167 168 new ChatbotEmbed(); 169 } 170 171 172 /** 173 * Initialize 174 * 175 * Stuff to call when files are initially loaded. Be careful. 176 * 177 * @since 0.1.0 178 * 179 * @return void 180 */ 181 protected static function initialize() : void {} 182 183 /** 184 * Textdomain 176 * Unserializing of the class is also forbidden in the singleton pattern. 185 177 * 186 178 * @since 0.1.0 187 *188 * @return void189 179 */ 190 public static function textdomain() : void{191 load_plugin_textdomain( self::NAME, false, SE_CHAT_DIR_LANGUAGES);180 public function __wakeup() { 181 _doing_it_wrong( __FUNCTION__, esc_html__( 'No can do! You may not unserialize an instance of the plugin.', self::SLUG ), esc_attr( self::$version ) ); 192 182 } 193 183 } -
staffing-engine-chatbot/tags/0.2.0/src/public/css/se-chatbot.css
r2784220 r2785528 13 13 } 14 14 15 /* Overrides to ensure themes don't mess up our styling that exists outside of 16 the rwc iframe. This is particularly a problem with themes like salient 17 that use `!important` on generic elements like `button` */ 15 /* 16 * Overrides to ensure themes don't mess up our styling that exists outside of 17 * the rwc iframe. This is particularly a problem with themes like salient 18 * that use `!important` on generic elements like `button`. 19 * 20 * TODO: We might consider only loading these on demand, or as an option to "resolve 21 * common theme conflicts" or something since they aren't always necessary. 22 */ 18 23 #staffing-engine-chatbot .rwc-embed-thumb { 19 24 border-radius: 50% !important; -
staffing-engine-chatbot/tags/0.2.0/src/public/js/se-chatbot.js
r2784220 r2785528 1 1 (function () { 2 2 function initStaffingEngineChat() { 3 varRWC = richWebChat.default;3 const RWC = richWebChat.default; 4 4 5 if (SEChat) { SEChat.destroy(); } 6 7 var hasStaffingEngineChatConfig = !!staffingEngineChatConfig; 5 const hasStaffingEngineChatConfig = !!staffingEngineChatConfig; 8 6 9 7 if (!hasStaffingEngineChatConfig) { … … 11 9 } 12 10 13 varSEChat = new RWC(staffingEngineChatConfig);11 const SEChat = new RWC(staffingEngineChatConfig); 14 12 } 15 13 -
staffing-engine-chatbot/tags/0.2.0/staffing-engine-chatbot.php
r2784220 r2785528 2 2 /** 3 3 * @package Staffing Engine - Chatbot 4 * @author Staffing Engine , Paul Bearne4 * @author Staffing Engine 5 5 * @copyright (c) 2022 staffing Engine 6 6 * @license GPL-3.0-or-later 7 * @version 0. 1.07 * @version 0.2.0 8 8 * 9 9 * @wordpress-plugin … … 15 15 * License: GPL v3 or later 16 16 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html 17 * Version: 0. 1.017 * Version: 0.2.0 18 18 * Requires at least: 5.5 19 19 * Requires PHP: 7.1 … … 41 41 } 42 42 43 define( 'SE_CHAT_VERSION', '0.2.0' ); 44 45 define( 'SE_CHAT_MIN_PHP', '7.1.0' ); 46 43 47 // Set up a dev logging mode 44 define('SE_CHAT_DEV_MODE', getenv('SE_CHAT_DEV_MODE')); 48 define( 'SE_CHAT_DEV_MODE', getenv('SE_CHAT_DEV_MODE') ); 49 50 // Basename 51 define( 'SE_CHAT_BASENAME', plugin_basename( __FILE__ ) ); 45 52 46 53 // Dir globals 47 define('SE_CHAT_DIR', path_join(plugin_dir_path( __FILE__ ), 'src')); 48 define('SE_CHAT_DIR_INCLUDES', trailingslashit(path_join(SE_CHAT_DIR, 'includes'))); 49 define('SE_CHAT_DIR_BIN', trailingslashit(path_join(SE_CHAT_DIR, 'bin'))); 50 define('SE_CHAT_DIR_PUBLIC', trailingslashit(path_join(SE_CHAT_DIR, 'public'))); 51 define('SE_CHAT_DIR_LANGUAGES', trailingslashit(path_join(SE_CHAT_DIR, 'languages'))); 52 define('SE_CHAT_PUBLIC_ASSET_PATH', '/wp-content/plugins/staffing-engine-chatbot/src/public/'); 53 54 /** 55 * Starts the Plugin 56 * 57 * @since 0.1.0 58 */ 59 function run() { 60 load_dependencies(); 61 62 start_log(); 63 64 $run = new Plugin(); 65 $run->instance(); 66 } 54 define( 'SE_CHAT_DIR', path_join(plugin_dir_path( __FILE__ ), 'src') ); 55 define( 'SE_CHAT_DIR_INCLUDES', trailingslashit(path_join(SE_CHAT_DIR, 'includes')) ); 56 define( 'SE_CHAT_DIR_BIN', trailingslashit(path_join(SE_CHAT_DIR, 'bin')) ); 57 define( 'SE_CHAT_DIR_PUBLIC', trailingslashit(path_join(SE_CHAT_DIR, 'public')) ); 58 define( 'SE_CHAT_DIR_LANGUAGES', trailingslashit(path_join(SE_CHAT_DIR, 'languages')) ); 59 define( 'SE_CHAT_PUBLIC_ASSET_PATH', '/wp-content/plugins/staffing-engine-chatbot/src/public/' ); 67 60 68 61 /** … … 78 71 * @return void 79 72 */ 80 function load_dependencies(): void { 81 if ( file_exists( SE_CHAT_DIR_INCLUDES . 'plugin.php' ) ) { 82 include_once SE_CHAT_DIR_INCLUDES . 'plugin.php'; 83 } 73 function load_dependencies() { 74 // Includes 75 include_once SE_CHAT_DIR_INCLUDES . 'plugin.php'; 76 include_once SE_CHAT_DIR_INCLUDES . 'embed.php'; 77 include_once SE_CHAT_DIR_INCLUDES . 'admin.php'; 78 include_once SE_CHAT_DIR_INCLUDES . 'utils.php'; 84 79 85 if ( file_exists( SE_CHAT_DIR_INCLUDES . 'chatbot-embed.php' ) ) {86 require SE_CHAT_DIR_INCLUDES . 'chatbot-embed.php';87 }80 // Bin 81 include_once SE_CHAT_DIR_BIN . 'rational-option-pages.php'; 82 } 88 83 89 if ( file_exists( SE_CHAT_DIR_INCLUDES . 'admin/settings.php' ) ) { 90 require SE_CHAT_DIR_INCLUDES . 'admin/settings.php'; 91 } 84 /** 85 * Starts the Plugin 86 * 87 * @since 0.1.0 88 */ 89 function init() { 90 load_dependencies(); 92 91 93 if ( file_exists( SE_CHAT_DIR_BIN . 'rational-option-pages.php' ) ) { 94 require SE_CHAT_DIR_BIN . 'rational-option-pages.php'; 92 $plugin = Plugin::get_instance(); 93 94 Plugin::load_textdomain(); 95 96 if ( is_admin() ) { 97 $admin = Admin::get_instance(); 98 } else { 99 $embed = Embed::get_instance(); 95 100 } 96 101 } 97 102 98 /** 99 * Admin Notice if Unsupported PHP Version 100 * 101 * If we can't load, lets tell our admins. 102 * 103 * @since 0.1.0 104 */ 105 function admin_notice_php() { 106 $html = '<div class="notice notice-error is-dismissible"><p>%1$s</p></div>'; 107 $plugin = __( 'Staffing Engine - Chatbot'); 108 // Translators: This string is translated in the parent plugin and the placeholder is the name of the child plugin. 109 $message = __( 'This - %s Plugin requires PHP Version %s or better. Contact your web host to upgrade so you can use the features offered by this plugin.'); 110 printf( $html, esc_html( sprintf( $message, $plugin, '7.1.0' ) ) ); 111 } 112 113 if ( version_compare( PHP_VERSION, '7.1.0', '<' ) ) { 114 add_action( 'admin_notices', __NAMESPACE__ . '\admin_notice_php' ); 115 } else { 116 add_action( 'plugins_loaded', __NAMESPACE__ . '\run' ); 117 } 103 add_action( 'plugins_loaded', 'StaffingEngine\\Chatbot\\init' ); 118 104 119 105 /** 120 * Check if the plugin is running in dev mode, for logging 121 * 122 * @since 0.1.0 106 * Register activation and deactivation hooks 123 107 */ 124 function is_dev() { 125 if ( SE_CHAT_DEV_MODE == true ) { 126 return true; 127 } else { 128 return false; 129 } 130 } 131 132 /** 133 * Print to debug log when in dev mode 134 * 135 * @since 0.1.0 136 */ 137 function debug_log($message) { 138 if ( is_dev() ) { 139 error_log('[SE Chat] ' . $message); 140 } 141 } 142 143 /** 144 * Start the debug log on init when in dev mode 145 * 146 * @since 0.1.0 147 */ 148 function start_log() { 149 if ( is_dev() ) { 150 debug_log(' --- Dev Mode Enabled ---'); 151 debug_log(' --- Globals ---'); 152 debug_log('SE_CHAT_DIR' . SE_CHAT_DIR ); 153 debug_log('SE_CHAT_DIR_INCLUDES' . SE_CHAT_DIR_INCLUDES ); 154 debug_log('SE_CHAT_DIR_BIN' . SE_CHAT_DIR_BIN ); 155 debug_log('SE_CHAT_DIR_PUBLIC' . SE_CHAT_DIR_PUBLIC ); 156 debug_log('SE_CHAT_DIR_LANGUAGES' . SE_CHAT_DIR_LANGUAGES ); 157 debug_log('SE_CHAT_PUBLIC_ASSET_PATH' . SE_CHAT_PUBLIC_ASSET_PATH ); 158 } 159 } 108 register_activation_hook( __FILE__, array( 'StaffingEngine\\Chatbot\\Plugin', 'activate' ) ); 109 register_deactivation_hook( __FILE__, array( 'StaffingEngine\\Chatbot\\Plugin', 'deactivate' ) ); -
staffing-engine-chatbot/trunk/index.php
r2784220 r2785528 1 <?php // Silence is golden.1 <?php // Silence is golden. -
staffing-engine-chatbot/trunk/readme.txt
r2784220 r2785528 4 4 - Donate Link: https://staffingengine.ai/ 5 5 - Tags: chatbot, live chat, AI, staffing, recruiting 6 - Stable tag: 0. 1.06 - Stable tag: 0.2.0 7 7 - Requires at least: 5.5 8 8 - Tested up to: 6.0.1 … … 35 35 == Changelog == 36 36 37 = 0. 9.0 : 2022-09-12 =37 = 0.1.0 : 2022-09-12 = 38 38 39 39 Initial release candidate 40 40 41 = 0.2.0 : 2022-09-15 = 42 43 Bug fixes and better guards for overzealous wordpress theme styles 44 -
staffing-engine-chatbot/trunk/src/includes/plugin.php
r2784220 r2785528 1 1 <?php 2 2 /** 3 * Staffing Engine - Chatbot 3 * Staffing Engine - Chatbot - Plugin class 4 4 * 5 5 * @link https://staffingengine.ai/ … … 7 7 * 8 8 * @package Staffing Engine - Chatbot 9 * @author Staffing Engine , Paul Bearnee9 * @author Staffing Enginee 10 10 * @copyright (c) 2022 staffing Engine 11 11 * … … 20 20 21 21 /** 22 * C lass Extension22 * Core plugin instance 23 23 * 24 24 * @final … … 27 27 final class Plugin { 28 28 /** 29 * Name 29 * Slug 30 * 31 * The plugin's slug 30 32 * 31 * @since 0. 1.033 * @since 0.2.0 32 34 * 33 35 * @var string 34 36 */ 35 const NAME= 'staffing-engine-chatbot';37 const SLUG = 'staffing-engine-chatbot'; 36 38 37 39 /** 38 * Constant Version 40 * Name 41 * 42 * The plugin's name, for rendering 39 43 * 40 * @since 0. 1.044 * @since 0.2.0 41 45 * 42 46 * @var string 43 47 */ 44 const VERSION = '0.1.0'; 48 const NAME = 'Staffing Engine - Chatbot'; 49 50 /** 51 * Plugin version 52 * 53 * @since 0.2.0 54 * 55 * @var string 56 */ 57 public static $version = ''; 58 59 /** 60 * Minimum supported php version 61 * 62 * @since 0.2.0 63 * 64 * @var string 65 */ 66 public static $min_supported_php = ''; 67 45 68 46 69 /** … … 60 83 * @var object 61 84 */ 62 pr ivate static $instance;85 protected static $instance = null; 63 86 64 87 /** … … 68 91 */ 69 92 function __construct() { 70 } 93 self::$version = SE_CHAT_VERSION; 94 self::$min_supported_php = SE_CHAT_MIN_PHP; 95 self::$directory = SE_CHAT_DIR; 71 96 72 /** 73 * Throw error on object clone. 74 * 75 * Singleton design pattern means is that there is a single object, 76 * and therefore, we don't want or allow the object to be cloned. 77 * 78 * @since 0.1.0 79 */ 80 public function __clone() { 81 _doing_it_wrong( __FUNCTION__, esc_html__( 'No can do! You may not clone an instance of the plugin.', self::NAME ), esc_attr( self::VERSION ) ); 82 } 97 Utils\start_debug_log(); 83 98 84 /** 85 * Disable unserializing of the class. 86 * 87 * Unserializing of the class is also forbidden in the singleton pattern. 88 * 89 * @since 0.1.0 90 */ 91 public function __wakeup() { 92 _doing_it_wrong( __FUNCTION__, esc_html__( 'No can do! You may not unserialize an instance of the plugin.', self::NAME ), esc_attr( self::VERSION ) ); 99 /** 100 * Staffing Engine Extension [Extension] Initialized 101 * 102 * Action to run immediately after a Staffing Engine Extension's Initialization Code Runs 103 * 104 * @since 0.1.0 105 */ 106 do_action( self::SLUG . '-initialized' ); 107 108 /** 109 * Staffing Engine Extension [Extension] Loaded 110 * 111 * Action to run immediately after a Staffing Engine Extension's Loading Code Runs (during WordPress's 112 * plugins_loaded action). 113 * 114 * @since 0.1.0 115 */ 116 do_action( self::SLUG . '-loaded' ); 93 117 } 94 118 … … 102 126 * @return object 103 127 */ 104 public static function instance() {128 public static function get_instance() { 105 129 if ( ! isset( self::$instance ) ) { 106 107 $instance = new self(); 108 109 $instance->properties(); 110 111 $instance->initialize(); 112 113 /** 114 * Staffing Engine Extension [Extension] Initialized 115 * 116 * Action to run immediately after a Staffing Engine Extension's Initialization Code Runs 117 * 118 * @since 0.1.0 119 */ 120 do_action( self::NAME . '-initialized' ); 121 122 add_action( 'plugins_loaded', [ $instance, 'textdomain' ] ); 123 124 self::load(); 125 126 /** 127 * Staffing Engine Extension [Extension] Loaded 128 * 129 * Action to run immediately after a Staffing Engine Extension's Loading Code Runs (during WordPress's 130 * plugins_loaded action). 131 * 132 * @since 0.1.0 133 */ 134 do_action( self::NAME . '-loaded' ); 135 136 self::$instance = $instance; 130 self::$instance = new self(); 137 131 } 138 132 … … 140 134 } 141 135 142 136 /** 137 * Fired when the plugin is activated. 138 * 139 * @since 1.0.0 140 */ 141 public static function activate() {} 143 142 144 143 /** 145 * Properties 144 * Fired when the plugin is deactivated. 145 * 146 * @since 1.0.0 147 */ 148 public static function deactivate() {} 149 150 /** 151 * Load the i18n text domain for the plugin 146 152 * 147 153 * @since 0.1.0 … … 149 155 * @return void 150 156 */ 151 protected function properties() : void { 152 self::$directory = SE_CHAT_DIR; 157 public static function load_textdomain() { 158 load_plugin_textdomain( self::SLUG, false, SE_CHAT_DIR_LANGUAGES ); 159 } 160 161 /** 162 * Throw error on object clone. 163 * 164 * Singleton design pattern means is that there is a single object, 165 * and therefore, we don't want or allow the object to be cloned. 166 * 167 * @since 0.1.0 168 */ 169 public function __clone() { 170 _doing_it_wrong( __FUNCTION__, esc_html__( 'No can do! You may not clone an instance of the plugin.', self::SLUG ), esc_attr( self::$version ) ); 153 171 } 154 172 155 173 /** 156 * Load Plugin174 * Disable unserializing of the class. 157 175 * 158 * @since 0.1.0 159 * 160 * @return void 161 */ 162 public static function load() : void { 163 164 if ( is_admin() ) { 165 new Admin\Settings(); 166 } 167 168 new ChatbotEmbed(); 169 } 170 171 172 /** 173 * Initialize 174 * 175 * Stuff to call when files are initially loaded. Be careful. 176 * 177 * @since 0.1.0 178 * 179 * @return void 180 */ 181 protected static function initialize() : void {} 182 183 /** 184 * Textdomain 176 * Unserializing of the class is also forbidden in the singleton pattern. 185 177 * 186 178 * @since 0.1.0 187 *188 * @return void189 179 */ 190 public static function textdomain() : void{191 load_plugin_textdomain( self::NAME, false, SE_CHAT_DIR_LANGUAGES);180 public function __wakeup() { 181 _doing_it_wrong( __FUNCTION__, esc_html__( 'No can do! You may not unserialize an instance of the plugin.', self::SLUG ), esc_attr( self::$version ) ); 192 182 } 193 183 } -
staffing-engine-chatbot/trunk/src/public/css/se-chatbot.css
r2784220 r2785528 13 13 } 14 14 15 /* Overrides to ensure themes don't mess up our styling that exists outside of 16 the rwc iframe. This is particularly a problem with themes like salient 17 that use `!important` on generic elements like `button` */ 15 /* 16 * Overrides to ensure themes don't mess up our styling that exists outside of 17 * the rwc iframe. This is particularly a problem with themes like salient 18 * that use `!important` on generic elements like `button`. 19 * 20 * TODO: We might consider only loading these on demand, or as an option to "resolve 21 * common theme conflicts" or something since they aren't always necessary. 22 */ 18 23 #staffing-engine-chatbot .rwc-embed-thumb { 19 24 border-radius: 50% !important; -
staffing-engine-chatbot/trunk/src/public/js/se-chatbot.js
r2784220 r2785528 1 1 (function () { 2 2 function initStaffingEngineChat() { 3 varRWC = richWebChat.default;3 const RWC = richWebChat.default; 4 4 5 if (SEChat) { SEChat.destroy(); } 6 7 var hasStaffingEngineChatConfig = !!staffingEngineChatConfig; 5 const hasStaffingEngineChatConfig = !!staffingEngineChatConfig; 8 6 9 7 if (!hasStaffingEngineChatConfig) { … … 11 9 } 12 10 13 varSEChat = new RWC(staffingEngineChatConfig);11 const SEChat = new RWC(staffingEngineChatConfig); 14 12 } 15 13 -
staffing-engine-chatbot/trunk/staffing-engine-chatbot.php
r2784220 r2785528 2 2 /** 3 3 * @package Staffing Engine - Chatbot 4 * @author Staffing Engine , Paul Bearne4 * @author Staffing Engine 5 5 * @copyright (c) 2022 staffing Engine 6 6 * @license GPL-3.0-or-later 7 * @version 0. 1.07 * @version 0.2.0 8 8 * 9 9 * @wordpress-plugin … … 15 15 * License: GPL v3 or later 16 16 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html 17 * Version: 0. 1.017 * Version: 0.2.0 18 18 * Requires at least: 5.5 19 19 * Requires PHP: 7.1 … … 41 41 } 42 42 43 define( 'SE_CHAT_VERSION', '0.2.0' ); 44 45 define( 'SE_CHAT_MIN_PHP', '7.1.0' ); 46 43 47 // Set up a dev logging mode 44 define('SE_CHAT_DEV_MODE', getenv('SE_CHAT_DEV_MODE')); 48 define( 'SE_CHAT_DEV_MODE', getenv('SE_CHAT_DEV_MODE') ); 49 50 // Basename 51 define( 'SE_CHAT_BASENAME', plugin_basename( __FILE__ ) ); 45 52 46 53 // Dir globals 47 define('SE_CHAT_DIR', path_join(plugin_dir_path( __FILE__ ), 'src')); 48 define('SE_CHAT_DIR_INCLUDES', trailingslashit(path_join(SE_CHAT_DIR, 'includes'))); 49 define('SE_CHAT_DIR_BIN', trailingslashit(path_join(SE_CHAT_DIR, 'bin'))); 50 define('SE_CHAT_DIR_PUBLIC', trailingslashit(path_join(SE_CHAT_DIR, 'public'))); 51 define('SE_CHAT_DIR_LANGUAGES', trailingslashit(path_join(SE_CHAT_DIR, 'languages'))); 52 define('SE_CHAT_PUBLIC_ASSET_PATH', '/wp-content/plugins/staffing-engine-chatbot/src/public/'); 53 54 /** 55 * Starts the Plugin 56 * 57 * @since 0.1.0 58 */ 59 function run() { 60 load_dependencies(); 61 62 start_log(); 63 64 $run = new Plugin(); 65 $run->instance(); 66 } 54 define( 'SE_CHAT_DIR', path_join(plugin_dir_path( __FILE__ ), 'src') ); 55 define( 'SE_CHAT_DIR_INCLUDES', trailingslashit(path_join(SE_CHAT_DIR, 'includes')) ); 56 define( 'SE_CHAT_DIR_BIN', trailingslashit(path_join(SE_CHAT_DIR, 'bin')) ); 57 define( 'SE_CHAT_DIR_PUBLIC', trailingslashit(path_join(SE_CHAT_DIR, 'public')) ); 58 define( 'SE_CHAT_DIR_LANGUAGES', trailingslashit(path_join(SE_CHAT_DIR, 'languages')) ); 59 define( 'SE_CHAT_PUBLIC_ASSET_PATH', '/wp-content/plugins/staffing-engine-chatbot/src/public/' ); 67 60 68 61 /** … … 78 71 * @return void 79 72 */ 80 function load_dependencies(): void { 81 if ( file_exists( SE_CHAT_DIR_INCLUDES . 'plugin.php' ) ) { 82 include_once SE_CHAT_DIR_INCLUDES . 'plugin.php'; 83 } 73 function load_dependencies() { 74 // Includes 75 include_once SE_CHAT_DIR_INCLUDES . 'plugin.php'; 76 include_once SE_CHAT_DIR_INCLUDES . 'embed.php'; 77 include_once SE_CHAT_DIR_INCLUDES . 'admin.php'; 78 include_once SE_CHAT_DIR_INCLUDES . 'utils.php'; 84 79 85 if ( file_exists( SE_CHAT_DIR_INCLUDES . 'chatbot-embed.php' ) ) {86 require SE_CHAT_DIR_INCLUDES . 'chatbot-embed.php';87 }80 // Bin 81 include_once SE_CHAT_DIR_BIN . 'rational-option-pages.php'; 82 } 88 83 89 if ( file_exists( SE_CHAT_DIR_INCLUDES . 'admin/settings.php' ) ) { 90 require SE_CHAT_DIR_INCLUDES . 'admin/settings.php'; 91 } 84 /** 85 * Starts the Plugin 86 * 87 * @since 0.1.0 88 */ 89 function init() { 90 load_dependencies(); 92 91 93 if ( file_exists( SE_CHAT_DIR_BIN . 'rational-option-pages.php' ) ) { 94 require SE_CHAT_DIR_BIN . 'rational-option-pages.php'; 92 $plugin = Plugin::get_instance(); 93 94 Plugin::load_textdomain(); 95 96 if ( is_admin() ) { 97 $admin = Admin::get_instance(); 98 } else { 99 $embed = Embed::get_instance(); 95 100 } 96 101 } 97 102 98 /** 99 * Admin Notice if Unsupported PHP Version 100 * 101 * If we can't load, lets tell our admins. 102 * 103 * @since 0.1.0 104 */ 105 function admin_notice_php() { 106 $html = '<div class="notice notice-error is-dismissible"><p>%1$s</p></div>'; 107 $plugin = __( 'Staffing Engine - Chatbot'); 108 // Translators: This string is translated in the parent plugin and the placeholder is the name of the child plugin. 109 $message = __( 'This - %s Plugin requires PHP Version %s or better. Contact your web host to upgrade so you can use the features offered by this plugin.'); 110 printf( $html, esc_html( sprintf( $message, $plugin, '7.1.0' ) ) ); 111 } 112 113 if ( version_compare( PHP_VERSION, '7.1.0', '<' ) ) { 114 add_action( 'admin_notices', __NAMESPACE__ . '\admin_notice_php' ); 115 } else { 116 add_action( 'plugins_loaded', __NAMESPACE__ . '\run' ); 117 } 103 add_action( 'plugins_loaded', 'StaffingEngine\\Chatbot\\init' ); 118 104 119 105 /** 120 * Check if the plugin is running in dev mode, for logging 121 * 122 * @since 0.1.0 106 * Register activation and deactivation hooks 123 107 */ 124 function is_dev() { 125 if ( SE_CHAT_DEV_MODE == true ) { 126 return true; 127 } else { 128 return false; 129 } 130 } 131 132 /** 133 * Print to debug log when in dev mode 134 * 135 * @since 0.1.0 136 */ 137 function debug_log($message) { 138 if ( is_dev() ) { 139 error_log('[SE Chat] ' . $message); 140 } 141 } 142 143 /** 144 * Start the debug log on init when in dev mode 145 * 146 * @since 0.1.0 147 */ 148 function start_log() { 149 if ( is_dev() ) { 150 debug_log(' --- Dev Mode Enabled ---'); 151 debug_log(' --- Globals ---'); 152 debug_log('SE_CHAT_DIR' . SE_CHAT_DIR ); 153 debug_log('SE_CHAT_DIR_INCLUDES' . SE_CHAT_DIR_INCLUDES ); 154 debug_log('SE_CHAT_DIR_BIN' . SE_CHAT_DIR_BIN ); 155 debug_log('SE_CHAT_DIR_PUBLIC' . SE_CHAT_DIR_PUBLIC ); 156 debug_log('SE_CHAT_DIR_LANGUAGES' . SE_CHAT_DIR_LANGUAGES ); 157 debug_log('SE_CHAT_PUBLIC_ASSET_PATH' . SE_CHAT_PUBLIC_ASSET_PATH ); 158 } 159 } 108 register_activation_hook( __FILE__, array( 'StaffingEngine\\Chatbot\\Plugin', 'activate' ) ); 109 register_deactivation_hook( __FILE__, array( 'StaffingEngine\\Chatbot\\Plugin', 'deactivate' ) );
Note: See TracChangeset
for help on using the changeset viewer.