Plugin Directory

Changeset 2785528


Ignore:
Timestamp:
09/15/2022 06:48:05 PM (4 years ago)
Author:
staffingengine
Message:

Update to version 0.2.0 from GitHub

Location:
staffing-engine-chatbot
Files:
6 added
4 deleted
12 edited
1 copied

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  
    44- Donate Link: https://staffingengine.ai/
    55- Tags: chatbot, live chat, AI, staffing, recruiting
    6 - Stable tag: 0.1.0
     6- Stable tag: 0.2.0
    77- Requires at least: 5.5
    88- Tested up to: 6.0.1
     
    3535== Changelog ==
    3636
    37 = 0.9.0 : 2022-09-12 =
     37= 0.1.0 : 2022-09-12 =
    3838
    3939Initial release candidate
    4040
     41= 0.2.0 : 2022-09-15 =
     42
     43Bug fixes and better guards for overzealous wordpress theme styles
     44
  • staffing-engine-chatbot/tags/0.2.0/src/includes/plugin.php

    r2784220 r2785528  
    11<?php
    22/**
    3  * Staffing Engine - Chatbot
     3 * Staffing Engine - Chatbot - Plugin class
    44 *
    55 * @link        https://staffingengine.ai/
     
    77 *
    88 * @package     Staffing Engine - Chatbot
    9  * @author      Staffing Engine, Paul Bearnee
     9 * @author      Staffing Enginee
    1010 * @copyright   (c) 2022 staffing Engine
    1111 *
     
    2020
    2121/**
    22  * Class Extension
     22 * Core plugin instance
    2323 *
    2424 * @final
     
    2727final class Plugin {
    2828    /**
    29      * Name
     29     * Slug
     30   *
     31   * The plugin's slug
    3032     *
    31      * @since 0.1.0
     33     * @since 0.2.0
    3234     *
    3335     * @var string
    3436     */
    35     const NAME = 'staffing-engine-chatbot';
     37    const SLUG = 'staffing-engine-chatbot';
    3638
    3739    /**
    38      * Constant Version
     40     * Name
     41   *
     42   * The plugin's name, for rendering
    3943     *
    40      * @since 0.1.0
     44     * @since 0.2.0
    4145     *
    4246     * @var string
    4347     */
    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
    4568
    4669    /**
     
    6083     * @var object
    6184     */
    62     private static $instance;
     85    protected static $instance = null;
    6386
    6487    /**
     
    6891     */
    6992    function __construct() {
    70     }
     93    self::$version = SE_CHAT_VERSION;
     94    self::$min_supported_php = SE_CHAT_MIN_PHP;
     95    self::$directory = SE_CHAT_DIR;
    7196
    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();
    8398
    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' );
    93117    }
    94118
     
    102126     * @return object
    103127     */
    104     public static function instance() {
     128    public static function get_instance() {
    105129        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();
    137131        }
    138132
     
    140134    }
    141135
    142 
     136  /**
     137     * Fired when the plugin is activated.
     138     *
     139     * @since    1.0.0
     140     */
     141    public static function activate() {}
    143142
    144143    /**
    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
    146152     *
    147153     * @since  0.1.0
     
    149155     * @return void
    150156     */
    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 ) );
    153171    }
    154172
    155173    /**
    156      * Load Plugin
     174     * Disable unserializing of the class.
    157175     *
    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.
    185177     *
    186178     * @since  0.1.0
    187      *
    188      * @return void
    189179     */
    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 ) );
    192182    }
    193183}
  • staffing-engine-chatbot/tags/0.2.0/src/public/css/se-chatbot.css

    r2784220 r2785528  
    1313}
    1414
    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 */
    1823#staffing-engine-chatbot .rwc-embed-thumb {
    1924  border-radius: 50% !important;
  • staffing-engine-chatbot/tags/0.2.0/src/public/js/se-chatbot.js

    r2784220 r2785528  
    11(function () {
    22  function initStaffingEngineChat() {
    3     var RWC = richWebChat.default;
     3    const RWC = richWebChat.default;
    44
    5     if (SEChat) { SEChat.destroy(); }
    6 
    7     var hasStaffingEngineChatConfig = !!staffingEngineChatConfig;
     5    const hasStaffingEngineChatConfig = !!staffingEngineChatConfig;
    86
    97    if (!hasStaffingEngineChatConfig) {
     
    119    }
    1210
    13     var SEChat = new RWC(staffingEngineChatConfig);
     11    const SEChat = new RWC(staffingEngineChatConfig);
    1412  }
    1513
  • staffing-engine-chatbot/tags/0.2.0/staffing-engine-chatbot.php

    r2784220 r2785528  
    22/**
    33 * @package     Staffing Engine - Chatbot
    4  * @author      Staffing Engine, Paul Bearne
     4 * @author      Staffing Engine
    55 * @copyright   (c) 2022 staffing Engine
    66 * @license     GPL-3.0-or-later
    7  * @version     0.1.0
     7 * @version     0.2.0
    88 *
    99 * @wordpress-plugin
     
    1515 * License: GPL v3 or later
    1616 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
    17  * Version: 0.1.0
     17 * Version: 0.2.0
    1818 * Requires at least: 5.5
    1919 * Requires PHP: 7.1
     
    4141}
    4242
     43define( 'SE_CHAT_VERSION', '0.2.0' );
     44
     45define( 'SE_CHAT_MIN_PHP', '7.1.0' );
     46
    4347// Set up a dev logging mode
    44 define('SE_CHAT_DEV_MODE', getenv('SE_CHAT_DEV_MODE'));
     48define( 'SE_CHAT_DEV_MODE', getenv('SE_CHAT_DEV_MODE') );
     49
     50// Basename
     51define( 'SE_CHAT_BASENAME', plugin_basename( __FILE__ ) );
    4552
    4653// 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 }
     54define( 'SE_CHAT_DIR', path_join(plugin_dir_path( __FILE__ ), 'src') );
     55define( 'SE_CHAT_DIR_INCLUDES', trailingslashit(path_join(SE_CHAT_DIR, 'includes')) );
     56define( 'SE_CHAT_DIR_BIN', trailingslashit(path_join(SE_CHAT_DIR, 'bin')) );
     57define( 'SE_CHAT_DIR_PUBLIC', trailingslashit(path_join(SE_CHAT_DIR, 'public')) );
     58define( 'SE_CHAT_DIR_LANGUAGES', trailingslashit(path_join(SE_CHAT_DIR, 'languages')) );
     59define( 'SE_CHAT_PUBLIC_ASSET_PATH', '/wp-content/plugins/staffing-engine-chatbot/src/public/' );
    6760
    6861/**
     
    7871 * @return void
    7972 */
    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   }
     73function 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';
    8479
    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}
    8883
    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 */
     89function init() {
     90  load_dependencies();
    9291
    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();
    95100  }
    96101}
    97102
    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 }
     103add_action( 'plugins_loaded', 'StaffingEngine\\Chatbot\\init' );
    118104
    119105/**
    120  * Check if the plugin is running in dev mode, for logging
    121  *
    122  * @since 0.1.0
     106 * Register activation and deactivation hooks
    123107 */
    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 }
     108register_activation_hook( __FILE__, array( 'StaffingEngine\\Chatbot\\Plugin', 'activate' ) );
     109register_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  
    44- Donate Link: https://staffingengine.ai/
    55- Tags: chatbot, live chat, AI, staffing, recruiting
    6 - Stable tag: 0.1.0
     6- Stable tag: 0.2.0
    77- Requires at least: 5.5
    88- Tested up to: 6.0.1
     
    3535== Changelog ==
    3636
    37 = 0.9.0 : 2022-09-12 =
     37= 0.1.0 : 2022-09-12 =
    3838
    3939Initial release candidate
    4040
     41= 0.2.0 : 2022-09-15 =
     42
     43Bug fixes and better guards for overzealous wordpress theme styles
     44
  • staffing-engine-chatbot/trunk/src/includes/plugin.php

    r2784220 r2785528  
    11<?php
    22/**
    3  * Staffing Engine - Chatbot
     3 * Staffing Engine - Chatbot - Plugin class
    44 *
    55 * @link        https://staffingengine.ai/
     
    77 *
    88 * @package     Staffing Engine - Chatbot
    9  * @author      Staffing Engine, Paul Bearnee
     9 * @author      Staffing Enginee
    1010 * @copyright   (c) 2022 staffing Engine
    1111 *
     
    2020
    2121/**
    22  * Class Extension
     22 * Core plugin instance
    2323 *
    2424 * @final
     
    2727final class Plugin {
    2828    /**
    29      * Name
     29     * Slug
     30   *
     31   * The plugin's slug
    3032     *
    31      * @since 0.1.0
     33     * @since 0.2.0
    3234     *
    3335     * @var string
    3436     */
    35     const NAME = 'staffing-engine-chatbot';
     37    const SLUG = 'staffing-engine-chatbot';
    3638
    3739    /**
    38      * Constant Version
     40     * Name
     41   *
     42   * The plugin's name, for rendering
    3943     *
    40      * @since 0.1.0
     44     * @since 0.2.0
    4145     *
    4246     * @var string
    4347     */
    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
    4568
    4669    /**
     
    6083     * @var object
    6184     */
    62     private static $instance;
     85    protected static $instance = null;
    6386
    6487    /**
     
    6891     */
    6992    function __construct() {
    70     }
     93    self::$version = SE_CHAT_VERSION;
     94    self::$min_supported_php = SE_CHAT_MIN_PHP;
     95    self::$directory = SE_CHAT_DIR;
    7196
    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();
    8398
    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' );
    93117    }
    94118
     
    102126     * @return object
    103127     */
    104     public static function instance() {
     128    public static function get_instance() {
    105129        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();
    137131        }
    138132
     
    140134    }
    141135
    142 
     136  /**
     137     * Fired when the plugin is activated.
     138     *
     139     * @since    1.0.0
     140     */
     141    public static function activate() {}
    143142
    144143    /**
    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
    146152     *
    147153     * @since  0.1.0
     
    149155     * @return void
    150156     */
    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 ) );
    153171    }
    154172
    155173    /**
    156      * Load Plugin
     174     * Disable unserializing of the class.
    157175     *
    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.
    185177     *
    186178     * @since  0.1.0
    187      *
    188      * @return void
    189179     */
    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 ) );
    192182    }
    193183}
  • staffing-engine-chatbot/trunk/src/public/css/se-chatbot.css

    r2784220 r2785528  
    1313}
    1414
    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 */
    1823#staffing-engine-chatbot .rwc-embed-thumb {
    1924  border-radius: 50% !important;
  • staffing-engine-chatbot/trunk/src/public/js/se-chatbot.js

    r2784220 r2785528  
    11(function () {
    22  function initStaffingEngineChat() {
    3     var RWC = richWebChat.default;
     3    const RWC = richWebChat.default;
    44
    5     if (SEChat) { SEChat.destroy(); }
    6 
    7     var hasStaffingEngineChatConfig = !!staffingEngineChatConfig;
     5    const hasStaffingEngineChatConfig = !!staffingEngineChatConfig;
    86
    97    if (!hasStaffingEngineChatConfig) {
     
    119    }
    1210
    13     var SEChat = new RWC(staffingEngineChatConfig);
     11    const SEChat = new RWC(staffingEngineChatConfig);
    1412  }
    1513
  • staffing-engine-chatbot/trunk/staffing-engine-chatbot.php

    r2784220 r2785528  
    22/**
    33 * @package     Staffing Engine - Chatbot
    4  * @author      Staffing Engine, Paul Bearne
     4 * @author      Staffing Engine
    55 * @copyright   (c) 2022 staffing Engine
    66 * @license     GPL-3.0-or-later
    7  * @version     0.1.0
     7 * @version     0.2.0
    88 *
    99 * @wordpress-plugin
     
    1515 * License: GPL v3 or later
    1616 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
    17  * Version: 0.1.0
     17 * Version: 0.2.0
    1818 * Requires at least: 5.5
    1919 * Requires PHP: 7.1
     
    4141}
    4242
     43define( 'SE_CHAT_VERSION', '0.2.0' );
     44
     45define( 'SE_CHAT_MIN_PHP', '7.1.0' );
     46
    4347// Set up a dev logging mode
    44 define('SE_CHAT_DEV_MODE', getenv('SE_CHAT_DEV_MODE'));
     48define( 'SE_CHAT_DEV_MODE', getenv('SE_CHAT_DEV_MODE') );
     49
     50// Basename
     51define( 'SE_CHAT_BASENAME', plugin_basename( __FILE__ ) );
    4552
    4653// 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 }
     54define( 'SE_CHAT_DIR', path_join(plugin_dir_path( __FILE__ ), 'src') );
     55define( 'SE_CHAT_DIR_INCLUDES', trailingslashit(path_join(SE_CHAT_DIR, 'includes')) );
     56define( 'SE_CHAT_DIR_BIN', trailingslashit(path_join(SE_CHAT_DIR, 'bin')) );
     57define( 'SE_CHAT_DIR_PUBLIC', trailingslashit(path_join(SE_CHAT_DIR, 'public')) );
     58define( 'SE_CHAT_DIR_LANGUAGES', trailingslashit(path_join(SE_CHAT_DIR, 'languages')) );
     59define( 'SE_CHAT_PUBLIC_ASSET_PATH', '/wp-content/plugins/staffing-engine-chatbot/src/public/' );
    6760
    6861/**
     
    7871 * @return void
    7972 */
    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   }
     73function 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';
    8479
    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}
    8883
    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 */
     89function init() {
     90  load_dependencies();
    9291
    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();
    95100  }
    96101}
    97102
    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 }
     103add_action( 'plugins_loaded', 'StaffingEngine\\Chatbot\\init' );
    118104
    119105/**
    120  * Check if the plugin is running in dev mode, for logging
    121  *
    122  * @since 0.1.0
     106 * Register activation and deactivation hooks
    123107 */
    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 }
     108register_activation_hook( __FILE__, array( 'StaffingEngine\\Chatbot\\Plugin', 'activate' ) );
     109register_deactivation_hook( __FILE__, array( 'StaffingEngine\\Chatbot\\Plugin', 'deactivate' ) );
Note: See TracChangeset for help on using the changeset viewer.