Plugin Directory

Changeset 1568083


Ignore:
Timestamp:
01/04/2017 08:45:09 PM (9 years ago)
Author:
Zoomd
Message:

2.1.0.25

Location:
zoomd-search/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • zoomd-search/trunk/classes/Core/Settings.php

    r1565735 r1568083  
    11<?php
     2//TODO
     3//add pictures for explaining each config
    24
    35namespace Zoomd\Core;
     
    79class Settings {
    810   
    9    
    10     public static function siteUrl(){
     11     public static function siteUrl(){
    1112        $siteurl = (get_option('zoomd_siteurl') != '') ? get_option('zoomd_siteurl') :  get_option('siteurl');
    1213        return $siteurl;
     
    6263    }
    6364
     65
     66    public static function get_zoomd_option($name, $defaultval, $checkempty = true)
     67    {
     68        $options = get_option('zoomd_options');
     69        if(!isset($options))
     70            return $defaultval;
     71        if(isset($options[$name]))
     72        {
     73            //error_log('name:'. $name . ' actualval:'.$options[$name]);
     74            if($checkempty)
     75                return settings::defaultifempty($options[$name],$defaultval);
     76            else
     77                return $option[$name];
     78        }
     79        return $defaultval;
     80    }
     81
    6482    public static function replacesearchbox(){
    65         return get_option('zoomd_replacesearchbox',1);
     83        return settings::get_zoomd_option('replacesearchbox',0);
    6684    }   
    6785
    6886    public static function showfloatingicon(){
    69         return get_option('zoomd_showfloatingicon',1);
     87        return settings::get_zoomd_option('showfloatingicon',0);
    7088    }
    7189
    7290    public static function searchboxhtml(){
    73         return get_option('zoomd_searchboxhtml',0);
     91        return settings::get_zoomd_option('searchboxhtml',0);
     92    }
     93
     94    public static function floatingicontop(){
     95        return settings::get_zoomd_option('floatingicontop',70,true);
     96    }
     97
     98    public static function floatingiconright(){
     99        return settings::get_zoomd_option('floatingiconright',30,true);
    74100    }
    75101
    76102    public static function searchboxvalidhtml()
    77103    {
    78         return get_option('searchboxvalidhtml',1);
     104        return settings::get_zoomd_option('searchboxvalidhtml',0);
     105    }
     106
     107    public static function enabletopsearches(){
     108        return settings::get_zoomd_option('enabletopsearches',0);
     109    }
     110
     111    public static function defaultifempty($val,$default)
     112    {
     113        return empty($val)?$default:$val;
    79114    }
    80115
     
    93128        . '</button>';
    94129    }
    95    
    96     public static function enabletopsearches(){
    97         return get_option('zoomd_enabletopsearches',1);
    98     }
     130
     131    public static function validatefloatingicontop($input)
     132    {   
     133        if(!is_numeric($input))
     134        {
     135            add_settings_error('zoomd_options[floatingicontop]', esc_attr( 'settings_failed' ),'Top must have numeric value, rolling back to default','error');
     136            return 70;
     137        }
     138        return $input;
     139    }
     140
     141    public static function validatefloatingiconright($input)
     142    {   
     143        if(!is_numeric($input))
     144        {
     145            add_settings_error('zoomd_options[floatingiconright]', esc_attr( 'settings_failed' ),'Right must have numeric value, rolling back to default','error');
     146            return 30;
     147        }
     148        return $input;
     149    }
     150
     151    public static function validatesearchboxhtml($input)
     152    {
     153        $checkhtml = htmlentities($input);
     154        return ($checkhtml == $input)?0:1;
     155    }   
    99156
    100157     public static function environment(){
     
    157214        delete_option('zoomd_apiHash');
    158215        delete_option('zoomd_notices');
    159         delete_option( 'zoomd_replacesearchbox');   
    160         delete_option( 'zoomd_showfloatingicon');   
    161         delete_option( 'zoomd_searchboxhtml');   
    162         delete_option( 'zoomd_enabletopsearches');   
     216        delete_option( 'zoomd_options');   
    163217        delete_option( 'zoomd_reg_token');   
    164218
  • zoomd-search/trunk/classes/zoomd_settingsView.php

    r1565730 r1568083  
    1313    $emailaddress  = Settings::email();
    1414    $adminUrl = "http://www.zoomd.com";
     15   
    1516    $replacesearchbox = Settings::replacesearchbox();
    1617    $showfloatingicon = Settings::showfloatingicon();
    1718    $searchboxhtml = Settings::searchboxhtml();
    1819    $enabletopsearches = Settings::enabletopsearches();
     20    $floatingicontop = Settings::floatingicontop();
     21    $floatingiconright = Settings::floatingiconright();
    1922
    2023    $updateAdminLink = false;
     
    9497                        <span><?php echo $clientId ?></span>
    9598                    </td>
    96                 </tr>
    97                 <!--<tr>
    98                     <td class="zdtdlable">
    99                         <label>Your Website URL: </label>
    100                     </td>
    101                     <td>
    102                         <span><?php echo $siteurl ?></span>
    103                     </td>
    104                 </tr>
    105                 <tr>
    106                     <td class="zdtdlable">
    107                         <label>Your Email Address: </label>
    108                     </td>
    109                     <td>
    110                         <span><?php echo $emailaddress ?></span>
    111                     </td>
    112                 </tr>-->
     99                </tr>               
    113100            </table>
    114101            </div>
     
    118105            <p style="padding-left:10px;font-style: italic;color:seagreen"><?php _e( 'In order to implement your own search trigger, just add the following attribute to the triggering element:', 'zoomd-search' );?><code> zoomdsearch="{ "trigger" : "OnClick" }" </code></p>
    119106            <div class="zdaccordion-content default">                                               
    120                 <p><input type="checkbox" name="zoomd_showfloatingicon" id="zoomd_showfloatingicon" <?php checked('1', $showfloatingicon); ?>
    121                     value="1"  /><?php _e( 'Add floating search icon', 'zoomd-search' );?></p>
    122                 <p><input type="checkbox" name="zoomd_replacesearchbox" id="zoomd_replacesearchbox" <?php checked('1', $replacesearchbox); ?>
     107                <p>
     108                        <input type="checkbox" name="zoomd_options[showfloatingicon]" id="zoomd_showfloatingicon" <?php checked('1', $showfloatingicon); ?>
     109                            value="1"  /><?php _e( 'Add floating search icon', 'zoomd-search' );?>
     110                        <span>Floating icon Location, Top:</span>
     111                        <input type="text" class="zdfloatingtext" id="zoomd_floatingicontop" name="zoomd_options[floatingicontop]" value="<?php echo $floatingicontop;?>" size="2"/>
     112                        <span>Right:</span>
     113                        <input type="text" class="zdfloatingtext" id="zoomd_floatingiconright" name="zoomd_options[floatingiconright]" value="<?php echo $floatingiconright;?>" size="2"/>
     114                </p>
     115                <p><input type="checkbox" name="zoomd_options[replacesearchbox]" id="zoomd_replacesearchbox" <?php checked('1', $replacesearchbox); ?>
    123116                    value="1" /><?php _e( 'Replace Wordpress build-in searchbox', 'zoomd-search' );?> <span style=";font-style: italic;color:seagreen">(<?php _e( 'If Disabled the searchbox will use Wordpress search', 'zoomd-search' );?>)</span></p>
    124                 <p><?php _e( 'Search Button Text', 'zoomd-search' );?>: <input type="text" name="zoomd_txtcaption" id="zoomd_txtcaption" value="<?php _e( 'Search', 'zoomd-search' );?>" onkeyup="updatecaption()"  />
     117                <p><?php _e( 'Search Button Text', 'zoomd-search' );?>: <input type="text" name="zoomd_options[txtcaption]" id="zoomd_txtcaption" value="<?php _e( 'Search', 'zoomd-search' );?>" onkeyup="updatecaption()"  />
    125118                 <a href="javascript:restoredefaultvalues()"><?php _e( 'Restore default', 'zoomd-search' );?></a></p>               
    126119                <div class="zdacewrapper">                   
     
    128121                    <div id="return" class="zdreturn"></div>
    129122                </div>
    130                 <textarea id="zoomd_searchboxhtml" name="zoomd_searchboxhtml" rows="100" cols="100" style="display:none">
     123                <textarea id="zoomd_searchboxhtml" name="zoomd_options[searchboxhtml]" rows="100" cols="100" style="display:none">
    131124                    <?php
    132125                        if(!empty($searchboxhtml) && !$searchboxhtml==0)
     
    145138            <h4 class="zdaccordion-toggle"><?php _e( 'Top Searches Settings', 'zoomd-search' );?></h4>
    146139            <div class="zdaccordion-content default">
    147                 <p><input type="checkbox" name="zoomd_enabletopsearches" id="zoomd_enabletopsearches" <?php checked('1', $enabletopsearches); ?>
     140                <p><input type="checkbox" name="zoomd_options[enabletopsearches]" id="zoomd_enabletopsearches" <?php checked('1', $enabletopsearches); ?>
    148141                    value="1" /><?php _e( 'Add at the bottom of the Post/Page', 'zoomd-search' );?></p>
    149142                <p style="font-style: italic;color:blue"><?php _e( 'Top search bar can be added by adding the', 'zoomd-search' );?> <b>[zoomd_ts/]</b> <?php _e( 'short code at any location inside a post/page', 'zoomd-search' );?></p>
     
    185178            $('#zoomd_searchboxhtml').text(editor.getValue());
    186179            $('#return').html(editor.getValue());
     180            $('#zoomd_txtcaption').val($('#zsbtn').val());           
    187181        }
    188182        // or use data: url to handle things like doctype
     
    212206
    213207    function updatecaption() {   
    214         $("#zsbtn").val($(zoomd_txtcaption).val());
     208        $("#zsbtn").val($('#zoomd_txtcaption').val());
    215209        var editor = ace.edit("editor");
    216210        var unescapetxt = document.createElement('textarea');
     
    227221        beatify(editor);
    228222        $(zoomd_txtcaption).val("Search");
     223        // $(zoomd_floatingicontop).val("70");
     224        // $(zoomd_floatingiconright).val("30");
    229225    }
    230226</script>
  • zoomd-search/trunk/classes/zoomd_utils.php

    r1565490 r1568083  
    6060        }
    6161
    62         public static function isHtml($string){
    63             $processed = htmlentities($string);
    64             if($processed == $string)
    65                 return false;
    66             return true;
    67         }
     62       
    6863    }
    6964?>
  • zoomd-search/trunk/classes/zoomd_widget.php

    r1565490 r1568083  
    1212        wp_register_script( 'zoomd_search', '//' . widgetbaseURL . '/zoomd/SearchUi/Script?clientId=' . $clientId, '', '', true );
    1313        wp_enqueue_script('zoomd_search');
    14         //}
     14       
    1515        if(Settings::showfloatingicon()==1 ) {       
    1616            wp_register_style( 'fonts.googleapis.com-css', 'https://fonts.googleapis.com/icon?family=Material+Icons', __FILE__ );
     
    2222            wp_register_script( 'zoomd_floating_button',  plugins_url('../js/zoomd-floating.js', __FILE__) );
    2323            wp_enqueue_script('zoomd_floating_button');
    24         }
     24
     25            $floatingicontop = Settings::floatingicontop();
     26            $floatingiconright = Settings::floatingiconright();
     27           
     28            $custom_inline_style = '#search-btn { top: ' . $floatingicontop . 'px;'
     29                . ' right: ' . $floatingiconright . 'px;}';
     30             
     31            wp_add_inline_style( 'zoomd-floating-css', $custom_inline_style );
     32        }       
    2533    }
    2634 }
     35
     36   
    2737
    2838function zoomd_search_form( $form ) {
  • zoomd-search/trunk/css/zoomd-floating.css

    r1565305 r1568083  
    11#search-btn {
    2     top: 70px;
     2    /*top: 70px;*/
    33    box-shadow: rgba(0, 0, 0, 0.3) 3px 5px 5px 0;
    44    color: rgb(255, 255, 255);
     
    66    height: 54px;
    77    position: fixed;
    8     right: 30px;
     8    /*right: 30px;*/
    99    width: 54px;
    1010    z-index: 102;
  • zoomd-search/trunk/css/zoomd-search.css

    r1565305 r1568083  
    5757    flex: 1;
    5858}
     59
     60.zdfloatingtext {
     61    size: 4;
     62}
  • zoomd-search/trunk/js/zoomd-floating.js

    r1565305 r1568083  
    11jQuery(document).ready(function($) {
    22    var injector = document.createElement("div");
    3     var src = '<button type="button" id="search-btn" zoomdsearch="{ "trigger" : "OnClick" }" zoomdid="zd-id-59290">' +
     3    var src = '<button type="button" id="search-btn" class="search-btn" zoomdsearch="{\'trigger\' : \'OnClick\' }">' +
    44        '<span id="search-icon" class="material-icons">search</span></button>';
    55    injector.innerHTML = src;
  • zoomd-search/trunk/plugin.php

    r1566098 r1568083  
    88Author URI: http://zoomd.com/
    99License: GPLv2 or later
    10 Version: 2.1.0.24
     10Version: 2.1.0.25
    1111*/
    1212
    1313use Zoomd\Core\Activator;
     14use Zoomd\Core\Settings;
    1415
    1516defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
     
    4748        wp_register_script( 'zoomd-debug', plugins_url( '/debug/zoomdjson.js', __FILE__ ), array( 'jquery' ) );
    4849    }
    49    
    5050}
    51 add_action( 'wp_enqueue_scripts', 'add_zoomd_debug_scripts' );     
     51add_action( 'wp_enqueue_scripts', 'add_zoomd_debug_scripts' ); 
    5252
    5353add_action('plugins_loaded', 'wan_load_textdomain');
     
    9999add_action('admin_init', 'zoomd_admin_init' );
    100100function zoomd_admin_init(){
    101     register_setting( 'zoomd_search_options', 'zoomd_replacesearchbox' );
    102     register_setting( 'zoomd_search_options', 'zoomd_showfloatingicon' );
    103     register_setting( 'zoomd_search_options', 'zoomd_searchboxhtml','validatesearchboxhtml' );
    104     register_setting( 'zoomd_search_options', 'zoomd_enabletopsearches' );
     101   
     102    register_setting( 'zoomd_search_options', 'zoomd_options','validateoptions' );
     103    $options = get_option('zoomd_options');
     104    if(empty($options))
     105    {
     106        $options =  array();
     107        $options['enabletopsearches'] = 1;
     108        $options['replacesearchbox'] = 1;
     109        $options['showfloatingicon'] = 1;
     110        $options['searchboxvalidhtml'] = 1;
     111        update_option('zoomd_options',$options);
     112    }
    105113}
    106114
    107 function validatesearchboxhtml($input)
    108 {
    109     //error_log($input);
    110     $ret = zoomd_utils::isHtml($input);
    111     if($ret == 1)
     115function validateoptions($input)
     116{   
     117    $input['floatingicontop'] = Settings::validatefloatingicontop($input['floatingicontop']);
     118    $input['floatingiconright'] = Settings::validatefloatingiconright($input['floatingiconright']);
     119    $validhtml = Settings::validatesearchboxhtml($input['searchboxhtml']);
     120    $input['searchboxvalidhtml'] = $validhtml;
     121    if(!$validhtml)
    112122    {
    113         //error_log('ok'); 
    114         update_option('searchboxvalidhtml', 1 );     
    115     }
    116     else
    117     {
    118         add_settings_error('zoomd_searchboxhtml', esc_attr( 'settings_failed' ),'Update Failed - Searchbox html is not valid','error');
    119         update_option('searchboxvalidhtml', 0 );     
     123        add_settings_error('zoomd_options[searchboxhtml]', esc_attr( 'settings_failed' ),'Update Failed - Searchbox html is not valid','error');
    120124    }
    121125    return $input;
    122126}
    123127
     128
     129
    124130function enqueue_zoomd_admin_scripts($hook) {
    125     //error_log($hook);
    126131    if ( 'toplevel_page_zoomd' != $hook  && 'settings_page_zoomd' != $hook) {
    127132        return;
  • zoomd-search/trunk/readme.txt

    r1566098 r1568083  
    4747
    4848== Changelog ==
     49= 2.1.0.25 =
     50* Add Floating icon location configuation
     51* Bug Fixes
     52
    4953= 2.1.0.24 =
    5054* Bug Fixes
Note: See TracChangeset for help on using the changeset viewer.