Plugin Directory

Changeset 2360765


Ignore:
Timestamp:
08/14/2020 06:00:39 AM (6 years ago)
Author:
humcommerce
Message:

Be able to watch recommended session recordings from within your WordPress admin

Location:
humcommerce
Files:
36 added
12 deleted
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • humcommerce/tags/3.0.0/README.txt

    r2272741 r2360765  
    1 === Wordpress Analytics, Heatmaps & Session Recordings Plugin by HumCommerce ===
     1=== User Session Recording WooCommerce Plugin : HumCommerce Magic ===
    22Contributors: humcommerce
    33Tags: Analytics, Wordpress analytics, Conversion optimization, User Behavior analytics, Heatmaps, Session recordings, Visitor behavior analytics, E-commerce analytics, E-commerce tracking, Surveys, Humcommerce, google analytics, google analytics dashboard, google analytics widget, WooCommerce stats, analytics dashboard, universal google analytics, statistics, tracking, stats, google, google analytics by yoast, ga
    44Requires at least: 3.0.1
    5 Tested up to: 5.3.1
    6 Requires PHP: 5.2.4
    7 Stable tag: 2.1.15
     5Tested up to: 5.5.0
     6Requires PHP: 5.6.0
     7Stable tag: 3.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Wordpress Analytics & Conversion Optimization plugin for WooCommerce Website. Track & analyse heatmaps, sessions recordings and more.
     11Seeing where people click and what error messages annoyed them is now possible with HumCommerce Magic.
    1212
    1313== Description ==
    1414
    15 = Wordpress Analytics & Conversion Optimization plugin =
     15= WooCommerce User Behaviour Analysis & Conversion Optimization plugin =
    1616
    17 Wordpress store owners find it challenging to analyze the traffic sources, customer journey, where visitors are spending time. [HumCommerce](https://www.humcommerce.com/features/?utm_source=wp&utm_medium=link_click_1&utm_campaign=humcommerce) gives you these deep insights that will help them to convert visitors to buyers.
     17Seeing where people click and what error messages annoyed them is now possible with HumCommerce Magic. See customers who can't complete their purchase with session replays and figure out exactly why that sale didn’t happen.
    1818
    19 HumCommerce is a WordPress Plugin for Analytics and Conversion Optimization. It makes it easy to analyze the traffic sources and boost your conversions. It enables you to know precisely what actions visitors take on the website.
     19 [HumCommerce Magic](https://www.humcommerce.com/wordpress-analytics-plugin/?utm_source=wporg&utm_medium=link&utm_campaign=plugin&utm_content=readme) has advanced intelligence to identify and show you, where & why you lost a customer?
    2020
    21 This official HumCommerce plugin enables seamless integration between your Wordpress website and the HumCommerce CRO tool. Once integrated, the HumCommerce plugin will start tracking and monitoring data of your Wordpress store.
     21* Recordings feature gives you the ability to virtually see the users screen, to understand how people use your site.
     22* Identification feature can identify and report the users who saw error messages on your site.
     23* Segmentation feature records the users who are trying to purchase but couldn't complete the purchase.
     24* False Clicks feature finds and records the users, who are clicking on things that aren't even links.
    2225
    23 With this extension, you can have the dashboard view of your e-commerce data like Sales order, Revenue, best-selling products, and much more.
     26HumCommerce Magic makes data-driven decisions very easy. It's the only WooCommerce plugin that shows you exactly how much revenue was lost and why? It helps you decide which site changes matter the most.
    2427
    25 HumCommerce comes with a simple Dashboard for WordPress that gives you actionable insights, visitor analytics data, and visitor behavior report ( heatmaps, and session recordings.)
     28Unlike any other plugins, there is no code or signup process, you just have to click on a button to get it working.
    2629
    27 You can create customized reports that will show you only the data that matters to your business, so you can see accurately what’s working and what’s not!
     30The best part is that all the reports are right within your WordPress Dashboard. You get daily alerts of precise and no-fluff reports with insights that matter.
    2831
    29 HumCommerce connects with your Wordpress site in simple steps with this plugin. Once this plugin is installed, it gives you actionable insights to start making data-driven decisions for your Wordpress site.
     32HumCommerce Magic comes with a simple dashboard for WooCommerce. You can see a summary of customer experience, how much revenue was lost and the reason why you lost a potential customer?. Session recording playback feature makes it possible to view these recordings and replay what the customer experienced.
    3033
    31 ***HumCommerce Plugin***
     34Once this plugin is installed, and activated, it monitors your website every day. After 24 hrs, it automatically generates the magic report. You get a daily summary email about the customer experience on your WooCommerce store. You can also login to the dashboard to see experience details of each visitor for the day.
    3235
    33 *This HumCommerce WordPress plugin comes with the Visitor Behavior Analytics features like Session Recordings, Heatmaps, including events tracking, custom dimensions tracking, and more.[Click here to Sign Up for FREE!](https://www.humcommerce.com/free-signup?utm_source=wpress&utm_medium=link_click&utm_campaign=freetrial)*
     36In a nutshell, if you are serious about improving your customer experience: HumCommerce Magic is a must have WooCommerce plugin which is POWERFUL and extremely USEFUL.
    3437
    35 Here’s why e-commerce business owners, digital marketers, digital marketing agencies, SEO agencies love HumCommerce. And you will too!
     38***HumCommerce Magic Dashboard + Customer Experience Reports ***
    3639
    37 [youtube https://www.youtube.com/watch?v=uIGVa_sxY5c]
     40*We believe that HumCommerce Magic plugin should save your time in analysing visitor analytics. It should also come up with reports which are actionable. That's why HumCommerce Magic comes up with intelligence to automatically filter through your visitors to find out the reasons and session recordings that matter!
    3841
    39 = Key features of HumCommerce: =
     42* Abandoned Cart Report helps you know why visitors didn't buy. Were there any website errors that stopped them from buying? It gives you insights like which country, cart value and a recording which you can play within your WordPress Dashboard to see what the customer saw.
    4043
    41 - **Visitor Session Recordings** - See where your visitors get confused with analyzing what visitors are doing on your website. Find areas of improvement, and opportunities to modify the contents, workflow on the site that can optimize for conversions.
     44* False Click Report shows you are the areas on your site where customers are clicking where there are no links. You can relook at your design to help your customers understand your site better.
    4245
    43 - **Heatmaps** - It allows you to see what visitors are doing based on their mouse clicks and scrolling behavior.
    44 
    45 - **Conversion Funnels** - Identify issues in your crucial website sales funnels to optimize visitor journey.
    46 
    47 - **Form Analytics** - Form Analytics gives you insights and enables you to track how your website visitors interact with the forms on your website. Test and boost the form conversion by modifying the form fields based on the insights.
    48 
    49 - **Cart Abandonment** - Analyze why visitors are dropping off the website without completing the checkout. You can work towards reducing cart abandonment, which will increase the conversion rate.
    5046
    5147***See what Tod (E-Commerce business owner) is saying about HumCommerce:***
     
    5450>- TOD HAMM
    5551
    56 = WORDPRESS ANALYTICS DASHBOARD WITH REAL-TIME VISITOR DATA =
    57 
    58 Our main objective at HumCommerce is to help you make more revenue with user behavior analytics and actionable insights.
    59 
    60 We are committed to your successful ecommerce journey.
    61 
    62 Most online business owners find it challenging to analyze complex visitor behavior data.
    63 
    64 With HumCommerce, it’s no longer a challenge.
    65 
    66 With a built-in Wordpress Analytics Dashboard for your Wordpress site, you can get useful, actionable insights like where visitors are spending time, the reason for abandonment carts, etc. right inside your HumCommerce dashboard.
    67 
    68 Use the HumCommerce plugin for your WordPress site to gather data and help you improve conversions.
    69 
    70 We help you with meaningful insights to make your ecommerce journey a success!
    71 
    72 - **CRO Analysis** HumCommerce allows you to analyze the visitor behavior to enable you with insights accurately. It helps you optimize the steps of your user journey to increase your online conversion.
    73 
    74 - **Session Recordings Analysis** Analysis will show visitor’s recordings track clicks, mouse movements, scrolls, screen resize, and page changes. It will help you understand how they react to the various elements on your website and find ways to improve website user experience (UX).
    75 
    76 - **Visitors Profile Analysis** helps you know your website visitors better. It shows you detailed insights of each visitor like country, which pages of your site they like the most, date/time of their visits, and much more. You get every action a user has taken on the website. It helps you to see the user lifetime journey on the website
    7752
    7853***See what Dave (E-Commerce business owner) is saying about HumCommerce:***
    7954
    80 >Nothing short of being in awe as I realized the power of having accurate data of what people are doing on your site. From heat maps to A/B testing, tracking forms, and pages or products, this tool has it all…This is a must-have tool.
     55>Nothing short of being in awe as I realized the power of having accurate data of what people are doing on your site tracking forms, and pages or products, this tool has it all…This is a must-have tool.
    8156>- DAVE SWEENY
    8257
    83 We strongly recommend all WordPress websites owners users to use this simple yet powerful plugin for their e-commerce business.
    84 
    85 Some Popular Blogs / Tutorials
    86 
    87 - [How to Record Website Traffic](https://www.humcommerce.com/blog/analyse-website-session-recordings/?utm_source=wp&utm_medium=blog1&utm_campaign=HumC)
    88 - [How to create Heatmaps](https://www.humcommerce.com/blog/beginners-guide-to-heatmaps/?utm_source=wp&utm_medium=blog2&utm_campaign=HumC)
    89 - [How to create conversion funnels](https://www.humcommerce.com/blog/how-to-build-an-e-commerce-funnel-that-drives-sales/?utm_source=wp&utm_medium=blog3&utm_campaign=HumC)
    90 
    91 This plugin provides a simple installation of HumCommerce on your WordPress website by providing you instant access to all HumCommerce features.
    9258
    9359== Installation ==
     
    100662. Activate the plugin through the 'Plugins' menu in WordPress
    10167
    102 = Frequently Asked Questions =
    10368
    104 = What are the HumCommerce Terms of Use? =
    105 
    106 The full [terms of use are available here](https://www.humcommerce.com/terms-of-use/) along with other legal and privacy documentation. If you have further questions do not hesitate to reach out to our [support](support@humcommerce.com).
    107 
    108 = What is Site ID? =
    109 
    110 Login to your HumCommerce Account. Go to My Account. Click on Launch Dashboard button.
    111 The site id number is listed under Settings/Website/Manage in your HumDash administration panel.
    112 
    113 = How do I view my stats? =
    114 
    115 Once you've installed HumCommerce, you can launch our tool from the "Launch Dashboard" button on My Account page.
    11669
    11770== Screenshots ==
    11871
    119 1. HumCommerce Heatmaps
    120 2. HumCommerce Session Recordings
    121 3. HumCommerce Funnels
    122 4. HumCommerce Settings
     721. HumCommerce Getting Started
     732. HumCommerce Recordings Table
     743. Abandoned Cart Recording
     754. HumCommerce Recordings
    12376
    12477== Frequently Asked Questions ==
    12578
    126 = Do I need a HumCommerce account to use this plugin? =
     79= Do I need to sign up or pay for this plugin? =
    12780
    128 Yes. You can sign up for a [free HumCommerce plan](https://www.humcommerce.com/lifetime-free/) that provides access to all our features including heatmaps, session recordings/replays, and deep e-commerce integration tools and more.
     81No, there is no signup or payment to be done to use this plugin. It’s a simple setup, only activate and click the button to allow the plugin to analyze your site visitors.
    12982
    130 = Do we need a developer to install HumCommerce Plugin? =
     83= Is HumCommerce Magic GDPR Compliant? =
    13184
    132 No. You don’t need a developer. HumCommerce plugin allows you to enable all advanced E-Commerce analytics tracking features with just a few clicks.
     85HumCommerce Magic takes user privacy very seriously. It doesn't record any user identifiable information. By default it suppresses all text-based on-page numbers and email addresses, input fields and some text in session recordings.
    13386
    134 = Is HumCommerce plugin different from Google Analytics plugin ? =
     87= Can I use HumCommerce Magic with other analytics plugins like Google Analytics Plugin? =
     88Sure. You can use any other analytics tools like Google Analytics plugin on your WordPress site.
    13589
    136 Yes. With HumCommerce plugin you get access to our additional features like heatmaps, visitor recordings, and surveys. [Click here](https://www.humcommerce.com/features) to checkout all HumCommerce features
    137 
    138 = Will HumCommerce slow down the performance of my website? =
    139 
    140 No. It will not affect your website speed or performance in any way.Analytics will get loaded asynchronously which means it will not slow down your website speed or performance.
     90= Does HumCommerce Magic work on WordPress multisite? =
     91No. Currently Magic is optimized to work only on standard WooCommerce websites, not on multisite instances.
    14192
    14293
    14394== Changelog ==
     95
     96Ver 3.0.0 (14 Aug 2020)
     97* Feature : Be able to watch recommended session recordings from wordpress admin itself
    14498
    14599Ver 2.1.15 (1 Apr 2020)
  • humcommerce/tags/3.0.0/admin/class-humcommerce-admin.php

    r2217514 r2360765  
    5353        $this->humcommerce = $humcommerce;
    5454        $this->version     = $version;
    55 
     55        $this->maybe_create_scheduled_event();
     56
     57        $this->api = \Magic_Api::get_instance();
     58
     59        add_action( 'admin_enqueue_scripts', array( $this, 'load_recording_css' ) );
     60        add_action( 'admin_init', array( $this, 'register_humc_settings' ) );
     61        add_action( 'wp_magic_fetch_cron_hook', array( $this, 'get_recordings_cron_exec' ) );
     62        add_action( 'admin_menu', array( $this, 'add_report_page' ) );
     63        add_action( 'admin_post_humc_create_magic_account', array( $this, 'create_humcommerce_account' ) );
     64        add_action( 'admin_post_report_magic_error', array( $this, 'report_error' ) );
     65    }
     66
     67    /**
     68     * Report error back to humcommerce support
     69     */
     70    public function report_error() {
     71
     72        if ( ! check_admin_referer( 'humc_report_error' ) ) {
     73            wp_die( 'Unauthorized request', 401 );
     74        }
     75
     76        $error = isset( $_POST['humc_error'] ) ? sanitize_text_field( wp_unslash( $_POST['humc_error'] ) ) : false;
     77
     78        if ( false === $error ) {
     79            $url = admin_url( 'admin.php?page=recommended-recordings' );
     80            wp_safe_redirect( $url );
     81            exit();
     82        }
     83
     84        $site = home_url();
     85        $user = wp_get_current_user();
     86
     87        $subject = sprintf( 'Error while setting up magic on %s', $site );
     88        $body    = sprintf( '%s reported following error : %s', $user->user_email, $error );
     89
     90        wp_mail( 'support@humcommerce.com', $subject, $body );
     91
     92        $url = admin_url( 'admin.php?page=recommended-recordings' );
     93        wp_safe_redirect( $url );
     94        exit();
     95    }
     96
     97    /**
     98     * Register site and token settings.
     99     */
     100    public function register_humc_settings() {
     101        register_setting( 'humc_magic', 'humc_site' );
     102        register_setting( 'humc_magic', 'humc_token' );
     103    }
     104
     105    /**
     106     * Add menu
     107     */
     108    public function add_report_page() {
     109        add_menu_page(
     110            'Must watch Customer recordings',
     111            'HumCommerce',
     112            'administrator',
     113            'recommended-recordings',
     114            array( $this, 'create_report_page' ),
     115            esc_url( plugins_url( 'images/icon.png', __FILE__ ) )
     116        );
     117
     118        add_submenu_page(
     119            'recommended-recordings',
     120            'Must watch Customer recordings',
     121            'Recordings',
     122            'administrator',
     123            'recommended-recordings',
     124            array( $this, 'create_report_page' ),
     125            10
     126        );
     127
     128        add_submenu_page(
     129            'recommended-recordings',
     130            'HumCommerce Settings',
     131            'Settings',
     132            'administrator',
     133            'humcommerce-settings',
     134            array( $this, 'create_settings_page' ),
     135            20
     136        );
     137    }
     138
     139    /**
     140     * Options page callback.
     141     *
     142     * @since 1.0.0
     143     */
     144    public function create_settings_page() {
     145        // Set class property.
     146        $site  = get_option( 'humc_site' );
     147        $token = get_option( 'humc_token' );
     148
     149        $email        = get_option( 'admin_email' );
     150        $logo_url     = plugins_url( '/images/logo.png', __FILE__ );
     151        $setting_hook = __FILE__;
     152        include_once plugin_dir_path( __FILE__ ) . 'views/settings-page.php';
     153    }
     154
     155    /**
     156     * Load css
     157     */
     158    public function load_recording_css() {
     159        wp_enqueue_style( $this->humcommerce, plugin_dir_url( __FILE__ ) . 'css/recording-table.css', array(), $this->version, 'all' );
     160        wp_enqueue_style( $this->humcommerce . '-css', plugin_dir_url( __FILE__ ) . 'css/humcommerce-admin.css', array(), $this->version, 'all' );
     161    }
     162
     163    /**
     164     * Render recordings list or getting started page
     165     */
     166    public function create_report_page() {
     167
     168        if ( $this->is_magic_setup() ) {
     169            $this->render_report();
     170            return;
     171        }
     172        $this->render_getting_started();
     173
     174    }
     175
     176    /**
     177     * Check if magic is setup
     178     *
     179     * @return bool
     180     */
     181    private function is_magic_setup() {
     182        $site  = get_option( 'humc_site' );
     183        $token = get_option( 'humc_token' );
     184
     185        if ( $site && $token ) {
     186            return true;
     187        }
     188        return false;
     189
     190    }
     191
     192    /**
     193     * Render magic table
     194     */
     195    private function render_report() {
     196        require_once plugin_dir_path( __FILE__ ) . '/class-magic-report.php';
     197
     198        $table = new Magic_Report();
     199        $table->prepare_items();
     200        ?>
     201        <div class="wrap">
     202            <h1>Recommended Recordings</h1>
     203            <?php $table->display(); ?>
     204        </div>
     205
     206        <?php
     207    }
     208
     209    /**
     210     * Render getting started
     211     */
     212    private function render_getting_started() {
     213        require_once plugin_dir_path( __FILE__ ) . '/getting-started.php';
     214    }
     215
     216    /**
     217     * Schedule cron event for fetching recordings
     218     */
     219    public function maybe_create_scheduled_event() {
     220        $tommorrow_nine = strtotime( gmdate( 'Y-m-d' ) ) + ( 12 * HOUR_IN_SECONDS );
     221        if ( ! wp_next_scheduled( 'wp_magic_fetch_cron_hook' ) ) {
     222            wp_schedule_event( $tommorrow_nine, 'daily', 'wp_magic_fetch_cron_hook' );
     223        }
     224    }
     225
     226    /**
     227     * Fetch recordings
     228     */
     229    public function get_recordings_cron_exec() {
     230
     231        $token  = get_option( 'humc_token' );
     232        $idsite = get_option( 'humc_site' );
     233        $day    = gmdate( 'Y-m-d', strtotime( 'yesterday' ) );
     234
     235        $data = $this->api->get_recordings( $idsite, $token, $day );
     236        if ( $data['error'] ) {
     237            error_log( $data['message'] ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     238            return;
     239        }
     240
     241        foreach ( $data['reportChunks'] as $report ) {
     242            $this->insert_recordings( $report );
     243        }
     244
     245        if ( count( $data['reportChunks'] ) > 1 ) {
     246            $summary = $this->get_summary( $data['reportChunks'] );
     247            $this->notify_via_email( $summary );
     248        }
     249
     250    }
     251
     252    /** Generate summary to send in mail
     253     *
     254     * @param array $data recording array.
     255     * @return array
     256     */
     257    private function get_summary( $data ) {
     258        $abandon_carts = 0;
     259        $no_errors     = 0;
     260        $no_clicks     = 0;
     261        $revenue_lost  = 0;
     262
     263        foreach ( $data as $rec ) {
     264
     265            if ( $rec['isAbandonCart'] ) {
     266                $abandon_carts++;
     267                $revenue_lost += $rec['cartValue'];
     268            }
     269
     270            if ( count( $rec['deadClicks'] ) ) {
     271                $no_clicks++;
     272            }
     273
     274            if ( count( $rec['errors'] ) ) {
     275                $no_errors++;
     276            }
     277        }
     278        if ( function_exists( 'wc_price' ) ) {
     279            $revenue_lost = wc_price( $revenue_lost );
     280        }
     281
     282        return array(
     283            sprintf( 'Estimated revenue lost %s from %s abandoned cart', $revenue_lost, $abandon_carts ),
     284            sprintf( '%s users saw some kind of errors. (More about this in your admin area)', $no_errors ),
     285            sprintf( '%s user clicked around expecting something would happen but nothing happened', $no_clicks ),
     286        );
     287
     288    }
     289
     290    /**
     291     * Notify admin via email about new recordings
     292     *
     293     * @param array $summary array of messages to send in email.
     294     */
     295    private function notify_via_email( $summary ) {
     296        $email     = get_option( 'admin_email' );
     297        $blog_name = get_option( 'blogname' );
     298
     299        ob_start();
     300        include_once plugin_dir_path( __FILe__ ) . '/views/recording-email.php';
     301        $content = ob_get_contents();
     302        ob_end_clean();
     303
     304        /* translators: New email address notification email subject. %s: Site title. */
     305        wp_mail( $email, sprintf( __( 'Recommended session recordings for [%s]' ), $blog_name ), $content, array( 'Content-Type:text/html' ) );
     306    }
     307
     308    /**
     309     * Insert recording in database table
     310     *
     311     * @param array $row recording row.
     312     */
     313    private function insert_recordings( $row ) {
     314        global $wpdb;
     315
     316        $clicks  = wp_json_encode( $row['deadClicks'] );
     317        $errors  = wp_json_encode( $row['errors'] );
     318        $abandon = (int) $row['isAbandonCart'];
     319
     320        $rec_date   = strtotime( $row['recording_date'] );
     321        $rec_date   = gmdate( 'Y-m-d H:i:s', $rec_date );
     322        $table_name = $wpdb->prefix . \Humcommerce::REC_TABLE;
     323
     324        $bind = array(
     325            $row['idloghsr'],
     326            $row['idsitehsr'],
     327            $row['cartValue'],
     328            $row['location_country'],
     329            $abandon,
     330            $row['sessionReplayUrl'],
     331            $rec_date,
     332            $clicks,
     333            $errors,
     334        );
     335
     336        $sql = "INSERT INTO `$table_name`
     337     (`idloghsr`,`idsitehsr`,`cart_value`,`location_country`,`is_abandon_cart`,`recording_url`,`recording_date`,`dead_clicks`,`errors`)
     338      VALUES (%d,%d,%f,%s,%d,'%s','%s','%s','%s')";
     339
     340        $wpdb->query( $wpdb->prepare( $sql, $bind ) ); // phpcs:ignore WordPress.DB
    56341    }
    57342
     
    74359    public function enqueue_scripts() {
    75360
    76         wp_enqueue_script( $this->humcommerce, plugin_dir_url( __FILE__ ) . 'js/humcommerce-admin.js', array(), $this->version, false );
    77         $options = get_option( 'humcommerce_options' );
    78         if ( is_array( $options ) ) {
    79             if ( array_key_exists( 'host', $options ) && ! empty( $options['host'] ) ) {
    80                 $host_url = $options['host'];
    81             } else {
    82                 $host_url = HUMCOMMERCE_HOST;
    83             }
    84         } else {
    85             $host_url = HUMCOMMERCE_HOST;
    86         }
    87         wp_localize_script(
    88             $this->humcommerce,
    89             'humcommerce_script',
    90             array(
    91                 'ajaxurl'         => admin_url( 'admin-ajax.php' ),
    92                 'humcommerce_url' => $host_url,
    93             )
    94         );
    95 
    96     }
    97 
    98     /**
    99      * Shows the notice after user saves the HumCommerce Settings.
    100      *
    101      * @since 2.1.12
    102      */
    103     public function humcommerce_add_settings_errors() {
    104 
    105         settings_errors();
    106 
    107     }
     361    }
     362
     363    /**
     364     * We are not going to use WordPress nonce because it is user dependent.
     365     * The nonce created by admin session won't match with nonce created publicly
     366     */
     367    public function create_humcommerce_account() {
     368
     369        $result = isset( $_POST['_wp_nonce'] ) ? wp_verify_nonce( sanitize_key( $_POST['_wp_nonce'] ), 'humc_account_create' ) : false;
     370
     371        if ( ! $result ) {
     372            wp_die( 'Unauthorized request', 401 );
     373        }
     374
     375        // This nonce will expire in 120 seconds so the whole request must complete within 120 seconds.
     376        $nonce = substr( wp_hash( time() . '|', 'nonce' ), -12, 10 );
     377        set_transient( '__humc_auth_nonce', $nonce, 120 );
     378
     379        $email     = get_option( 'admin_email' );
     380        $domain    = get_site_url();
     381        $blog_name = get_option( 'blogname' );
     382
     383        $params = array(
     384            'email'    => $email,
     385            'domain'   => $domain,
     386            'blogName' => $blog_name,
     387            'nonce'    => $nonce,
     388        );
     389
     390        $response = $this->api->create_humcommerce_account( $params );
     391
     392        if ( $response['error'] ) {
     393            wp_die( $this->get_error_html( $response['message'] ) ); //phpcs:ignore
     394        }
     395
     396        update_option( 'humc_site', $response['site'], false );
     397        update_option( 'humc_token', $response['token'], false );
     398        $url = admin_url( 'admin.php?page=recommended-recordings' );
     399        wp_safe_redirect( $url );
     400        exit();
     401    }
     402
     403    /**
     404     * Get error html
     405     *
     406     * @param string $message variable is used inside error.php.
     407     */
     408    private function get_error_html( $message ) {
     409        ob_start();
     410        include_once plugin_dir_path( __FILe__ ) . '/views/error.php';
     411        $content = ob_get_contents();
     412        ob_end_clean();
     413        return $content;
     414    }
     415
    108416
    109417    /**
     
    116424    public function humcommerce_activation_redirect( $plugin ) {
    117425        if ( plugin_basename( 'humcommerce/humcommerce.php' ) === $plugin ) {
    118             exit( wp_safe_redirect( get_admin_url( null, 'admin.php?page=humcommerce-settings' ) ) );
     426            wp_safe_redirect( admin_url( 'admin.php?page=recommended-recordings' ) );
     427            exit();
    119428        }
    120429    }
  • humcommerce/tags/3.0.0/admin/css/humcommerce-admin.css

    r2217514 r2360765  
    1 .wp-admin.jetpack_page_humcommerce-key-config, .wp-admin.settings_page_humcommerce-key-config {
    2     background-color: #f3f6f8;
     1#intro-section,#setup-section,#section-video{
     2    text-align: center;
     3    background-color: #fff;
     4    padding:50px 10px;
    35}
    46
    5 #submitted-on {
    6     position: relative;
     7#setup-button{
     8    display: inline-block;
     9    text-decoration: none;
     10    font-size: 18px;
     11    line-height: 2.15384615;
     12    min-height: 30px;
     13    margin: 10px;
     14    padding: 10px 20px;
     15    cursor: pointer;
     16    border-width: 0px;
     17    -webkit-appearance: none;
     18    white-space: nowrap;
     19    box-sizing: border-box;
     20    background-color: #e53935;
     21    color:#fff;
    722}
    823
    9 #the-comment-list .author .humcommerce-user-comment-count {
    10     display: inline;
     24#section-video {
     25    background-color: #f5f3ff;
    1126}
    1227
    13 #the-comment-list .author a span {
    14     text-decoration: none;
    15     color: #999;
     28#section-video > div {
     29    width:40%;
     30    display: inline-block;
     31    vertical-align: middle;
     32    text-align: center;
     33    background-color: #f5f3ff;
    1634}
    1735
    18 #the-comment-list .author a span.humcommerce-span-link {
    19     text-decoration: inherit;
    20     color: inherit;
     36.humc-text{
     37    font-size:16px;
     38    width:70%;
     39    text-align: center;
     40    margin:auto;
    2141}
    22 
    23 #the-comment-list .humcommerce_remove_url {
    24     margin-left: 3px;
    25     color: #999;
    26     padding: 2px 3px 2px 0;
    27 }
    28 
    29 #the-comment-list .humcommerce_remove_url:hover {
    30     color: #A7301F;
    31     font-weight: bold;
    32     padding: 2px 2px 2px 0;
    33 }
    34 
    35 #dashboard_recent_comments .humcommerce-status {
    36     display: none;
    37 }
    38 
    39 .humcommerce-status {
    40     float: right;
    41 }
    42 
    43 .humcommerce-status a {
    44     color: #AAA;
    45     font-style: italic;
    46 }
    47 
    48 table.comments td.comment p a {
    49     text-decoration: underline;
    50 }
    51 
    52 table.comments td.comment p a:after {
    53     content: attr(href);
    54     color: #aaa;
    55     display: inline-block; /* Show the URL without the link's underline extending under it. */
    56     padding: 0 1ex; /* Because it's inline block, we can't just use spaces in the content: attribute to separate it from the link text. */
    57 }
    58 
    59 .mshot-arrow {
    60     width: 0;
    61     height: 0;
    62     border-top: 10px solid transparent;
    63     border-bottom: 10px solid transparent;
    64     border-right: 10px solid #5C5C5C;
    65     position: absolute;
    66     left: -6px;
    67     top: 91px;
    68 }
    69 
    70 .mshot-container {
    71     background: #5C5C5C;
    72     position: absolute;
    73     top: -94px;
    74     padding: 7px;
    75     width: 450px;
    76     height: 338px;
    77     z-index: 20000;
    78     -moz-border-radius: 6px;
    79     border-radius: 6px;
    80     -webkit-border-radius: 6px;
    81 }
    82 
    83 .humcommerce-mshot {
    84     position: absolute;
    85     z-index: 100;
    86 }
    87 
    88 .humcommerce-mshot .mshot-image {
    89     margin: 0;
    90     height: 338px;
    91     width: 450px;
    92 }
    93 
    94 .checkforspam {
    95     display: inline-block !important;
    96 }
    97 
    98 .checkforspam-progress {
    99     padding-left: 1ex;
    100     display: none;
    101 }
    102 
    103 .checkforspam.button-disabled .checkforspam-progress {
    104     display: inline;
    105 }
    106 
    107 .checkforspam-spinner {
    108     display: inline-block;
    109     margin-top: 7px;
    110 }
    111 
    112 .humcommerce-right {
    113     float: right;
    114 }
    115 
    116 .humcommerce-card .humcommerce-right {
    117     margin: 1em 0;
    118 }
    119 
    120 .humcommerce-alert-text {
    121     color: #dd3d36;
    122     font-weight: bold;
    123     font-size: 120%;
    124     margin-top: .5rem;
    125 }
    126 
    127 .humcommerce-alert {
    128     border: 1px solid #e5e5e5;
    129     padding: 0.4em 1em 1.4em 1em;
    130     border-radius: 3px;
    131     -webkit-border-radius: 3px;
    132     border-width: 1px;
    133     border-style: solid;
    134 }
    135 
    136 .humcommerce-alert h3.humcommerce-key-status {
    137     color: #fff;
    138     margin: 1em 0 0.5em 0;
    139 }
    140 
    141 .humcommerce-alert.humcommerce-critical {
    142     background-color: #993300;
    143 }
    144 
    145 .humcommerce-alert.humcommerce-active {
    146     background-color: #649316;
    147 }
    148 
    149 .humcommerce-alert p.humcommerce-key-status {
    150     font-size: 24px;
    151 }
    152 
    153 .humcommerce-alert p.humcommerce-description {
    154     color: #fff;
    155     font-size: 14px;
    156     margin: 0 0;
    157     font-style: normal;
    158 }
    159 
    160 .humcommerce-alert p.humcommerce-description a,
    161 .humcommerce-alert p.humcommerce-description a,
    162 .humcommerce-alert p.humcommerce-description a,
    163 .humcommerce-alert p.humcommerce-description a {
    164     color: #fff;
    165 }
    166 
    167 .humcommerce-new-snapshot {
    168     margin-top: 1em;
    169     padding: 1em;
    170     text-align: center;
    171     background: #fff;
    172 }
    173 
    174 .humcommerce-new-snapshot h3 {
    175     background: #f5f5f5;
    176     color: #888;
    177     font-size: 11px;
    178     margin: 0;
    179     padding: 3px;
    180 }
    181 
    182 .new-snapspot ul {
    183     font-size: 12px;
    184     width: 100%;
    185 }
    186 
    187 .humcommerce-new-snapshot ul li {
    188     color: #999;
    189     float: left;
    190     font-size: 11px;
    191     padding: 0 20px;
    192     text-transform: uppercase;
    193     width: 33%;
    194     box-sizing: border-box;
    195     -moz-box-sizing: border-box;
    196     -webkit-box-sizing: border-box;
    197     -ms-box-sizing: border-box;
    198 }
    199 
    200 .humcommerce-new-snapshot ul li:first-child,
    201 .humcommerce-new-snapshot ul li:nth-child(2) {
    202     border-right: 1px dotted #ccc;
    203 }
    204 
    205 .humcommerce-new-snapshot ul li span {
    206     color: #52accc;
    207     display: block;
    208     font-size: 32px;
    209     font-weight: lighter;
    210     line-height: 1.5em;
    211 }
    212 
    213 .humcommerce-settings th:first-child {
    214     vertical-align: top;
    215     padding-top: 15px;
    216 }
    217 
    218 .humcommerce-settings th.humcommerce-api-key {
    219     vertical-align: middle;
    220     padding-top: 0;
    221 }
    222 
    223 .humcommerce-settings input[type=text] {
    224     width: 75%;
    225 }
    226 
    227 .humcommerce-settings span.humcommerce-note {
    228     float: left;
    229     padding-left: 23px;
    230     font-size: 75%;
    231     margin-top: -10px;
    232 }
    233 
    234 /**
    235  * For the activation notice on the plugins page.
    236  */
    237 .humcommerce_activate {
    238     min-width: 825px;
    239     border: 1px solid #4F800D;
    240     padding: 5px;
    241     margin: 15px 0;
    242     background: #83AF24;
    243     background-image: -webkit-gradient(linear, 0% 0, 80% 100%, from(#83AF24), to(#4F800D));
    244     background-image: -moz-linear-gradient(80% 100% 120deg, #4F800D, #83AF24);
    245     -moz-border-radius: 3px;
    246     border-radius: 3px;
    247     -webkit-border-radius: 3px;
    248     position: relative;
    249     overflow: hidden;
    250 }
    251 
    252 .humcommerce_activate .aa_a {
    253     position: absolute;
    254     top: -5px;
    255     right: 10px;
    256     font-size: 140px;
    257     color: #769F33;
    258     font-family: Georgia, "Times New Roman", Times, serif;
    259     z-index: 1;
    260 }
    261 
    262 .humcommerce_activate .aa_button {
    263     font-weight: bold;
    264     border: 1px solid #029DD6;
    265     border-top: 1px solid #06B9FD;
    266     font-size: 15px;
    267     text-align: center;
    268     padding: 9px 0 8px 0;
    269     color: #FFF;
    270     background: #029DD6;
    271     background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1));
    272     background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6);
    273     -moz-border-radius: 2px;
    274     border-radius: 2px;
    275     -webkit-border-radius: 2px;
    276     width: 100%;
    277     cursor: pointer;
    278     margin: 0;
    279 }
    280 
    281 .humcommerce_activate .aa_button:hover {
    282     text-decoration: none !important;
    283     border: 1px solid #029DD6;
    284     border-bottom: 1px solid #00A8EF;
    285     font-size: 15px;
    286     text-align: center;
    287     padding: 9px 0 8px 0;
    288     color: #F0F8FB;
    289     background: #0079B1;
    290     background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#0079B1), to(#0092BF));
    291     background-image: -moz-linear-gradient(0% 100% 90deg, #0092BF, #0079B1);
    292     -moz-border-radius: 2px;
    293     border-radius: 2px;
    294     -webkit-border-radius: 2px;
    295 }
    296 
    297 .humcommerce_activate .aa_button_border {
    298     border: 1px solid #006699;
    299     -moz-border-radius: 2px;
    300     border-radius: 2px;
    301     -webkit-border-radius: 2px;
    302     background: #029DD6;
    303     background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1));
    304     background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6);
    305 }
    306 
    307 .humcommerce_activate .aa_button_container {
    308     display: inline-block;
    309     background: #DEF1B8;
    310     padding: 5px;
    311     -moz-border-radius: 2px;
    312     border-radius: 2px;
    313     -webkit-border-radius: 2px;
    314     width: 266px;
    315 }
    316 
    317 .humcommerce_activate .aa_description {
    318     position: absolute;
    319     top: 22px;
    320     left: 285px;
    321     margin-left: 25px;
    322     color: #E5F2B1;
    323     font-size: 15px;
    324     z-index: 1000;
    325 }
    326 
    327 .humcommerce_activate .aa_description strong {
    328     color: #FFF;
    329     font-weight: normal;
    330 }
    331 
    332 .jetpack_page_humcommerce-key-config #wpcontent, .settings_page_humcommerce-key-config #wpcontent {
    333     padding-left: 0;
    334 }
    335 
    336 .humcommerce-masthead {
    337     background-color: #fff;
    338     text-align: center;
    339     box-shadow: 0 1px 0 rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
    340     max-width: 45rem;
    341     margin: 0 auto;
    342 }
    343 
    344 @media (max-width: 45rem) {
    345     .humcommerce-masthead {
    346         padding: 0 1.25rem
    347     }
    348 }
    349 
    350 .humcommerce-masthead__inside-container {
    351     padding: .375rem 0;
    352     margin: 0 auto;
    353     width: 100%;
    354     max-width: 45rem;
    355     text-align: left;
    356 }
    357 
    358 .humcommerce-masthead__logo-container {
    359     padding: 0.3125rem 0 0;
    360 }
    361 
    362 .humcommerce-masthead__logo {
    363     width: 8.375rem;
    364     height: 2.8125rem;
    365 }
    366 
    367 .humcommerce-masthead__logo-link {
    368     display: inline-block;
    369     outline: none;
    370     vertical-align: middle
    371 }
    372 
    373 .humcommerce-masthead__logo-link:focus {
    374     line-height: 0;
    375     box-shadow: 0 0 0 2px #78dcfa
    376 }
    377 
    378 .humcommerce-masthead__logo-link + code {
    379     margin: 0 10px;
    380     padding: 5px 9px;
    381     border-radius: 2px;
    382     background: #e6ecf1;
    383     color: #647a88
    384 }
    385 
    386 .humcommerce-masthead__links {
    387     display: -ms-flexbox;
    388     display: flex;
    389     -ms-flex-flow: row wrap;
    390     flex-flow: row wrap;
    391     -ms-flex: 2 50%;
    392     flex: 2 50%;
    393     -ms-flex-pack: end;
    394     justify-content: flex-end;
    395     margin: 0
    396 }
    397 
    398 @media (max-width: 480px) {
    399     .humcommerce-masthead__links {
    400         padding-right: .625rem
    401     }
    402 }
    403 
    404 .humcommerce-masthead__link-li {
    405     margin: 0;
    406     padding: 0
    407 }
    408 
    409 .humcommerce-masthead__link {
    410     font-style: normal;
    411     color: #0087be;
    412     padding: .625rem;
    413     display: inline-block
    414 }
    415 
    416 .humcommerce-masthead__link:visited {
    417     color: #0087be
    418 }
    419 
    420 .humcommerce-masthead__link:active, .humcommerce-masthead__link:hover {
    421     color: #00aadc
    422 }
    423 
    424 .humcommerce-masthead__link:hover {
    425     text-decoration: underline
    426 }
    427 
    428 .humcommerce-masthead__link .dashicons {
    429     display: none
    430 }
    431 
    432 @media (max-width: 480px) {
    433     .humcommerce-masthead__link:hover, .humcommerce-masthead__link:active {
    434         text-decoration: none
    435     }
    436 
    437     .humcommerce-masthead__link .dashicons {
    438         display: block;
    439         font-size: 1.75rem
    440     }
    441 
    442     .humcommerce-masthead__link span + span {
    443         display: none
    444     }
    445 }
    446 
    447 .humcommerce-masthead__link-li:last-of-type .humcommerce-masthead__link {
    448     padding-right: 0
    449 }
    450 
    451 .humcommerce-lower {
    452     margin: 0 auto;
    453     text-align: left;
    454     max-width: 45rem;
    455     padding: 1.5rem;
    456 }
    457 
    458 .humcommerce-lower .notice {
    459     margin-bottom: 2rem;
    460 }
    461 
    462 .humcommerce-card {
    463     margin-top: 1rem;
    464     margin-bottom: 0;
    465     position: relative;
    466     margin: 0 auto 0.625rem auto;
    467     box-sizing: border-box;
    468     background: white;
    469     box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
    470 }
    471 
    472 .humcommerce-card:after, .humcommerce-card .inside:after, .humcommerce-masthead__logo-container:after {
    473     content: ".";
    474     display: block;
    475     height: 0;
    476     clear: both;
    477     visibility: hidden;
    478 }
    479 
    480 .humcommerce-card .inside {
    481     padding: 1.5rem;
    482     padding-top: 1rem;
    483 }
    484 
    485 .humcommerce-card .humcommerce-card-actions {
    486     margin-top: 1rem;
    487 }
    488 
    489 .jetpack_page_humcommerce-key-config .update-nag, .settings_page_humcommerce-key-config .update-nag {
    490     display: none;
    491 }
    492 
    493 .humcommerce-masthead .humcommerce-right {
    494     line-height: 2.125rem;
    495     font-size: 0.9rem;
    496 }
    497 
    498 .humcommerce-box {
    499     box-sizing: border-box;
    500     background: white;
    501     border: 1px solid rgba(200, 215, 225, 0.5);
    502 }
    503 
    504 .humcommerce-box h2, .humcommerce-box h3 {
    505     padding: 1.5rem 1.5rem .5rem 1.5rem;
    506     margin: 0;
    507 }
    508 
    509 .humcommerce-box p {
    510     padding: 0 1.5rem 1.5rem 1.5rem;
    511     margin: 0;
    512 }
    513 
    514 .humcommerce-jetpack-email {
    515     font-style: oblique;
    516 }
    517 
    518 .humcommerce-jetpack-gravatar {
    519     padding: 0 0 0 1.5rem;
    520     float: left;
    521     margin-right: 1rem;
    522     width: 54px;
    523     height: 54px;
    524 }
    525 
    526 .humcommerce-box p:after {
    527     content: ".";
    528     display: block;
    529     height: 0;
    530     clear: both;
    531     visibility: hidden;
    532 }
    533 
    534 .humcommerce-box .humcommerce-right {
    535     padding-right: 1.5rem;
    536 }
    537 
    538 .humcommerce-boxes .humcommerce-box {
    539     margin-bottom: 0;
    540     padding: 0;
    541     margin-top: -1px;
    542 }
    543 
    544 .humcommerce-boxes .humcommerce-box:last-child {
    545     margin-bottom: 1.5rem;
    546 }
    547 
    548 .humcommerce-boxes .humcommerce-box:first-child {
    549     margin-top: 1.5rem;
    550 }
    551 
    552 .humcommerce-button, .humcommerce-button:hover, .humcommerce-button:visited {
    553     background: white;
    554     border-color: #c8d7e1;
    555     border-style: solid;
    556     border-width: 1px 1px 2px;
    557     color: #2e4453;
    558     cursor: pointer;
    559     display: inline-block;
    560     margin: 0;
    561     outline: 0;
    562     overflow: hidden;
    563     font-size: 14px;
    564     font-weight: 500;
    565     text-overflow: ellipsis;
    566     text-decoration: none;
    567     vertical-align: top;
    568     box-sizing: border-box;
    569     font-size: 14px;
    570     line-height: 21px;
    571     border-radius: 4px;
    572     padding: 7px 14px 9px;
    573     -webkit-appearance: none;
    574     -moz-appearance: none;
    575     appearance: none;
    576 }
    577 
    578 .humcommerce-button:hover {
    579     border-color: #a8bece;
    580 }
    581 
    582 .humcommerce-button:active {
    583     border-width: 2px 1px 1px;
    584 }
    585 
    586 .humcommerce-is-primary, .humcommerce-is-primary:hover, .humcommerce-is-primary:visited {
    587     background: #00aadc;
    588     border-color: #0087be;
    589     color: white;
    590 }
    591 
    592 .humcommerce-is-primary:hover, .humcommerce-is-primary:focus {
    593     border-color: #005082;
    594 }
    595 
    596 .humcommerce-is-primary:hover {
    597     border-color: #005082;
    598 }
    599 
    600 .humcommerce-section-header {
    601     position: relative;
    602     margin: 0 auto 0.625rem auto;
    603     padding: 1rem;
    604     box-sizing: border-box;
    605     box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
    606     background: #ffffff;
    607     width: 100%;
    608     padding-top: 0.6875rem;
    609     padding-bottom: 0.6875rem;
    610     display: flex;
    611 }
    612 
    613 .humcommerce-section-header__label {
    614     display: -ms-flexbox;
    615     display: flex;
    616     -ms-flex-align: center;
    617     align-items: center;
    618     -ms-flex-positive: 1;
    619     flex-grow: 1;
    620     line-height: 1.75rem;
    621     position: relative;
    622     font-size: 0.875rem;
    623     color: #4f748e;
    624 }
    625 
    626 .humcommerce-section-header__actions {
    627     line-height: 1.75rem;
    628 }
    629 
    630 #humcommerce-plugin-container table.form-table {
    631     padding: 0px 0px 0px 0px;
    632     margin: -18px 0px 0px 26px;
    633 }
    634 
    635 #si {
    636     width: 120px;
    637 }
    638 
    639 #humcommerce-plugin-container {
    640     margin: 0 0 0 -20px;
    641 }
  • humcommerce/tags/3.0.0/humcommerce.php

    r2272741 r2360765  
    1616 * Plugin URI:        https://wordpress.org/plugins/humcommerce/
    1717 * Description:       HumCommerce WordPress plugin to Record, Analyze & Convert your visitors.
    18  * Version:           2.1.15
     18 * Version:           3.0.0
    1919 * Author:            HumCommerce
    2020 * Author URI:        https://www.humcommerce.com
     
    2929}
    3030
    31 define( 'HUMCOMMERCE_VERSION', '2.1.15' );
    32 define( 'HUMCOMMERCE_HOST', 'app.humcommerce.com' );
     31define( 'HUMCOMMERCE_VERSION', '3.0.0' );
     32
     33if ( ! defined( 'HUMCOMMERCE_HOST' ) ) {
     34    define( 'HUMCOMMERCE_HOST', 'https://app.humcommerce.com' );
     35}
     36
    3337
    3438
    3539require plugin_dir_path( __FILE__ ) . 'includes/class-humcommerce.php';
     40
     41/**
     42 * Unschedule cron hook
     43 * @since 3.0.0
     44 */
     45function uninstall_magic_plugin() {
     46    $timestamp = wp_next_scheduled( 'wp_magic_fetch_cron_hook' );
     47    wp_unschedule_event( $timestamp, 'wp_magic_fetch_cron_hook' );
     48}
     49
     50register_deactivation_hook( __FILE__, 'uninstall_magic_plugin' );
     51
     52/**
     53 * Install tables and do version upgrade
     54 * @since 3.0.0
     55 */
     56function activate_humcommerce_magic() {
     57    $curr_version = get_option( 'humcommerce_magic_version', true );
     58    if ( false === $curr_version || version_compare( $curr_version, '3.0.0', '<' ) ) {
     59        Humcommerce::install_tables();
     60
     61        $options = get_option( 'humcommerce_options' );
     62        if ( is_array( $options ) && isset( $options['si'] ) ) {
     63            update_option( 'humc_site', $options['si'], false );
     64            delete_option( 'humcommerce_options' );
     65        }
     66    }
     67    update_option( 'humcommerce_magic_version', HUMCOMMERCE_VERSION, false );
     68}
     69
     70add_action( 'admin_init', 'activate_humcommerce_magic' );
     71
    3672
    3773/**
  • humcommerce/tags/3.0.0/includes/class-humcommerce.php

    r2272741 r2360765  
    2626 */
    2727class Humcommerce {
     28
     29    const REC_TABLE = 'magic_recordings';
    2830
    2931    /**
     
    7981
    8082    /**
     83     * Install recordings table
     84     */
     85    public static function install_tables() {
     86        global $wpdb;
     87        $table_name      = $wpdb->prefix . self::REC_TABLE;
     88        $charset_collate = $wpdb->get_charset_collate();
     89
     90        $ddl = "CREATE TABLE IF NOT EXISTS {$table_name} (
     91                    id INT(11) unsigned NOT NULL AUTO_INCREMENT,
     92                    idloghsr INT(11) unsigned NOT NULL,
     93                    idsitehsr INT(11) unsigned NOT NULL,
     94                    cart_value FLOAT (8,2) default 0.00,
     95                    location_country varchar (120),
     96                    is_abandon_cart tinyint(1) NOT NULL default 0,
     97                    recording_url varchar (255),
     98                    recording_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
     99                    dead_clicks TEXT NOT NULL,
     100                    errors TEXT NOT NULL,
     101                    PRIMARY KEY (`id`),
     102                    KEY `magic_recording_date_idx` (`recording_date`)
     103                ) $charset_collate";
     104        $wpdb->query( $ddl );
     105    }
     106
     107    /**
    81108     * Load the required dependencies for this plugin.
    82109     *
     
    98125        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-humcommerce-loader.php';
    99126
     127        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-magic-api.php';
     128
    100129        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-humcommerce-admin.php';
    101130
    102131        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-humcommerce-public.php';
    103 
    104         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-humcommerce-settings.php';
    105132
    106133        $this->loader = new Humcommerce_Loader();
     
    120147        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
    121148        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
    122         $this->loader->add_action( 'admin_notices', $plugin_admin, 'humcommerce_add_settings_errors' );
    123149        $this->loader->add_action( 'activated_plugin', $plugin_admin, 'humcommerce_activation_redirect', 10, 1 );
    124150    }
     
    132158     */
    133159    private function define_public_hooks() {
    134         $plugin_public = new Humcommerce_Public( $this->get_humcommerce(), $this->get_version() );
     160        $plugin_public = new Humcommerce_Public();
    135161
    136162        $this->loader->add_action( 'wp_head', $plugin_public, 'add_humcommerce_script_to_wp_head' );
    137     }
     163
     164        add_action( 'rest_api_init', array( $this, 'register_api_endpoints' ) );
     165
     166    }
     167
     168    /**
     169     * Register rest endpoints
     170     */
     171    public function register_api_endpoints() {
     172
     173        register_rest_route(
     174            'humcommerce/v1',
     175            'verify-domain',
     176            array(
     177                'method'   => 'GET',
     178                'callback' => array( $this, 'verify_domain' ),
     179            )
     180        );
     181    }
     182
     183    /**
     184     * Verify domain
     185     *
     186     * @param WP_REST_Request $request Rest request object.
     187     */
     188    public function verify_domain( WP_REST_Request $request ) {
     189
     190        if ( get_transient( '__humc_auth_nonce' ) !== $request->get_param( '_wp_nonce' ) ) {
     191            // nonce sent from app server does not match send 403.
     192            wp_die( 'Unauthorized request', 403 );
     193        }
     194
     195        wp_die( 'ok', 200 );
     196    }
     197
     198
    138199
    139200    /**
  • humcommerce/tags/3.0.0/public/class-humcommerce-public.php

    r2272741 r2360765  
    1919class Humcommerce_Public {
    2020
    21     /**
    22      * The ID of this plugin.
    23      *
    24      * @since    1.0.0
    25      * @access   private
    26      * @var      string    $humcommerce_custom    The ID of this plugin.
    27      */
    28     private $humcommerce;
    2921
    30     /**
    31      * The version of this plugin.
    32      *
    33      * @since    1.0.0
    34      * @access   private
    35      * @var      string    $version    The current version of this plugin.
    36      */
    37     private $version;
    38 
    39     /**
    40      * Tracker object.
    41      *
    42      * @since 2.1.4
    43      * @access private
    44      * @var object $tracker Tracker object.
    45      */
    46     private $tracker;
    47 
    48     /**
    49      * Initialize the class and set its properties.
    50      *
    51      * @since    1.0.0
    52      * @param      string $humcommerce       The name of the plugin.
    53      * @param      string $version    The version of this plugin.
    54      */
    55     public function __construct( $humcommerce, $version ) {
    56 
    57         $this->humcommerce_custom = $humcommerce;
    58         $this->version            = $version;
    59 
    60     }
    61 
    62     /**
    63      * Register the stylesheets for the public-facing side of the site.
    64      *
    65      * @since    1.0.0
    66      */
    67     public function enqueue_styles() {
    68 
    69         /**
    70          * This function is provided for demonstration purposes only.
    71          *
    72          * An instance of this class should be passed to the run() function
    73          * defined in Humcommerce_Custom_Loader as all of the hooks are defined
    74          * in that particular class.
    75          *
    76          * The Humcommerce_Custom_Loader will then create the relationship
    77          * between the defined hooks and the functions defined in this
    78          * class.
    79          */
    80 
    81         wp_enqueue_style( $this->humcommerce_custom, plugin_dir_url( __FILE__ ) . 'css/humcommerce-custom-public.css', array(), $this->version, 'all' );
    82 
    83     }
    84 
    85     /**
    86      * Register the JavaScript for the public-facing side of the site.
    87      *
    88      * @since    1.0.0
    89      */
    90     public function enqueue_scripts() {
    91 
    92         /**
    93          * This function is provided for demonstration purposes only.
    94          *
    95          * An instance of this class should be passed to the run() function
    96          * defined in Humcommerce_Custom_Loader as all of the hooks are defined
    97          * in that particular class.
    98          *
    99          * The Humcommerce_Custom_Loader will then create the relationship
    100          * between the defined hooks and the functions defined in this
    101          * class.
    102          */
    103 
    104         wp_enqueue_script( $this->humcommerce_custom, plugin_dir_url( __FILE__ ) . 'js/humcommerce-custom-public.js', array( 'jquery' ), $this->version, false );
    105 
    106     }
    10722
    10823    /**
     
    11227     */
    11328    public function add_humcommerce_script_to_wp_head() {
    114         $options = get_option( 'humcommerce_options' );
     29        $site_id = get_option( 'humc_site' );
    11530
    116         $set_ecommerce_view = null;
    117         $set_user_id        = null;
    118         include_once ABSPATH . 'wp-admin/includes/plugin.php';
     31        if ( ! $site_id ) {
     32            return;
     33        }
    11934
    120        if ( is_array( $options ) ) {
    121             if ( array_key_exists( 'host', $options ) && ! empty( $options['host'] ) ) {
    122                 $host_url = $options['host'];
    123            } else {
    124                 $host_url = HUMCOMMERCE_HOST;
    125             }
     35        $host_url = rtrim( HUMCOMMERCE_HOST, '/' );
    12636
    127             if ( is_user_logged_in() && array_key_exists( 'set-user-id', $options ) ) {
    128                 $user        = get_user_by( 'ID', get_current_user_id() );
    129                 $set_user_id = "_ha.push(['setUserId', '" . $user->user_email . "']);";
    130             }
    131         }
    132         if ( isset( $options['si'] ) && ! empty( $options['si'] ) ) {
    133             echo ' <!-- HumCommerce Tracking code -->
    134                 <script type="text/javascript">
    135                   var _ha = _ha || [];
    136                   ' . $set_user_id . '
    137                   _ha.push(["trackPageView"]);
    138                   _ha.push(["enableLinkTracking"]);
    139                   (function() {
    140                     var u="https://' . esc_js( $host_url ) . '/";
    141                      _ha.push([\'setTrackerUrl\', u+\'humdash.php\']);
    142                     _ha.push(["setSiteId", "' . esc_js( $options['si'] ) . '"]);
    143                     var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0];
    144                     g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"sites/h-' . esc_js( $options['si'] ) . '.js"; s.parentNode.insertBefore(g,s);
    145                   })();
    146                 </script>
    147            <!-- End of HumCommerce Code -->';// phpcs:ignore
     37        ?>
     38            <!-- HumCommerce Tracking code -->
     39            <script type="text/javascript">
     40                var _ha = _ha || [];
    14841
    149         }
     42                _ha.push(["trackPageView"]);
     43                _ha.push(["enableLinkTracking"]);
     44                (function () {
     45                    var u = '<?php echo esc_url( $host_url ); ?>';
     46                    _ha.push(['setTrackerUrl', u + '/humdash.php']);
     47                    _ha.push(['setSiteId', '<?php echo esc_html( $site_id ); ?>']);
     48                    var d = document, g = d.createElement("script"), s = d.getElementsByTagName("script")[0];
     49                    g.type = "text/javascript";
     50                    g.async = true;
     51                    g.defer = true;
     52                    g.src = u + "/sites/h-<?php echo esc_html( $site_id ); ?>.js";
     53                    s.parentNode.insertBefore(g, s);
     54                })();
     55            </script>
     56            <!-- End of HumCommerce Code -->
     57            <?php
     58
    15059    }
    15160
  • humcommerce/trunk/README.txt

    r2272741 r2360765  
    1 === Wordpress Analytics, Heatmaps & Session Recordings Plugin by HumCommerce ===
     1=== User Session Recording WooCommerce Plugin : HumCommerce Magic ===
    22Contributors: humcommerce
    33Tags: Analytics, Wordpress analytics, Conversion optimization, User Behavior analytics, Heatmaps, Session recordings, Visitor behavior analytics, E-commerce analytics, E-commerce tracking, Surveys, Humcommerce, google analytics, google analytics dashboard, google analytics widget, WooCommerce stats, analytics dashboard, universal google analytics, statistics, tracking, stats, google, google analytics by yoast, ga
    44Requires at least: 3.0.1
    5 Tested up to: 5.3.1
    6 Requires PHP: 5.2.4
    7 Stable tag: 2.1.15
     5Tested up to: 5.5.0
     6Requires PHP: 5.6.0
     7Stable tag: 3.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Wordpress Analytics & Conversion Optimization plugin for WooCommerce Website. Track & analyse heatmaps, sessions recordings and more.
     11Seeing where people click and what error messages annoyed them is now possible with HumCommerce Magic.
    1212
    1313== Description ==
    1414
    15 = Wordpress Analytics & Conversion Optimization plugin =
     15= WooCommerce User Behaviour Analysis & Conversion Optimization plugin =
    1616
    17 Wordpress store owners find it challenging to analyze the traffic sources, customer journey, where visitors are spending time. [HumCommerce](https://www.humcommerce.com/features/?utm_source=wp&utm_medium=link_click_1&utm_campaign=humcommerce) gives you these deep insights that will help them to convert visitors to buyers.
     17Seeing where people click and what error messages annoyed them is now possible with HumCommerce Magic. See customers who can't complete their purchase with session replays and figure out exactly why that sale didn’t happen.
    1818
    19 HumCommerce is a WordPress Plugin for Analytics and Conversion Optimization. It makes it easy to analyze the traffic sources and boost your conversions. It enables you to know precisely what actions visitors take on the website.
     19 [HumCommerce Magic](https://www.humcommerce.com/wordpress-analytics-plugin/?utm_source=wporg&utm_medium=link&utm_campaign=plugin&utm_content=readme) has advanced intelligence to identify and show you, where & why you lost a customer?
    2020
    21 This official HumCommerce plugin enables seamless integration between your Wordpress website and the HumCommerce CRO tool. Once integrated, the HumCommerce plugin will start tracking and monitoring data of your Wordpress store.
     21* Recordings feature gives you the ability to virtually see the users screen, to understand how people use your site.
     22* Identification feature can identify and report the users who saw error messages on your site.
     23* Segmentation feature records the users who are trying to purchase but couldn't complete the purchase.
     24* False Clicks feature finds and records the users, who are clicking on things that aren't even links.
    2225
    23 With this extension, you can have the dashboard view of your e-commerce data like Sales order, Revenue, best-selling products, and much more.
     26HumCommerce Magic makes data-driven decisions very easy. It's the only WooCommerce plugin that shows you exactly how much revenue was lost and why? It helps you decide which site changes matter the most.
    2427
    25 HumCommerce comes with a simple Dashboard for WordPress that gives you actionable insights, visitor analytics data, and visitor behavior report ( heatmaps, and session recordings.)
     28Unlike any other plugins, there is no code or signup process, you just have to click on a button to get it working.
    2629
    27 You can create customized reports that will show you only the data that matters to your business, so you can see accurately what’s working and what’s not!
     30The best part is that all the reports are right within your WordPress Dashboard. You get daily alerts of precise and no-fluff reports with insights that matter.
    2831
    29 HumCommerce connects with your Wordpress site in simple steps with this plugin. Once this plugin is installed, it gives you actionable insights to start making data-driven decisions for your Wordpress site.
     32HumCommerce Magic comes with a simple dashboard for WooCommerce. You can see a summary of customer experience, how much revenue was lost and the reason why you lost a potential customer?. Session recording playback feature makes it possible to view these recordings and replay what the customer experienced.
    3033
    31 ***HumCommerce Plugin***
     34Once this plugin is installed, and activated, it monitors your website every day. After 24 hrs, it automatically generates the magic report. You get a daily summary email about the customer experience on your WooCommerce store. You can also login to the dashboard to see experience details of each visitor for the day.
    3235
    33 *This HumCommerce WordPress plugin comes with the Visitor Behavior Analytics features like Session Recordings, Heatmaps, including events tracking, custom dimensions tracking, and more.[Click here to Sign Up for FREE!](https://www.humcommerce.com/free-signup?utm_source=wpress&utm_medium=link_click&utm_campaign=freetrial)*
     36In a nutshell, if you are serious about improving your customer experience: HumCommerce Magic is a must have WooCommerce plugin which is POWERFUL and extremely USEFUL.
    3437
    35 Here’s why e-commerce business owners, digital marketers, digital marketing agencies, SEO agencies love HumCommerce. And you will too!
     38***HumCommerce Magic Dashboard + Customer Experience Reports ***
    3639
    37 [youtube https://www.youtube.com/watch?v=uIGVa_sxY5c]
     40*We believe that HumCommerce Magic plugin should save your time in analysing visitor analytics. It should also come up with reports which are actionable. That's why HumCommerce Magic comes up with intelligence to automatically filter through your visitors to find out the reasons and session recordings that matter!
    3841
    39 = Key features of HumCommerce: =
     42* Abandoned Cart Report helps you know why visitors didn't buy. Were there any website errors that stopped them from buying? It gives you insights like which country, cart value and a recording which you can play within your WordPress Dashboard to see what the customer saw.
    4043
    41 - **Visitor Session Recordings** - See where your visitors get confused with analyzing what visitors are doing on your website. Find areas of improvement, and opportunities to modify the contents, workflow on the site that can optimize for conversions.
     44* False Click Report shows you are the areas on your site where customers are clicking where there are no links. You can relook at your design to help your customers understand your site better.
    4245
    43 - **Heatmaps** - It allows you to see what visitors are doing based on their mouse clicks and scrolling behavior.
    44 
    45 - **Conversion Funnels** - Identify issues in your crucial website sales funnels to optimize visitor journey.
    46 
    47 - **Form Analytics** - Form Analytics gives you insights and enables you to track how your website visitors interact with the forms on your website. Test and boost the form conversion by modifying the form fields based on the insights.
    48 
    49 - **Cart Abandonment** - Analyze why visitors are dropping off the website without completing the checkout. You can work towards reducing cart abandonment, which will increase the conversion rate.
    5046
    5147***See what Tod (E-Commerce business owner) is saying about HumCommerce:***
     
    5450>- TOD HAMM
    5551
    56 = WORDPRESS ANALYTICS DASHBOARD WITH REAL-TIME VISITOR DATA =
    57 
    58 Our main objective at HumCommerce is to help you make more revenue with user behavior analytics and actionable insights.
    59 
    60 We are committed to your successful ecommerce journey.
    61 
    62 Most online business owners find it challenging to analyze complex visitor behavior data.
    63 
    64 With HumCommerce, it’s no longer a challenge.
    65 
    66 With a built-in Wordpress Analytics Dashboard for your Wordpress site, you can get useful, actionable insights like where visitors are spending time, the reason for abandonment carts, etc. right inside your HumCommerce dashboard.
    67 
    68 Use the HumCommerce plugin for your WordPress site to gather data and help you improve conversions.
    69 
    70 We help you with meaningful insights to make your ecommerce journey a success!
    71 
    72 - **CRO Analysis** HumCommerce allows you to analyze the visitor behavior to enable you with insights accurately. It helps you optimize the steps of your user journey to increase your online conversion.
    73 
    74 - **Session Recordings Analysis** Analysis will show visitor’s recordings track clicks, mouse movements, scrolls, screen resize, and page changes. It will help you understand how they react to the various elements on your website and find ways to improve website user experience (UX).
    75 
    76 - **Visitors Profile Analysis** helps you know your website visitors better. It shows you detailed insights of each visitor like country, which pages of your site they like the most, date/time of their visits, and much more. You get every action a user has taken on the website. It helps you to see the user lifetime journey on the website
    7752
    7853***See what Dave (E-Commerce business owner) is saying about HumCommerce:***
    7954
    80 >Nothing short of being in awe as I realized the power of having accurate data of what people are doing on your site. From heat maps to A/B testing, tracking forms, and pages or products, this tool has it all…This is a must-have tool.
     55>Nothing short of being in awe as I realized the power of having accurate data of what people are doing on your site tracking forms, and pages or products, this tool has it all…This is a must-have tool.
    8156>- DAVE SWEENY
    8257
    83 We strongly recommend all WordPress websites owners users to use this simple yet powerful plugin for their e-commerce business.
    84 
    85 Some Popular Blogs / Tutorials
    86 
    87 - [How to Record Website Traffic](https://www.humcommerce.com/blog/analyse-website-session-recordings/?utm_source=wp&utm_medium=blog1&utm_campaign=HumC)
    88 - [How to create Heatmaps](https://www.humcommerce.com/blog/beginners-guide-to-heatmaps/?utm_source=wp&utm_medium=blog2&utm_campaign=HumC)
    89 - [How to create conversion funnels](https://www.humcommerce.com/blog/how-to-build-an-e-commerce-funnel-that-drives-sales/?utm_source=wp&utm_medium=blog3&utm_campaign=HumC)
    90 
    91 This plugin provides a simple installation of HumCommerce on your WordPress website by providing you instant access to all HumCommerce features.
    9258
    9359== Installation ==
     
    100662. Activate the plugin through the 'Plugins' menu in WordPress
    10167
    102 = Frequently Asked Questions =
    10368
    104 = What are the HumCommerce Terms of Use? =
    105 
    106 The full [terms of use are available here](https://www.humcommerce.com/terms-of-use/) along with other legal and privacy documentation. If you have further questions do not hesitate to reach out to our [support](support@humcommerce.com).
    107 
    108 = What is Site ID? =
    109 
    110 Login to your HumCommerce Account. Go to My Account. Click on Launch Dashboard button.
    111 The site id number is listed under Settings/Website/Manage in your HumDash administration panel.
    112 
    113 = How do I view my stats? =
    114 
    115 Once you've installed HumCommerce, you can launch our tool from the "Launch Dashboard" button on My Account page.
    11669
    11770== Screenshots ==
    11871
    119 1. HumCommerce Heatmaps
    120 2. HumCommerce Session Recordings
    121 3. HumCommerce Funnels
    122 4. HumCommerce Settings
     721. HumCommerce Getting Started
     732. HumCommerce Recordings Table
     743. Abandoned Cart Recording
     754. HumCommerce Recordings
    12376
    12477== Frequently Asked Questions ==
    12578
    126 = Do I need a HumCommerce account to use this plugin? =
     79= Do I need to sign up or pay for this plugin? =
    12780
    128 Yes. You can sign up for a [free HumCommerce plan](https://www.humcommerce.com/lifetime-free/) that provides access to all our features including heatmaps, session recordings/replays, and deep e-commerce integration tools and more.
     81No, there is no signup or payment to be done to use this plugin. It’s a simple setup, only activate and click the button to allow the plugin to analyze your site visitors.
    12982
    130 = Do we need a developer to install HumCommerce Plugin? =
     83= Is HumCommerce Magic GDPR Compliant? =
    13184
    132 No. You don’t need a developer. HumCommerce plugin allows you to enable all advanced E-Commerce analytics tracking features with just a few clicks.
     85HumCommerce Magic takes user privacy very seriously. It doesn't record any user identifiable information. By default it suppresses all text-based on-page numbers and email addresses, input fields and some text in session recordings.
    13386
    134 = Is HumCommerce plugin different from Google Analytics plugin ? =
     87= Can I use HumCommerce Magic with other analytics plugins like Google Analytics Plugin? =
     88Sure. You can use any other analytics tools like Google Analytics plugin on your WordPress site.
    13589
    136 Yes. With HumCommerce plugin you get access to our additional features like heatmaps, visitor recordings, and surveys. [Click here](https://www.humcommerce.com/features) to checkout all HumCommerce features
    137 
    138 = Will HumCommerce slow down the performance of my website? =
    139 
    140 No. It will not affect your website speed or performance in any way.Analytics will get loaded asynchronously which means it will not slow down your website speed or performance.
     90= Does HumCommerce Magic work on WordPress multisite? =
     91No. Currently Magic is optimized to work only on standard WooCommerce websites, not on multisite instances.
    14192
    14293
    14394== Changelog ==
     95
     96Ver 3.0.0 (14 Aug 2020)
     97* Feature : Be able to watch recommended session recordings from wordpress admin itself
    14498
    14599Ver 2.1.15 (1 Apr 2020)
  • humcommerce/trunk/admin/class-humcommerce-admin.php

    r2217514 r2360765  
    5353        $this->humcommerce = $humcommerce;
    5454        $this->version     = $version;
    55 
     55        $this->maybe_create_scheduled_event();
     56
     57        $this->api = \Magic_Api::get_instance();
     58
     59        add_action( 'admin_enqueue_scripts', array( $this, 'load_recording_css' ) );
     60        add_action( 'admin_init', array( $this, 'register_humc_settings' ) );
     61        add_action( 'wp_magic_fetch_cron_hook', array( $this, 'get_recordings_cron_exec' ) );
     62        add_action( 'admin_menu', array( $this, 'add_report_page' ) );
     63        add_action( 'admin_post_humc_create_magic_account', array( $this, 'create_humcommerce_account' ) );
     64        add_action( 'admin_post_report_magic_error', array( $this, 'report_error' ) );
     65    }
     66
     67    /**
     68     * Report error back to humcommerce support
     69     */
     70    public function report_error() {
     71
     72        if ( ! check_admin_referer( 'humc_report_error' ) ) {
     73            wp_die( 'Unauthorized request', 401 );
     74        }
     75
     76        $error = isset( $_POST['humc_error'] ) ? sanitize_text_field( wp_unslash( $_POST['humc_error'] ) ) : false;
     77
     78        if ( false === $error ) {
     79            $url = admin_url( 'admin.php?page=recommended-recordings' );
     80            wp_safe_redirect( $url );
     81            exit();
     82        }
     83
     84        $site = home_url();
     85        $user = wp_get_current_user();
     86
     87        $subject = sprintf( 'Error while setting up magic on %s', $site );
     88        $body    = sprintf( '%s reported following error : %s', $user->user_email, $error );
     89
     90        wp_mail( 'support@humcommerce.com', $subject, $body );
     91
     92        $url = admin_url( 'admin.php?page=recommended-recordings' );
     93        wp_safe_redirect( $url );
     94        exit();
     95    }
     96
     97    /**
     98     * Register site and token settings.
     99     */
     100    public function register_humc_settings() {
     101        register_setting( 'humc_magic', 'humc_site' );
     102        register_setting( 'humc_magic', 'humc_token' );
     103    }
     104
     105    /**
     106     * Add menu
     107     */
     108    public function add_report_page() {
     109        add_menu_page(
     110            'Must watch Customer recordings',
     111            'HumCommerce',
     112            'administrator',
     113            'recommended-recordings',
     114            array( $this, 'create_report_page' ),
     115            esc_url( plugins_url( 'images/icon.png', __FILE__ ) )
     116        );
     117
     118        add_submenu_page(
     119            'recommended-recordings',
     120            'Must watch Customer recordings',
     121            'Recordings',
     122            'administrator',
     123            'recommended-recordings',
     124            array( $this, 'create_report_page' ),
     125            10
     126        );
     127
     128        add_submenu_page(
     129            'recommended-recordings',
     130            'HumCommerce Settings',
     131            'Settings',
     132            'administrator',
     133            'humcommerce-settings',
     134            array( $this, 'create_settings_page' ),
     135            20
     136        );
     137    }
     138
     139    /**
     140     * Options page callback.
     141     *
     142     * @since 1.0.0
     143     */
     144    public function create_settings_page() {
     145        // Set class property.
     146        $site  = get_option( 'humc_site' );
     147        $token = get_option( 'humc_token' );
     148
     149        $email        = get_option( 'admin_email' );
     150        $logo_url     = plugins_url( '/images/logo.png', __FILE__ );
     151        $setting_hook = __FILE__;
     152        include_once plugin_dir_path( __FILE__ ) . 'views/settings-page.php';
     153    }
     154
     155    /**
     156     * Load css
     157     */
     158    public function load_recording_css() {
     159        wp_enqueue_style( $this->humcommerce, plugin_dir_url( __FILE__ ) . 'css/recording-table.css', array(), $this->version, 'all' );
     160        wp_enqueue_style( $this->humcommerce . '-css', plugin_dir_url( __FILE__ ) . 'css/humcommerce-admin.css', array(), $this->version, 'all' );
     161    }
     162
     163    /**
     164     * Render recordings list or getting started page
     165     */
     166    public function create_report_page() {
     167
     168        if ( $this->is_magic_setup() ) {
     169            $this->render_report();
     170            return;
     171        }
     172        $this->render_getting_started();
     173
     174    }
     175
     176    /**
     177     * Check if magic is setup
     178     *
     179     * @return bool
     180     */
     181    private function is_magic_setup() {
     182        $site  = get_option( 'humc_site' );
     183        $token = get_option( 'humc_token' );
     184
     185        if ( $site && $token ) {
     186            return true;
     187        }
     188        return false;
     189
     190    }
     191
     192    /**
     193     * Render magic table
     194     */
     195    private function render_report() {
     196        require_once plugin_dir_path( __FILE__ ) . '/class-magic-report.php';
     197
     198        $table = new Magic_Report();
     199        $table->prepare_items();
     200        ?>
     201        <div class="wrap">
     202            <h1>Recommended Recordings</h1>
     203            <?php $table->display(); ?>
     204        </div>
     205
     206        <?php
     207    }
     208
     209    /**
     210     * Render getting started
     211     */
     212    private function render_getting_started() {
     213        require_once plugin_dir_path( __FILE__ ) . '/getting-started.php';
     214    }
     215
     216    /**
     217     * Schedule cron event for fetching recordings
     218     */
     219    public function maybe_create_scheduled_event() {
     220        $tommorrow_nine = strtotime( gmdate( 'Y-m-d' ) ) + ( 12 * HOUR_IN_SECONDS );
     221        if ( ! wp_next_scheduled( 'wp_magic_fetch_cron_hook' ) ) {
     222            wp_schedule_event( $tommorrow_nine, 'daily', 'wp_magic_fetch_cron_hook' );
     223        }
     224    }
     225
     226    /**
     227     * Fetch recordings
     228     */
     229    public function get_recordings_cron_exec() {
     230
     231        $token  = get_option( 'humc_token' );
     232        $idsite = get_option( 'humc_site' );
     233        $day    = gmdate( 'Y-m-d', strtotime( 'yesterday' ) );
     234
     235        $data = $this->api->get_recordings( $idsite, $token, $day );
     236        if ( $data['error'] ) {
     237            error_log( $data['message'] ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     238            return;
     239        }
     240
     241        foreach ( $data['reportChunks'] as $report ) {
     242            $this->insert_recordings( $report );
     243        }
     244
     245        if ( count( $data['reportChunks'] ) > 1 ) {
     246            $summary = $this->get_summary( $data['reportChunks'] );
     247            $this->notify_via_email( $summary );
     248        }
     249
     250    }
     251
     252    /** Generate summary to send in mail
     253     *
     254     * @param array $data recording array.
     255     * @return array
     256     */
     257    private function get_summary( $data ) {
     258        $abandon_carts = 0;
     259        $no_errors     = 0;
     260        $no_clicks     = 0;
     261        $revenue_lost  = 0;
     262
     263        foreach ( $data as $rec ) {
     264
     265            if ( $rec['isAbandonCart'] ) {
     266                $abandon_carts++;
     267                $revenue_lost += $rec['cartValue'];
     268            }
     269
     270            if ( count( $rec['deadClicks'] ) ) {
     271                $no_clicks++;
     272            }
     273
     274            if ( count( $rec['errors'] ) ) {
     275                $no_errors++;
     276            }
     277        }
     278        if ( function_exists( 'wc_price' ) ) {
     279            $revenue_lost = wc_price( $revenue_lost );
     280        }
     281
     282        return array(
     283            sprintf( 'Estimated revenue lost %s from %s abandoned cart', $revenue_lost, $abandon_carts ),
     284            sprintf( '%s users saw some kind of errors. (More about this in your admin area)', $no_errors ),
     285            sprintf( '%s user clicked around expecting something would happen but nothing happened', $no_clicks ),
     286        );
     287
     288    }
     289
     290    /**
     291     * Notify admin via email about new recordings
     292     *
     293     * @param array $summary array of messages to send in email.
     294     */
     295    private function notify_via_email( $summary ) {
     296        $email     = get_option( 'admin_email' );
     297        $blog_name = get_option( 'blogname' );
     298
     299        ob_start();
     300        include_once plugin_dir_path( __FILe__ ) . '/views/recording-email.php';
     301        $content = ob_get_contents();
     302        ob_end_clean();
     303
     304        /* translators: New email address notification email subject. %s: Site title. */
     305        wp_mail( $email, sprintf( __( 'Recommended session recordings for [%s]' ), $blog_name ), $content, array( 'Content-Type:text/html' ) );
     306    }
     307
     308    /**
     309     * Insert recording in database table
     310     *
     311     * @param array $row recording row.
     312     */
     313    private function insert_recordings( $row ) {
     314        global $wpdb;
     315
     316        $clicks  = wp_json_encode( $row['deadClicks'] );
     317        $errors  = wp_json_encode( $row['errors'] );
     318        $abandon = (int) $row['isAbandonCart'];
     319
     320        $rec_date   = strtotime( $row['recording_date'] );
     321        $rec_date   = gmdate( 'Y-m-d H:i:s', $rec_date );
     322        $table_name = $wpdb->prefix . \Humcommerce::REC_TABLE;
     323
     324        $bind = array(
     325            $row['idloghsr'],
     326            $row['idsitehsr'],
     327            $row['cartValue'],
     328            $row['location_country'],
     329            $abandon,
     330            $row['sessionReplayUrl'],
     331            $rec_date,
     332            $clicks,
     333            $errors,
     334        );
     335
     336        $sql = "INSERT INTO `$table_name`
     337     (`idloghsr`,`idsitehsr`,`cart_value`,`location_country`,`is_abandon_cart`,`recording_url`,`recording_date`,`dead_clicks`,`errors`)
     338      VALUES (%d,%d,%f,%s,%d,'%s','%s','%s','%s')";
     339
     340        $wpdb->query( $wpdb->prepare( $sql, $bind ) ); // phpcs:ignore WordPress.DB
    56341    }
    57342
     
    74359    public function enqueue_scripts() {
    75360
    76         wp_enqueue_script( $this->humcommerce, plugin_dir_url( __FILE__ ) . 'js/humcommerce-admin.js', array(), $this->version, false );
    77         $options = get_option( 'humcommerce_options' );
    78         if ( is_array( $options ) ) {
    79             if ( array_key_exists( 'host', $options ) && ! empty( $options['host'] ) ) {
    80                 $host_url = $options['host'];
    81             } else {
    82                 $host_url = HUMCOMMERCE_HOST;
    83             }
    84         } else {
    85             $host_url = HUMCOMMERCE_HOST;
    86         }
    87         wp_localize_script(
    88             $this->humcommerce,
    89             'humcommerce_script',
    90             array(
    91                 'ajaxurl'         => admin_url( 'admin-ajax.php' ),
    92                 'humcommerce_url' => $host_url,
    93             )
    94         );
    95 
    96     }
    97 
    98     /**
    99      * Shows the notice after user saves the HumCommerce Settings.
    100      *
    101      * @since 2.1.12
    102      */
    103     public function humcommerce_add_settings_errors() {
    104 
    105         settings_errors();
    106 
    107     }
     361    }
     362
     363    /**
     364     * We are not going to use WordPress nonce because it is user dependent.
     365     * The nonce created by admin session won't match with nonce created publicly
     366     */
     367    public function create_humcommerce_account() {
     368
     369        $result = isset( $_POST['_wp_nonce'] ) ? wp_verify_nonce( sanitize_key( $_POST['_wp_nonce'] ), 'humc_account_create' ) : false;
     370
     371        if ( ! $result ) {
     372            wp_die( 'Unauthorized request', 401 );
     373        }
     374
     375        // This nonce will expire in 120 seconds so the whole request must complete within 120 seconds.
     376        $nonce = substr( wp_hash( time() . '|', 'nonce' ), -12, 10 );
     377        set_transient( '__humc_auth_nonce', $nonce, 120 );
     378
     379        $email     = get_option( 'admin_email' );
     380        $domain    = get_site_url();
     381        $blog_name = get_option( 'blogname' );
     382
     383        $params = array(
     384            'email'    => $email,
     385            'domain'   => $domain,
     386            'blogName' => $blog_name,
     387            'nonce'    => $nonce,
     388        );
     389
     390        $response = $this->api->create_humcommerce_account( $params );
     391
     392        if ( $response['error'] ) {
     393            wp_die( $this->get_error_html( $response['message'] ) ); //phpcs:ignore
     394        }
     395
     396        update_option( 'humc_site', $response['site'], false );
     397        update_option( 'humc_token', $response['token'], false );
     398        $url = admin_url( 'admin.php?page=recommended-recordings' );
     399        wp_safe_redirect( $url );
     400        exit();
     401    }
     402
     403    /**
     404     * Get error html
     405     *
     406     * @param string $message variable is used inside error.php.
     407     */
     408    private function get_error_html( $message ) {
     409        ob_start();
     410        include_once plugin_dir_path( __FILe__ ) . '/views/error.php';
     411        $content = ob_get_contents();
     412        ob_end_clean();
     413        return $content;
     414    }
     415
    108416
    109417    /**
     
    116424    public function humcommerce_activation_redirect( $plugin ) {
    117425        if ( plugin_basename( 'humcommerce/humcommerce.php' ) === $plugin ) {
    118             exit( wp_safe_redirect( get_admin_url( null, 'admin.php?page=humcommerce-settings' ) ) );
     426            wp_safe_redirect( admin_url( 'admin.php?page=recommended-recordings' ) );
     427            exit();
    119428        }
    120429    }
  • humcommerce/trunk/admin/css/humcommerce-admin.css

    r2217514 r2360765  
    1 .wp-admin.jetpack_page_humcommerce-key-config, .wp-admin.settings_page_humcommerce-key-config {
    2     background-color: #f3f6f8;
     1#intro-section,#setup-section,#section-video{
     2    text-align: center;
     3    background-color: #fff;
     4    padding:50px 10px;
    35}
    46
    5 #submitted-on {
    6     position: relative;
     7#setup-button{
     8    display: inline-block;
     9    text-decoration: none;
     10    font-size: 18px;
     11    line-height: 2.15384615;
     12    min-height: 30px;
     13    margin: 10px;
     14    padding: 10px 20px;
     15    cursor: pointer;
     16    border-width: 0px;
     17    -webkit-appearance: none;
     18    white-space: nowrap;
     19    box-sizing: border-box;
     20    background-color: #e53935;
     21    color:#fff;
    722}
    823
    9 #the-comment-list .author .humcommerce-user-comment-count {
    10     display: inline;
     24#section-video {
     25    background-color: #f5f3ff;
    1126}
    1227
    13 #the-comment-list .author a span {
    14     text-decoration: none;
    15     color: #999;
     28#section-video > div {
     29    width:40%;
     30    display: inline-block;
     31    vertical-align: middle;
     32    text-align: center;
     33    background-color: #f5f3ff;
    1634}
    1735
    18 #the-comment-list .author a span.humcommerce-span-link {
    19     text-decoration: inherit;
    20     color: inherit;
     36.humc-text{
     37    font-size:16px;
     38    width:70%;
     39    text-align: center;
     40    margin:auto;
    2141}
    22 
    23 #the-comment-list .humcommerce_remove_url {
    24     margin-left: 3px;
    25     color: #999;
    26     padding: 2px 3px 2px 0;
    27 }
    28 
    29 #the-comment-list .humcommerce_remove_url:hover {
    30     color: #A7301F;
    31     font-weight: bold;
    32     padding: 2px 2px 2px 0;
    33 }
    34 
    35 #dashboard_recent_comments .humcommerce-status {
    36     display: none;
    37 }
    38 
    39 .humcommerce-status {
    40     float: right;
    41 }
    42 
    43 .humcommerce-status a {
    44     color: #AAA;
    45     font-style: italic;
    46 }
    47 
    48 table.comments td.comment p a {
    49     text-decoration: underline;
    50 }
    51 
    52 table.comments td.comment p a:after {
    53     content: attr(href);
    54     color: #aaa;
    55     display: inline-block; /* Show the URL without the link's underline extending under it. */
    56     padding: 0 1ex; /* Because it's inline block, we can't just use spaces in the content: attribute to separate it from the link text. */
    57 }
    58 
    59 .mshot-arrow {
    60     width: 0;
    61     height: 0;
    62     border-top: 10px solid transparent;
    63     border-bottom: 10px solid transparent;
    64     border-right: 10px solid #5C5C5C;
    65     position: absolute;
    66     left: -6px;
    67     top: 91px;
    68 }
    69 
    70 .mshot-container {
    71     background: #5C5C5C;
    72     position: absolute;
    73     top: -94px;
    74     padding: 7px;
    75     width: 450px;
    76     height: 338px;
    77     z-index: 20000;
    78     -moz-border-radius: 6px;
    79     border-radius: 6px;
    80     -webkit-border-radius: 6px;
    81 }
    82 
    83 .humcommerce-mshot {
    84     position: absolute;
    85     z-index: 100;
    86 }
    87 
    88 .humcommerce-mshot .mshot-image {
    89     margin: 0;
    90     height: 338px;
    91     width: 450px;
    92 }
    93 
    94 .checkforspam {
    95     display: inline-block !important;
    96 }
    97 
    98 .checkforspam-progress {
    99     padding-left: 1ex;
    100     display: none;
    101 }
    102 
    103 .checkforspam.button-disabled .checkforspam-progress {
    104     display: inline;
    105 }
    106 
    107 .checkforspam-spinner {
    108     display: inline-block;
    109     margin-top: 7px;
    110 }
    111 
    112 .humcommerce-right {
    113     float: right;
    114 }
    115 
    116 .humcommerce-card .humcommerce-right {
    117     margin: 1em 0;
    118 }
    119 
    120 .humcommerce-alert-text {
    121     color: #dd3d36;
    122     font-weight: bold;
    123     font-size: 120%;
    124     margin-top: .5rem;
    125 }
    126 
    127 .humcommerce-alert {
    128     border: 1px solid #e5e5e5;
    129     padding: 0.4em 1em 1.4em 1em;
    130     border-radius: 3px;
    131     -webkit-border-radius: 3px;
    132     border-width: 1px;
    133     border-style: solid;
    134 }
    135 
    136 .humcommerce-alert h3.humcommerce-key-status {
    137     color: #fff;
    138     margin: 1em 0 0.5em 0;
    139 }
    140 
    141 .humcommerce-alert.humcommerce-critical {
    142     background-color: #993300;
    143 }
    144 
    145 .humcommerce-alert.humcommerce-active {
    146     background-color: #649316;
    147 }
    148 
    149 .humcommerce-alert p.humcommerce-key-status {
    150     font-size: 24px;
    151 }
    152 
    153 .humcommerce-alert p.humcommerce-description {
    154     color: #fff;
    155     font-size: 14px;
    156     margin: 0 0;
    157     font-style: normal;
    158 }
    159 
    160 .humcommerce-alert p.humcommerce-description a,
    161 .humcommerce-alert p.humcommerce-description a,
    162 .humcommerce-alert p.humcommerce-description a,
    163 .humcommerce-alert p.humcommerce-description a {
    164     color: #fff;
    165 }
    166 
    167 .humcommerce-new-snapshot {
    168     margin-top: 1em;
    169     padding: 1em;
    170     text-align: center;
    171     background: #fff;
    172 }
    173 
    174 .humcommerce-new-snapshot h3 {
    175     background: #f5f5f5;
    176     color: #888;
    177     font-size: 11px;
    178     margin: 0;
    179     padding: 3px;
    180 }
    181 
    182 .new-snapspot ul {
    183     font-size: 12px;
    184     width: 100%;
    185 }
    186 
    187 .humcommerce-new-snapshot ul li {
    188     color: #999;
    189     float: left;
    190     font-size: 11px;
    191     padding: 0 20px;
    192     text-transform: uppercase;
    193     width: 33%;
    194     box-sizing: border-box;
    195     -moz-box-sizing: border-box;
    196     -webkit-box-sizing: border-box;
    197     -ms-box-sizing: border-box;
    198 }
    199 
    200 .humcommerce-new-snapshot ul li:first-child,
    201 .humcommerce-new-snapshot ul li:nth-child(2) {
    202     border-right: 1px dotted #ccc;
    203 }
    204 
    205 .humcommerce-new-snapshot ul li span {
    206     color: #52accc;
    207     display: block;
    208     font-size: 32px;
    209     font-weight: lighter;
    210     line-height: 1.5em;
    211 }
    212 
    213 .humcommerce-settings th:first-child {
    214     vertical-align: top;
    215     padding-top: 15px;
    216 }
    217 
    218 .humcommerce-settings th.humcommerce-api-key {
    219     vertical-align: middle;
    220     padding-top: 0;
    221 }
    222 
    223 .humcommerce-settings input[type=text] {
    224     width: 75%;
    225 }
    226 
    227 .humcommerce-settings span.humcommerce-note {
    228     float: left;
    229     padding-left: 23px;
    230     font-size: 75%;
    231     margin-top: -10px;
    232 }
    233 
    234 /**
    235  * For the activation notice on the plugins page.
    236  */
    237 .humcommerce_activate {
    238     min-width: 825px;
    239     border: 1px solid #4F800D;
    240     padding: 5px;
    241     margin: 15px 0;
    242     background: #83AF24;
    243     background-image: -webkit-gradient(linear, 0% 0, 80% 100%, from(#83AF24), to(#4F800D));
    244     background-image: -moz-linear-gradient(80% 100% 120deg, #4F800D, #83AF24);
    245     -moz-border-radius: 3px;
    246     border-radius: 3px;
    247     -webkit-border-radius: 3px;
    248     position: relative;
    249     overflow: hidden;
    250 }
    251 
    252 .humcommerce_activate .aa_a {
    253     position: absolute;
    254     top: -5px;
    255     right: 10px;
    256     font-size: 140px;
    257     color: #769F33;
    258     font-family: Georgia, "Times New Roman", Times, serif;
    259     z-index: 1;
    260 }
    261 
    262 .humcommerce_activate .aa_button {
    263     font-weight: bold;
    264     border: 1px solid #029DD6;
    265     border-top: 1px solid #06B9FD;
    266     font-size: 15px;
    267     text-align: center;
    268     padding: 9px 0 8px 0;
    269     color: #FFF;
    270     background: #029DD6;
    271     background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1));
    272     background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6);
    273     -moz-border-radius: 2px;
    274     border-radius: 2px;
    275     -webkit-border-radius: 2px;
    276     width: 100%;
    277     cursor: pointer;
    278     margin: 0;
    279 }
    280 
    281 .humcommerce_activate .aa_button:hover {
    282     text-decoration: none !important;
    283     border: 1px solid #029DD6;
    284     border-bottom: 1px solid #00A8EF;
    285     font-size: 15px;
    286     text-align: center;
    287     padding: 9px 0 8px 0;
    288     color: #F0F8FB;
    289     background: #0079B1;
    290     background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#0079B1), to(#0092BF));
    291     background-image: -moz-linear-gradient(0% 100% 90deg, #0092BF, #0079B1);
    292     -moz-border-radius: 2px;
    293     border-radius: 2px;
    294     -webkit-border-radius: 2px;
    295 }
    296 
    297 .humcommerce_activate .aa_button_border {
    298     border: 1px solid #006699;
    299     -moz-border-radius: 2px;
    300     border-radius: 2px;
    301     -webkit-border-radius: 2px;
    302     background: #029DD6;
    303     background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1));
    304     background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6);
    305 }
    306 
    307 .humcommerce_activate .aa_button_container {
    308     display: inline-block;
    309     background: #DEF1B8;
    310     padding: 5px;
    311     -moz-border-radius: 2px;
    312     border-radius: 2px;
    313     -webkit-border-radius: 2px;
    314     width: 266px;
    315 }
    316 
    317 .humcommerce_activate .aa_description {
    318     position: absolute;
    319     top: 22px;
    320     left: 285px;
    321     margin-left: 25px;
    322     color: #E5F2B1;
    323     font-size: 15px;
    324     z-index: 1000;
    325 }
    326 
    327 .humcommerce_activate .aa_description strong {
    328     color: #FFF;
    329     font-weight: normal;
    330 }
    331 
    332 .jetpack_page_humcommerce-key-config #wpcontent, .settings_page_humcommerce-key-config #wpcontent {
    333     padding-left: 0;
    334 }
    335 
    336 .humcommerce-masthead {
    337     background-color: #fff;
    338     text-align: center;
    339     box-shadow: 0 1px 0 rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
    340     max-width: 45rem;
    341     margin: 0 auto;
    342 }
    343 
    344 @media (max-width: 45rem) {
    345     .humcommerce-masthead {
    346         padding: 0 1.25rem
    347     }
    348 }
    349 
    350 .humcommerce-masthead__inside-container {
    351     padding: .375rem 0;
    352     margin: 0 auto;
    353     width: 100%;
    354     max-width: 45rem;
    355     text-align: left;
    356 }
    357 
    358 .humcommerce-masthead__logo-container {
    359     padding: 0.3125rem 0 0;
    360 }
    361 
    362 .humcommerce-masthead__logo {
    363     width: 8.375rem;
    364     height: 2.8125rem;
    365 }
    366 
    367 .humcommerce-masthead__logo-link {
    368     display: inline-block;
    369     outline: none;
    370     vertical-align: middle
    371 }
    372 
    373 .humcommerce-masthead__logo-link:focus {
    374     line-height: 0;
    375     box-shadow: 0 0 0 2px #78dcfa
    376 }
    377 
    378 .humcommerce-masthead__logo-link + code {
    379     margin: 0 10px;
    380     padding: 5px 9px;
    381     border-radius: 2px;
    382     background: #e6ecf1;
    383     color: #647a88
    384 }
    385 
    386 .humcommerce-masthead__links {
    387     display: -ms-flexbox;
    388     display: flex;
    389     -ms-flex-flow: row wrap;
    390     flex-flow: row wrap;
    391     -ms-flex: 2 50%;
    392     flex: 2 50%;
    393     -ms-flex-pack: end;
    394     justify-content: flex-end;
    395     margin: 0
    396 }
    397 
    398 @media (max-width: 480px) {
    399     .humcommerce-masthead__links {
    400         padding-right: .625rem
    401     }
    402 }
    403 
    404 .humcommerce-masthead__link-li {
    405     margin: 0;
    406     padding: 0
    407 }
    408 
    409 .humcommerce-masthead__link {
    410     font-style: normal;
    411     color: #0087be;
    412     padding: .625rem;
    413     display: inline-block
    414 }
    415 
    416 .humcommerce-masthead__link:visited {
    417     color: #0087be
    418 }
    419 
    420 .humcommerce-masthead__link:active, .humcommerce-masthead__link:hover {
    421     color: #00aadc
    422 }
    423 
    424 .humcommerce-masthead__link:hover {
    425     text-decoration: underline
    426 }
    427 
    428 .humcommerce-masthead__link .dashicons {
    429     display: none
    430 }
    431 
    432 @media (max-width: 480px) {
    433     .humcommerce-masthead__link:hover, .humcommerce-masthead__link:active {
    434         text-decoration: none
    435     }
    436 
    437     .humcommerce-masthead__link .dashicons {
    438         display: block;
    439         font-size: 1.75rem
    440     }
    441 
    442     .humcommerce-masthead__link span + span {
    443         display: none
    444     }
    445 }
    446 
    447 .humcommerce-masthead__link-li:last-of-type .humcommerce-masthead__link {
    448     padding-right: 0
    449 }
    450 
    451 .humcommerce-lower {
    452     margin: 0 auto;
    453     text-align: left;
    454     max-width: 45rem;
    455     padding: 1.5rem;
    456 }
    457 
    458 .humcommerce-lower .notice {
    459     margin-bottom: 2rem;
    460 }
    461 
    462 .humcommerce-card {
    463     margin-top: 1rem;
    464     margin-bottom: 0;
    465     position: relative;
    466     margin: 0 auto 0.625rem auto;
    467     box-sizing: border-box;
    468     background: white;
    469     box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
    470 }
    471 
    472 .humcommerce-card:after, .humcommerce-card .inside:after, .humcommerce-masthead__logo-container:after {
    473     content: ".";
    474     display: block;
    475     height: 0;
    476     clear: both;
    477     visibility: hidden;
    478 }
    479 
    480 .humcommerce-card .inside {
    481     padding: 1.5rem;
    482     padding-top: 1rem;
    483 }
    484 
    485 .humcommerce-card .humcommerce-card-actions {
    486     margin-top: 1rem;
    487 }
    488 
    489 .jetpack_page_humcommerce-key-config .update-nag, .settings_page_humcommerce-key-config .update-nag {
    490     display: none;
    491 }
    492 
    493 .humcommerce-masthead .humcommerce-right {
    494     line-height: 2.125rem;
    495     font-size: 0.9rem;
    496 }
    497 
    498 .humcommerce-box {
    499     box-sizing: border-box;
    500     background: white;
    501     border: 1px solid rgba(200, 215, 225, 0.5);
    502 }
    503 
    504 .humcommerce-box h2, .humcommerce-box h3 {
    505     padding: 1.5rem 1.5rem .5rem 1.5rem;
    506     margin: 0;
    507 }
    508 
    509 .humcommerce-box p {
    510     padding: 0 1.5rem 1.5rem 1.5rem;
    511     margin: 0;
    512 }
    513 
    514 .humcommerce-jetpack-email {
    515     font-style: oblique;
    516 }
    517 
    518 .humcommerce-jetpack-gravatar {
    519     padding: 0 0 0 1.5rem;
    520     float: left;
    521     margin-right: 1rem;
    522     width: 54px;
    523     height: 54px;
    524 }
    525 
    526 .humcommerce-box p:after {
    527     content: ".";
    528     display: block;
    529     height: 0;
    530     clear: both;
    531     visibility: hidden;
    532 }
    533 
    534 .humcommerce-box .humcommerce-right {
    535     padding-right: 1.5rem;
    536 }
    537 
    538 .humcommerce-boxes .humcommerce-box {
    539     margin-bottom: 0;
    540     padding: 0;
    541     margin-top: -1px;
    542 }
    543 
    544 .humcommerce-boxes .humcommerce-box:last-child {
    545     margin-bottom: 1.5rem;
    546 }
    547 
    548 .humcommerce-boxes .humcommerce-box:first-child {
    549     margin-top: 1.5rem;
    550 }
    551 
    552 .humcommerce-button, .humcommerce-button:hover, .humcommerce-button:visited {
    553     background: white;
    554     border-color: #c8d7e1;
    555     border-style: solid;
    556     border-width: 1px 1px 2px;
    557     color: #2e4453;
    558     cursor: pointer;
    559     display: inline-block;
    560     margin: 0;
    561     outline: 0;
    562     overflow: hidden;
    563     font-size: 14px;
    564     font-weight: 500;
    565     text-overflow: ellipsis;
    566     text-decoration: none;
    567     vertical-align: top;
    568     box-sizing: border-box;
    569     font-size: 14px;
    570     line-height: 21px;
    571     border-radius: 4px;
    572     padding: 7px 14px 9px;
    573     -webkit-appearance: none;
    574     -moz-appearance: none;
    575     appearance: none;
    576 }
    577 
    578 .humcommerce-button:hover {
    579     border-color: #a8bece;
    580 }
    581 
    582 .humcommerce-button:active {
    583     border-width: 2px 1px 1px;
    584 }
    585 
    586 .humcommerce-is-primary, .humcommerce-is-primary:hover, .humcommerce-is-primary:visited {
    587     background: #00aadc;
    588     border-color: #0087be;
    589     color: white;
    590 }
    591 
    592 .humcommerce-is-primary:hover, .humcommerce-is-primary:focus {
    593     border-color: #005082;
    594 }
    595 
    596 .humcommerce-is-primary:hover {
    597     border-color: #005082;
    598 }
    599 
    600 .humcommerce-section-header {
    601     position: relative;
    602     margin: 0 auto 0.625rem auto;
    603     padding: 1rem;
    604     box-sizing: border-box;
    605     box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
    606     background: #ffffff;
    607     width: 100%;
    608     padding-top: 0.6875rem;
    609     padding-bottom: 0.6875rem;
    610     display: flex;
    611 }
    612 
    613 .humcommerce-section-header__label {
    614     display: -ms-flexbox;
    615     display: flex;
    616     -ms-flex-align: center;
    617     align-items: center;
    618     -ms-flex-positive: 1;
    619     flex-grow: 1;
    620     line-height: 1.75rem;
    621     position: relative;
    622     font-size: 0.875rem;
    623     color: #4f748e;
    624 }
    625 
    626 .humcommerce-section-header__actions {
    627     line-height: 1.75rem;
    628 }
    629 
    630 #humcommerce-plugin-container table.form-table {
    631     padding: 0px 0px 0px 0px;
    632     margin: -18px 0px 0px 26px;
    633 }
    634 
    635 #si {
    636     width: 120px;
    637 }
    638 
    639 #humcommerce-plugin-container {
    640     margin: 0 0 0 -20px;
    641 }
  • humcommerce/trunk/humcommerce.php

    r2272741 r2360765  
    1616 * Plugin URI:        https://wordpress.org/plugins/humcommerce/
    1717 * Description:       HumCommerce WordPress plugin to Record, Analyze & Convert your visitors.
    18  * Version:           2.1.15
     18 * Version:           3.0.0
    1919 * Author:            HumCommerce
    2020 * Author URI:        https://www.humcommerce.com
     
    2929}
    3030
    31 define( 'HUMCOMMERCE_VERSION', '2.1.15' );
    32 define( 'HUMCOMMERCE_HOST', 'app.humcommerce.com' );
     31define( 'HUMCOMMERCE_VERSION', '3.0.0' );
     32
     33if ( ! defined( 'HUMCOMMERCE_HOST' ) ) {
     34    define( 'HUMCOMMERCE_HOST', 'https://app.humcommerce.com' );
     35}
     36
    3337
    3438
    3539require plugin_dir_path( __FILE__ ) . 'includes/class-humcommerce.php';
     40
     41/**
     42 * Unschedule cron hook
     43 * @since 3.0.0
     44 */
     45function uninstall_magic_plugin() {
     46    $timestamp = wp_next_scheduled( 'wp_magic_fetch_cron_hook' );
     47    wp_unschedule_event( $timestamp, 'wp_magic_fetch_cron_hook' );
     48}
     49
     50register_deactivation_hook( __FILE__, 'uninstall_magic_plugin' );
     51
     52/**
     53 * Install tables and do version upgrade
     54 * @since 3.0.0
     55 */
     56function activate_humcommerce_magic() {
     57    $curr_version = get_option( 'humcommerce_magic_version', true );
     58    if ( false === $curr_version || version_compare( $curr_version, '3.0.0', '<' ) ) {
     59        Humcommerce::install_tables();
     60
     61        $options = get_option( 'humcommerce_options' );
     62        if ( is_array( $options ) && isset( $options['si'] ) ) {
     63            update_option( 'humc_site', $options['si'], false );
     64            delete_option( 'humcommerce_options' );
     65        }
     66    }
     67    update_option( 'humcommerce_magic_version', HUMCOMMERCE_VERSION, false );
     68}
     69
     70add_action( 'admin_init', 'activate_humcommerce_magic' );
     71
    3672
    3773/**
  • humcommerce/trunk/includes/class-humcommerce.php

    r2272741 r2360765  
    2626 */
    2727class Humcommerce {
     28
     29    const REC_TABLE = 'magic_recordings';
    2830
    2931    /**
     
    7981
    8082    /**
     83     * Install recordings table
     84     */
     85    public static function install_tables() {
     86        global $wpdb;
     87        $table_name      = $wpdb->prefix . self::REC_TABLE;
     88        $charset_collate = $wpdb->get_charset_collate();
     89
     90        $ddl = "CREATE TABLE IF NOT EXISTS {$table_name} (
     91                    id INT(11) unsigned NOT NULL AUTO_INCREMENT,
     92                    idloghsr INT(11) unsigned NOT NULL,
     93                    idsitehsr INT(11) unsigned NOT NULL,
     94                    cart_value FLOAT (8,2) default 0.00,
     95                    location_country varchar (120),
     96                    is_abandon_cart tinyint(1) NOT NULL default 0,
     97                    recording_url varchar (255),
     98                    recording_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
     99                    dead_clicks TEXT NOT NULL,
     100                    errors TEXT NOT NULL,
     101                    PRIMARY KEY (`id`),
     102                    KEY `magic_recording_date_idx` (`recording_date`)
     103                ) $charset_collate";
     104        $wpdb->query( $ddl );
     105    }
     106
     107    /**
    81108     * Load the required dependencies for this plugin.
    82109     *
     
    98125        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-humcommerce-loader.php';
    99126
     127        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-magic-api.php';
     128
    100129        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-humcommerce-admin.php';
    101130
    102131        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-humcommerce-public.php';
    103 
    104         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-humcommerce-settings.php';
    105132
    106133        $this->loader = new Humcommerce_Loader();
     
    120147        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
    121148        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
    122         $this->loader->add_action( 'admin_notices', $plugin_admin, 'humcommerce_add_settings_errors' );
    123149        $this->loader->add_action( 'activated_plugin', $plugin_admin, 'humcommerce_activation_redirect', 10, 1 );
    124150    }
     
    132158     */
    133159    private function define_public_hooks() {
    134         $plugin_public = new Humcommerce_Public( $this->get_humcommerce(), $this->get_version() );
     160        $plugin_public = new Humcommerce_Public();
    135161
    136162        $this->loader->add_action( 'wp_head', $plugin_public, 'add_humcommerce_script_to_wp_head' );
    137     }
     163
     164        add_action( 'rest_api_init', array( $this, 'register_api_endpoints' ) );
     165
     166    }
     167
     168    /**
     169     * Register rest endpoints
     170     */
     171    public function register_api_endpoints() {
     172
     173        register_rest_route(
     174            'humcommerce/v1',
     175            'verify-domain',
     176            array(
     177                'method'   => 'GET',
     178                'callback' => array( $this, 'verify_domain' ),
     179            )
     180        );
     181    }
     182
     183    /**
     184     * Verify domain
     185     *
     186     * @param WP_REST_Request $request Rest request object.
     187     */
     188    public function verify_domain( WP_REST_Request $request ) {
     189
     190        if ( get_transient( '__humc_auth_nonce' ) !== $request->get_param( '_wp_nonce' ) ) {
     191            // nonce sent from app server does not match send 403.
     192            wp_die( 'Unauthorized request', 403 );
     193        }
     194
     195        wp_die( 'ok', 200 );
     196    }
     197
     198
    138199
    139200    /**
  • humcommerce/trunk/public/class-humcommerce-public.php

    r2272741 r2360765  
    1919class Humcommerce_Public {
    2020
    21     /**
    22      * The ID of this plugin.
    23      *
    24      * @since    1.0.0
    25      * @access   private
    26      * @var      string    $humcommerce_custom    The ID of this plugin.
    27      */
    28     private $humcommerce;
    2921
    30     /**
    31      * The version of this plugin.
    32      *
    33      * @since    1.0.0
    34      * @access   private
    35      * @var      string    $version    The current version of this plugin.
    36      */
    37     private $version;
    38 
    39     /**
    40      * Tracker object.
    41      *
    42      * @since 2.1.4
    43      * @access private
    44      * @var object $tracker Tracker object.
    45      */
    46     private $tracker;
    47 
    48     /**
    49      * Initialize the class and set its properties.
    50      *
    51      * @since    1.0.0
    52      * @param      string $humcommerce       The name of the plugin.
    53      * @param      string $version    The version of this plugin.
    54      */
    55     public function __construct( $humcommerce, $version ) {
    56 
    57         $this->humcommerce_custom = $humcommerce;
    58         $this->version            = $version;
    59 
    60     }
    61 
    62     /**
    63      * Register the stylesheets for the public-facing side of the site.
    64      *
    65      * @since    1.0.0
    66      */
    67     public function enqueue_styles() {
    68 
    69         /**
    70          * This function is provided for demonstration purposes only.
    71          *
    72          * An instance of this class should be passed to the run() function
    73          * defined in Humcommerce_Custom_Loader as all of the hooks are defined
    74          * in that particular class.
    75          *
    76          * The Humcommerce_Custom_Loader will then create the relationship
    77          * between the defined hooks and the functions defined in this
    78          * class.
    79          */
    80 
    81         wp_enqueue_style( $this->humcommerce_custom, plugin_dir_url( __FILE__ ) . 'css/humcommerce-custom-public.css', array(), $this->version, 'all' );
    82 
    83     }
    84 
    85     /**
    86      * Register the JavaScript for the public-facing side of the site.
    87      *
    88      * @since    1.0.0
    89      */
    90     public function enqueue_scripts() {
    91 
    92         /**
    93          * This function is provided for demonstration purposes only.
    94          *
    95          * An instance of this class should be passed to the run() function
    96          * defined in Humcommerce_Custom_Loader as all of the hooks are defined
    97          * in that particular class.
    98          *
    99          * The Humcommerce_Custom_Loader will then create the relationship
    100          * between the defined hooks and the functions defined in this
    101          * class.
    102          */
    103 
    104         wp_enqueue_script( $this->humcommerce_custom, plugin_dir_url( __FILE__ ) . 'js/humcommerce-custom-public.js', array( 'jquery' ), $this->version, false );
    105 
    106     }
    10722
    10823    /**
     
    11227     */
    11328    public function add_humcommerce_script_to_wp_head() {
    114         $options = get_option( 'humcommerce_options' );
     29        $site_id = get_option( 'humc_site' );
    11530
    116         $set_ecommerce_view = null;
    117         $set_user_id        = null;
    118         include_once ABSPATH . 'wp-admin/includes/plugin.php';
     31        if ( ! $site_id ) {
     32            return;
     33        }
    11934
    120        if ( is_array( $options ) ) {
    121             if ( array_key_exists( 'host', $options ) && ! empty( $options['host'] ) ) {
    122                 $host_url = $options['host'];
    123            } else {
    124                 $host_url = HUMCOMMERCE_HOST;
    125             }
     35        $host_url = rtrim( HUMCOMMERCE_HOST, '/' );
    12636
    127             if ( is_user_logged_in() && array_key_exists( 'set-user-id', $options ) ) {
    128                 $user        = get_user_by( 'ID', get_current_user_id() );
    129                 $set_user_id = "_ha.push(['setUserId', '" . $user->user_email . "']);";
    130             }
    131         }
    132         if ( isset( $options['si'] ) && ! empty( $options['si'] ) ) {
    133             echo ' <!-- HumCommerce Tracking code -->
    134                 <script type="text/javascript">
    135                   var _ha = _ha || [];
    136                   ' . $set_user_id . '
    137                   _ha.push(["trackPageView"]);
    138                   _ha.push(["enableLinkTracking"]);
    139                   (function() {
    140                     var u="https://' . esc_js( $host_url ) . '/";
    141                      _ha.push([\'setTrackerUrl\', u+\'humdash.php\']);
    142                     _ha.push(["setSiteId", "' . esc_js( $options['si'] ) . '"]);
    143                     var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0];
    144                     g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"sites/h-' . esc_js( $options['si'] ) . '.js"; s.parentNode.insertBefore(g,s);
    145                   })();
    146                 </script>
    147            <!-- End of HumCommerce Code -->';// phpcs:ignore
     37        ?>
     38            <!-- HumCommerce Tracking code -->
     39            <script type="text/javascript">
     40                var _ha = _ha || [];
    14841
    149         }
     42                _ha.push(["trackPageView"]);
     43                _ha.push(["enableLinkTracking"]);
     44                (function () {
     45                    var u = '<?php echo esc_url( $host_url ); ?>';
     46                    _ha.push(['setTrackerUrl', u + '/humdash.php']);
     47                    _ha.push(['setSiteId', '<?php echo esc_html( $site_id ); ?>']);
     48                    var d = document, g = d.createElement("script"), s = d.getElementsByTagName("script")[0];
     49                    g.type = "text/javascript";
     50                    g.async = true;
     51                    g.defer = true;
     52                    g.src = u + "/sites/h-<?php echo esc_html( $site_id ); ?>.js";
     53                    s.parentNode.insertBefore(g, s);
     54                })();
     55            </script>
     56            <!-- End of HumCommerce Code -->
     57            <?php
     58
    15059    }
    15160
Note: See TracChangeset for help on using the changeset viewer.