Changeset 1597874
- Timestamp:
- 02/17/2017 09:44:35 AM (9 years ago)
- Location:
- tawkto-live-chat/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (2 diffs)
-
tawkto.php (modified) (9 diffs)
-
templates/settings.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tawkto-live-chat/trunk/readme.txt
r1596474 r1597874 4 4 Requires at least: 2.7 5 5 Tested up to: 4.7 6 Stable tag: 0.2. 36 Stable tag: 0.2.4 7 7 8 8 (OFFICIAL tawk.to plugin) Instantly chat with visitors on your website with the free tawk.to chat widget. … … 93 93 * Updating widget code due to known conflict 94 94 95 = 0.2.4 = 96 * updated session handling 97 * Added the ability to include a specific url slug 98 * modified plugin settings page interface 95 99 96 100 == Frequently Asked Questions == -
tawkto-live-chat/trunk/tawkto.php
r1596474 r1597874 4 4 Plugin URI: https://tawk.to 5 5 Description: Embeds Tawk.to live chat widget to your site 6 Version: 0.2. 36 Version: 0.2.4 7 7 Author: Tawkto 8 8 */ … … 25 25 'show_onarticlepages' => 0, 26 26 'exclude_url' => 0, 27 'excluded_url_list' => '' 27 'excluded_url_list' => '', 28 'include_url' => 0, 29 'included_url_list' => '' 28 30 ); 29 31 update_option( 'tawkto-visibility-options', $visibility); … … 34 36 add_action('wp_ajax_tawkto_setwidget', array(&$this, 'action_setwidget')); 35 37 add_action('wp_ajax_tawkto_removewidget', array(&$this, 'action_removewidget')); 36 37 add_action('init', array(&$this, 'start_session'), 1); 38 add_action('wp_logout', array(&$this, 'end_session')); 39 add_action('wp_login', array(&$this, 'end_session')); 40 } 41 42 function start_session() { 43 if(!session_id()) { 44 session_start(); 45 } 46 } 47 48 function end_session() { 49 session_destroy (); 38 add_action('admin_head', array(&$this,'tawk_custom_admin_style') ); 50 39 } 51 40 … … 93 82 $input['exclude_url'] = ($input['exclude_url'] != '1')? 0 : 1; 94 83 $input['excluded_url_list'] = sanitize_text_field($input['excluded_url_list']); 84 $input['include_url'] = ($input['include_url'] != '1')? 0 : 1; 85 $input['included_url_list'] = sanitize_text_field($input['included_url_list']); 95 86 96 87 return $input; … … 107 98 } 108 99 100 public function tawk_custom_admin_style(){ 101 echo '<style> 102 .form-table th.tawksetting { 103 width: 350px; 104 } 105 .tawknotice{ 106 font-size:14px; 107 } 108 </style>'; 109 } 110 109 111 public function create_plugin_settings_page(){ 110 112 … … 119 121 $base_url = 'https://plugins.tawk.to'; 120 122 121 if( 122 isset($wpdb->blogid) && 123 ( 124 !isset($_SESSION['active_page']) || 125 $_SESSION['active_page'] != $wpdb->blogid 126 ) 127 ) { 128 $_SESSION['active_page'] = $wpdb->blogid; 129 $iframe_url = $base_url.'/generic/logout' 123 $iframe_url = $base_url.'/generic/widgets' 130 124 .'?currentWidgetId='.$widget_id 131 125 .'¤tPageId='.$page_id 132 126 .'&transparentBackground=1'; 133 }else{ 134 $iframe_url = $base_url.'/generic/widgets' 135 .'?currentWidgetId='.$widget_id 136 .'¤tPageId='.$page_id 137 .'&transparentBackground=1'; 138 } 127 139 128 140 129 include(sprintf("%s/templates/settings.php", dirname(__FILE__))); … … 163 152 'show_onarticlepages' => 0, 164 153 'exclude_url' => 0, 165 'excluded_url_list' => '' 154 'excluded_url_list' => '', 155 'include_url' => 0, 156 'included_url_list' => '' 166 157 ); 167 158 … … 195 186 { 196 187 $vsibility = get_option( 'tawkto-visibility-options' ); 197 188 198 189 $display = FALSE; 199 190 … … 203 194 if($vsibility['always_display'] == 1){ $display = TRUE; } 204 195 if(($vsibility['show_onarticlepages'] == 1) && is_single() ){ $display = TRUE; } 196 205 197 if(($vsibility['exclude_url'] == 1)){ 206 198 $excluded_url_list = $vsibility['excluded_url_list']; 199 207 200 $current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; 208 201 $current_url = urldecode($current_url); 202 203 $ssl = ( ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ); 204 $sp = strtolower( $_SERVER['SERVER_PROTOCOL'] ); 205 $protocol = substr( $sp, 0, strpos( $sp, '/' ) ) . ( ( $ssl ) ? 's' : '' ); 206 207 $current_url = $protocol.'://'.$current_url; 208 $current_url = strtolower($current_url); 209 209 210 $excluded_url_list = preg_split("/,/", $excluded_url_list); 210 211 foreach($excluded_url_list as $exclude_url) 211 212 { 212 $exclude_url = urldecode(trim($exclude_url)); 213 $exclude_url = strtolower(urldecode(trim($exclude_url))); 214 213 215 if (strpos($current_url, $exclude_url) !== false) { 214 216 $display = false; 217 } 218 } 219 } 220 221 if(($vsibility['include_url'] == 1)){ 222 $included_url_list = $vsibility['included_url_list']; 223 $current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; 224 $current_url = urldecode($current_url); 225 226 $ssl = ( ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ); 227 $sp = strtolower( $_SERVER['SERVER_PROTOCOL'] ); 228 $protocol = substr( $sp, 0, strpos( $sp, '/' ) ) . ( ( $ssl ) ? 's' : '' ); 229 230 $current_url = $protocol.'://'.$current_url; 231 $current_url = strtolower($current_url); 232 233 $included_url_list = preg_split("/,/", $included_url_list); 234 foreach($included_url_list as $include_url) 235 { 236 $include_url = strtolower(urldecode(trim($include_url))); 237 if (strpos($current_url, $include_url) !== false) { 238 $display = TRUE; 215 239 } 216 240 } -
tawkto-live-chat/trunk/templates/settings.php
r1450167 r1597874 16 16 id="tawkIframe" 17 17 src="" 18 style="min-height: 400px; width : 100%; border: none; margin-top: 20px">18 style="min-height: 295px; width : 100%; border: none; margin-top: 20px"> 19 19 </iframe> 20 20 … … 80 80 'show_onarticlepages' => 0, 81 81 'exclude_url' => 0, 82 'excluded_url_list' => '' 82 'excluded_url_list' => '', 83 'include_url' => 0, 84 'included_url_list' => '' 83 85 ); 84 86 } … … 87 89 <div id="tawkvisibilitysettings"> 88 90 <h2>Visibility Options</h2> 89 <p >Please Note: that you can use the visibility options below, or you can show the tawk.to widget on any page independent of these visibility options by simply using the <b>[tawkto]</b> shortcode inthe post or page.</p>91 <p class='tawknotice'>Please Note: that you can use the visibility options below, or you can show the tawk.to widget<BR> on any page independent of these visibility options by simply using the <b>[tawkto]</b> shortcode in<BR> the post or page.</p> 90 92 <table class="form-table"> 91 93 <tr valign="top"> 92 <th scope="row">Always show Tawk.To widget on every page</th>94 <th class="tawksetting" scope="row">Always show Tawk.To widget on every page</th> 93 95 <td><input type="checkbox" id="always_display" name="tawkto-visibility-options[always_display]" value="1" <?php echo checked( 1, $visibility['always_display'], false ); ?> /></td> 94 96 </tr> 95 97 <tr valign="top"> 96 <th scope="row">Show on front page</th>98 <th class="tawksetting" scope="row">Show on front page</th> 97 99 <td><input type="checkbox" id="show_onfrontpage" name="tawkto-visibility-options[show_onfrontpage]" value="1" <?php echo checked( 1, $visibility['show_onfrontpage'], false ); ?> /></td> 98 100 </tr> 99 101 <tr valign="top"> 100 <th scope="row">Show on Category pages</th>102 <th class="tawksetting" scope="row">Show on Category pages</th> 101 103 <td><input type="checkbox" id="show_oncategory" name="tawkto-visibility-options[show_oncategory]" value="1" <?php echo checked( 1, $visibility['show_oncategory'], false ); ?> /></td> 102 104 </tr> 103 105 <tr valign="top"> 104 <th scope="row">Show on Tag pages</th>106 <th class="tawksetting" scope="row">Show on Tag pages</th> 105 107 <td><input type="checkbox" id="show_ontagpage" name="tawkto-visibility-options[show_ontagpage]" value="1" <?php echo checked( 1, $visibility['show_ontagpage'], false ); ?> /></td> 106 108 </tr> 107 109 <tr valign="top"> 108 <th scope="row">Show on Single Post Pages</th>110 <th class="tawksetting" scope="row">Show on Single Post Pages</th> 109 111 <td><input type="checkbox" id="show_onarticlepages" name="tawkto-visibility-options[show_onarticlepages]" value="1" <?php echo checked( 1, $visibility['show_onarticlepages'], false ); ?> /></td> 110 112 </tr> 111 113 <tr valign="top"> 112 <th scope="row">Exclude on specific url</th>114 <th class="tawksetting" scope="row">Exclude on specific url</th> 113 115 <td><input type="checkbox" id="exclude_url" name="tawkto-visibility-options[exclude_url]" value="1" <?php echo checked( 1, $visibility['exclude_url'], false ); ?> /> 114 116 <div id="exlucded_urls_container" style="display:none;"> 115 117 <textarea id="excluded_url_list" name="tawkto-visibility-options[excluded_url_list]" cols="50" rows="10"><?php echo $visibility['excluded_url_list']; ?></textarea><BR> 116 Enter fragment or slug of the url where you <b>don't</b> want the widget to show.<BR>118 Enter a unique fragment or slug of the url where you <b>don't</b> want the widget to show.<BR> 117 119 e.g. <?php echo site_url(); ?>/contact-us/<BR> 118 120 to exclude this page from displaying the tawk.to widget input <b>contact-us</b><BR> 121 Separate entries with comma (,). <BR> 122 </div> 123 </td> 124 </tr> 125 <tr valign="top"> 126 <th class="tawksetting" scope="row">Include on specific url</th> 127 <td><input type="checkbox" id="include_url" name="tawkto-visibility-options[include_url]" value="1" <?php echo checked( 1, $visibility['include_url'], false ); ?> /> 128 <div id="included_urls_container" style="display:none;"> 129 <textarea id="included_url_list" name="tawkto-visibility-options[included_url_list]" cols="50" rows="10"><?php echo $visibility['included_url_list']; ?></textarea><BR> 130 Enter a unique fragment or slug of the url where you <b>want</b> the widget to show.<BR> 131 e.g. <?php echo site_url(); ?>/about-us/<BR> 132 to include this page from displaying the tawk.to widget input <b>about-us</b><BR> 119 133 Separate entries with comma (,). <BR> 120 134 </div> … … 124 138 <script> 125 139 jQuery(document).ready(function() { 140 if(jQuery("#always_display").prop("checked")){ 141 $('#show_onfrontpage').prop('disabled', true); 142 $('#show_oncategory').prop('disabled', true); 143 $('#show_ontagpage').prop('disabled', true); 144 $('#show_onarticlepages').prop('disabled', true); 145 $('#include_url').prop('disabled', true); 146 } 147 148 jQuery("#always_display").change(function() { 149 if(this.checked){ 150 $('#show_onfrontpage').prop('disabled', true); 151 $('#show_oncategory').prop('disabled', true); 152 $('#show_ontagpage').prop('disabled', true); 153 $('#show_onarticlepages').prop('disabled', true); 154 $('#include_url').prop('disabled', true); 155 }else{ 156 $('#show_onfrontpage').prop('disabled', false); 157 $('#show_oncategory').prop('disabled', false); 158 $('#show_ontagpage').prop('disabled', false); 159 $('#show_onarticlepages').prop('disabled', false); 160 $('#include_url').prop('disabled', false); 161 } 162 }); 163 126 164 if(jQuery("#exclude_url").prop("checked")){ 127 165 jQuery("#exlucded_urls_container").show(); 128 166 } 167 129 168 jQuery("#exclude_url").change(function() { 130 169 if(this.checked){ … … 132 171 }else{ 133 172 jQuery("#exlucded_urls_container").hide(); 173 } 174 }); 175 176 if(jQuery("#include_url").prop("checked")){ 177 jQuery("#included_urls_container").show(); 178 } 179 180 jQuery("#include_url").change(function() { 181 if(this.checked){ 182 jQuery("#included_urls_container").show(); 183 }else{ 184 jQuery("#included_urls_container").hide(); 134 185 } 135 186 }); … … 140 191 141 192 </form> 142
Note: See TracChangeset
for help on using the changeset viewer.