Changeset 1967374
- Timestamp:
- 11/01/2018 07:06:46 PM (7 years ago)
- Location:
- recomendo/trunk
- Files:
-
- 8 edited
-
README.txt (modified) (7 diffs)
-
inc/libraries/recomendo-async-request.php (modified) (1 diff)
-
inc/recomendo-background-order-copy.php (modified) (1 diff)
-
recomendo-client.php (modified) (1 diff)
-
recomendo-plugin.php (modified) (9 diffs)
-
recomendo-widget.php (modified) (8 diffs)
-
recomendo.php (modified) (1 diff)
-
screens/dashboard.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
recomendo/trunk/README.txt
r1963755 r1967374 1 1 === Recomendo === 2 2 Contributors: recomendo 3 Tags: artificial intelligence, machine learning, related posts, recommendations, personali sation3 Tags: artificial intelligence, machine learning, related posts, recommendations, personalization 4 4 Requires at least: 4.7 5 5 Tested up to: 4.9 … … 21 21 And if you have WooCommerce activated, Recomendo can also show its recommendations in the related products area of Product pages, and items "usually bought together" in the Cart page. 22 22 23 Recomendo makes uses of standard WordPress template partials to fully integr ete into your themes appearance, or call the PHP API directly to unleash ultimate control.23 Recomendo makes uses of standard WordPress template partials to fully integrate into your themes appearance, or call the PHP API directly to unleash ultimate control. 24 24 25 25 Recomendo offers 1 month free trial with all its subscription plans. You can learn more about our features and plans at the [Recomendo](https://www.recomendo.ai "Recomendo") website. … … 27 27 = Features = 28 28 29 * Easy to use - Recomendo is very easy to use just drag the widget to a sidebar and start getting personali sed recommendations in your website.29 * Easy to use - Recomendo is very easy to use just drag the widget to a sidebar and start getting personalized recommendations in your website. 30 30 31 31 * Uses your theme's template partials to fully integrate into your site with the same appearance. … … 98 98 = How can I further customize the look? = 99 99 100 Recomendo uses template partia s to directly get the look of your theme and integrate seamlessly into your site. If you need to further customize the appearance, you can create your own template partial in your child-theme.100 Recomendo uses template partials to directly get the look of your theme and integrate seamlessly into your site. If you need to further customize the appearance, you can create your own template partial in your child-theme. 101 101 102 102 = Is Recomendo Free? = … … 125 125 126 126 == Changelog == 127 = 1.0.4 = 128 * WooCommerce 3.5 tested 129 130 * Better robots detection 131 132 * Bug fixes 133 127 134 = 1.0.3 = 128 135 * Bug fixes … … 146 153 147 154 = 0.9.8 = 148 * JWT API authenti acion155 * JWT API authentication 149 156 150 157 * Display recommendations using template parts … … 159 166 * GDPR features. Data Explorer with search, delete and export 160 167 161 * Users can om mit to being tracked via the user settings.168 * Users can omit to being tracked via the user settings. 162 169 163 170 * Customizable widget. Now you can choose post metas and the titles to display -
recomendo/trunk/inc/libraries/recomendo-async-request.php
r1963755 r1967374 17 17 * @access protected 18 18 */ 19 protected $prefix = ' wp';19 protected $prefix = 'recomendo'; 20 20 /** 21 21 * Action -
recomendo/trunk/inc/recomendo-background-order-copy.php
r1963755 r1967374 36 36 $line_items = $order->get_items(); 37 37 38 // This loops over line items39 foreach ( $line_items as $item ) {38 // Send the order 39 $userid = $order->get_user_id(); 40 40 41 // This will be a product 42 $productid = $item->get_product_id(); 41 if ( $userid == 0 ) { 42 // If the purchase was from unregistered user 43 // we need to create the user 44 $userid = 'order_' . strval( $order->get_id() ); 45 } 43 46 44 if ( $productid != 0 ) {47 $response = $recomendo->client->set_user( $userid ); 45 48 46 // Send the order 47 $userid = $order->get_user_id(); 49 if ( is_wp_error( $response )) { 50 error_log( "[RECOMENDO] --- Error adding user " . strval( $userid ) . " when recording all orders." ); 51 error_log( "[RECOMENDO] --- " . $response->get_error_message() ); 52 } else { 48 53 49 // If the purchase was from unregistered user 50 // we need to create the user 54 // This loops over line items 55 foreach ( $line_items as $item ) { 56 // This will be a product 57 $productid = $item->get_product_id(); 51 58 52 if ( $userid == 0 ) { 53 $userid = 'order_' . strval( $order->get_id() ); 59 // check product has not been deleted 60 if ( $productid != 0 ) { 61 $response = $recomendo->client->record_user_action( 'buy', $userid , $productid ); 54 62 55 $response = $recomendo->client->set_user( $userid ); 56 57 if ( is_wp_error( $response )) { 58 error_log( "[RECOMENDO] --- Error adding user " . strval( $userid ) . " when recording all orders." ); 63 if ( is_wp_error( $response ) ) { 64 error_log( "[RECOMENDO] --- Error recording buy event for order " . strval($order->get_id()) ); 59 65 error_log( "[RECOMENDO] --- " . $response->get_error_message() ); 60 } else {61 $response = $recomendo->client->record_user_action( 'buy', $userid , $productid );62 63 if ( is_wp_error( $response ) ) {64 error_log( "[RECOMENDO] --- Error recording buy event for order " . strval($order->get_id()) );65 error_log( "[RECOMENDO] --- " . $response->get_error_message() );66 67 }68 66 } 69 67 } -
recomendo/trunk/recomendo-client.php
r1963755 r1967374 498 498 if ( ! is_wp_error( $response )) { 499 499 set_transient( 'recomendo_train_request_sent', true, 1800 ); 500 } 500 } 501 501 502 502 } else { -
recomendo/trunk/recomendo-plugin.php
r1963755 r1967374 37 37 $body = json_decode( wp_remote_retrieve_body( $response ), true ); 38 38 if ( $body['message'] == 'Not Found') { 39 // server is up but with no data40 return 2;39 // server is up but with no data 40 return 2; 41 41 } else { 42 42 return 0; … … 57 57 $status = wp_remote_retrieve_response_code( $response ); 58 58 if ( $status == 200 ) { 59 return true; 59 return 1; 60 } elseif ( $status == 429 ) { 61 // quota exceeded 62 return 2; 60 63 } else { 61 return false;64 return 0; 62 65 } 63 66 } // end of method --> get_event_server_statuss 67 64 68 65 69 … … 117 121 118 122 // ignore requests from this wordpress server... cron or other plugins 119 120 //if ( $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR'] ) return TRUE; 123 #if ( $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR'] ) return TRUE; 121 124 122 125 if( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { … … 140 143 'amazon', 141 144 'wordpress', 145 'wget', 142 146 'go-http-client' 143 147 ); … … 436 440 public function get_trending_items( $number ) { 437 441 442 //ignore bots and crawlers 443 if ( $this->detect_crawler() ) return false; 444 438 445 $query = array( 439 446 'num' => $number … … 500 507 // returns post ids and relevance score 501 508 public function get_user_recommendations( $number ) { 509 510 //ignore bots and crawlers 511 if ( $this->detect_crawler() ) return false; 502 512 503 513 if ( get_current_user_id() == 0 ) { … … 624 634 public function get_item_recommendations( $item, $number ) { 625 635 636 //ignore bots and crawlers 637 if ( $this->detect_crawler() ) return false; 638 639 626 640 $fields = array(); 627 641 … … 826 840 public function get_itemset_recommendations( array $items, $number ) { 827 841 842 //ignore bots and crawlers 843 if ( $this->detect_crawler() ) return false; 844 845 828 846 $fields = array(); 829 847 … … 1263 1281 1264 1282 1265 // Send Completed WooCommerce Order to PredictionIO1283 // Send Completed WooCommerce Order as Buy event 1266 1284 public function record_buy_event( $order_id ) { 1267 1285 -
recomendo/trunk/recomendo-widget.php
r1931195 r1967374 95 95 96 96 } 97 97 98 98 99 99 if ( $response != false and array_key_exists( 'itemScores', $response ) ) { … … 105 105 if ( ! empty( $title ) ) 106 106 echo $args['before_title'] . $title . $args['after_title']; 107 107 108 108 // This is where you run the code and display the output 109 109 // ----------------------------------------------- … … 111 111 if ( class_exists( 'woocommerce' ) ) { 112 112 echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '<ul class="' . $instance['class'] . '">' ) ); 113 woocommerce_product_loop_start();114 113 foreach ($response['itemScores'] as $i ) { 115 114 if ( get_post_status ( $i['item'] ) == 'publish' ) { 116 115 $post_object = get_post( $i['item'] ); 117 116 setup_postdata( $GLOBALS['post'] =& $post_object ); 118 // add .php to the template -> woocommerce requires it 117 // add .php to the template -> woocommerce requires it 119 118 // but get_template_part does not 120 119 wc_get_template( $instance['template'] . '.php', $template_args ); 121 } 120 } 122 121 } 123 woocommerce_product_loop_end();124 122 } else { 125 123 … … 131 129 get_template_part( $instance['template'] ); 132 130 133 } 131 } 134 132 } 135 133 136 134 } 137 135 138 wp_reset_postdata(); 139 136 wp_reset_postdata(); 137 140 138 // ----------------------------------------------- 141 139 // till here … … 147 145 // Widget Backend 148 146 public function form( $instance ) { 149 147 150 148 global $recomendo; 151 149 152 150 if ( isset( $instance[ 'title' ] ) ) { 153 151 $title = $instance[ 'title' ]; … … 171 169 $number = __( 5, 'recomendo_widget_domain' ); 172 170 } 173 171 174 172 if ( isset( $instance[ 'template' ] ) ) { 175 173 $template = $instance[ 'template' ]; … … 182 180 } 183 181 } 184 185 182 183 186 184 if ( isset( $instance[ 'class' ] ) ) { 187 185 $class = $instance[ 'class' ]; … … 245 243 $instance['type'] = ( ! empty( $new_instance['type'] ) ) ? strip_tags( $new_instance['type'] ) : ''; 246 244 $instance['number'] = ( ! empty( $new_instance['number'] ) ) ? strip_tags( $new_instance['number'] ) : ''; 247 245 248 246 $instance['template'] = ( ! empty( $new_instance['template'] ) ) ? str_replace( '.php', '', strip_tags( $new_instance['template'] ) ) : ''; 249 247 $instance['class'] = ( ! empty( $new_instance['class'] ) ) ? strip_tags( $new_instance['class'] ) : ''; -
recomendo/trunk/recomendo.php
r1963755 r1967374 5 5 * Description: Make your website smart with Artificial Intelligence recommendations. 6 6 * Author: Recomendo 7 * Version: 1.0. 37 * Version: 1.0.4 8 8 * Requires at least: 4.7 9 9 * Tested up to: 4.9.8 -
recomendo/trunk/screens/dashboard.php
r1963755 r1967374 3 3 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 4 4 5 $options = get_option( 'recomendo_options' ); 6 // To avoid showing in post type selection 7 $avoid_post_types = array( 8 'attachment', 'revision', 'nav_menu_item', 'custom_css', 9 'customize_changeset', 'oembed_cache', 'mc4wp-form', 'user_request', 10 'mailpoet_page', 'product_variation', 'shop_order', 'shop_order_refund', 11 'shop_coupon', 'shop_webhook', 'vc4_templates', 'vc_grid_item' , 12 'wpcf7_contact_form', 'featured_item', 'sidebar', 'blocks', 13 'scheduled-action' 14 ); 15 5 16 ?> 6 17 7 <?php $options = get_option( 'recomendo_options' ); ?>8 18 <div id="recomendo-dashboard" class="wrap"> 9 19 … … 130 140 </th> 131 141 <td> 132 <?php $avoid_post_types = array('attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'mc4wp-form', 'user_request', 'mailpoet_page', 'product_variation', 'shop_order', 'shop_order_refund', 'shop_coupon', 'shop_webhook', 'vc4_templates', 'vc_grid_item' , 'wpcf7_contact_form', 'featured_item', 'sidebar', 'blocks');142 <?php 133 143 foreach ( get_post_types( '', 'names' ) as $post_type ) { 134 144 if (!in_array($post_type, $avoid_post_types)) { … … 163 173 <td> 164 174 <?php 165 $avoid_post_types = array('attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'mc4wp-form', 'user_request', 'mailpoet_page', 'product_variation', 'shop_order', 'shop_order_refund', 'shop_coupon', 'shop_webhook', 'vc4_templates', 'vc_grid_item' , 'wpcf7_contact_form', 'featured_item', 'sidebar', 'blocks');166 175 foreach ( get_post_types( '', 'names' ) as $post_type ) { 167 176 if ( $post_type == $options['post_type']) { … … 218 227 echo '<input type="range" id="recomendo_general_options" name="recomendo_general_options[similar_categories_relevance]" min="-1" max="3" step="1" value="' . $general_options['similar_categories_relevance'] . '" list="tickmarks" />'; 219 228 } else { 220 echo '<input type="range" id="recomendo_general_options" name="recomendo_general_options[similar_categories_relevance]" min="-1" max="3" step="1" value=" 1" list="tickmarks"/>';229 echo '<input type="range" id="recomendo_general_options" name="recomendo_general_options[similar_categories_relevance]" min="-1" max="3" step="1" value="2" list="tickmarks"/>'; 221 230 } 222 231 ?> … … 235 244 echo '<input type="range" id="recomendo_general_options" name="recomendo_general_options[similar_tags_relevance]" min="-1" max="3" step="1" value="' . $general_options['similar_tags_relevance'] . '" list="tickmarks" />'; 236 245 } else { 237 echo '<input type="range" id="recomendo_general_options" name="recomendo_general_options[similar_tags_relevance]" min="-1" max="3" step="1" value=" 1" list="tickmarks"/>';246 echo '<input type="range" id="recomendo_general_options" name="recomendo_general_options[similar_tags_relevance]" min="-1" max="3" step="1" value="2" list="tickmarks"/>'; 238 247 } 239 248 ?> … … 432 441 <?php 433 442 434 if ( Recomendo_Plugin::is_prediction_server_up() ) {443 if ( Recomendo_Plugin::is_prediction_server_up() == 1 ) { 435 444 _e( '<code class="status-good">Connection OK</code>', 'admin-screen' ); 436 } elseif ( Recomendo_Plugin::is_event_server_up()) {445 } elseif ( Recomendo_Plugin::is_prediction_server_up() == 0 and Recomendo_Plugin::is_event_server_up() == 1) { 437 446 _e( '<code class="status-okay">Connection DOWN</code> Recomendo servers do not have any data yet. Please check again in 30 minutes.', 'admin-screen' ); 438 } else{447 } elseif ( Recomendo_Plugin::is_prediction_server_up() == 0 ) { 439 448 _e( '<code class="status-bad">Connection DOWN</code> Servers not reachable. Please contact support.', 'admin-screen' ); 449 } elseif ( Recomendo_Plugin::is_prediction_server_up() == 2 ) { 450 _e( '<code class="status-bad">Connection UP</code> You have reached your monthly API quota limit. Please contact support to upgrade your subscription.', 'admin-screen' ); 440 451 } 452 441 453 ?> 442 454 </td>
Note: See TracChangeset
for help on using the changeset viewer.