Plugin Directory

Changeset 1967374


Ignore:
Timestamp:
11/01/2018 07:06:46 PM (7 years ago)
Author:
recomendo
Message:

version 1.0.4

Location:
recomendo/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • recomendo/trunk/README.txt

    r1963755 r1967374  
    11=== Recomendo ===
    22Contributors: recomendo
    3 Tags: artificial intelligence, machine learning, related posts, recommendations, personalisation
     3Tags: artificial intelligence, machine learning, related posts, recommendations, personalization
    44Requires at least: 4.7
    55Tested up to: 4.9
     
    2121And 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.
    2222
    23 Recomendo makes uses of standard WordPress template partials to fully integrete into your themes appearance, or call the PHP API directly to unleash ultimate control.
     23Recomendo makes uses of standard WordPress template partials to fully integrate into your themes appearance, or call the PHP API directly to unleash ultimate control.
    2424
    2525Recomendo 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.
     
    2727= Features =
    2828
    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.
     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.
    3030
    3131* Uses your theme's template partials to fully integrate into your site with the same appearance.
     
    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 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.
    101101
    102102= Is Recomendo Free? =
     
    125125
    126126== Changelog ==
     127= 1.0.4 =
     128* WooCommerce 3.5 tested
     129
     130* Better robots detection
     131
     132* Bug fixes
     133
    127134= 1.0.3 =
    128135* Bug fixes
     
    146153
    147154= 0.9.8 =
    148 * JWT API authentiacion
     155* JWT API authentication
    149156
    150157* Display recommendations using template parts
     
    159166* GDPR features. Data Explorer with search, delete and export
    160167
    161 * Users can ommit to being tracked via the user settings.
     168* Users can omit to being tracked via the user settings.
    162169
    163170* Customizable widget. Now you can choose post metas and the titles to display
  • recomendo/trunk/inc/libraries/recomendo-async-request.php

    r1963755 r1967374  
    1717         * @access protected
    1818         */
    19         protected $prefix = 'wp';
     19        protected $prefix = 'recomendo';
    2020        /**
    2121         * Action
  • recomendo/trunk/inc/recomendo-background-order-copy.php

    r1963755 r1967374  
    3636        $line_items = $order->get_items();
    3737
    38         // This loops over line items
    39         foreach ( $line_items as $item ) {
     38        // Send the order
     39        $userid = $order->get_user_id();
    4040
    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        }
    4346
    44             if ( $productid != 0 ) {
     47        $response = $recomendo->client->set_user( $userid );
    4548
    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 {
    4853
    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();
    5158
    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 );
    5462
    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()) );
    5965                        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                         }
    6866                    }
    6967                }
  • recomendo/trunk/recomendo-client.php

    r1963755 r1967374  
    498498            if ( ! is_wp_error( $response )) {
    499499                set_transient( 'recomendo_train_request_sent', true, 1800 );
    500             }       
     500            }
    501501
    502502        } else {
  • recomendo/trunk/recomendo-plugin.php

    r1963755 r1967374  
    3737            $body = json_decode( wp_remote_retrieve_body( $response ), true );
    3838            if ( $body['message'] == 'Not Found') {
    39                     // server is up but with no data
    40                     return 2;
     39                // server is up but with no data
     40                return 2;
    4141            } else {
    4242                return 0;
     
    5757        $status = wp_remote_retrieve_response_code( $response );
    5858        if  ( $status == 200 ) {
    59             return true;
     59            return 1;
     60        } elseif ( $status == 429 ) {
     61            // quota exceeded
     62            return 2;
    6063        } else {
    61             return false;
     64            return 0;
    6265        }
    6366    } // end of method --> get_event_server_statuss
     67
    6468
    6569
     
    117121
    118122        // 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;
    121124
    122125        if( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
     
    140143                                'amazon',
    141144                                'wordpress',
     145                                'wget',
    142146                                'go-http-client'
    143147                                );
     
    436440    public function get_trending_items( $number ) {
    437441
     442        //ignore bots and crawlers
     443        if ( $this->detect_crawler() ) return false;
     444
    438445        $query = array(
    439446            'num' => $number
     
    500507    // returns post ids and relevance score
    501508    public function get_user_recommendations( $number ) {
     509
     510        //ignore bots and crawlers
     511        if ( $this->detect_crawler() ) return false;
    502512
    503513        if ( get_current_user_id() == 0 ) {
     
    624634    public function get_item_recommendations( $item, $number ) {
    625635
     636        //ignore bots and crawlers
     637        if ( $this->detect_crawler() ) return false;
     638
     639
    626640        $fields = array();
    627641
     
    826840    public function get_itemset_recommendations( array $items, $number ) {
    827841
     842        //ignore bots and crawlers
     843        if ( $this->detect_crawler() ) return false;
     844
     845
    828846        $fields = array();
    829847
     
    12631281
    12641282
    1265     // Send Completed WooCommerce Order to PredictionIO
     1283    // Send Completed WooCommerce Order as Buy event
    12661284    public function record_buy_event( $order_id ) {
    12671285
  • recomendo/trunk/recomendo-widget.php

    r1931195 r1967374  
    9595
    9696        }
    97        
     97
    9898
    9999        if ( $response != false and array_key_exists( 'itemScores', $response ) ) {
     
    105105            if ( ! empty( $title ) )
    106106                echo $args['before_title'] . $title . $args['after_title'];
    107            
     107
    108108            // This is where you run the code and display the output
    109109            // -----------------------------------------------
     
    111111            if ( class_exists( 'woocommerce' ) ) {
    112112                echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '<ul class="' . $instance['class'] .  '">' ) );
    113                 woocommerce_product_loop_start();
    114113                foreach ($response['itemScores'] as $i ) {
    115114                    if ( get_post_status ( $i['item'] ) == 'publish' ) {
    116115                        $post_object = get_post( $i['item'] );
    117116                        setup_postdata( $GLOBALS['post'] =& $post_object );
    118                         // add .php to the template -> woocommerce requires it 
     117                        // add .php to the template -> woocommerce requires it
    119118                        // but get_template_part does not
    120119                        wc_get_template( $instance['template'] . '.php', $template_args );
    121                     } 
     120                    }
    122121                }
    123                 woocommerce_product_loop_end();                             
    124122            } else {
    125123
     
    131129                        get_template_part( $instance['template'] );
    132130
    133                     } 
     131                    }
    134132                }
    135133
    136134            }
    137135
    138             wp_reset_postdata();                   
    139  
     136            wp_reset_postdata();
     137
    140138            // -----------------------------------------------
    141139            // till here
     
    147145    // Widget Backend
    148146    public function form( $instance ) {
    149        
     147
    150148        global $recomendo;
    151                
     149
    152150        if ( isset( $instance[ 'title' ] ) ) {
    153151            $title = $instance[ 'title' ];
     
    171169            $number = __( 5, 'recomendo_widget_domain' );
    172170        }
    173        
     171
    174172        if ( isset( $instance[ 'template' ] ) ) {
    175173            $template = $instance[ 'template' ];
     
    182180            }
    183181        }
    184        
    185        
     182
     183
    186184        if ( isset( $instance[ 'class' ] ) ) {
    187185            $class = $instance[ 'class' ];
     
    245243        $instance['type'] = ( ! empty( $new_instance['type'] ) ) ? strip_tags( $new_instance['type'] ) : '';
    246244        $instance['number'] = ( ! empty( $new_instance['number'] ) ) ? strip_tags( $new_instance['number'] ) : '';
    247        
     245
    248246        $instance['template'] = ( ! empty( $new_instance['template'] ) ) ? str_replace( '.php', '', strip_tags( $new_instance['template'] ) ) : '';
    249247        $instance['class'] = ( ! empty( $new_instance['class'] ) ) ? strip_tags( $new_instance['class'] ) : '';
  • recomendo/trunk/recomendo.php

    r1963755 r1967374  
    55* Description: Make your website smart with Artificial Intelligence recommendations.
    66* Author: Recomendo
    7 * Version: 1.0.3
     7* Version: 1.0.4
    88* Requires at least: 4.7
    99* Tested up to: 4.9.8
  • recomendo/trunk/screens/dashboard.php

    r1963755 r1967374  
    33defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    44
     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
    516?>
    617
    7 <?php $options = get_option( 'recomendo_options' ); ?>
    818<div id="recomendo-dashboard" class="wrap">
    919
     
    130140                                </th>
    131141                                <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
    133143                                        foreach ( get_post_types( '', 'names' ) as $post_type ) {
    134144                                            if (!in_array($post_type, $avoid_post_types)) {
     
    163173                            <td>
    164174                                <?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');
    166175                                    foreach ( get_post_types( '', 'names' ) as $post_type ) {
    167176                                        if ( $post_type == $options['post_type']) {
     
    218227                                            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" />';
    219228                                        } 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"/>';
    221230                                        }
    222231                                ?>
     
    235244                                            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" />';
    236245                                        } 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"/>';
    238247                                        }
    239248                                ?>
     
    432441                            <?php
    433442
    434                             if ( Recomendo_Plugin::is_prediction_server_up() ) {
     443                            if ( Recomendo_Plugin::is_prediction_server_up() == 1 ) {
    435444                                _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) {
    437446                                _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 ) {
    439448                                _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' );
    440451                            }
     452
    441453                            ?>
    442454                        </td>
Note: See TracChangeset for help on using the changeset viewer.