commons
1 month ago
dashboard
1 month ago
dialogs
1 month ago
email-lists
9 months ago
embedded
3 years ago
global
5 months ago
integrations
1 month ago
integrations-page
5 months ago
popup
3 years ago
settings
1 month ago
slidein
3 years ago
sshare
9 months ago
dashboard.php
1 month ago
entries.php
2 years ago
image-markup.php
3 years ago
integrations.php
1 month ago
settings.php
1 month ago
tutorials.php
3 years ago
upsell.php
2 years ago
widget-analytics.php
3 years ago
widget-analytics.php
117 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Dashboard Hustle analytics widget: Displayed on site dashboards with stats. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since 4.1.0 |
| 7 | */ |
| 8 | |
| 9 | $array_days_ago = $this->admin->get_analytic_ranges(); |
| 10 | |
| 11 | $active_module_types = $settings['modules']; |
| 12 | |
| 13 | $available_module_types = array( |
| 14 | 'overall' => __( 'Overall', 'hustle' ), |
| 15 | Hustle_Module_Model::POPUP_MODULE => __( 'Pop-ups', 'hustle' ), |
| 16 | Hustle_Module_Model::SLIDEIN_MODULE => __( 'Slide-ins', 'hustle' ), |
| 17 | Hustle_Module_Model::EMBEDDED_MODULE => __( 'Embeds', 'hustle' ), |
| 18 | Hustle_Module_Model::SOCIAL_SHARING_MODULE => __( 'Social Sharing', 'hustle' ), |
| 19 | ); |
| 20 | |
| 21 | ?> |
| 22 | <div |
| 23 | class="hustle-widget" |
| 24 | data-nonce="<?php echo esc_attr( wp_create_nonce( 'hustle_update_wp_dashboard_chart' ) ); ?>" |
| 25 | > |
| 26 | <div class="hustle-dashboard-widget-heading-extra"> |
| 27 | <span id="hustle-dashboard-widget-last-updated"></span> |
| 28 | <a href="#" id="hustle-dashboard-widget-reload-cache"><span class="sui-icon-update" aria-hidden="true"></span> <?php esc_html_e( 'Reload data', 'hustle' ); ?></a> |
| 29 | </div> |
| 30 | |
| 31 | <form class="hustle-widget-header"> |
| 32 | |
| 33 | <div class="hustle-form-field"> |
| 34 | |
| 35 | <label for="hustle-analytics-show" id="hustle-analytics-show-label" class="hustle-label" aria-labelledby="hustle-analytics-show-label"><?php esc_html_e( 'Show', 'hustle' ); ?></label> |
| 36 | |
| 37 | <select id="hustle-analytics-show" class="hustle-select"> |
| 38 | <option value="view" selected><?php esc_html_e( 'Views', 'hustle' ); ?></option> |
| 39 | <option value="conversion"><?php esc_html_e( 'All Conversions', 'hustle' ); ?></option> |
| 40 | <option value="cta_conversion"><?php esc_html_e( 'CTA Conversions', 'hustle' ); ?></option> |
| 41 | <option value="optin_conversion"><?php esc_html_e( 'Optin Conversions', 'hustle' ); ?></option> |
| 42 | <option value="rate"><?php esc_html_e( 'Conversion Rate', 'hustle' ); ?></option> |
| 43 | </select> |
| 44 | |
| 45 | </div> |
| 46 | |
| 47 | <div class="hustle-form-field"> |
| 48 | |
| 49 | <label for="hustle-analytics-data" id="hustle-analytics-data-label" class="hustle-label"><?php esc_html_e( 'from', 'hustle' ); ?></label> |
| 50 | |
| 51 | <select id="hustle-analytics-data" class="hustle-select" aria-labelledby="hustle-analytics-data-label"> |
| 52 | <?php foreach ( $array_days_ago as $val => $range_title ) : ?> |
| 53 | <option value="<?php echo esc_attr( $val ); ?>"<?php selected( $val, 7 ); ?>><?php echo esc_html( $range_title ); ?></option> |
| 54 | <?php endforeach; ?> |
| 55 | </select> |
| 56 | |
| 57 | </div> |
| 58 | |
| 59 | <button id="hustle-analytics-apply" class="button hustle-button"><?php esc_html_e( 'Apply', 'hustle' ); ?></button> |
| 60 | |
| 61 | </form> |
| 62 | |
| 63 | <div class="hustle-widget-body"> |
| 64 | |
| 65 | <div class="hustle-options-embed" style="display: none;"> |
| 66 | |
| 67 | <button role="tab" class="hustle-option hustle-active" aria-selected="true" data-display-type="total"><?php esc_html_e( 'Total', 'hustle' ); ?></button> |
| 68 | |
| 69 | <button role="tab" class="hustle-option" aria-selected="false" data-display-type="<?php echo esc_attr( Hustle_SShare_Model::FLOAT_MODULE ); ?>"><?php esc_html_e( 'Floating', 'hustle' ); ?></button> |
| 70 | |
| 71 | <button role="tab" class="hustle-option" aria-selected="false" data-display-type="<?php echo esc_attr( Hustle_Module_Model::INLINE_MODULE ); ?>"><?php esc_html_e( 'Inline', 'hustle' ); ?></button> |
| 72 | |
| 73 | <button role="tab" class="hustle-option" aria-selected="false" data-display-type="<?php echo esc_attr( Hustle_Module_Model::WIDGET_MODULE ); ?>"><?php esc_html_e( 'Widget', 'hustle' ); ?></button> |
| 74 | |
| 75 | <button role="tab" class="hustle-option" aria-selected="false" data-display-type="<?php echo esc_attr( Hustle_Module_Model::SHORTCODE_MODULE ); ?>"><?php esc_html_e( 'Shortcode', 'hustle' ); ?></button> |
| 76 | |
| 77 | </div> |
| 78 | |
| 79 | <div class="hustle-chart-wrap"> |
| 80 | |
| 81 | <div class="hustle-options-chart"> |
| 82 | |
| 83 | <?php foreach ( $active_module_types as $module_type ) : ?> |
| 84 | |
| 85 | <?php $is_selected = $module_type === $active_module_types[0]; ?> |
| 86 | <button |
| 87 | role="tab" |
| 88 | class="hustle-option<?php echo $is_selected ? ' hustle-active' : ''; ?>" |
| 89 | aria-selected="<?php echo $is_selected ? 'true' : 'false'; ?>" |
| 90 | data-module-type="<?php echo esc_attr( $module_type ); ?>" |
| 91 | > |
| 92 | <span class="hustle-option--title"><?php echo esc_html( $available_module_types[ $module_type ] ); ?></span> |
| 93 | <span class="hustle-option--value"></span> |
| 94 | <span class="hustle-option--trend"></span> |
| 95 | </button> |
| 96 | |
| 97 | <?php endforeach; ?> |
| 98 | |
| 99 | </div> |
| 100 | |
| 101 | <div class="hustle-chart-graph"> |
| 102 | |
| 103 | <div class="hustle-message-empty" style="display:none;"> |
| 104 | <p class="hustle-title"><?php esc_html_e( "We haven't collected enough data yet.", 'hustle' ); ?></p> |
| 105 | <p class="hustle-text"><?php /* translators: Plugin name */ echo esc_html( sprintf( __( 'You will start viewing the performance statistics of your %s modules shortly. So feel free to check back soon', 'hustle' ), Opt_In_Utils::get_plugin_name() ) ); ?></p> |
| 106 | </div> |
| 107 | |
| 108 | <canvas id="hustle-analytics-chart"></canvas> |
| 109 | |
| 110 | </div> |
| 111 | |
| 112 | </div> |
| 113 | |
| 114 | </div> |
| 115 | |
| 116 | </div> |
| 117 |