Changeset 3140987
- Timestamp:
- 08/25/2024 08:13:28 AM (7 months ago)
- Location:
- better-business-reviews
- Files:
-
- 34 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
better-business-reviews/trunk/admin/css/settings.css
r3124390 r3140987 49 49 } 50 50 51 .brtpmj_input {52 min-width: 95%;53 width: 95%;51 .brtpmj_input { 52 min-width: 75%; 53 width: 75%; 54 54 border-radius: 0 !important; 55 }55 } 56 56 57 57 #brtpmj_admin_sync_progress{ … … 66 66 color: forestgreen; 67 67 } 68 .brtpmj_adm_btn { 69 background: #00b67a; 70 border: none; 71 color: #fff; 72 padding: 0px 10px; 73 height: 30px; 74 cursor: pointer; 75 } 76 #license_key_better-business-revi { 77 min-width: 75%; 78 width: 75%; 79 border-radius: 0 !important; 80 background: #fff; 81 border: 1px solid #8c8f94; 82 height: 30px; 83 } 84 .brtpmj_btn, #brtpmj_activate_license { 85 border: none; 86 color: #fff; 87 background: #207196; 88 height: 30px; 89 padding: 0 20px; 90 cursor: pointer; 91 } 92 .brtpmj_shortcode { 93 background: #fff; 94 padding: 5px 10px; 95 } 96 .brtpmj_info { 97 padding-top: 20px; 98 display: flex; 99 } 100 101 .brtpmj_get_pro { 102 color: #fff; 103 text-decoration: none; 104 float: right; 105 background: #207196; 106 padding: 10px 20px; 107 font-size: 16px; 108 margin: -7.5px; 109 } 110 .brtpmj_get_pro:hover { 111 background: #00b67a; 112 color: #fff; 113 } -
better-business-reviews/trunk/admin/settings.php
r3124390 r3140987 23 23 ?> 24 24 <div class="brtpmj_setting-container"> 25 26 <h2 class="brtpmj_admin_heading">General Settings</h2> 27 28 <p style="text-align: center;"> Use Shortcode <strong>[brtpmj_reviews]</strong> to load reviews from the below business profile.</p> 29 25 <h2 class="brtpmj_admin_heading">General Settings <a href="https://mediajedi.com/product/trust-pilot-wordpress-plugin/" class="brtpmj_get_pro" target="_blank">Display More Reviews with PRO Plugin</a></h2> 30 26 <div class="brtpmj_inner-container"> 31 27 <div class="brtpmj_col-1"> … … 35 31 <?php $brtpmj_url = get_option('brtpmj_url'); ?> 36 32 <input type="text" name="brtpmj_url" id="brtpmj_url" class="brtpmj_input" value="<?php echo esc_url( $brtpmj_url ); ?>"> 33 <input type="submit" name="brtpmj_settings_submit" class="brtpmj_adm_btn" value="Fetch Your Reviews"/> 34 <div class="brtpmj_info"> 35 <span id="brtpmj_admin_sync_progress"><img src="<?php echo esc_url( $brtpmj_plugin_url ); ?>/assets/bbr-loading-icon.gif"> Fetching Your Reviews...</span> 36 <span id="brtpmj_admin_sync_status"></span> 37 </div> 37 38 </div> 38 39 </div> 39 40 </div>41 42 <div class="brtpmj_admin_save">43 <input type="submit" name="brtpmj_settings_submit" class="button-primary" value="Sync"/>44 <span id="brtpmj_admin_sync_progress"><img src="<?php echo esc_url( $brtpmj_plugin_url ); ?>/assets/bbr-loading-icon.gif"> Fetching Your Reviews...</span>45 <span id="brtpmj_admin_sync_status"></span>46 40 </div> 47 41 </form> 42 </div> 43 <div class="brtpmj_setting-container"> 44 45 <h2 class="brtpmj_admin_heading">Shortcodes</h2> 46 <div class="brtpmj_inner-container"> 47 <div class="brtpmj_col-1"> 48 <label>List Layout (Default)</label> 49 </div> 50 <div class="brtpmj_col-2"> 51 <span class="brtpmj_shortcode">[brtpmj_reviews]</span> 52 </div> 53 </div> 54 <div class="brtpmj_inner-container"> 55 <div class="brtpmj_col-1"> 56 <label>Grid Layout</label> 57 </div> 58 <div class="brtpmj_col-2"> 59 <span class="brtpmj_shortcode">[brtpmj_reviews layout="grid"]</span> 60 </div> 61 </div> 62 <div class="brtpmj_inner-container"> 63 <div class="brtpmj_col-1"> 64 <label>Carousel Layout</label> 65 </div> 66 <div class="brtpmj_col-2"> 67 <span class="brtpmj_shortcode">[brtpmj_reviews layout="carousel"]</span> 68 </div> 69 </div> 70 <div class="brtpmj_inner-container"> 71 <div class="brtpmj_col-1"> 72 <label>Post Limit (PRO)</label> 73 </div> 74 <div class="brtpmj_col-2"> 75 <span class="brtpmj_shortcode">[brtpmj_reviews limit="8"]</span> 76 </div> 77 </div> 78 <div class="brtpmj_inner-container"> 79 <div class="brtpmj_col-1"> 80 <label>Minimum Stars (PRO)</label> 81 </div> 82 <div class="brtpmj_col-2"> 83 <span class="brtpmj_shortcode">[brtpmj_reviews min_stars="4"]</span> 84 </div> 85 </div> 48 86 </div> 49 87 </div> -
better-business-reviews/trunk/admin/sync.php
r3124390 r3140987 34 34 $args = array( 35 35 "method" => "GET", 36 "timeout" => 10,36 "timeout" => 20, 37 37 "Referrer Policy" => "origin-when-cross-origin", 38 38 "headers" => array( … … 53 53 $data = json_decode($response['body']); 54 54 55 $pageProps = $data->pageProps;55 if(isset($data->pageProps)){ 56 56 57 // busines unit 58 $unit = $pageProps->businessUnit; 59 $displayName = sanitize_text_field( $unit->displayName ); 60 $identifyingName = sanitize_text_field( $unit->identifyingName ); 61 $numberOfReviews = sanitize_text_field( $unit->numberOfReviews ); 62 $score = sanitize_text_field( $unit->trustScore ); 63 $profileImageUrl = sanitize_text_field( $unit->profileImageUrl ); 64 $stars = sanitize_text_field( $unit->stars ); 65 66 // Add to options 67 update_option('brtpmj_bu_displayname', $displayName); 68 update_option('brtpmj_bu_identifyingname', $identifyingName); 69 update_option('brtpmj_bu_numberofreviews', $numberOfReviews); 70 update_option('brtpmj_bu_score', $score); 71 update_option('brtpmj_bu_profileimageurl', $profileImageUrl); 72 update_option('brtpmj_bu_stars', $stars); 73 74 // Reviews - insert custom posts 75 $reviews = $pageProps->reviews; 76 77 if(is_array($reviews)){ 57 $pageProps = $data->pageProps; 78 58 79 $reversed_array_reviews = array_reverse($reviews); 59 // busines unit 60 $unit = $pageProps->businessUnit; 61 $displayName = sanitize_text_field( $unit->displayName ); 62 $identifyingName = sanitize_text_field( $unit->identifyingName ); 63 $numberOfReviews = sanitize_text_field( $unit->numberOfReviews ); 64 $score = sanitize_text_field( $unit->trustScore ); 65 $profileImageUrl = sanitize_text_field( $unit->profileImageUrl ); 66 $stars = sanitize_text_field( $unit->stars ); 80 67 81 // let's remove past entries first 82 $current_reviews = get_posts(array( 83 'numberposts' => -1, 84 'status' => 'any', 85 'post_type' => 'brtpmj_review' 86 )); 87 foreach($current_reviews as $cr){ 88 wp_delete_post($cr->ID, true); 89 } 68 // Add to options 69 update_option('brtpmj_bu_displayname', $displayName); 70 update_option('brtpmj_bu_identifyingname', $identifyingName); 71 update_option('brtpmj_bu_numberofreviews', $numberOfReviews); 72 update_option('brtpmj_bu_score', $score); 73 update_option('brtpmj_bu_profileimageurl', $profileImageUrl); 74 update_option('brtpmj_bu_stars', $stars); 90 75 91 // insert new reviews92 $ inserted = 0;76 // Reviews - insert custom posts 77 $reviews = $pageProps->reviews; 93 78 94 foreach($reversed_array_reviews as $review){ 95 $title = sanitize_text_field( $review->title ); 96 $text = sanitize_text_field( $review->text ); 97 $rating = sanitize_text_field( $review->rating ); 79 if(is_array($reviews)){ 98 80 99 $rev iewDate = date('Y-m-d', strtotime( sanitize_text_field( $review->dates->publishedDate ) ));81 $reversed_array_reviews = array_reverse($reviews); 100 82 101 $consumer = $review->consumer; 102 $cName = sanitize_text_field( $consumer->displayName ); 103 $cimage = sanitize_text_field( $consumer->imageUrl ); 104 105 $initials_img = ''; 106 if(!$cimage || $cimage == ''){ 107 preg_match_all('/\b\w/', $cName, $matches); 108 $initials_img = '<span>' . implode( $matches[0] ) . '</span>'; 109 } 110 else{ 111 $initials_img = '<img src="' . $cimage . '">'; 83 // let's remove past entries first 84 $current_reviews = get_posts(array( 85 'numberposts' => -1, 86 'status' => 'any', 87 'post_type' => 'brtpmj_review' 88 )); 89 foreach($current_reviews as $cr){ 90 wp_delete_post($cr->ID, true); 112 91 } 113 92 114 $post_args = array( 115 'post_title' => $title, 116 'post_type' => 'brtpmj_review', 117 'post_status' => 'publish', 118 'post_content' => $text 119 ); 93 // insert new reviews 94 $inserted = 0; 120 95 121 $id = wp_insert_post($post_args); 122 123 if(!is_wp_error($id)){ 96 foreach($reversed_array_reviews as $review){ 97 $title = sanitize_text_field( $review->title ); 98 $text = sanitize_text_field( $review->text ); 99 $rating = sanitize_text_field( $review->rating ); 124 100 125 update_post_meta($id, 'rating', $rating); 126 update_post_meta($id, 'reviewDate', $reviewDate); 127 update_post_meta($id, 'cName', $cName); 128 update_post_meta($id, 'cimage', $initials_img); 101 $reviewDate = date('Y-m-d', strtotime( sanitize_text_field( $review->dates->publishedDate ) )); 129 102 130 $inserted++; 103 $consumer = $review->consumer; 104 $cName = sanitize_text_field( $consumer->displayName ); 105 $cimage = sanitize_text_field( $consumer->imageUrl ); 106 107 $initials_img = ''; 108 if(!$cimage || $cimage == ''){ 109 preg_match_all('/\b\w/', $cName, $matches); 110 $initials_img = '<span>' . implode( $matches[0] ) . '</span>'; 111 } 112 else{ 113 $initials_img = '<img src="' . $cimage . '">'; 114 } 115 116 $post_args = array( 117 'post_title' => $title, 118 'post_type' => 'brtpmj_review', 119 'post_status' => 'publish', 120 'post_content' => $text 121 ); 122 123 $id = wp_insert_post($post_args); 124 125 if(!is_wp_error($id)){ 126 127 update_post_meta($id, 'rating', $rating); 128 update_post_meta($id, 'reviewDate', $reviewDate); 129 update_post_meta($id, 'cName', $cName); 130 update_post_meta($id, 'cimage', $initials_img); 131 132 $inserted++; 133 134 } 131 135 132 136 } 133 137 138 $brtpmj_res_array['success'] = 1; 139 $brtpmj_res_array['inserted_count'] = $inserted; 140 134 141 } 135 142 136 $brtpmj_res_array['success'] = 1;137 $brtpmj_res_array['inserted_count'] = $inserted;138 143 } 144 else{ 145 $brtpmj_res_array['error'] = __("Error getting reviews. Please make sure to enter correct profile URL.", "better-business-reviews"); 139 146 } 140 147 141 148 } 142 149 else{ 143 $brtpmj_res_array['error'] = __("Error getting reviews. Empty Body! ", "better-business-reviews");150 $brtpmj_res_array['error'] = __("Error getting reviews. Empty Body! Please try again.", "better-business-reviews"); 144 151 } 145 152 146 153 } 147 154 else { 148 $brtpmj_res_array['error'] = __("Error getting reviews. No response! ", "better-business-reviews");155 $brtpmj_res_array['error'] = __("Error getting reviews. No response! Please try again.", "better-business-reviews"); 149 156 } 150 157 -
better-business-reviews/trunk/better-business-reviews.php
r3127804 r3140987 3 3 * Plugin Name: Better Business Reviews - Trustpilot WordPress Plugin. 4 4 * Description: Display your business reviews from a Trustpilot profile. 5 * Version: 0.0. 46 * Author: Media Jedi5 * Version: 0.0.5 6 * Author: Better Business Reviews 7 7 * Author URI: https://www.mediajedi.com/product/trust-pilot-wordpress-plugin/ 8 8 * License: GPLv2 or later … … 21 21 22 22 define ( 'BRTPMJ_PLUGIN_DIR', plugin_dir_path(__FILE__ ) ); 23 define ( 'BRTPMJ_PLUGIN_VER', '0.0. 4' );23 define ( 'BRTPMJ_PLUGIN_VER', '0.0.5' ); 24 24 25 25 global $brtpmj_plugin_url, $brtpmj_api_url; … … 80 80 BRTPMJ_PLUGIN_VER 81 81 ); 82 wp_register_style( 83 'brtpmj-grid-style', 84 plugin_dir_url( __FILE__ ) . 'css/grid.css', 85 [], 86 BRTPMJ_PLUGIN_VER 87 ); 88 wp_register_style( 89 'brtpmj-carousel-style', 90 plugin_dir_url( __FILE__ ) . 'css/carousel.css', 91 [], 92 BRTPMJ_PLUGIN_VER 93 ); 94 wp_register_script( 95 'brtpmj-carousel-script', 96 plugins_url('js/carousel.js',__FILE__ ), 97 array('jquery'), 98 BRTPMJ_PLUGIN_VER 99 ); 82 100 } 83 101 } -
better-business-reviews/trunk/css/style.css
r3124390 r3140987 46 46 padding: 15px; 47 47 border-radius: 8px; 48 break-inside: avoid; 48 49 } 49 50 .brtpmj_sr_author_overview{ -
better-business-reviews/trunk/readme.txt
r3131178 r3140987 4 4 Requires at least: 6.0 5 5 Tested up to: 6.6 6 Stable tag: 0.0. 46 Stable tag: 0.0.5 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 67 67 68 68 == Screenshots == 69 1. Sample reviews from a Trustpilot account70 2. Plugin Settings71 3. Importing reviews from a Trustpilot account72 4. Success message after import69 1. Plugin Settings 70 2. List Layout 71 3. Grid Layout 72 4. Carousel Layout 73 73 74 74 == Changelog == 75 76 = 0.0.5 = 77 * 2024-08-25 78 * Added grid layout. 79 * Added carousel layout. 80 * Added new setting section. 75 81 76 82 = 0.0.4 = -
better-business-reviews/trunk/shortcode.php
r3124390 r3140987 15 15 if( !is_admin() ){ // only run when in front-end 16 16 17 // parameters 18 $layout = 'list'; 19 $container_class = ''; 20 21 if(isset($atts['layout'])) { 22 $layout = sanitize_text_field($atts['layout']); 23 } 24 17 25 wp_enqueue_style('brtpmj-style'); 18 26 wp_enqueue_script('brtpmj-script'); 27 28 if($layout == 'grid') { 29 $container_class = ' brtpmj_grid_container'; 30 wp_enqueue_style('brtpmj-grid-style'); 31 } 32 if($layout == 'carousel') { 33 $container_class = ' carousel'; 34 wp_enqueue_style('brtpmj-carousel-style'); 35 wp_enqueue_script('brtpmj-carousel-script'); 36 } 19 37 20 38 global $brtpmj_plugin_url; … … 50 68 $initials_img = get_post_meta($review->ID, 'cimage', true); 51 69 52 $rvw_html .= '<div class="brtpmj_single_rvw ">70 $rvw_html .= '<div class="brtpmj_single_rvw' . ($layout == 'carousel' ? ' carousel-item' : '') . '"> 53 71 54 72 <div class="brtpmj_sr_author_overview"> … … 90 108 </p>'; 91 109 92 $html .= '<div class="brtpmj_all_reviews">' . $rvw_html . '</div>'; 93 94 110 $html .= '<div class="' . ($layout == 'carousel' ? 'carousel-container': '') . '">'; 111 $html .= '<div class="brtpmj_all_reviews' . $container_class .'">' . $rvw_html . '</div>'; 112 113 if($layout == 'carousel') { 114 $html .= ' 115 <div class="carousel-nav" data-index="0"> 116 <button class="slider-btn slider-prev">❮</button> 117 <button class="slider-btn slider-next">❯</button> 118 </div> 119 '; 120 } 121 $html .= '</div>'; 95 122 96 123 $html .= '</div>';
Note: See TracChangeset
for help on using the changeset viewer.