Changeset 2719869
- Timestamp:
- 05/07/2022 12:32:25 PM (4 years ago)
- Location:
- wp-rate-and-review
- Files:
-
- 45 added
- 3 deleted
- 4 edited
-
tags/1.0.8 (added)
-
tags/1.0.8/assets (added)
-
tags/1.0.8/assets/css (added)
-
tags/1.0.8/assets/css/fonts (added)
-
tags/1.0.8/assets/css/fonts/slick.eot (added)
-
tags/1.0.8/assets/css/fonts/slick.svg (added)
-
tags/1.0.8/assets/css/fonts/slick.ttf (added)
-
tags/1.0.8/assets/css/fonts/slick.woff (added)
-
tags/1.0.8/assets/css/select2.min.css (added)
-
tags/1.0.8/assets/css/slick.css (added)
-
tags/1.0.8/assets/css/wphp-frontend.css (added)
-
tags/1.0.8/assets/css/wphp-progressbar.css (added)
-
tags/1.0.8/assets/css/wpic-admin.css (added)
-
tags/1.0.8/assets/images (added)
-
tags/1.0.8/assets/images/ajax-loader.gif (added)
-
tags/1.0.8/assets/images/banner-772x250.png (added)
-
tags/1.0.8/assets/images/default2.jpg (added)
-
tags/1.0.8/assets/images/iconfinder_15_Tick_16x16_173960.png (added)
-
tags/1.0.8/assets/images/mega-772x250.png (added)
-
tags/1.0.8/assets/images/multicolor2.jpg (added)
-
tags/1.0.8/assets/images/multicolor21.jpg (added)
-
tags/1.0.8/assets/images/multicolor_with_circle.jpg (added)
-
tags/1.0.8/assets/images/paypal2.png (added)
-
tags/1.0.8/assets/images/slide1.jpg (added)
-
tags/1.0.8/assets/images/wp-helppopup-banner-772x250.png (added)
-
tags/1.0.8/assets/js (added)
-
tags/1.0.8/assets/js/select2.min.js (added)
-
tags/1.0.8/assets/js/slick.min.js (added)
-
tags/1.0.8/assets/js/wpic-admin.js (added)
-
tags/1.0.8/includes (added)
-
tags/1.0.8/includes/class-wcrr-admin-menu.php (added)
-
tags/1.0.8/readme.txt (added)
-
tags/1.0.8/views (added)
-
tags/1.0.8/views/settings.php (added)
-
tags/1.0.8/views/welcome.php (added)
-
tags/1.0.8/wp-rate-and-review.php (added)
-
trunk/ajax-loader.gif (deleted)
-
trunk/assets/css/ajax-loader.gif (deleted)
-
trunk/assets/css/slick.css (modified) (1 diff)
-
trunk/assets/css/wpic-admin.css (modified) (1 diff)
-
trunk/assets/images/ajax-loader.gif (added)
-
trunk/assets/images/mega-772x250.png (added)
-
trunk/assets/images/paypal2.png (added)
-
trunk/assets/images/wp-helppopup-banner-772x250.png (added)
-
trunk/include (deleted)
-
trunk/includes (added)
-
trunk/includes/class-wcrr-admin-menu.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/views (added)
-
trunk/views/settings.php (added)
-
trunk/views/welcome.php (added)
-
trunk/wp-rate-and-review.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-rate-and-review/trunk/assets/css/slick.css
r2178050 r2719869 124 124 .slick-loading .slick-list 125 125 { 126 background: #fff url('../../ ajax-loader.gif') center center no-repeat;126 background: #fff url('../../images/ajax-loader.gif') center center no-repeat; 127 127 } 128 128 -
wp-rate-and-review/trunk/assets/css/wpic-admin.css
r2570508 r2719869 1587 1587 width: 24px; 1588 1588 height: 24px; 1589 background: url( '../images/iconfinder_15_Tick_16x16_173960.png');1589 background: url("../../images/iconfinder_15_Tick_16x16_173960.png"); 1590 1590 margin: 0 auto; 1591 1591 text-align: center; -
wp-rate-and-review/trunk/readme.txt
r2570645 r2719869 4 4 Tags: woocommerce, woocommerce rating, woocommerce review, woocommerce rating progress bar, rating progress bar 5 5 Requires at least: 5.8 6 Stable tag: 1.0. 76 Stable tag: 1.0.8 7 7 Requires PHP: 5.6 8 8 Tested up to: 5.8 … … 43 43 == Changelog == 44 44 45 = 1.0.8 = 46 * Compatible to latest Wordpress and WooCommerce 47 45 48 = 1.0.7 = 46 49 * Compatible to latest Wordpress and WooCommerce -
wp-rate-and-review/trunk/wp-rate-and-review.php
r2570508 r2719869 3 3 * Plugin Name: WP Rate And Review 4 4 * Description: A WooCommerce Add-on which provides complete feature to show your rating and review with progressbar. 5 * Version: 1.0. 75 * Version: 1.0.8 6 6 * Author: K.Kumar 7 7 * Author URI: https://profiles.wordpress.org/krishna121/ … … 15 15 } 16 16 17 /** 18 * WCRR_Rate_Review main class 19 * @package wp-rate-and-review 20 * @author Krishna 21 */ 22 17 23 if ( ! class_exists('WCRR_Rate_Review') ) { 18 24 19 25 class WCRR_Rate_Review{ 20 26 27 28 29 /** 30 * Current plugin version 31 * @var $version 32 */ 33 public $version = '1.0.8'; 34 35 /** 36 * Instance of plugin 37 * @var $instance 38 */ 39 private static $instance; 40 41 /** 42 * @var array 43 */ 21 44 public $result = array(); 22 45 46 /** 47 * Constructor of class 48 */ 23 49 function __construct(){ 24 50 … … 51 77 52 78 function wcrr_required_woocommerce(){ 53 54 79 ?> 55 80 <div class="notice notice-error"> 56 <p><?php esc_html_e( 'WooCommerce is required for WP Rate and Review plugin. Please install and configure woocommerce first.', 'wp-rate-and-review' ); ?></p>81 <p><?php esc_html_e( 'WooCommerce is required for WP Rate and Review plugin. Please install and configure woocommerce first.', 'wp-rate-and-review' ); ?></p> 57 82 </div> 58 83 <?php 59 84 } 60 85 86 /** 87 * Setup plugin 88 * @since 1.0.0 89 * @return void 90 */ 61 91 function wcrr_setup_plugin(){ 92 93 $this->wcrr_define_constant(); 94 $this->wcrr_load_files(); 95 $this->wcrr_hooks(); 96 97 } 98 99 100 /** 101 * 102 * Define constact of plugin 103 * @since 1.0.8 104 * 105 */ 106 107 function wcrr_define_constant(){ 108 109 $this->wcrr_define('WCRR_VERSION',$this->version); 110 $this->wcrr_define('WCRR_FILE',__FILE__); 111 $this->wcrr_define('WCRR_PATH',dirname(WCRR_FILE)); 112 $this->wcrr_define('WCRR_INCLUDES',WCRR_PATH . '/includes'); 113 $this->wcrr_define('WCRR_URL', plugins_url('', WCRR_FILE)); 114 $this->wcrr_define('WCRR_ASSETS',WCRR_URL . '/assets'); 115 $this->wcrr_define('WCRR_VIEWS',WCRR_PATH . '/views'); 116 $this->wcrr_define('WCRR_TEMPLATES',WCRR_PATH . '/templates/'); 117 $this->wcrr_define('WCRR_CSS',WCRR_URL. '/assets/css/'); 118 $this->wcrr_define('WCRR_JS',WCRR_URL. '/assets/js/'); 119 $this->wcrr_define('WCRR_IMAGES',WCRR_URL. '/assets/images/'); 120 121 } 122 123 /** 124 * Define constant if not already set. 125 * 126 * @param string $name 127 * @param string|bool $value 128 */ 129 function wcrr_define( $name, $value ) { 130 if ( ! defined( $name ) ) { 131 define( $name, $value ); 132 } 133 } 134 135 136 function wcrr_load_files(){ 137 138 if(is_admin()){ 139 require_once WCRR_INCLUDES . '/class-wcrr-admin-menu.php'; 140 $this->wcrr_admin = new WCRR_Admin_Menu(); 141 } 142 } 143 144 /** 145 * Actual function for load hooks 146 */ 147 function wcrr_hooks(){ 62 148 63 149 add_action( 'wp_ajax_nopriv_wcrr_ajax_call', array($this,'wcrr_ajax_call' )); 64 150 add_action( 'wp_ajax_wcrr_ajax_call', array($this,'wcrr_ajax_call' )); 65 151 66 67 if(is_admin()){ 68 $this->wcrr_backend_hook(); 69 }else{ 152 // Check admin 153 if(!is_admin()){ 70 154 $this->wcrr_frontend_hook(); 71 155 } … … 73 157 } 74 158 159 /** 160 * Ajax call handler 161 * @since 1.0.0 162 * 163 */ 75 164 function wcrr_ajax_call(){ 76 77 165 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 78 79 166 if (isset($_POST['nonce']) && !wp_verify_nonce( $_POST['nonce'], 'wcrr_nonce_value' ) ) 80 167 die ( 'Busted!'); 81 82 168 $ajax_handler = isset($_POST['ajax_handler']) ? $_POST['ajax_handler'] :''; 83 169 $response = $this->$ajax_handler($_POST); … … 85 171 exit; 86 172 } 87 } 88 173 } 174 /** 175 * Regiter hooks which worked into site frontend 176 * @since 1.0.0 177 * 178 * 179 */ 89 180 function wcrr_frontend_hook(){ 181 // Register comment 90 182 add_filter( 'comments_template', array( $this, 'wcrr_enhance_review_rating' ) ); 91 add_action( 'wp_enqueue_scripts', array($this,'wcrr_theme_name_scripts' )); 92 add_shortcode('wp_rate_review', array($this,'wcrr_review_markup_via_shortcode')); 93 add_filter( 'woocommerce_my_account_my_orders_actions', array($this,'wcrr_show_review_actions' ),10,2); 94 183 184 // Load css and js frontend files 185 add_action( 'wp_enqueue_scripts', array($this,'wcrr_load_css_js' )); 95 186 96 } 97 98 function wcrr_backend_hook(){ 99 add_action( 'admin_menu', array($this,'wcrr_plugin_menu' )); 100 add_action( 'admin_enqueue_scripts', array($this,'wcrr_enqueue_admin_script' )); 101 add_action( 'admin_init', array($this,'wcrr_plugin_settings' )); 102 } 103 187 // Register shortcode of plugin 188 add_shortcode('wp_rate_review', array($this,'wcrr_review_markup_via_shortcode')); 189 190 // Register new order actions on my-account's orders listing 191 add_filter( 'woocommerce_my_account_my_orders_actions', array($this,'wcrr_show_review_actions' ),10,2); 192 } 193 194 195 /** 196 * Register new order action button 197 */ 104 198 function wcrr_show_review_actions($actions,$order){ 105 199 … … 110 204 'url'=>get_home_url(), 111 205 'name'=>esc_html__('Review','wp-rate-and-review') 112 113 206 ); 114 115 207 } 116 208 return $actions; 117 209 } 118 210 119 function wcrr_theme_name_scripts(){ 211 212 /** 213 * Load css and js files 214 * @since 1.0.0 215 */ 216 function wcrr_load_css_js(){ 120 217 121 218 wp_enqueue_style( 'wpic-wcprogressbar-css', plugin_dir_url( __FILE__ ).'assets/css/wphp-progressbar.css'); … … 126 223 127 224 $selected_tempalte = (!empty($plugin_settings['review_template'])) ?$plugin_settings['review_template']:'singlecolor'; 128 129 130 225 $custom_css = " 131 226 .w3-light-grey{background-color: {$wp_pbar_bg_color} !important;} … … 181 276 } 182 277 183 function wcrr_plugin_menu(){ 184 185 add_menu_page( 186 __('WP Rate And Review ', 'wp-rate-and-review' ), 187 __('WP Rate And Review','wp-rate-and-review'), 188 'manage_options', 189 'wp_rate_overview', 190 array($this,'wcrr_plugin_overview'), 191 'dashicons-welcome-widgets-menus'); 192 193 194 add_submenu_page( 'wp_rate_overview', 195 __('Settings','wp-rate-and-review'), 196 __('Settings','wp-rate-and-review'), 197 'manage_options', 198 'wcr_rate_review_settings', 199 array($this,'wcrr_setting_page')); 200 } 201 202 function wcrr_plugin_settings(){ 203 204 205 $settings = array(); 206 register_setting( 'wcr_options_group','wcr_options_group'); 207 208 if(isset($_POST) && isset($_POST['action']) && ( sanitize_text_field( wp_unslash($_POST['action']))=="rating-form") ){ 209 210 if ( isset( $_POST['wcr_nonce'] ) ) { 211 $nonce = sanitize_text_field( wp_unslash( $_POST['wcr_nonce'] ) ); 212 } 213 $checknonce = wp_verify_nonce($nonce,'wcr'); 214 if($checknonce){ 215 $error=false; 216 if(!$error){ 217 218 $settings['wp_enable_rate_review'] = (!empty( $_POST['wp_enable_rate_review'])) ? sanitize_text_field( wp_unslash( $_POST['wp_enable_rate_review'] ) ) : ''; 219 $settings['wphp_exclude_products'] = (!empty($_POST['wphp_exclude_products'])) ? (array)$_POST['wphp_exclude_products'] :array(); 220 $settings['wp_pbar_bg_color'] = (!empty($_POST['wp_pbar_bg_color'])) ? sanitize_text_field( wp_unslash( $_POST['wp_pbar_bg_color'] ) ) : ''; 221 $settings['wp_pbar_fill_color'] = (!empty($_POST['wp_pbar_fill_color'])) ? sanitize_text_field( wp_unslash( $_POST['wp_pbar_fill_color'] ) ) : ''; 222 $settings['review_template'] = (!empty($_POST['review_template'])) ? sanitize_text_field( wp_unslash( $_POST['review_template'] ) ) : ''; 223 $settings['wp_progress_bar_height'] = (!empty($_POST['wp_progress_bar_height'])) ? sanitize_text_field( wp_unslash( $_POST['wp_progress_bar_height'] ) ) : ''; 224 update_option('wcr_options_group',$settings); 225 $this->result['success'] = esc_html__('Settings Saved Successfully.','wp-rate-and-review'); 226 } 227 }else{ 228 wp_die('Cheating'); 229 } 230 } 231 } 232 233 function wcrr_enqueue_admin_script($hook){ 234 235 if($hook=='toplevel_page_wp_rate_overview' || $hook=='wp-rate-and-review_page_wcr_rate_review_settings'){ 236 $plugin_settings = maybe_unserialize(get_option('wcr_options_group')); 237 238 wp_enqueue_style( 'wp-color-picker' ); 239 wp_enqueue_style( 'wpic-slick-css', plugin_dir_url( __FILE__ ).'/assets/css/slick.css'); 240 wp_enqueue_style( 'wpic-admin-css', plugin_dir_url( __FILE__ ).'/assets/css/wpic-admin.css',array(),rand(10,100)); 241 wp_enqueue_style( 'select2-min-css', plugin_dir_url( __FILE__ ).'/assets/css/select2.min.css'); 242 wp_enqueue_script( 'select2-min-js', plugin_dir_url( __FILE__ ).'/assets/js/select2.min.js'); 243 wp_enqueue_script( 'silk-min-js', plugin_dir_url( __FILE__ ).'/assets/js/slick.min.js'); 244 wp_enqueue_script( 'wpic-admin-js', plugin_dir_url( __FILE__ ).'/assets/js/wpic-admin.js',array( 'wp-color-picker' ), rand(10,100), true); 245 246 wp_localize_script( 'wpic-admin-js', 'wcrr_ajax_obj', array( 247 'ajax_url' => admin_url('admin-ajax.php'), 248 'nonce'=> wp_create_nonce('wcrr_nonce_value'), 249 'active_template'=>$plugin_settings['review_template'] 250 )); 251 252 } 253 254 } 278 279 280 281 255 282 256 283 function wcrr_update_template_name($data){ … … 262 289 } 263 290 264 function wcrr_plugin_overview(){ 265 ob_start(); 266 require_once(plugin_dir_path( __FILE__ )."/include/view/welcome.php"); 267 $welcome = ob_get_contents(); 268 ob_clean(); 269 echo $welcome; 270 } 271 272 273 function wcrr_setting_page(){ 274 275 if(!empty($this->result) && array_key_exists('error',$this->result) ){ 276 echo "<div class='error notice is-dismissible'><p><strong>".$this->result['error']."</strong></p><button type='button' class='notice-dismiss'><span class='screen-reader-text'>Dismiss this notice.</span></button></div>"; 277 }else if(!empty($this->result) && array_key_exists('success',$this->result)){ 278 echo "<div class='updated published'><p>".$this->result['success']."</p></div>"; 279 } 280 $plugin_setting_markup = ''; 281 ob_start(); 282 require_once(plugin_dir_path( __FILE__ )."/include/settings/settings.php"); 283 $plugin_setting_markup .= ob_get_contents(); 284 ob_clean(); 285 echo $plugin_setting_markup; 286 } 291 287 292 288 293 function wcrr_review_markup_via_shortcode($atts){ … … 299 304 } 300 305 306 /** 307 * Get Number of ratings of rating status of current products 308 * @param int $rating_number rating number of product like- 5*,4*,3*,2* 309 * @param int $product_id product id 310 * @return int 311 */ 301 312 function wcrr_get_number_ratings($rating_number,$product_id){ 302 313 … … 321 332 function wcrr_prepare_review_markup($product_id){ 322 333 334 323 335 $plugin_settings = maybe_unserialize(get_option('wcr_options_group')); 324 336 … … 326 338 return; 327 339 328 if(!empty($plugin_settings['wphp_exclude_products']) && in_array($p ost->ID, $plugin_settings['wphp_exclude_products']))340 if(!empty($plugin_settings['wphp_exclude_products']) && in_array($product_id, $plugin_settings['wphp_exclude_products'])) 329 341 return; 330 342 … … 377 389 </div> 378 390 </div>'; 379 380 381 391 } 382 383 384 385 386 392 387 393 $html.='<div class="wcrr_total_review_rating">'; … … 402 408 } 403 409 410 /** 411 * Show Rating markup on product page 412 * 413 * @param html @html 414 */ 404 415 function wcrr_enhance_review_rating($html){ 405 406 416 global $product,$post; 407 408 417 $is_product_single = ($post->post_type =='product' && is_single()) ? true : false; 409 410 418 if(!$is_product_single) 411 419 return; … … 415 423 } 416 424 425 /** 426 * Main WCRR_Rate_Review Instance 427 * 428 * @since 1.0.0 429 * @see instance() 430 * @return instance 431 */ 432 433 public static function instance() 434 { 435 if (is_null(self::$instance)) { 436 self::$instance = new self(); 437 } 438 return self::$instance; 439 } 440 441 /** 442 * Initializes the extension. 443 * 444 * @since 1.0.0 445 * @return Object Instance of extension. 446 447 */ 448 449 public static function wcrr_init() 450 { 451 452 $GLOBALS['wcrr_rate_review'] = WCRR_Rate_Review::instance(); 453 } 454 455 456 /** 457 * Entry point of plugin 458 * 459 * @since 1.0.0 460 */ 461 public static function init() 462 { 463 add_action('plugins_loaded', array(__CLASS__, 'wcrr_init')); 464 465 466 } 467 417 468 } 418 return new WCRR_Rate_Review(); 419 469 470 WCRR_Rate_Review::init(); 420 471 }
Note: See TracChangeset
for help on using the changeset viewer.