Changeset 2881771
- Timestamp:
- 03/17/2023 08:05:32 AM (3 years ago)
- Location:
- ryviu/trunk
- Files:
-
- 7 edited
-
assets/css/ryviu-admin.css (modified) (6 diffs)
-
assets/js/local-ryviu.js (modified) (1 diff)
-
includes/class-ryviu.php (modified) (2 diffs)
-
includes/functions.php (modified) (5 diffs)
-
includes/main-class.php (modified) (3 diffs)
-
includes/settings.php (modified) (9 diffs)
-
ryviu.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ryviu/trunk/assets/css/ryviu-admin.css
r2764966 r2881771 338 338 .settings_page_ryviu-setting-admin #wpbody-content h2{ 339 339 font-size: 25px; 340 color: #2d89c2;341 340 } 342 341 .settings_page_ryviu-setting-admin.wp-core-ui .button-primary{ … … 349 348 border-radius: 6px; 350 349 border: 1px solid #dedede; 351 height: 40px;352 line-height: 3 8px;350 height: 38px; 351 line-height: 36px; 353 352 padding:0 25px 0 15px; 354 353 } … … 358 357 } 359 358 .settings_page_ryviu-setting-admin input{ 360 height: 40px;361 line-height: 40px;359 height: 38px; 360 line-height: 38px; 362 361 border-color: #d9d9d9; 363 362 color: #333; … … 366 365 .settings_page_ryviu-setting-admin .form-table td p{ 367 366 font-style: italic; 368 opacity: 0.8;367 font-size: 13px; 369 368 } 370 369 .settings_page_ryviu-setting-admin .wrap form{ … … 382 381 .r--notices{ 383 382 position: relative; 384 padding-left: 40px!important; 383 height: 40px; 384 margin: 10px 0; 385 padding-left: 60px!important; 386 display: flex; 387 align-items: center; 388 } 389 .r-cl-connect .notice-dismiss{ 390 top: 50%; 391 transform: translateY(-50%); 385 392 } 386 393 .r--notices img{ 387 height: 30px;394 height: 40px; 388 395 position: absolute; 389 396 left: 0; 390 top: -4px; 397 top: 50%; 398 transform: translateY(-50%); 391 399 vertical-align: middle; 400 } 401 .r--notices p{ 402 font-size: 14px; 403 color: #000; 392 404 } 393 405 .notice-success.r-cl-connect{ … … 397 409 display: block!important; 398 410 } 411 .ryviu-page--image{ 412 width: 130px; 413 margin-right:20px; 414 } 415 .r-des{ 416 font-size: 14px; 417 } 418 .ryviu-page--header{ 419 padding: 30px 0 30px; 420 display: flex; 421 align-items: center; 422 border-bottom: 1px solid #d5d5d5; 423 max-width: 860px; 424 } 425 .ryviu-page--intro{ 426 font-size: 14px; 427 padding-right: 10px; 428 } 429 .ryviu-page--title{ 430 margin-top: 5px; 431 } 432 .ryviu-page--btn{ 433 border: solid 1px #549ecb; 434 color: #fff; 435 font-weight: 500; 436 padding: 8px 20px; 437 border-radius: 5px; 438 display: inline-block; 439 background: #549ecb; 440 text-decoration: none; 441 margin-right: 8px; 442 margin-bottom: 10px; 443 } 444 .ryviu-page--btn:hover, 445 .ryviu-page--btn:active, 446 .ryviu-page--btn:focus{ 447 background: #187ebd; 448 border-color: #187ebd; 449 color: #fff; 450 } 451 .ryviu-page--btnnd{ 452 border: solid 1px #dedede; 453 background: #fff; 454 color: #413434; 455 } 456 .ryviu-page--btnnd:hover, 457 .ryviu-page--btnnd:active, 458 .ryviu-page--btnnd:focus{ 459 background: #F7F7F7; 460 border-color: #D6D6D6; 461 color: #413434; 462 } 463 .r-rate--us{ 464 color: #fdbe11; 465 border-color: #fdbe11; 466 } 467 @media only screen and (max-width: 600px) { 468 .ryviu-page--header { 469 display: none; 470 } 471 } -
ryviu/trunk/assets/js/local-ryviu.js
r2764966 r2881771 8 8 //Nothing to do 9 9 let element_trigger_click = '.ryviu_reviews_tab_tab > a'; 10 10 11 if(ryviu_app.element_trigger_click && ryviu_app.element_trigger_click != ''){ 11 12 element_trigger_click = ryviu_app.element_trigger_click; 12 13 } 14 13 15 if (ryviu_app.active_reviews_tab == 1) { 14 16 $(element_trigger_click).trigger('click'); 15 17 } 16 18 17 if (ryviu_app.position_display == 1 ) {19 if (ryviu_app.position_display == 1 || element_trigger_click != '.ryviu_reviews_tab_tab > a') { 18 20 $(document).on('click','.product-widget__ryviu',function(){ 19 21 $(element_trigger_click).trigger('click'); -
ryviu/trunk/includes/class-ryviu.php
r2764966 r2881771 75 75 */ 76 76 public function query_vars( $vars ){ 77 array_push( $vars, 'ryviu' ); 78 array_push( $vars, 'type' ); 79 array_push( $vars, 'handle' ); 80 array_push( $vars, 'endpoint' ); 81 return $vars; 77 $new_vars = ['ryviu', 'type', 'handle', 'endpoint']; 78 return array_merge($vars, $new_vars); 82 79 } 83 80 … … 172 169 // Add js to check Ryviu connect 173 170 174 wp_enqueue_script( 'ryviu_check_connect', RYVIU_URL_ASSETS.'js/check-ryviu.js ' );171 wp_enqueue_script( 'ryviu_check_connect', RYVIU_URL_ASSETS.'js/check-ryviu.js?version=3' ); 175 172 176 173 if ( 'settings_page_ryviu-setting-admin' == $hook ) { -
ryviu/trunk/includes/functions.php
r2872853 r2881771 30 30 } 31 31 } 32 33 // Check connect Ryviu 34 $check_settings = get_option( 'ryviu_client_settings' ); 35 $check_ryviu_connect = $check_settings && $check_settings != new \stdClass() ? true : false; 36 37 // Remove default reviews 38 $check_reviews_woo_active = get_option( 'woocommerce_enable_reviews' ); 39 40 if(isset($check_reviews_woo_active) && $check_reviews_woo_active == 'yes' && $check_ryviu_connect){ 41 function iconic_disable_reviews() { 42 remove_post_type_support( 'product', 'comments' ); 43 } 44 45 add_action( 'init', 'iconic_disable_reviews' ); 46 47 function remove_reviews_tab($tabs) { 48 unset($tabs['reviews']); 49 return $tabs; 50 } 51 52 add_filter( 'woocommerce_product_tabs', 'remove_reviews_tab', 98 ); 53 54 remove_action ('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 ); 55 } 56 57 58 // End remove default reviews 32 59 33 60 /** … … 110 137 111 138 112 if($position_display){ 113 switch($position_display){ 114 case 1: { 115 $priority = 65; 116 if(null !== RyviuSettings::get_option('position_display')){ 117 $priority = RyviuSettings::get_option('priority_position_display'); 139 140 // Check if 141 if($check_ryviu_connect){ 142 143 if($position_display){ 144 switch($position_display){ 145 case 1: { 146 $priority = 65; 147 if(null !== RyviuSettings::get_option('position_display')){ 148 $priority = RyviuSettings::get_option('priority_position_display'); 149 } 150 151 add_filter( 'woocommerce_product_tabs', 'woo_ryviu_review_product_tab', $priority ); 118 152 } 119 add_filter( 'woocommerce_product_tabs', 'woo_ryviu_review_product_tab', $priority );120 } 121 break;122 123 case 11:124 case 4: {125 $config_hook = ryviu_display_position_hook();126 $config = $config_hook[$position_display];127 $priority = 10;128 if(null !== RyviuSettings::get_option('position_display')){129 $priority = RyviuSettings::get_option('priority_position_display');153 break; 154 155 case 11: 156 case 4: { 157 $config_hook = ryviu_display_position_hook(); 158 $config = $config_hook[$position_display]; 159 $priority = 10; 160 if(null !== RyviuSettings::get_option('position_display')){ 161 $priority = RyviuSettings::get_option('priority_position_display'); 162 } 163 add_action( $config['hook_name'], 'ryviu_product_display_review', $config['priority'] ); 130 164 } 131 add_action( $config['hook_name'], 'ryviu_product_display_review', $config['priority'] );132 } 133 break;134 135 case 10:{136 $priority = 20;137 if(null !== RyviuSettings::get_option('position_display')){138 $priority = RyviuSettings::get_option('priority_position_display');165 break; 166 167 case 10: { 168 $priority = 20; 169 if(null !== RyviuSettings::get_option('position_display')){ 170 $priority = RyviuSettings::get_option('priority_position_display'); 171 } 172 add_action('ryviu_display_review', 'ryviu_product_display_review', 20 ); 139 173 } 140 add_action('ryviu_display_review', 'ryviu_product_display_review', 20 ); 141 } 142 break; 143 } 144 } 145 146 if($position_display_widget){ 147 switch($position_display_widget){ 148 case 2: 149 case 3: { 150 $config_hook = ryviu_display_position_hook(); 151 $config = $config_hook[$position_display_widget]; 152 add_action( $config['hook_name'], 'ryviu_widget_rating_total', $config['priority'] ); 153 } 154 break; 155 156 case 10: { 157 add_action('ryviu_display_total_review', 'ryviu_widget_rating_total', 20 ); 158 } 159 break; 160 } 161 } 162 163 164 if($position_display_widget_in_loop){ 165 switch($position_display_widget_in_loop){ 166 case 5: 167 case 6: { 168 $config_hook = ryviu_display_position_hook(); 169 $config = $config_hook[$position_display_widget_in_loop]; 170 add_action( $config['hook_name'], 'ryviu_widget_rating_total_in_product_category', $config['priority'] ); 171 } 172 break; 173 174 case 10: { 175 add_action('ryviu_display_review_total_in_loop', 'ryviu_widget_rating_total_in_product_category', 20 ); 176 } 177 break; 178 } 179 } 180 174 break; 175 } 176 } 177 178 if($position_display_widget){ 179 switch($position_display_widget){ 180 case 2: 181 case 3: { 182 $config_hook = ryviu_display_position_hook(); 183 $config = $config_hook[$position_display_widget]; 184 add_action( $config['hook_name'], 'ryviu_widget_rating_total', $config['priority'] ); 185 } 186 break; 187 188 case 10: { 189 add_action('ryviu_display_total_review', 'ryviu_widget_rating_total', 20 ); 190 } 191 break; 192 } 193 } 194 195 196 if($position_display_widget_in_loop){ 197 switch($position_display_widget_in_loop){ 198 case 5: 199 case 6: { 200 $config_hook = ryviu_display_position_hook(); 201 $config = $config_hook[$position_display_widget_in_loop]; 202 add_action( $config['hook_name'], 'ryviu_widget_rating_total_in_product_category', $config['priority'] ); 203 } 204 break; 205 206 case 10: { 207 add_action('ryviu_display_review_total_in_loop', 'ryviu_widget_rating_total_in_product_category', 20 ); 208 } 209 break; 210 } 211 } 212 } 181 213 182 214 /** … … 409 441 function woo_ryviu_review_product_tab( $tabs ) { 410 442 global $product; 443 411 444 if(!$product){ 412 445 $product_id = ryviu_get_page_id(); … … 418 451 $custom_title = isset($custom_title)? $custom_title: 'Reviews (%total_number%)'; 419 452 if ($custom_title == '') { 420 $custom_title = 'Reviews (%total_number%)';453 $custom_title = 'Reviews (%total_number%)'; 421 454 } 422 455 … … 439 472 } 440 473 441 $tabs['ryviu_reviews_tab'] = array(442 'title' => __( $custom_title, 'woocommerce' ),443 'priority' => 50,444 'callback' => 'ryviu_product_display_review'445 );446 447 unset($tabs['reviews']);448 449 return $tabs;474 $tabs['ryviu_reviews_tab'] = array( 475 'title' => __( $custom_title, 'woocommerce' ), 476 'priority' => 50, 477 'callback' => 'ryviu_product_display_review' 478 ); 479 480 unset($tabs['reviews']); 481 482 return $tabs; 450 483 } 451 484 } -
ryviu/trunk/includes/main-class.php
r2872856 r2881771 8 8 9 9 public static function check_connect_ryviu($check = false) { 10 $mes = 'Connection failed, please contact Ryviu support for help.'; 10 11 delete_option( 'ryviu_client_settings' ); 11 12 $settings = get_option( 'ryviu_client_settings' ); … … 34 35 } 35 36 } 37 $mes = 'Your store has not been linked to Ryviu, or the connected WordPress address is incorrect. Please login your Ryviu account and check in the settings page.'; 36 38 }catch(Exception $e){ 37 39 //handle exception … … 41 43 wp_send_json([ 42 44 'status' => 'error', 43 'mes' => 'Connection failed, please contact Ryviu support for help.'45 'mes' => $mes 44 46 ]); 45 47 } -
ryviu/trunk/includes/settings.php
r2872853 r2881771 59 59 $this->options = get_option( 'ryviu_settings_reviews' ); 60 60 ?> 61 <div class="ryviu-page--header"> 62 <img class="ryviu-page--image" src="https://app.ryviu.io/images/logo-ryviu-v8.svg"/> 63 <div class="ryviu-page--intro"> 64 <h1 class="ryviu-page--title">Welcome to Ryviu!</h1> 65 <p class="ryviu-page--intro">Ryviu is a product review app that helps you generate eCommerce social proof, increase trust & sales. You can easy to customize reviews with Ryviu and show them in your store.</p> 66 <a class="ryviu-page--btn" href="https://app.ryviu.io" target="_blank">Ryviu Dashboard</a> 67 <a class="ryviu-page--btn ryviu-page--btnnd" href="https://docs.ryviu.com/en/collections/1861213-woocommerce" target="_blank">Document</a> 68 <a class="ryviu-page--btn ryviu-page--btnnd r-rate--us" href="https://wordpress.org/support/plugin/ryviu/reviews/#new-post" target="_blank">★ Rate Us</a> 69 </div> 70 </div> 61 71 <div class="wrap"> 62 72 63 73 <form method="post" action="options.php"> 64 <?php65 // This prints out all hidden setting fields66 settings_fields( 'ryviu_option_group' );67 do_settings_sections( 'ryviu-setting-admin' );68 69 echo '<div class="info">70 <p><strong>Priority</strong>: Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.</p>71 </div>';72 73 submit_button();74 ?>74 <?php 75 // This prints out all hidden setting fields 76 settings_fields( 'ryviu_option_group' ); 77 do_settings_sections( 'ryviu-setting-admin' ); 78 79 echo '<div class="info"> 80 <p><strong>Priority</strong>: Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.</p> 81 </div>'; 82 83 submit_button(); 84 ?> 75 85 </form> 76 86 </div> … … 108 118 109 119 public function fields_settings(){ 110 return array( 111 array( 112 'name' => 'custom_tab_title', 113 'title' => 'Title reviews tab' 114 ), 115 array( 116 'name' => 'position_display_widget', 117 'title' => 'Star rating on product page' 118 ), 119 array( 120 'name' => 'position_display', 121 'title' => 'Review box on product page' 122 ), 123 array( 124 'name' => 'active_reviews_tab', 125 'title' => 'Default active review tab' 126 ), 127 array( 128 'name' => 'position_display_widget_in_loop', 129 'title' => 'Star rating on collection page' 130 ), 131 array( 132 'name' => 'question_and_answer', 133 'title' => 'Question and Answer' 134 ), 135 array( 136 'name' => 'custom_question_tab_title', 137 'title' => 'Title Question & Answer tab' 138 ), 139 array( 140 'name' => 'wordpress_theme', 141 'title' => 'Wordpress Theme' 142 ), 143 array( 144 'name' => 'data_rocket_status', 145 'title' => 'Cloudfare CDN & Data Rocket' 146 ), 147 array( 148 'name' => 'element_trigger_click', 149 'title' => 'Title reviews tab HTML' 150 ) 151 ); 120 $fields = [ 121 'custom_tab_title' => 'Title reviews tab', 122 'position_display_widget' => 'Star rating on product page', 123 'position_display' => 'Review box on product page', 124 'active_reviews_tab' => 'Default active review tab', 125 'position_display_widget_in_loop' => 'Star rating on collection page', 126 'question_and_answer' => 'Question and Answer', 127 'custom_question_tab_title' => 'Title Question & Answer tab', 128 'wordpress_theme' => 'Wordpress Theme', 129 'data_rocket_status' => 'Cloudfare CDN & Data Rocket', 130 'element_trigger_click' => 'Title reviews tab HTML', 131 ]; 132 133 return array_map(function($name, $title) { 134 return ['name' => $name, 'title' => $title]; 135 }, array_keys($fields), array_values($fields)); 136 } 137 138 public function check_selected($val1 = '1', $val2 = '2'){ 139 if($val1 == $val2){ 140 return 'selected="selected"'; 141 } 142 return ''; 152 143 } 153 144 … … 197 188 */ 198 189 public function print_section_info(){ 199 print ' Enter your settings below:';190 print '<p class="r-des">Enter your settings below:</p>'; 200 191 } 201 192 … … 265 256 $select = isset($this->options[$name])? $this->options[$name] : 1; 266 257 $priority_select = isset($this->options['priority_'.$name])?$this->options['priority_'.$name] : 10; 267 268 258 echo '<select id="position_display" class="ryviu_settings_reviews" name="ryviu_settings_reviews['.$name.']">'; 269 259 foreach (ryviu_display_position_hook($name) as $key => $data) { 270 echo '<option value="'. $key .'" '. selected($select, $key) .'>'. $data['title'] .'</option>';260 echo '<option value="'. $key .'" '. $this->check_selected($select, $key) .'>'. $data['title'] .'</option>'; 271 261 } 272 262 echo '</select>'; … … 274 264 echo '<span class="priority-label">Priority</span><select name="ryviu_settings_reviews[priority_'.$name.']">'; 275 265 foreach([6, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80] as $priority){ 276 echo '<option value="'. $priority .'" '. selected($priority_select, $priority) .'>'. $priority .'</option>';266 echo '<option value="'. $priority .'" '. $this->check_selected($priority_select, $priority) .'>'. $priority .'</option>'; 277 267 } 278 268 echo '</select>'; … … 314 304 315 305 foreach ($themes as $key => $data) { 316 echo '<option value="'. $key .'" '. selected($select, $key) .'>'. $data .'</option>';306 echo '<option value="'. $key .'" '. $this->check_selected($select, $key) .'>'. $data .'</option>'; 317 307 } 318 308 echo '</select>'; … … 328 318 echo '<select id="active_reviews_tab" class="ryviu_settings_reviews" name="ryviu_settings_reviews[active_reviews_tab]">'; 329 319 foreach (array('1' => 'Yes', '0' => 'No') as $key => $data) { 330 echo '<option value="'. $key .'" '. selected($select, $key) .'>'. $data .'</option>';320 echo '<option value="'. $key .'" '. $this->check_selected($select, $key) .'>'. $data .'</option>'; 331 321 } 332 322 echo '</select>'; … … 340 330 echo '<select id="question_and_answer" class="ryviu_settings_reviews" name="ryviu_settings_reviews[question_and_answer]">'; 341 331 foreach (array('0' => 'Disable', '1' => 'After single product summary','2' => 'Question and Answer tab' ) as $key => $data) { 342 echo '<option value="'. $key .'" '. selected($select, $key) .'>'. $data .'</option>';332 echo '<option value="'. $key .'" '. $this->check_selected($select, $key) .'>'. $data .'</option>'; 343 333 } 344 334 echo '</select>'; … … 356 346 $select = $this->options['enable_ajax_add_to_cart']; 357 347 } 358 348 359 349 echo '<select id="position_display" class="ryviu_settings_reviews" name="ryviu_settings_reviews[enable_ajax_add_to_cart]">'; 360 350 foreach (array('1' => 'Yes', '0' => 'No') as $key => $data) { 361 echo '<option value="'. $key .'" '. selected($select, $key) .'>'. $data .'</option>';351 echo '<option value="'. $key .'" '. $this->check_selected($select, $key) .'>'. $data .'</option>'; 362 352 } 363 353 echo '</select>'; -
ryviu/trunk/ryviu.php
r2872853 r2881771 43 43 define('RYVIU_APP_HOOK_URL', 'https://app.ryviu.io/webhook/woocommerce/'); 44 44 45 require plugin_dir_path( __FILE__ ) . 'includes/main-class.php';45 require_once plugin_dir_path( __FILE__ ) . 'includes/main-class.php'; 46 46 47 47 /** … … 73 73 74 74 if(!$settings || $settings == new \stdClass()){ 75 echo '<div class="notice notice-error is-dismissible r-cl-connect">< p class="r--notices"><img src="https://app.ryviu.io/images/logo-ryviu-v8.svg" alt="" /><b>Ryviu:</b> It looks like there is a problem connecting your store to Ryviu. Please <a class="ryviu-check-connect" href="javascript:void(0)">click here</a> to check the issue, or please <a target="_blank" href="https://www.ryviu.com">contact us</a> for help.</p></div>';75 echo '<div class="notice notice-error is-dismissible r-cl-connect"><div class="r--notices"><img src="https://app.ryviu.io/images/logo-ryviu-v8.svg" alt="" /><p><b>Ryviu:</b> It looks like there is a problem connecting your store to Ryviu. Please <a class="ryviu-check-connect" href="javascript:void(0)">click here</a> to check the issue, or please <a target="_blank" href="https://www.ryviu.com/contact-us">contact us</a> for help.</p></div></div>'; 76 76 echo '<div class="notice notice-success is-dismissible r-cl-connect"><p class="r--notices"><img src="https://app.ryviu.io/images/logo-ryviu-v8.svg" alt="" /><b>Ryviu: Successful connection</b></p></div>'; 77 77 } 78 78 } 79 79 80 80 81 register_activation_hook( __FILE__, 'activate_ryviu' ); … … 84 85 85 86 // Include main ryviu class 86 require plugin_dir_path( __FILE__ ) . 'includes/class-ryviu.php';87 require_once plugin_dir_path( __FILE__ ) . 'includes/class-ryviu.php'; 87 88 88 89 // Main Class Called
Note: See TracChangeset
for help on using the changeset viewer.