Plugin Directory

Changeset 1963755


Ignore:
Timestamp:
10/26/2018 04:32:17 PM (7 years ago)
Author:
recomendo
Message:

1.0.3

Location:
recomendo/trunk
Files:
3 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • recomendo/trunk/README.txt

    r1960659 r1963755  
    2929* Easy to use - Recomendo is very easy to use just drag the widget to a sidebar and start getting personalised recommendations in your website.
    3030
    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.
    3232
    3333* 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.
     
    8181[recomendo number=5 type="personalized" template="content-product"]
    8282
    83 Displays 5 personalized recommendations using the template part "content-product.php" from your theme. 
     83Displays 5 personalized recommendations using the template part "content-product.php" from your theme.
    8484
    8585[recomendo number=16 type="similar" template="content-product"]
     
    9393[recomendo number=12 type="trending" template="content-product"] using the template part "content-product.php"
    9494
    95 Displays 12 trending products recommendations. 
     95Displays 12 trending products recommendations.
    9696
    9797
    9898= How can I further customize the look? =
    9999
    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. 
     100Recomendo 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.
    101101
    102102= Is Recomendo Free? =
     
    125125
    126126== Changelog ==
     127= 1.0.3 =
     128* Bug fixes
     129
    127130= 1.0.2 =
    128131* Bug fixes
     
    136139* Control the relevance of on-sale and featured products
    137140
    138 * Control the relevance of tags and categories in similar items recommendations 
     141* Control the relevance of tags and categories in similar items recommendations
    139142
    140143* Exclude out-of-stock products
     
    149152* Data copied on the background after activating the Recomendo subscription
    150153
    151 * New branding and logo. 
     154* New branding and logo.
    152155
    153156* Bug fixes and optimizations
  • recomendo/trunk/inc/recomendo-background-item-copy.php

    r1960775 r1963755  
    44defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    55
    6 require_once plugin_dir_path( __DIR__ ) . 'libraries/recomendo-async-request.php';
    7 require_once plugin_dir_path( __DIR__ ) . 'libraries/recomendo-background-process.php';
     6require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-async-request.php';
     7require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-background-process.php';
    88
    99class Recomendo_Background_Item_Copy extends Recomendo_Background_Process {
    1010
    1111    /**
    12      * @var string
    13      */
     12    * @var string
     13    */
    1414    protected $action = 'item_copy';
    1515
    1616    /**
    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      */
     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    */
    2828    protected function task( $item ) {
    29                
     29
    3030        // Actions to perform
    3131        global $recomendo;
    32        
     32
    3333        // Check if WPML is installed and get the id of the original language post (not translation)
    3434        if ( function_exists('icl_object_id') ) {
     
    5353
    5454        $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 ones
    58         //if ( mb_strlen( $description, 'utf8' ) > 32766 ) {
    59         //  $description = mb_substr($description, 0 , 32766, 'utf8' );
    60         //}
    6155
    6256        $categories = array();
     
    7367            }
    7468        }
    75        
     69
    7670        $published_date = get_the_date( 'c', $item );
    7771
    7872        $properties = compact(
    7973            'title',
    80         //  'description',
    8174            'categories',
    8275            'tags',
     
    8780
    8881        $response = $recomendo->client->set_item($item, $properties);
    89        
     82
    9083
    9184        if ( is_wp_error( $response ) ) {
     
    9891
    9992    /**
    100      * Complete
    101      *
    102      * Override if applicable, but ensure that the below actions are
    103      * 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    */
    10598    protected function complete() {
    10699        parent::complete();
     
    109102
    110103}
    111 
  • recomendo/trunk/inc/recomendo-background-order-copy.php

    r1931195 r1963755  
    44defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    55
    6 require_once plugin_dir_path( __DIR__ ) . 'libraries/recomendo-async-request.php';
    7 require_once plugin_dir_path( __DIR__ ) . 'libraries/recomendo-background-process.php';
     6require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-async-request.php';
     7require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-background-process.php';
    88
    99class Recomendo_Background_Order_Copy extends Recomendo_Background_Process {
    1010
    1111    /**
    12      * @var string
    13      */
     12    * @var string
     13    */
     14
    1415    protected $action = 'order_copy';
    1516
    1617    /**
    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
    2830    protected function task( $item ) {
    2931
     
    3234
    3335        $order = wc_get_order( $item );
    34         $userid = $order->get_user_id();
     36        $line_items = $order->get_items();
    3537
    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 ) {
    4040
    41             $response = $recomendo->client->set_user( $userid );
     41            // This will be a product
     42            $productid = $item->get_product_id();
    4243
    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 ) {
    4845
    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();
    5448
    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
    6251
    63             // Save the ID to PredictionIO
    64             $response = $recomendo->client->record_user_action( 'buy',  $userid , $productid );
     52                if ( $userid == 0 ) {
     53                    $userid = 'order_' . strval( $order->get_id() );
    6554
    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                }
    7070            }
    7171        }
     
    7373        return false;
    7474    }
     75    /**
     76    * Complete
     77    *
     78    * Override if applicable, but ensure that the below actions are
     79    * performed, or, call parent::complete().
     80    */
    7581
    76     /**
    77      * Complete
    78      *
    79      * Override if applicable, but ensure that the below actions are
    80      * performed, or, call parent::complete().
    81      */
    8282    protected function complete() {
    8383        parent::complete();
     
    8686
    8787}
    88 
  • recomendo/trunk/inc/recomendo-background-user-copy.php

    r1931195 r1963755  
    44defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    55
    6 require_once plugin_dir_path( __DIR__ ) . 'libraries/recomendo-async-request.php';
    7 require_once plugin_dir_path( __DIR__ ) . 'libraries/recomendo-background-process.php';
     6require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-async-request.php';
     7require_once plugin_dir_path( __DIR__ ) . 'inc/libraries/recomendo-background-process.php';
    88
    99class Recomendo_Background_User_Copy extends Recomendo_Background_Process {
     
    2828    protected function task( $item ) {
    2929        // Actions to perform
    30            
     30
    3131        global $recomendo;
    3232        $response = $recomendo->client->set_user( $item, array(
     
    3535                                        )
    3636                             );
    37    
     37
    3838
    3939        // check the response
     
    4141            error_log( "[RECOMENDO] --- Error adding a user." );
    4242            error_log( "[RECOMENDO] --- " . $response->get_error_message() );
    43         }       
    44        
     43        }
     44
    4545        return false;
    4646    }
     
    5555        parent::complete();
    5656        // Show notice to user or perform some other arbitrary task...
    57        
     57
    5858    }
    5959
    6060}
    61 
  • recomendo/trunk/recomendo-client.php

    r1953598 r1963755  
    496496
    497497            // 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            }       
    499501
    500502        } else {
  • recomendo/trunk/recomendo-plugin.php

    r1960775 r1963755  
    117117
    118118        // 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;
    120121
    121122        if( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
     
    407408        $post_ids = get_posts( $args );
    408409
     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
    409424        return $post_ids;
    410425
     
    528543                if ( $featured_bias != 1.0 ) {
    529544                    // less importance boost "no" instead
    530                     if ( $featured_bias == 0.5 ) { 
     545                    if ( $featured_bias == 0.5 ) {
    531546                        $featured_args = array(
    532547                            'name' => 'is_featured',
     
    10031018
    10041019        $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 ones
    1008         //if ( mb_strlen( $description, 'utf8' ) > 32766 ) {
    1009         //    $description = mb_substr( $description, 0 , 32766, 'utf8' );
    1010         //}
    10111020
    10121021        $categories = array();
     
    10281037        $properties = compact(
    10291038            'title',
    1030         //  'description',
    10311039            'categories',
    10321040            'tags',
  • recomendo/trunk/recomendo.php

    r1960659 r1963755  
    55* Description: Make your website smart with Artificial Intelligence recommendations.
    66* Author: Recomendo
    7 * Version: 1.0.2
     7* Version: 1.0.3
    88* Requires at least: 4.7
    99* Tested up to: 4.9.8
    1010* WC requires at least: 3.0
    11 * WC tested up to: 3.4
     11* WC tested up to: 3.5
    1212* License: GPLv2
    1313**/
  • recomendo/trunk/screens/dashboard.php

    r1945379 r1963755  
    55?>
    66
    7 <?php $options = get_option( 'recomendo_options' ); ?> 
     7<?php $options = get_option( 'recomendo_options' ); ?>
    88<div id="recomendo-dashboard" class="wrap">
    99
     
    110110        </div>
    111111    </div>
    112    
     112
    113113   <?php if ( Recomendo_Admin::is_authorized() ) : ?>
    114114        <?php if ( !Recomendo_Admin::is_configured() ) : ?>
     
    144144                </form>
    145145            </div>
    146         <?php else : ?> 
     146        <?php else : ?>
    147147            <?php if (!get_option('recomendo_data_saved_ok')) : ?>
    148148                <?php global $recomendo; ?>
    149149                <?php $recomendo->copy_data_to_eventserver(); ?>
    150150            <?php endif; ?>
    151            
     151
    152152            <div class="recomendo-postbox">
    153153                <h2>Post Type to Recommend is Configured</h2>
    154154                <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.
    156156                </p>
    157157                <table class="form-table">
     
    162162                            </th>
    163163                            <td>
    164                                 <?php 
     164                                <?php
    165165                                    $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');
    166166                                    foreach ( get_post_types( '', 'names' ) as $post_type ) {
    167167                                        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>';
    169169                                        } else if (!in_array($post_type, $avoid_post_types)) {
    170170                                            echo '<label><input type="radio" id="recomendo_post_type" name="recomendo_options[post_type]" value="' . $post_type . '" disabled />' . ucwords($post_type) . '</label><br>';
     
    177177                </table>
    178178            </div>
    179                
     179
    180180        <?php endif; ?>
    181181    <?php endif; ?>
    182    
    183     <?php if ( Recomendo_Admin::is_authorized() ) : ?>
     182
     183    <?php if ( Recomendo_Admin::is_authorized() and Recomendo_Admin::is_configured() ) : ?>
    184184
    185185        <div class="recomendo-postbox">
     
    202202                                    echo '<label><input type="number" id="recomendo_general_options" name="recomendo_general_options[expire_date]" value="0" /> Days</label><br>';
    203203                                }
    204                                
     204
    205205                                ?>
    206206                            </td>
     
    240240                            </td>
    241241                        </tr>
    242                                    
    243                                
     242
     243
    244244                    </tbody>
    245245                </table>
     
    250250        </div>
    251251    <?php endif; ?>
    252    
    253     <?php if ( Recomendo_Admin::is_authorized() ) : ?>
     252
     253    <?php if ( Recomendo_Admin::is_authorized() and Recomendo_Admin::is_configured() ) : ?>
    254254        <?php if ( class_exists( 'woocommerce' ) and $options['post_type'] == "product" ) : ?>
    255255
     
    297297                                    ?>
    298298                                </td>
    299                             </tr>                           
    300                            
     299                            </tr>
     300
    301301                            <tr>
    302302                                <th scope="row">
     
    334334                                </td>
    335335                            </tr>
    336                            
     336
    337337                            <tr>
    338338                                <th scope="row">
     
    348348                                    ?>
    349349                                </td>
    350                                
     350
    351351                            <tr>
    352352                                <th scope="row">
     
    364364                                        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"/>';
    365365                                    }
    366                                     ?>         
     366                                    ?>
    367367                                    <datalist id="tickmarks">
    368368                                        <option value="-1">
     
    373373                                    </datalist>
    374374                                </td>
    375                                
    376                             </tr>       
    377                                
     375
     376                            </tr>
     377
    378378                            <tr>
    379379                                <th scope="row">
     
    393393                                </td>
    394394                            </tr>
    395                                    
    396                            
     395
     396
    397397                        </tbody>
    398398                    </table>
Note: See TracChangeset for help on using the changeset viewer.