Changeset 1568083
- Timestamp:
- 01/04/2017 08:45:09 PM (9 years ago)
- Location:
- zoomd-search/trunk
- Files:
-
- 9 edited
-
classes/Core/Settings.php (modified) (5 diffs)
-
classes/zoomd_settingsView.php (modified) (8 diffs)
-
classes/zoomd_utils.php (modified) (1 diff)
-
classes/zoomd_widget.php (modified) (2 diffs)
-
css/zoomd-floating.css (modified) (2 diffs)
-
css/zoomd-search.css (modified) (1 diff)
-
js/zoomd-floating.js (modified) (1 diff)
-
plugin.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
zoomd-search/trunk/classes/Core/Settings.php
r1565735 r1568083 1 1 <?php 2 //TODO 3 //add pictures for explaining each config 2 4 3 5 namespace Zoomd\Core; … … 7 9 class Settings { 8 10 9 10 public static function siteUrl(){ 11 public static function siteUrl(){ 11 12 $siteurl = (get_option('zoomd_siteurl') != '') ? get_option('zoomd_siteurl') : get_option('siteurl'); 12 13 return $siteurl; … … 62 63 } 63 64 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 64 82 public static function replacesearchbox(){ 65 return get_option('zoomd_replacesearchbox',1);83 return settings::get_zoomd_option('replacesearchbox',0); 66 84 } 67 85 68 86 public static function showfloatingicon(){ 69 return get_option('zoomd_showfloatingicon',1);87 return settings::get_zoomd_option('showfloatingicon',0); 70 88 } 71 89 72 90 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); 74 100 } 75 101 76 102 public static function searchboxvalidhtml() 77 103 { 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; 79 114 } 80 115 … … 93 128 . '</button>'; 94 129 } 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 } 99 156 100 157 public static function environment(){ … … 157 214 delete_option('zoomd_apiHash'); 158 215 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'); 163 217 delete_option( 'zoomd_reg_token'); 164 218 -
zoomd-search/trunk/classes/zoomd_settingsView.php
r1565730 r1568083 13 13 $emailaddress = Settings::email(); 14 14 $adminUrl = "http://www.zoomd.com"; 15 15 16 $replacesearchbox = Settings::replacesearchbox(); 16 17 $showfloatingicon = Settings::showfloatingicon(); 17 18 $searchboxhtml = Settings::searchboxhtml(); 18 19 $enabletopsearches = Settings::enabletopsearches(); 20 $floatingicontop = Settings::floatingicontop(); 21 $floatingiconright = Settings::floatingiconright(); 19 22 20 23 $updateAdminLink = false; … … 94 97 <span><?php echo $clientId ?></span> 95 98 </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> 113 100 </table> 114 101 </div> … … 118 105 <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> 119 106 <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); ?> 123 116 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()" /> 125 118 <a href="javascript:restoredefaultvalues()"><?php _e( 'Restore default', 'zoomd-search' );?></a></p> 126 119 <div class="zdacewrapper"> … … 128 121 <div id="return" class="zdreturn"></div> 129 122 </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"> 131 124 <?php 132 125 if(!empty($searchboxhtml) && !$searchboxhtml==0) … … 145 138 <h4 class="zdaccordion-toggle"><?php _e( 'Top Searches Settings', 'zoomd-search' );?></h4> 146 139 <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); ?> 148 141 value="1" /><?php _e( 'Add at the bottom of the Post/Page', 'zoomd-search' );?></p> 149 142 <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> … … 185 178 $('#zoomd_searchboxhtml').text(editor.getValue()); 186 179 $('#return').html(editor.getValue()); 180 $('#zoomd_txtcaption').val($('#zsbtn').val()); 187 181 } 188 182 // or use data: url to handle things like doctype … … 212 206 213 207 function updatecaption() { 214 $("#zsbtn").val($( zoomd_txtcaption).val());208 $("#zsbtn").val($('#zoomd_txtcaption').val()); 215 209 var editor = ace.edit("editor"); 216 210 var unescapetxt = document.createElement('textarea'); … … 227 221 beatify(editor); 228 222 $(zoomd_txtcaption).val("Search"); 223 // $(zoomd_floatingicontop).val("70"); 224 // $(zoomd_floatingiconright).val("30"); 229 225 } 230 226 </script> -
zoomd-search/trunk/classes/zoomd_utils.php
r1565490 r1568083 60 60 } 61 61 62 public static function isHtml($string){ 63 $processed = htmlentities($string); 64 if($processed == $string) 65 return false; 66 return true; 67 } 62 68 63 } 69 64 ?> -
zoomd-search/trunk/classes/zoomd_widget.php
r1565490 r1568083 12 12 wp_register_script( 'zoomd_search', '//' . widgetbaseURL . '/zoomd/SearchUi/Script?clientId=' . $clientId, '', '', true ); 13 13 wp_enqueue_script('zoomd_search'); 14 //}14 15 15 if(Settings::showfloatingicon()==1 ) { 16 16 wp_register_style( 'fonts.googleapis.com-css', 'https://fonts.googleapis.com/icon?family=Material+Icons', __FILE__ ); … … 22 22 wp_register_script( 'zoomd_floating_button', plugins_url('../js/zoomd-floating.js', __FILE__) ); 23 23 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 } 25 33 } 26 34 } 35 36 27 37 28 38 function zoomd_search_form( $form ) { -
zoomd-search/trunk/css/zoomd-floating.css
r1565305 r1568083 1 1 #search-btn { 2 top: 70px;2 /*top: 70px;*/ 3 3 box-shadow: rgba(0, 0, 0, 0.3) 3px 5px 5px 0; 4 4 color: rgb(255, 255, 255); … … 6 6 height: 54px; 7 7 position: fixed; 8 right: 30px;8 /*right: 30px;*/ 9 9 width: 54px; 10 10 z-index: 102; -
zoomd-search/trunk/css/zoomd-search.css
r1565305 r1568083 57 57 flex: 1; 58 58 } 59 60 .zdfloatingtext { 61 size: 4; 62 } -
zoomd-search/trunk/js/zoomd-floating.js
r1565305 r1568083 1 1 jQuery(document).ready(function($) { 2 2 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\' }">' + 4 4 '<span id="search-icon" class="material-icons">search</span></button>'; 5 5 injector.innerHTML = src; -
zoomd-search/trunk/plugin.php
r1566098 r1568083 8 8 Author URI: http://zoomd.com/ 9 9 License: GPLv2 or later 10 Version: 2.1.0.2 410 Version: 2.1.0.25 11 11 */ 12 12 13 13 use Zoomd\Core\Activator; 14 use Zoomd\Core\Settings; 14 15 15 16 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); … … 47 48 wp_register_script( 'zoomd-debug', plugins_url( '/debug/zoomdjson.js', __FILE__ ), array( 'jquery' ) ); 48 49 } 49 50 50 } 51 add_action( 'wp_enqueue_scripts', 'add_zoomd_debug_scripts' ); 51 add_action( 'wp_enqueue_scripts', 'add_zoomd_debug_scripts' ); 52 52 53 53 add_action('plugins_loaded', 'wan_load_textdomain'); … … 99 99 add_action('admin_init', 'zoomd_admin_init' ); 100 100 function 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 } 105 113 } 106 114 107 function validatesearchboxhtml($input) 108 { 109 //error_log($input); 110 $ret = zoomd_utils::isHtml($input); 111 if($ret == 1) 115 function 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) 112 122 { 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'); 120 124 } 121 125 return $input; 122 126 } 123 127 128 129 124 130 function enqueue_zoomd_admin_scripts($hook) { 125 //error_log($hook);126 131 if ( 'toplevel_page_zoomd' != $hook && 'settings_page_zoomd' != $hook) { 127 132 return; -
zoomd-search/trunk/readme.txt
r1566098 r1568083 47 47 48 48 == Changelog == 49 = 2.1.0.25 = 50 * Add Floating icon location configuation 51 * Bug Fixes 52 49 53 = 2.1.0.24 = 50 54 * Bug Fixes
Note: See TracChangeset
for help on using the changeset viewer.