Changeset 2492145
- Timestamp:
- 03/10/2021 01:30:16 PM (5 years ago)
- Location:
- freetobook-review-widget/trunk
- Files:
-
- 3 edited
-
freetobook-review-widget.php (modified) (7 diffs)
-
ftb_admin.js (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
freetobook-review-widget/trunk/freetobook-review-widget.php
r1817328 r2492145 1 1 <?php 2 /* 3 Plugin Name: Freetobook review widget 4 Plugin URI: https://www.freetobook.com/diary/bookings/reviews/wordpress_instructions.php 5 Description: Freetobook review Widget for wordpress 6 Version: 1.0 7 Author: freetobook.com 8 Author URI: http://www.freetobook.com 9 License: GPL v2 10 */ 2 3 /** 4 * Plugin Name: Freetobook review widget 5 * Plugin URI: https://en.freetobook.com/developers/wordpress.php 6 * Description: Freetobook Review Widget for wordpress 7 * Version: 1.1 8 * Author: freetobook.com 9 * Author URI: https://en.freetobook.com 10 * License: GPL v2 11 */ 11 12 12 13 … … 64 65 function admin_page() 65 66 { 66 67 $update=false;68 67 //must check that the user has the required capability 69 if (!current_user_can('manage_options')) 70 { 68 if (!current_user_can('manage_options')) { 71 69 wp_die( __('You do not have sufficient permissions to access this page.') ); 72 70 } 73 74 75 //update widget settings 76 if (!empty($_POST['ftb-review-widget-key'])) 77 { 78 check_admin_referer('freetobook_review_update','ftb_nonce' ); 79 update_option('ftb_review_widget_key',$_POST['ftb-review-widget-key']); 80 $update=true; 81 } 71 72 $updated = $this->update_widget_settings($updateErrors); 73 82 74 83 75 $this->widget_key=get_option('ftb_review_widget_key'); … … 88 80 89 81 $html.='<div id="icon-options-general" class="icon32"><br /></div><h2>Freetobook Review Widget Settings</h2>'; 90 if ($update) $html.='<h3>Changes saved</h3>'; 82 83 if ($updated === true) { 84 $html.='<h3>Changes saved</h3>'; 85 } 86 87 if (!empty($updateErrors)) { 88 $html.='<h3>Error: ' . implode(', ', $updateErrors) . '</h3>'; 89 } 90 91 91 $html.=' 92 92 <br /> … … 127 127 } 128 128 129 function update_widget_settings(&$updateErrors = array()) 130 { 131 $update = false; 132 $updateErrors = array(); 133 134 if (!empty($_POST['ftb-review-widget-key'])) { 135 $reviewWidgetKey = trim($_POST['ftb-review-widget-key']); 136 if (preg_match('/^[a-z0-9]+$/i', $reviewWidgetKey) === 1) { 137 check_admin_referer('freetobook_review_update', 'ftb_nonce'); 138 update_option('ftb_review_widget_key', $reviewWidgetKey); 139 $update = true; 140 } else { 141 $updateErrors[] = "Invalid review widget key."; 142 } 143 } 144 145 return $update; 146 } 147 129 148 130 function add_widget_scripts() 131 { 132 if ( !is_admin() ) 133 { 134 // instruction to only load if it is not the admin area 135 // register your script location, dependencies and version 136 wp_register_script('freetobook-reviews-js', 137 'https://static.freetobook.com/widgets/js/'. $this->widget_key .'.js' , 138 139 array(), 140 '1.0' ); 141 // enqueue the script 142 wp_enqueue_script('freetobook-reviews-js'); 143 } 144 else 145 { 146 wp_enqueue_script(array('jquery', 'jquery-ui-core','jquery-ui-slider')); 147 148 wp_register_script('freetobook-reviews-js', 149 plugins_url().'/freetobook-review-widget/ftb_admin.js', 150 array(), 151 '1.0' ); 152 153 wp_enqueue_script('freetobook-reviews-js'); 154 $params=array('base_url'=>plugins_url().'/freetobook-review-widget/'); 155 wp_localize_script('freetobook-reviews-js','freetobook_reviews_params',$params); 156 157 158 } 159 } 160 161 function add_admin_widget_stylesheet() 162 { 163 wp_enqueue_style('jquery-ui-slider', plugins_url() . '/freetobook-review-widget/css/ui-lightness/jquery-ui-slider.min.css'); 164 } 165 166 167 function load_widgets() 168 { 169 register_widget( 'FreetobookReviewWidget' ); 170 } 171 149 function add_widget_scripts() 150 { 151 if (!is_admin()) { 152 // instruction to only load if it is not the admin area 153 // register your script location, dependencies and version 154 wp_register_script( 155 'freetobook-reviews-js', 156 'https://static.freetobook.com/widgets/js/'. $this->widget_key .'.js' , 157 array(), 158 '1.0' 159 ); 160 161 // enqueue the script 162 wp_enqueue_script('freetobook-reviews-js'); 163 } else { 164 wp_enqueue_script(array('jquery', 'jquery-ui-core','jquery-ui-slider')); 165 166 wp_register_script( 167 'freetobook-reviews-js', 168 plugins_url('/ftb_admin.js', __FILE__), 169 array(), 170 '1.0' 171 ); 172 173 wp_enqueue_script('freetobook-reviews-js'); 174 $params = array('base_url' => plugin_dir_url(__FILE__)); 175 wp_localize_script('freetobook-reviews-js','freetobook_reviews_params',$params); 176 } 177 } 178 179 function add_admin_widget_stylesheet() 180 { 181 wp_enqueue_style('jquery-ui-slider', plugins_url('/css/ui-lightness/jquery-ui-slider.min.css', __FILE__)); 182 } 183 184 function load_widgets() 185 { 186 register_widget( 'FreetobookReviewWidget' ); 187 } 188 172 189 function get_widget_html($instance) 173 190 { … … 222 239 width:170px;height:120px; 223 240 background-position:center center; 224 background-image:url(<?php echo plugins_url( ).'/freetobook-review-widget/images/previews/' . $style .'.png'?>)"></div>241 background-image:url(<?php echo plugins_url('/images/previews/' . $style .'.png', __FILE__) ?>)"></div> 225 242 <strong>Style</strong><br> 226 243 <br> … … 236 253 <br> 237 254 <div style="text-align:center;width:220px;margin:0 auto;"> 238 Width:<input readonly type="text" size="3" 255 Width:<input readonly type="text" size="3" 239 256 id="ftb_review_width_<?php echo $this->number?>" 240 257 name="<?php echo $this->get_field_name( 'width' ) ?>" … … 283 300 add_action('init', array(&$ftb_review_widget,'add_widget_scripts')); 284 301 } 285 286 ?> -
freetobook-review-widget/trunk/ftb_admin.js
r1817295 r2492145 42 42 ftb_reviews_update_slider_range(id[1],jQuery(this).val()); 43 43 }); 44 45 44 45 46 46 jQuery('.ftb_slider').each(function(){ 47 47 … … 53 53 54 54 if (!range) range=[150,400]; 55 55 56 56 jQuery(this).slider({ 57 57 min:range[0], … … 71 71 72 72 ftb_reviews_add_handlers(); 73 console.log("argh"); 73 74 /* hook into save handler */ 74 75 jQuery(document).ajaxSuccess(function(e, xhr, settings) { 75 var widget_id_base = 'freetobook_reviews'; 76 var widget_id_base = 'freetobook_reviews'; 76 77 77 78 if(settings.data.search('action=save-widget') != -1 && -
freetobook-review-widget/trunk/readme.txt
r2489583 r2492145 3 3 Tags: freetobook, booking system, online booking,pms, web booking, booking engine,booking button 4 4 Requires at least: 3.0 5 Tested up to: 5. 6.26 Stable tag: trunk5 Tested up to: 5.7 6 Stable tag: 1.1 7 7 8 8 Add the freetobook booking button to your wordpress blog. … … 27 27 == Changelog == 28 28 29 = 1.1 = 30 * Tidy up and review 31 29 32 = 1.0 = 30 33 * Initial release
Note: See TracChangeset
for help on using the changeset viewer.