| @@ -1,16 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: Userlike |
| 4 | -Plugin URI: https://www.userlike.com | |
| 5 | -Description: Userlike Live Chat integration for Wordpress | |
| 6 | -Version: 2.1 | |
| 7 | -Author: David Voswinkel <david.voswinkel@userlike.com> | |
| 8 | -Author URI: https://www.userlike.com | |
| 4 | +Plugin URI: http://userlike.com | |
| 5 | +Description: Userlike live chat integration for Wordpress | |
| 6 | +Version: 1.0 | |
| 7 | +Author: Sven Gebhardt <sven@devcores.com> | |
| 8 | +Author URI: http://devcores.com | |
| 9 | 9 | License: GPL2 |
| 10 | 10 | |
| 11 | +Copyright 2012 Sven Gebhardt <sven@devcores.com> | |
| 12 | + | |
| 11 | 13 | This program is free software; you can redistribute it and/or modify |
| 12 | -it under the terms of the GNU General Public License, version 2, as | |
| 14 | +it under the terms of the GNU General Public License, version 2, as | |
| 13 | 15 | published by the Free Software Foundation. |
| 14 | 16 | |
| 15 | 17 | This program is distributed in the hope that it will be useful, |
| 16 | 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| @@ -26,14 +28,14 @@ | ||
| 26 | 28 | static $is_enabled = false; |
| 27 | 29 | static $json; |
| 28 | 30 | static $plugin_dir; |
| 29 | 31 | |
| 30 | - public static function init(){ | |
| 32 | + function init(){ | |
| 31 | 33 | add_option("userlike_secret"); |
| 32 | - load_plugin_textdomain('userlike', false, dirname(plugin_basename(__FILE__))); | |
| 34 | + load_plugin_textdomain('userlike', false, dirname(plugin_basename(__FILE__))); | |
| 33 | 35 | if(get_option("userlike_secret") && strlen(get_option("userlike_secret")) > 30 && !preg_match("/[^a-f0-9]/", get_option("userlike_secret"))) |
| 34 | 36 | self::$is_enabled = true; |
| 35 | - else | |
| 37 | + else | |
| 36 | 38 | self::$is_enabled = false; |
| 37 | 39 | self::$plugin_dir = get_option('siteurl').'/'.PLUGINDIR.'/userlike/'; |
| 38 | 40 | if(function_exists('current_user_can') && current_user_can('manage_options')){ |
| 39 | 41 | add_action('admin_menu', array(__CLASS__, 'add_settings_page')); |
| @@ -38,9 +40,9 @@ | ||
| 38 | 40 | if(function_exists('current_user_can') && current_user_can('manage_options')){ |
| 39 | 41 | add_action('admin_menu', array(__CLASS__, 'add_settings_page')); |
| 40 | 42 | add_filter('plugin_action_links', array(__CLASS__, 'register_actions'), 10, 2); |
| 41 | 43 | } |
| 42 | - | |
| 44 | + | |
| 43 | 45 | if(self::$is_enabled){ |
| 44 | 46 | add_action('wp_footer', array(__CLASS__, 'insert_code')); |
| 45 | 47 | } else { |
| 46 | 48 | add_action('admin_notices', array(__CLASS__, 'admin_notice')); |
| @@ -46,21 +48,21 @@ | ||
| 46 | 48 | add_action('admin_notices', array(__CLASS__, 'admin_notice')); |
| 47 | 49 | } |
| 48 | 50 | } |
| 49 | 51 | |
| 50 | - public static function insert_code(){ | |
| 52 | + function insert_code(){ | |
| 51 | 53 | /* Insert Userlike javascript code into the page */ |
| 52 | 54 | if(!self::$is_enabled) return false; |
| 53 | 55 | $secret = get_option("userlike_secret"); |
| 54 | - echo "<script async type=\"text/javascript\" src=\"https://s3-eu-west-1.amazonaws.com/userlike-cdn-widgets/".$secret.".js\"></script>"; | |
| 56 | + echo "<script src=\"http://widgets.userlike.com/".$secret.".js\"></script>"; | |
| 55 | 57 | } |
| 56 | 58 | |
| 57 | - public static function admin_notice(){ | |
| 58 | - if(!self::$is_enabled) | |
| 59 | + function admin_notice(){ | |
| 60 | + if(!self::$is_enabled) | |
| 59 | 61 | echo '<div class="error"><p><strong>'.sprintf(__('Userlike integration has not been set up. Please go to the <a href="%s">plugin page</a> and enter your Userlike credentials to enable it.' ), admin_url('options-general.php?page=userlike')).'</strong></p></div>'; |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | - public static function add_settings_page(){ | |
| 64 | + function add_settings_page(){ | |
| 63 | 65 | add_action('admin_init', array(__CLASS__, 'register_settings')); |
| 64 | 66 | add_submenu_page('options-general.php', 'Userlike', 'Userlike', 'manage_options', 'userlike', array(__CLASS__, 'settings_page')); |
| 65 | 67 | } |
| 66 | 68 | |
| @@ -65,14 +67,14 @@ | ||
| 65 | 67 | } |
| 66 | 68 | |
| 67 | 69 | /* Helper Functions */ |
| 68 | 70 | |
| 69 | - public static function register_settings(){ | |
| 71 | + function register_settings(){ | |
| 70 | 72 | register_setting('userlike', 'userlike_secret'); |
| 71 | 73 | add_settings_section('userlike', 'Userlike', '', 'userlike'); |
| 72 | 74 | } |
| 73 | 75 | |
| 74 | - public static function register_actions($links, $file){ | |
| 76 | + function register_actions($links, $file){ | |
| 75 | 77 | $this_plugin = plugin_basename(__FILE__); |
| 76 | 78 | if($file == $this_plugin && function_exists('admin_url')){ |
| 77 | 79 | $settings_link = '<a href="'.admin_url('options-general.php?page=userlike').'">'.__('Settings', 'userlike').'</a>'; |
| 78 | 80 | array_unshift($links, $settings_link); |
| @@ -79,11 +81,11 @@ | ||
| 79 | 81 | } |
| 80 | 82 | return($links); |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | - public static function settings_page(){ | |
| 85 | + function settings_page(){ | |
| 84 | 86 | if(get_option("userlike_secret") && !self::$is_enabled){ |
| 85 | - echo '<div id="setting-error-settings_error" class="error settings-error"><p><strong>Your credentials don\'t look like they are correct. Please make sure that your credentials are correct! <a href="#" onClick="return userlikeStartChat();">Click here for live help</a></strong></p></div>'; | |
| 87 | + echo '<div id="setting-error-settings_error" class="error settings-error"><p><strong>Your credentials don\'t look like they are correct. Please make sure that your credentials are correct! <a href="#" onClick="return userlikeChat();">Click here for live help</a></strong></p></div>'; | |
| 86 | 88 | } |
| 87 | 89 | $plugin_dir = self::$plugin_dir; |
| 88 | 90 | $in_userlike = true; |
| 89 | 91 | require_once "userlike.admin.php"; |
| @@ -89,5 +91,5 @@ | ||
| 89 | 91 | require_once "userlike.admin.php"; |
| 90 | 92 | } |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | -add_action('init', array('UserLike', 'init')); | |
| 95 | +add_action('init', array('UserLike', 'init')); | |