actions.php
1 month ago
bulk-actions.php
3 years ago
empty-message.php
2 years ago
empty-search.php
2 years ago
module.php
3 years ago
pagination-list.php
5 months ago
pagination.php
6 years ago
summary.php
10 months ago
tracking-data-chart.php
5 months ago
tracking-data.php
6 years ago
module.php
213 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Displays the tracking charts in the listing page. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since 4.0.0 |
| 7 | */ |
| 8 | |
| 9 | $is_tracking_disabled = empty( $module->get_tracking_types() ); |
| 10 | $last_conversion_text = __( 'Last conversion', 'hustle' ); |
| 11 | |
| 12 | $global_tracking = Hustle_Settings_Admin::global_tracking(); |
| 13 | $module_tag_class = $module->active ? ' sui-tag-blue' : ''; |
| 14 | $tooltip_message = ''; |
| 15 | $is_scheduled = false; |
| 16 | |
| 17 | // Let's handle the icons and messages for the Schedule settings. |
| 18 | // Social sharing modules don't have schedules. And drafted modules disregard it. |
| 19 | if ( Hustle_Module_Model::SOCIAL_SHARING_MODULE !== $module->module_type ) { |
| 20 | |
| 21 | $settings = $module->get_settings(); |
| 22 | $settings_array = $settings->to_array(); |
| 23 | $schedule = $settings_array['schedule']; |
| 24 | $is_scheduled = '1' === $settings_array['is_schedule']; |
| 25 | |
| 26 | // If a schedule isn't set for the module, no need to add schedule icons. |
| 27 | if ( $is_scheduled ) { |
| 28 | |
| 29 | /* translators: module type capitalized and in singular */ |
| 30 | $tooltip_message = sprintf( __( "%s schedule has not started, so your visitors can't see it yet.", 'hustle' ), $capitalize_singular ); |
| 31 | |
| 32 | $module_tag_class .= ' hui-tag-scheduled sui-tooltip sui-tooltip-constrained sui-tooltip-top-left-mobile'; |
| 33 | |
| 34 | // Notify the admin that the module won't be shown again because of the schedule. |
| 35 | if ( ! $settings->will_be_shown_again() || $settings->is_schedule_finished() ) { |
| 36 | |
| 37 | $module_tag_class .= ' hui-scheduled-error'; |
| 38 | |
| 39 | $tooltip_message = sprintf( |
| 40 | /* translators: 1. module type capitalized and in singular, 2. module type in lowercase and in singular. */ |
| 41 | __( "%1\$s schedule is over and your visitors can't see this %2\$s anymore.", 'hustle' ), |
| 42 | $capitalize_singular, |
| 43 | $smallcaps_singular |
| 44 | ); |
| 45 | |
| 46 | // Notify the admin that this module is currently being displayed according to the schedule. |
| 47 | } elseif ( $settings->is_currently_scheduled() || $settings->is_between_start_and_end_date() ) { |
| 48 | |
| 49 | $module_tag_class .= ' hui-scheduled-success'; |
| 50 | |
| 51 | $tooltip_message = sprintf( |
| 52 | /* translators: 1. module type capitalized and in singular, 2. module type in lowercase and in singular. */ |
| 53 | __( '%1$s schedule is active now and the %2$s is visible to your visitors.', 'hustle' ), |
| 54 | $capitalize_singular, |
| 55 | $smallcaps_singular |
| 56 | ); |
| 57 | } |
| 58 | } |
| 59 | } else { |
| 60 | $last_conversion_text = __( 'Last share', 'hustle' ); |
| 61 | } |
| 62 | |
| 63 | ?> |
| 64 | <div class="sui-accordion-item"> |
| 65 | |
| 66 | <?php |
| 67 | $module_id = $module->module_id; |
| 68 | $can_edit = Opt_In_Utils::is_user_allowed( 'hustle_edit_module', $module_id ); |
| 69 | $view_stats = filter_input( INPUT_GET, 'view_stats', FILTER_VALIDATE_INT ); |
| 70 | |
| 71 | if ( $view_stats && intval( $module_id ) === $view_stats ) { |
| 72 | $display_chart_class = ' hustle-display-chart hustle-scroll-to'; |
| 73 | } else { |
| 74 | $display_chart_class = ''; |
| 75 | } |
| 76 | |
| 77 | // START: Item header. |
| 78 | ?> |
| 79 | <div |
| 80 | class="sui-accordion-item-header<?php echo esc_attr( $display_chart_class ); ?>" |
| 81 | data-id="<?php echo esc_attr( $module->id ); ?>" |
| 82 | data-nonce="<?php echo esc_attr( wp_create_nonce( 'module_get_tracking_data' . $module->id ) ); ?>" |
| 83 | > |
| 84 | |
| 85 | <?php // This should have sui-trim-title, but that class prevents the schedule tooltip from showing up. ?> |
| 86 | <div class="sui-accordion-item-title"> |
| 87 | |
| 88 | <label for="hustle-module-<?php echo esc_html( $module_id ); ?>" class="sui-checkbox sui-accordion-item-action"> |
| 89 | <input |
| 90 | type="checkbox" |
| 91 | value="<?php echo esc_html( $module_id ); ?>" |
| 92 | id="hustle-module-<?php echo esc_html( $module_id ); ?>" |
| 93 | class="hustle-listing-checkbox" |
| 94 | /> |
| 95 | <span aria-hidden="true"></span> |
| 96 | <span class="sui-screen-reader-text"><?php esc_html_e( 'Select this module', 'hustle' ); ?></span> |
| 97 | </label> |
| 98 | |
| 99 | <span class="sui-trim-text"><?php echo esc_html( $module->module_name ); ?></span> |
| 100 | |
| 101 | <span |
| 102 | class="sui-tag<?php echo esc_attr( $module_tag_class ); ?>" |
| 103 | <?php echo ! empty( $tooltip_message ) ? 'data-tooltip="' . esc_html( $tooltip_message ) . '"' : ''; ?> |
| 104 | > |
| 105 | |
| 106 | <span class="hustle-toggle-status-button-description<?php echo $module->active ? ' sui-hidden' : ''; ?>"> |
| 107 | <?php esc_html_e( 'Draft', 'hustle' ); ?> |
| 108 | </span> |
| 109 | |
| 110 | <span class="hustle-toggle-status-button-description<?php echo $module->active ? '' : ' sui-hidden'; ?>"> |
| 111 | <?php esc_html_e( 'Published', 'hustle' ); ?> |
| 112 | <?php if ( $is_scheduled ) { ?> |
| 113 | <span class="sui-icon-clock sui-sm" aria-hidden="true"></span> |
| 114 | <?php } ?> |
| 115 | </span> |
| 116 | |
| 117 | </span> |
| 118 | |
| 119 | <?php if ( $global_tracking ) { ?> |
| 120 | <span class="sui-tag sui-tag-disabled hustle-analytics-disabled-tag<?php echo ( $module->active && $is_tracking_disabled ) ? '' : ' sui-hidden-important'; ?>"> |
| 121 | <?php esc_html_e( 'Tracking Disabled', 'hustle' ); ?> |
| 122 | </span> |
| 123 | <?php } ?> |
| 124 | |
| 125 | </div> |
| 126 | |
| 127 | <?php |
| 128 | if ( Hustle_Settings_Admin::global_tracking() ) { |
| 129 | $tracking_model = Hustle_Tracking_Model::get_instance(); |
| 130 | $last_entry_time = $tracking_model->get_latest_conversion_time_by_module_id( $module_id ); |
| 131 | ?> |
| 132 | <div class="sui-accordion-item-date"> |
| 133 | <strong><?php echo esc_html( $last_conversion_text ); ?></strong> |
| 134 | <?php echo esc_html( $last_entry_time ); ?> |
| 135 | </div> |
| 136 | <?php } ?> |
| 137 | |
| 138 | <div class="sui-accordion-col-auto"> |
| 139 | |
| 140 | <?php if ( $can_edit ) { ?> |
| 141 | <a |
| 142 | href="<?php echo esc_url( $module->get_edit_url() ); ?>" |
| 143 | class="sui-button sui-button-ghost sui-accordion-item-action sui-desktop-visible" |
| 144 | > |
| 145 | <span class="sui-icon-pencil" aria-hidden="true"></span> <?php esc_attr_e( 'Edit', 'hustle' ); ?> |
| 146 | </a> |
| 147 | |
| 148 | <a |
| 149 | href="<?php echo esc_url( $module->get_edit_url() ); ?>" |
| 150 | class="sui-button-icon sui-accordion-item-action sui-mobile-visible" |
| 151 | > |
| 152 | <span class="sui-icon-pencil" aria-hidden="true"></span> |
| 153 | <span class="sui-screen-reader-text"><?php esc_attr_e( 'Edit', 'hustle' ); ?></span> |
| 154 | </a> |
| 155 | <?php } ?> |
| 156 | |
| 157 | <div class="sui-dropdown sui-accordion-item-action"> |
| 158 | |
| 159 | <?php |
| 160 | // ELEMENT: Actions. |
| 161 | $this->render( |
| 162 | 'admin/commons/sui-listing/elements/actions', |
| 163 | array( |
| 164 | 'module' => $module, |
| 165 | 'smallcaps_singular' => $smallcaps_singular, |
| 166 | 'capitalize_singular' => $capitalize_singular, |
| 167 | 'is_tracking_disabled' => $is_tracking_disabled, |
| 168 | ) |
| 169 | ); |
| 170 | ?> |
| 171 | |
| 172 | </div> |
| 173 | |
| 174 | <?php if ( $global_tracking ) { ?> |
| 175 | <button class="sui-button-icon sui-accordion-open-indicator"> |
| 176 | <span class="sui-icon-chevron-down" aria-hidden="true"></span> |
| 177 | <span class="sui-screen-reader-text"><?php esc_html_e( 'View module stats', 'hustle' ); ?></span> |
| 178 | </button> |
| 179 | <?php } ?> |
| 180 | |
| 181 | </div> |
| 182 | |
| 183 | </div> |
| 184 | |
| 185 | <?php if ( $global_tracking ) { ?> |
| 186 | <?php // START: Item body. ?> |
| 187 | <div class="sui-accordion-item-body"> |
| 188 | |
| 189 | <?php |
| 190 | $render_arguments = array( |
| 191 | 'module' => $module, |
| 192 | 'total_module_views' => 0, |
| 193 | 'total_module_conversions' => 0, |
| 194 | 'tracking_types' => $tracking_types, |
| 195 | 'last_entry_time' => esc_html__( 'Never', 'hustle' ), |
| 196 | 'rate' => 0, |
| 197 | ); |
| 198 | |
| 199 | // ELEMENT: Tracking data. |
| 200 | $this->render( |
| 201 | 'admin/commons/sui-listing/elements/tracking-data', |
| 202 | array( |
| 203 | 'render_arguments' => $render_arguments, |
| 204 | 'multiple_charts' => false, |
| 205 | ) |
| 206 | ); |
| 207 | ?> |
| 208 | |
| 209 | </div> |
| 210 | <?php } ?> |
| 211 | |
| 212 | </div> |
| 213 |