Plugin Directory

Changeset 1782143


Ignore:
Timestamp:
12/06/2017 05:12:45 PM (8 years ago)
Author:
yozeg
Message:

New plugin core

Location:
chatbro/trunk
Files:
52 added
7 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • chatbro/trunk/index.php

    r1752019 r1782143  
    22/**
    33 * @package ChatBro
    4  * @version 2.3.0
     4 * @version 3.0.0
    55 */
    66/*
     
    88Plugin URI: http://chatbro.com
    99Description: Live group chat for your community with social networks integration. Chat conversation is being syncronized with popular messengers. Love ChatBro? Spread the word! <a href="https://wordpress.org/support/view/plugin-reviews/chatbro">Click here to review the plugin!</a>.
    10 Version: 2.3.0
     10Version: 3.0.0
    1111Author: ChatBro
    1212Author URI: http://chatbro.com
    1313License: GPL3
    1414Text Domain: chatbro
    15 Domain Path: /languages/
     15Domain Path: /common/languages/
    1616*/
    1717
    1818defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    19 define('CHATBRO_PLUGIN_VERSION', '2.2.10', true);
    2019
    21 require_once('util.php');
    22 require_once('deprecated.php');
    23 require_once('plugin.php');
    24 require_once('shortcode.php');
    25 require_once('templater.php');
    26 require_once('widget.php');
     20require_once('init.php');
     21CBroInit::init();
    2722
    28 ChatBroPlugin::get_instance();
    29 ChatBroShortCode::get_instance();
    30 
    31 add_action('plugins_loaded', array('ChatBroUtils', 'load_my_textdomain'));
    32 add_action('plugins_loaded', array( 'ChatBroPluginTemplater', 'get_instance'));
    33 add_action('widgets_init', array('ChatBroWidget', 'register'));
    34 register_uninstall_hook(__FILE__, array('ChatBroPlugin', 'clenup_settings'));
    35 register_activation_hook(__FILE__, array('ChatBroPlugin', 'on_activation'));
     23?>
  • chatbro/trunk/readme.txt

    r1752012 r1782143  
    33Tags: Chat, Telegram, Telegram chat, Chat Tool, Chat Widget, Free Live Chat, Group Chat, Live Chat, Online Live Chat, Plugin Chat, Web Chat, live chat widget, online support, wordpress live chat, chat software, chat services, live help, live chat help, chat widget, live support plugin, live chat support plugin
    44Requires at least: 3.5
    5 Tested up to: 4.8.2
    6 Stable tag: 2.3.0
     5Tested up to: 4.9.1
     6Stable tag: 3.0.0
    77License: GPLv2
    88
     
    3333== ChangeLog ==
    3434
     35= 3.0.0 =
     36* New plugin core
     37
    3538= 2.3.0 =
    3639* Updated chat embed code
     
    5558
    5659= 2.2.4 =
    57 * Fixed an issue where chat was always displaying to guests despite of "Display to guests"
    58   setting value.
     60* Fixed an issue where chat was always displaying to guests despite of "Display to guests" setting value.
    5961
    6062= 2.2.3 =
    6163* Compatibility with most plugins that replaces Gravatar avatars with locally
    62   stored ones.
    6364
    6465= 2.2.2 =
     
    163164= 1.0.0 =
    164165* Initial release
     166
  • chatbro/trunk/shortcode.php

    r1586694 r1782143  
    33defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    44
    5 if (!class_exists("ChatBroShortCode")) {
    6     class ChatBroShortCode {
    7         private static $instance = null;
     5require_once('common/settings/settings.php');
     6require_once('common/user/user.php');
     7require_once('common/chat.php');
    88
    9         private function __construct() {
    10             add_shortcode('chatbro', array(&$this, 'render'));
    11         }
     9if (!class_exists("CBroShortCode")) {
     10  class CBroShortCode {
     11    private static $instance = null;
    1212
    13         public static function get_instance() {
    14           if (!self::$instance)
    15             self::$instance = new ChatBroShortCode();
     13    private function __construct() {
     14        add_shortcode('chatbro', array(&$this, 'render'));
     15    }
    1616
    17           return self::$instance;
    18         }
     17    public static function get_instance() {
     18      if (!self::$instance)
     19        self::$instance = new CBroShortCode();
    1920
    20         public static function render($atts, $content = null) {
    21             $a = shortcode_atts(array(
    22                 'static' => true,
    23                 'registered_only' => false
    24             ), $atts);
     21      return self::$instance;
     22    }
     23
     24    public static function render($atts, $content = null) {
     25      $a = shortcode_atts(array(
     26          'static' => true,
     27          'registered_only' => false
     28      ), $atts);
     29
     30      if (!CBroSettings::get(CBroSettings::enable_shortcodes))
     31          return "";
     32
     33      // If "registered_only" attribute is explicitly set in shortcode then it will be used or global display_to_guests_setting will be used
     34      $registered_only = $atts && array_key_exists('registered_only', $atts) ? (strtolower($a['registered_only']) == 'true' || $a['registered_only'] == '1') : !CBroSettings::get(CBroWPSettingsBackend::display_to_guests);
     35      $static = strtolower($a['static']) == 'true' || $a['static'] == '1';
    2536
    2637
    27             if (!ChatBroUtils::get_option(ChatBroPlugin::enable_shortcodes_setting))
    28                 return "";
     38      if (!CBroUser::can_view() || ($registered_only && !CBroUser::is_logged_in()))
     39        return "";
    2940
    30             // If "registered_only" attribute is explicitly set in shortcode then it will be used or global display_to_guests_setting will be used
    31             $registered_only = $atts && array_key_exists('registered_only', $atts) ? (strtolower($a['registered_only']) == 'true' || $a['registered_only'] == '1') : !ChatBroUtils::get_option(ChatBroPlugin::display_to_guests_setting);
    32             $static = strtolower($a['static']) == 'true' || $a['static'] == '1';
    33             $logged_in = is_user_logged_in();
    34 
    35             if ((!$logged_in && $registered_only) || ($logged_in && !current_user_can(ChatBroPlugin::cap_view)))
    36                 return "";
    37 
    38             $guid = strtolower(ChatBroUtils::get_option(ChatBroPlugin::guid_setting));
    39             $encoded_guid = md5($guid);
    40             $container_id = $static ? "chatbro-{$encoded_guid}-" . rand(0, 99999) : null;
    41             $code = $container_id ? "<div id=\"{$container_id}\"></div>" : "";
    42 
    43             return $code . ChatBroUtils::generate_chat_code($guid, $container_id, $static);
    44         }
     41      return $static ? CBroChat::get_static_chat_code() : CBroChat::generate_popup_chat_code();
    4542    }
     43  }
    4644}
    4745
  • chatbro/trunk/widget.php

    r1592647 r1782143  
    66require_once(ABSPATH . '/wp-includes/formatting.php');
    77
    8 if (!class_exists('ChatbroWidget')) {
    9   class ChatBroWidget extends WP_Widget {
     8require_once('common/settings/settings.php');
     9require_once('common/user/user.php');
     10require_once('common/chat.php');
     11
     12
     13if (!class_exists('CBroWidget')) {
     14  class CBroWidget extends WP_Widget {
     15    const dtg = CBroWPSettingsBackend::display_to_guests;
     16
    1017    public function __construct() {
    1118      parent::__construct(
     
    1724
    1825    public static function register() {
    19       register_widget('ChatBroWidget');
     26      register_widget('CBroWidget');
     27    }
     28
     29    private static function get_dtg($instance) {
     30      $display_to_guests = !!CBroSettings::get(self::dtg);
     31
     32      if (isset($instance[self::dtg]))
     33        $display_to_guests = !!$instance[self::dtg];
     34
     35      return $display_to_guests;
    2036    }
    2137
    2238    public function widget($args, $instance) {
    23       $display_to_guests = true;
     39      $display_to_guests = self::get_dtg($instance);
    2440
    25       if (isset($instance[ChatBroPlugin::display_to_guests_setting]))
    26         $display_to_guests = !!$instance[ChatBroPlugin::display_to_guests_setting];
    27 
    28       if (!ChatBroUtils::user_can_view($display_to_guests))
     41      if (!CBroUser::can_view() || ((!CBroUser::is_logged_in()) && (!$display_to_guests)))
    2942        return;
    3043
    31       $guid = strtolower(ChatBroUtils::get_option(ChatBroPlugin::guid_setting));
    3244      $container_id = 'chatbro-widget-' . rand(0, 99999);
    3345
    3446      ?>
    3547        <section id="<?php echo $container_id; ?>" class="widget">
    36           <?php echo ChatBroUtils::generate_chat_code($guid, $container_id, true); ?>
     48          <?php echo CBroChat::get_static_chat_code(); ?>
    3749        </section>
    3850      <?php
     
    4052
    4153    public function form($instance) {
    42       $display_to_guests = true;
     54      $display_to_guests = self::get_dtg($instance);
     55      $dtg_id = $this->get_field_id(self::dtg);
     56      $dtg_name = $this->get_field_name(self::dtg);
    4357
    44       if (isset($instance[ChatBroPlugin::display_to_guests_setting]))
    45         $display_to_guests = !!$instance[ChatBroPlugin::display_to_guests_setting];
    46 
    47       $dtg_id = $this->get_field_id(ChatBroPlugin::display_to_guests_setting);
    48       $dtg_name = $this->get_field_name(ChatBroPlugin::display_to_guests_setting);
    4958      ?>
    5059      <p>
    51         <label for="<?php echo $display_to_guests_id; ?>">
     60        <label for="<?php echo $dtg_id; ?>">
    5261          <input type="checkbox" id="<?php echo $dtg_id; ?>" name="<?php echo $dtg_name; ?>" class="checkbox" <?php echo $display_to_guests ? 'checked' : ''; ?>>
    5362          <?php _e("Display chat to guests", "chatbro"); ?>
     
    5968    public function update($new_instance, $old_instance) {
    6069      $instance = array();
    61       $instance[ChatBroPlugin::display_to_guests_setting] = isset($new_instance[ChatBroPlugin::display_to_guests_setting]) ? !!$new_instance[ChatBroPlugin::display_to_guests_setting] : false;
     70      $instance[self::dtg] = isset($new_instance[self::dtg]) ? !!$new_instance[self::dtg] : false;
    6271      return $instance;
    6372    }
Note: See TracChangeset for help on using the changeset viewer.