Changeset 1963755
- Timestamp:
- 10/26/2018 04:32:17 PM (7 years ago)
- Location:
- recomendo/trunk
- Files:
-
- 3 added
- 1 deleted
- 8 edited
-
README.txt (modified) (6 diffs)
-
inc/libraries (added)
-
inc/libraries/recomendo-async-request.php (added)
-
inc/libraries/recomendo-background-process.php (added)
-
inc/recomendo-background-item-copy.php (modified) (6 diffs)
-
inc/recomendo-background-order-copy.php (modified) (4 diffs)
-
inc/recomendo-background-user-copy.php (modified) (5 diffs)
-
libraries (deleted)
-
recomendo-client.php (modified) (1 diff)
-
recomendo-plugin.php (modified) (5 diffs)
-
recomendo.php (modified) (1 diff)
-
screens/dashboard.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
recomendo/trunk/README.txt
r1960659 r1963755 29 29 * Easy to use - Recomendo is very easy to use just drag the widget to a sidebar and start getting personalised recommendations in your website. 30 30 31 * Uses your theme's template partials to fully integrate into your site with the same appearance. 31 * Uses your theme's template partials to fully integrate into your site with the same appearance. 32 32 33 33 * Personalized Recommendations - Show the right content to your visitors using State-of-the-art Machine Learning algorithms to significantly boost sales and average order value. … … 81 81 [recomendo number=5 type="personalized" template="content-product"] 82 82 83 Displays 5 personalized recommendations using the template part "content-product.php" from your theme. 83 Displays 5 personalized recommendations using the template part "content-product.php" from your theme. 84 84 85 85 [recomendo number=16 type="similar" template="content-product"] … … 93 93 [recomendo number=12 type="trending" template="content-product"] using the template part "content-product.php" 94 94 95 Displays 12 trending products recommendations. 95 Displays 12 trending products recommendations. 96 96 97 97 98 98 = How can I further customize the look? = 99 99 100 Recomendo uses template partias 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 partias 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.3 = 128 * Bug fixes 129 127 130 = 1.0.2 = 128 131 * Bug fixes … … 136 139 * Control the relevance of on-sale and featured products 137 140 138 * Control the relevance of tags and categories in similar items recommendations 141 * Control the relevance of tags and categories in similar items recommendations 139 142 140 143 * Exclude out-of-stock products … … 149 152 * Data copied on the background after activating the Recomendo subscription 150 153 151 * New branding and logo. 154 * New branding and logo. 152 155 153 156 * Bug fixes and optimizations -
recomendo/trunk/inc/recomendo-background-item-copy.php
r1960775 r1963755 4 4 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 5 5 6 require_once plugin_dir_path( __DIR__ ) . ' libraries/recomendo-async-request.php';7 require_once plugin_dir_path( __DIR__ ) . ' libraries/recomendo-background-process.php';6 require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-async-request.php'; 7 require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-background-process.php'; 8 8 9 9 class Recomendo_Background_Item_Copy extends Recomendo_Background_Process { 10 10 11 11 /** 12 * @var string13 */12 * @var string 13 */ 14 14 protected $action = 'item_copy'; 15 15 16 16 /** 17 * Task18 *19 * Override this method to perform any actions required on each20 * queue item. Return the modified item for further processing21 * in the next pass through. Or, return false to remove the22 * item from the queue.23 *24 * @param mixed $item Queue item to iterate over25 *26 * @return mixed27 */17 * Task 18 * 19 * Override this method to perform any actions required on each 20 * queue item. Return the modified item for further processing 21 * in the next pass through. Or, return false to remove the 22 * item from the queue. 23 * 24 * @param mixed $item Queue item to iterate over 25 * 26 * @return mixed 27 */ 28 28 protected function task( $item ) { 29 29 30 30 // Actions to perform 31 31 global $recomendo; 32 32 33 33 // Check if WPML is installed and get the id of the original language post (not translation) 34 34 if ( function_exists('icl_object_id') ) { … … 53 53 54 54 $title = wp_filter_nohtml_kses( get_the_title( $item ) ); 55 //$description = wp_filter_nohtml_kses( get_post_field('post_content', $item) );56 57 // reduce the size of description for extra long ones58 //if ( mb_strlen( $description, 'utf8' ) > 32766 ) {59 // $description = mb_substr($description, 0 , 32766, 'utf8' );60 //}61 55 62 56 $categories = array(); … … 73 67 } 74 68 } 75 69 76 70 $published_date = get_the_date( 'c', $item ); 77 71 78 72 $properties = compact( 79 73 'title', 80 // 'description',81 74 'categories', 82 75 'tags', … … 87 80 88 81 $response = $recomendo->client->set_item($item, $properties); 89 82 90 83 91 84 if ( is_wp_error( $response ) ) { … … 98 91 99 92 /** 100 * Complete101 *102 * Override if applicable, but ensure that the below actions are103 * performed, or, call parent::complete().104 */93 * Complete 94 * 95 * Override if applicable, but ensure that the below actions are 96 * performed, or, call parent::complete(). 97 */ 105 98 protected function complete() { 106 99 parent::complete(); … … 109 102 110 103 } 111 -
recomendo/trunk/inc/recomendo-background-order-copy.php
r1931195 r1963755 4 4 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 5 5 6 require_once plugin_dir_path( __DIR__ ) . ' libraries/recomendo-async-request.php';7 require_once plugin_dir_path( __DIR__ ) . ' libraries/recomendo-background-process.php';6 require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-async-request.php'; 7 require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-background-process.php'; 8 8 9 9 class Recomendo_Background_Order_Copy extends Recomendo_Background_Process { 10 10 11 11 /** 12 * @var string 13 */ 12 * @var string 13 */ 14 14 15 protected $action = 'order_copy'; 15 16 16 17 /** 17 * Task 18 * 19 * Override this method to perform any actions required on each 20 * queue item. Return the modified item for further processing 21 * in the next pass through. Or, return false to remove the 22 * item from the queue. 23 * 24 * @param mixed $item Queue item to iterate over 25 * 26 * @return mixed 27 */ 18 * Task 19 * 20 * Override this method to perform any actions required on each 21 * queue item. Return the modified item for further processing 22 * in the next pass through. Or, return false to remove the 23 * item from the queue. 24 * 25 * @param mixed $item Queue item to iterate over 26 * 27 * @return mixed 28 */ 29 28 30 protected function task( $item ) { 29 31 … … 32 34 33 35 $order = wc_get_order( $item ); 34 $ userid = $order->get_user_id();36 $line_items = $order->get_items(); 35 37 36 // If the purchase was from unregistered user 37 // we need to create the user 38 if ( $userid == 0 ) { 39 $userid = 'order_' . strval( $order->get_id() ); 38 // This loops over line items 39 foreach ( $line_items as $item ) { 40 40 41 $response = $recomendo->client->set_user( $userid ); 41 // This will be a product 42 $productid = $item->get_product_id(); 42 43 43 if ( is_wp_error( $response )) { 44 error_log( "[RECOMENDO] --- Error adding user " . strval( $userid ) . " when recording all orders." ); 45 error_log( "[RECOMENDO] --- " . $response->get_error_message() ); 46 } 47 } 44 if ( $productid != 0 ) { 48 45 49 $line_items = $order->get_items(); 50 // This loops over line items 51 foreach ( $line_items as $i ) { 52 // This will be a product 53 $product = $order->get_product_from_item( $i ); 46 // Send the order 47 $userid = $order->get_user_id(); 54 48 55 if ( $product->is_type( 'variation' )) { 56 // Get the parent id of the product 57 $productid = $product->get_parent_id(); 58 } else { 59 // This is the products ID 60 $productid = $product->get_id(); 61 } 49 // If the purchase was from unregistered user 50 // we need to create the user 62 51 63 // Save the ID to PredictionIO64 $response = $recomendo->client->record_user_action( 'buy', $userid , $productid);52 if ( $userid == 0 ) { 53 $userid = 'order_' . strval( $order->get_id() ); 65 54 66 if ( is_wp_error( $response ) ) { 67 error_log( "[RECOMENDO] --- Error recording buy event for order " . strval($order->get_id()) ); 68 error_log( "[RECOMENDO] --- " . $response->get_error_message() ); 69 continue; 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." ); 59 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 } 69 } 70 70 } 71 71 } … … 73 73 return false; 74 74 } 75 /** 76 * Complete 77 * 78 * Override if applicable, but ensure that the below actions are 79 * performed, or, call parent::complete(). 80 */ 75 81 76 /**77 * Complete78 *79 * Override if applicable, but ensure that the below actions are80 * performed, or, call parent::complete().81 */82 82 protected function complete() { 83 83 parent::complete(); … … 86 86 87 87 } 88 -
recomendo/trunk/inc/recomendo-background-user-copy.php
r1931195 r1963755 4 4 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 5 5 6 require_once plugin_dir_path( __DIR__ ) . ' libraries/recomendo-async-request.php';7 require_once plugin_dir_path( __DIR__ ) . ' libraries/recomendo-background-process.php';6 require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-async-request.php'; 7 require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-background-process.php'; 8 8 9 9 class Recomendo_Background_User_Copy extends Recomendo_Background_Process { … … 28 28 protected function task( $item ) { 29 29 // Actions to perform 30 30 31 31 global $recomendo; 32 32 $response = $recomendo->client->set_user( $item, array( … … 35 35 ) 36 36 ); 37 37 38 38 39 39 // check the response … … 41 41 error_log( "[RECOMENDO] --- Error adding a user." ); 42 42 error_log( "[RECOMENDO] --- " . $response->get_error_message() ); 43 } 44 43 } 44 45 45 return false; 46 46 } … … 55 55 parent::complete(); 56 56 // Show notice to user or perform some other arbitrary task... 57 57 58 58 } 59 59 60 60 } 61 -
recomendo/trunk/recomendo-client.php
r1953598 r1963755 496 496 497 497 // It wasn't there, so regenerate the data and save the transient 498 set_transient( 'recomendo_train_request_sent', true, 1800 ); 498 if ( ! is_wp_error( $response )) { 499 set_transient( 'recomendo_train_request_sent', true, 1800 ); 500 } 499 501 500 502 } else { -
recomendo/trunk/recomendo-plugin.php
r1960775 r1963755 117 117 118 118 // ignore requests from this wordpress server... cron or other plugins 119 if ( $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR'] ) return TRUE; 119 120 //if ( $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR'] ) return TRUE; 120 121 121 122 if( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { … … 407 408 $post_ids = get_posts( $args ); 408 409 410 // Remove Singular pages from Recommendations... 411 if ( is_singular( $this->options['post_type'] ) ) { 412 // Check if WPML is installed and get the id of the original language post (not translation) 413 if ( function_exists('icl_object_id') ) { 414 global $sitepress; 415 $postid = icl_object_id( get_the_ID(), $this->options['post_type'], true, $sitepress->get_default_language() ); 416 } else { 417 $postid = get_the_ID(); 418 } 419 420 // add the id of singular page 421 $post_ids[] = $postid; 422 } 423 409 424 return $post_ids; 410 425 … … 528 543 if ( $featured_bias != 1.0 ) { 529 544 // less importance boost "no" instead 530 if ( $featured_bias == 0.5 ) { 545 if ( $featured_bias == 0.5 ) { 531 546 $featured_args = array( 532 547 'name' => 'is_featured', … … 1003 1018 1004 1019 $title = wp_filter_nohtml_kses( get_the_title( $postid ) ); 1005 //$description = wp_filter_nohtml_kses( get_the_content( $postid ) );1006 1007 // reduce the size of description for extra long ones1008 //if ( mb_strlen( $description, 'utf8' ) > 32766 ) {1009 // $description = mb_substr( $description, 0 , 32766, 'utf8' );1010 //}1011 1020 1012 1021 $categories = array(); … … 1028 1037 $properties = compact( 1029 1038 'title', 1030 // 'description',1031 1039 'categories', 1032 1040 'tags', -
recomendo/trunk/recomendo.php
r1960659 r1963755 5 5 * Description: Make your website smart with Artificial Intelligence recommendations. 6 6 * Author: Recomendo 7 * Version: 1.0. 27 * Version: 1.0.3 8 8 * Requires at least: 4.7 9 9 * Tested up to: 4.9.8 10 10 * WC requires at least: 3.0 11 * WC tested up to: 3. 411 * WC tested up to: 3.5 12 12 * License: GPLv2 13 13 **/ -
recomendo/trunk/screens/dashboard.php
r1945379 r1963755 5 5 ?> 6 6 7 <?php $options = get_option( 'recomendo_options' ); ?> 7 <?php $options = get_option( 'recomendo_options' ); ?> 8 8 <div id="recomendo-dashboard" class="wrap"> 9 9 … … 110 110 </div> 111 111 </div> 112 112 113 113 <?php if ( Recomendo_Admin::is_authorized() ) : ?> 114 114 <?php if ( !Recomendo_Admin::is_configured() ) : ?> … … 144 144 </form> 145 145 </div> 146 <?php else : ?> 146 <?php else : ?> 147 147 <?php if (!get_option('recomendo_data_saved_ok')) : ?> 148 148 <?php global $recomendo; ?> 149 149 <?php $recomendo->copy_data_to_eventserver(); ?> 150 150 <?php endif; ?> 151 151 152 152 <div class="recomendo-postbox"> 153 153 <h2>Post Type to Recommend is Configured</h2> 154 154 <p> 155 If you want to change the post type you need to uninstall and re-install the Recomendo plugin. 155 If you want to change the post type you need to uninstall and re-install the Recomendo plugin. 156 156 </p> 157 157 <table class="form-table"> … … 162 162 </th> 163 163 <td> 164 <?php 164 <?php 165 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 166 foreach ( get_post_types( '', 'names' ) as $post_type ) { 167 167 if ( $post_type == $options['post_type']) { 168 echo '<label><input type="radio" id="recomendo_post_type" name="recomendo_options[post_type]" value="' . $post_type . '" checked disabled/>' . ucwords($post_type) . '</label><br>'; 168 echo '<label><input type="radio" id="recomendo_post_type" name="recomendo_options[post_type]" value="' . $post_type . '" checked disabled/>' . ucwords($post_type) . '</label><br>'; 169 169 } else if (!in_array($post_type, $avoid_post_types)) { 170 170 echo '<label><input type="radio" id="recomendo_post_type" name="recomendo_options[post_type]" value="' . $post_type . '" disabled />' . ucwords($post_type) . '</label><br>'; … … 177 177 </table> 178 178 </div> 179 179 180 180 <?php endif; ?> 181 181 <?php endif; ?> 182 183 <?php if ( Recomendo_Admin::is_authorized() ) : ?>182 183 <?php if ( Recomendo_Admin::is_authorized() and Recomendo_Admin::is_configured() ) : ?> 184 184 185 185 <div class="recomendo-postbox"> … … 202 202 echo '<label><input type="number" id="recomendo_general_options" name="recomendo_general_options[expire_date]" value="0" /> Days</label><br>'; 203 203 } 204 204 205 205 ?> 206 206 </td> … … 240 240 </td> 241 241 </tr> 242 243 242 243 244 244 </tbody> 245 245 </table> … … 250 250 </div> 251 251 <?php endif; ?> 252 253 <?php if ( Recomendo_Admin::is_authorized() ) : ?>252 253 <?php if ( Recomendo_Admin::is_authorized() and Recomendo_Admin::is_configured() ) : ?> 254 254 <?php if ( class_exists( 'woocommerce' ) and $options['post_type'] == "product" ) : ?> 255 255 … … 297 297 ?> 298 298 </td> 299 </tr> 300 299 </tr> 300 301 301 <tr> 302 302 <th scope="row"> … … 334 334 </td> 335 335 </tr> 336 336 337 337 <tr> 338 338 <th scope="row"> … … 348 348 ?> 349 349 </td> 350 350 351 351 <tr> 352 352 <th scope="row"> … … 364 364 echo '<input type="range" id="recomendo_woo_options" name="recomendo_woo_options[woo_onsale_relevance]" min="-1" max="3" step="1" value="1" list="tickmarks"/>'; 365 365 } 366 ?> 366 ?> 367 367 <datalist id="tickmarks"> 368 368 <option value="-1"> … … 373 373 </datalist> 374 374 </td> 375 376 </tr> 377 375 376 </tr> 377 378 378 <tr> 379 379 <th scope="row"> … … 393 393 </td> 394 394 </tr> 395 396 395 396 397 397 </tbody> 398 398 </table>
Note: See TracChangeset
for help on using the changeset viewer.