Plugin Directory

Changeset 1597874


Ignore:
Timestamp:
02/17/2017 09:44:35 AM (9 years ago)
Author:
tawkto
Message:

Included http protocol on include/exclude url option

Location:
tawkto-live-chat/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tawkto-live-chat/trunk/readme.txt

    r1596474 r1597874  
    44Requires at least: 2.7
    55Tested up to: 4.7
    6 Stable tag: 0.2.3
     6Stable tag: 0.2.4
    77
    88(OFFICIAL tawk.to plugin) Instantly chat with  visitors on your website with the free tawk.to chat widget.
     
    9393* Updating widget code due to known conflict
    9494
     95= 0.2.4 =
     96* updated session handling
     97* Added the ability to include a specific url slug
     98* modified plugin settings page interface
    9599
    96100== Frequently Asked Questions ==
  • tawkto-live-chat/trunk/tawkto.php

    r1596474 r1597874  
    44Plugin URI: https://tawk.to
    55Description: Embeds Tawk.to live chat widget to your site
    6 Version: 0.2.3
     6Version: 0.2.4
    77Author: Tawkto
    88*/
     
    2525                'show_onarticlepages' => 0,
    2626                'exclude_url' => 0,
    27                 'excluded_url_list' => ''
     27                'excluded_url_list' => '',
     28                'include_url' => 0,
     29                'included_url_list' => ''
    2830            );
    2931            update_option( 'tawkto-visibility-options', $visibility);
     
    3436            add_action('wp_ajax_tawkto_setwidget',  array(&$this, 'action_setwidget'));
    3537            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') );
    5039        }
    5140
     
    9382            $input['exclude_url'] = ($input['exclude_url'] != '1')? 0 : 1;
    9483            $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']);
    9586
    9687            return $input;
     
    10798        }
    10899
     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
    109111        public function create_plugin_settings_page(){
    110112
     
    119121            $base_url = 'https://plugins.tawk.to';
    120122
    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'
    130124                    .'?currentWidgetId='.$widget_id
    131125                    .'&currentPageId='.$page_id
    132126                    .'&transparentBackground=1';
    133             }else{
    134                 $iframe_url = $base_url.'/generic/widgets'
    135                     .'?currentWidgetId='.$widget_id
    136                     .'&currentPageId='.$page_id
    137                     .'&transparentBackground=1';
    138             }
     127
    139128
    140129            include(sprintf("%s/templates/settings.php", dirname(__FILE__)));
     
    163152                'show_onarticlepages' => 0,
    164153                'exclude_url' => 0,
    165                 'excluded_url_list' => ''
     154                'excluded_url_list' => '',
     155                'include_url' => 0,
     156                'included_url_list' => ''
    166157            );
    167158
     
    195186        {
    196187            $vsibility = get_option( 'tawkto-visibility-options' );
    197 
     188           
    198189            $display = FALSE;
    199190
     
    203194            if($vsibility['always_display'] == 1){ $display = TRUE; }
    204195            if(($vsibility['show_onarticlepages'] == 1) && is_single() ){ $display = TRUE; }
     196
    205197            if(($vsibility['exclude_url'] == 1)){
    206198                $excluded_url_list = $vsibility['excluded_url_list'];
     199
    207200                $current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    208201                $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
    209210                $excluded_url_list = preg_split("/,/", $excluded_url_list);
    210211                foreach($excluded_url_list as $exclude_url)
    211212                {
    212                     $exclude_url = urldecode(trim($exclude_url));
     213                    $exclude_url = strtolower(urldecode(trim($exclude_url)));
     214                   
    213215                    if (strpos($current_url, $exclude_url) !== false) {
    214216                            $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;
    215239                    }
    216240                }
  • tawkto-live-chat/trunk/templates/settings.php

    r1450167 r1597874  
    1616    id="tawkIframe"
    1717    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">
    1919</iframe>
    2020
     
    8080                'show_onarticlepages' => 0,
    8181                'exclude_url' => 0,
    82                 'excluded_url_list' => ''
     82                'excluded_url_list' => '',
     83                'include_url' => 0,
     84                'included_url_list' => ''
    8385            );
    8486   }
     
    8789   <div id="tawkvisibilitysettings">
    8890    <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 in the 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>
    9092    <table class="form-table">
    9193      <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>
    9395      <td><input type="checkbox" id="always_display" name="tawkto-visibility-options[always_display]" value="1" <?php echo checked( 1, $visibility['always_display'], false ); ?> /></td>
    9496      </tr>
    9597      <tr valign="top">
    96       <th scope="row">Show on front page</th>
     98      <th class="tawksetting" scope="row">Show on front page</th>
    9799      <td><input type="checkbox" id="show_onfrontpage" name="tawkto-visibility-options[show_onfrontpage]" value="1" <?php echo checked( 1, $visibility['show_onfrontpage'], false ); ?> /></td>
    98100      </tr>
    99101      <tr valign="top">
    100       <th scope="row">Show on Category pages</th>
     102      <th class="tawksetting" scope="row">Show on Category pages</th>
    101103      <td><input type="checkbox" id="show_oncategory" name="tawkto-visibility-options[show_oncategory]" value="1" <?php echo checked( 1, $visibility['show_oncategory'], false ); ?> /></td>
    102104      </tr>
    103105      <tr valign="top">
    104       <th scope="row">Show on Tag pages</th>
     106      <th class="tawksetting" scope="row">Show on Tag pages</th>
    105107      <td><input type="checkbox" id="show_ontagpage" name="tawkto-visibility-options[show_ontagpage]" value="1" <?php echo checked( 1, $visibility['show_ontagpage'], false ); ?> /></td>
    106108      </tr>
    107109      <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>
    109111      <td><input type="checkbox" id="show_onarticlepages" name="tawkto-visibility-options[show_onarticlepages]" value="1" <?php echo checked( 1, $visibility['show_onarticlepages'], false ); ?> /></td>
    110112      </tr>
    111113      <tr valign="top">
    112       <th scope="row">Exclude on specific url</th>
     114      <th class="tawksetting" scope="row">Exclude on specific url</th>
    113115      <td><input type="checkbox" id="exclude_url" name="tawkto-visibility-options[exclude_url]" value="1" <?php echo checked( 1, $visibility['exclude_url'], false ); ?> />
    114116        <div id="exlucded_urls_container" style="display:none;">
    115117        <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>
    117119        e.g. <?php echo site_url(); ?>/contact-us/<BR>
    118120        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>
    119133        Separate entries with comma (,). <BR>
    120134        </div>
     
    124138    <script>
    125139        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
    126164            if(jQuery("#exclude_url").prop("checked")){
    127165                jQuery("#exlucded_urls_container").show();
    128166            }
     167
    129168            jQuery("#exclude_url").change(function() {
    130169                if(this.checked){
     
    132171                }else{
    133172                    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();
    134185                }
    135186            });
     
    140191
    141192  </form>
    142 
Note: See TracChangeset for help on using the changeset viewer.