listing.php
249 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Displays the listing page. |
| 4 | * |
| 5 | * @uses ../../dialogs/migrate-dismiss-confirmation.php |
| 6 | * @uses ../../global/sui-components/sui-footer.php |
| 7 | * @uses ../dialogs/create-module.php |
| 8 | * @uses ../dialogs/import-module.php |
| 9 | * @uses ../dialogs/delete-module.php |
| 10 | * @uses ../dialogs/manage-tracking.php |
| 11 | * @uses ../dialogs/pro-upgrade.php |
| 12 | * @uses ./summary.php |
| 13 | * @uses ./pagination.php |
| 14 | * @uses ./module.php |
| 15 | * @uses ./empty-message.php |
| 16 | * @uses ../dialogs/modal-preview.php |
| 17 | * |
| 18 | * @package Hustle |
| 19 | * @since 4.0.0 |
| 20 | */ |
| 21 | |
| 22 | if ( isset( $page_title ) ) { |
| 23 | $page_title = $page_title; |
| 24 | } else { |
| 25 | $page_title = esc_html__( 'Module', 'hustle' ); |
| 26 | } |
| 27 | $sql_month_start_date = date( 'Y-m-d H:i:s', strtotime( '-30 days midnight' ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date |
| 28 | $is_search = filter_input( INPUT_GET, 'q' ); |
| 29 | ?> |
| 30 | |
| 31 | <div class="sui-header"> |
| 32 | |
| 33 | <h1 class="sui-title"><?php echo esc_html( $page_title ); ?></h1> |
| 34 | |
| 35 | <?php if ( 0 < $total && $capability['hustle_create'] ) { ?> |
| 36 | |
| 37 | <div class="sui-actions-left"> |
| 38 | |
| 39 | <button |
| 40 | id="hustle-create-new-module" |
| 41 | class="sui-button sui-button-blue hustle-create-module" |
| 42 | > |
| 43 | <span class="sui-icon-plus" aria-hidden="true"></span> <?php esc_html_e( 'Create', 'hustle' ); ?> |
| 44 | </button> |
| 45 | |
| 46 | <button |
| 47 | class="sui-button hustle-import-module-button" |
| 48 | > |
| 49 | <span class="sui-icon-upload-cloud" aria-hidden="true"></span> <?php esc_html_e( 'Import', 'hustle' ); ?> |
| 50 | </button> |
| 51 | |
| 52 | </div> |
| 53 | |
| 54 | <?php } ?> |
| 55 | |
| 56 | <?php if ( false && 0 < count( $modules ) ) : ?> |
| 57 | |
| 58 | <div class="sui-actions-right"> |
| 59 | |
| 60 | <div class="hui-reporting-period"> |
| 61 | |
| 62 | <label><?php esc_html_e( 'Reporting Period', 'hustle' ); ?></label> |
| 63 | |
| 64 | <select class="sui-select sui-select-inline" data-width="160"> |
| 65 | <option value="7"><?php esc_html_e( 'Last 7 days', 'hustle' ); ?></option> |
| 66 | <option value="15"><?php esc_html_e( 'Last 15 days', 'hustle' ); ?></option> |
| 67 | <option value="30" selected><?php esc_html_e( 'Last 30 days', 'hustle' ); ?></option> |
| 68 | </select> |
| 69 | |
| 70 | </div> |
| 71 | |
| 72 | <?php |
| 73 | $this->render( |
| 74 | 'admin/commons/view-documentation', |
| 75 | array( |
| 76 | 'unwrap' => true, |
| 77 | 'docs_section' => 'module-dashboards', |
| 78 | ) |
| 79 | ); |
| 80 | ?> |
| 81 | |
| 82 | </div> |
| 83 | |
| 84 | <?php else : ?> |
| 85 | |
| 86 | <?php $this->render( 'admin/commons/view-documentation', array( 'docs_section' => 'module-dashboards' ) ); ?> |
| 87 | |
| 88 | <?php endif; ?> |
| 89 | |
| 90 | </div> |
| 91 | |
| 92 | <div id="hustle-floating-notifications-wrapper" class="sui-floating-notices"></div> |
| 93 | |
| 94 | <?php |
| 95 | if ( 0 < count( $modules ) || $is_search ) { |
| 96 | $args = array( |
| 97 | 'active_modules_count' => $active, |
| 98 | 'capitalize_singular' => $capitalize_singular, |
| 99 | 'capitalize_plural' => $capitalize_plural, |
| 100 | 'module_type' => $module_type, |
| 101 | 'sui' => $sui, |
| 102 | ); |
| 103 | |
| 104 | if ( Hustle_Settings_Admin::global_tracking() ) { |
| 105 | $tracking_model = Hustle_Tracking_Model::get_instance(); |
| 106 | $args['latest_entry_time'] = $tracking_model->get_latest_conversion_time( $module_type ); |
| 107 | $args['latest_entries_count'] = $tracking_model->count_newer_conversions_by_module_type( $module_type, $sql_month_start_date ); |
| 108 | } |
| 109 | |
| 110 | // ELEMENT: Summary. |
| 111 | $this->render( |
| 112 | 'admin/commons/sui-listing/elements/summary', |
| 113 | $args |
| 114 | ); |
| 115 | ?> |
| 116 | |
| 117 | <?php |
| 118 | // ELEMENT: Pagination. |
| 119 | if ( count( $modules ) ) { |
| 120 | $this->render( |
| 121 | 'admin/commons/sui-listing/elements/pagination', |
| 122 | array( |
| 123 | 'module_type' => $module_type, |
| 124 | 'items' => $modules, |
| 125 | 'total' => $total, |
| 126 | 'entries_per_page' => $entries_per_page, |
| 127 | ) |
| 128 | ); |
| 129 | } |
| 130 | ?> |
| 131 | |
| 132 | <div class="hustle-list sui-accordion sui-accordion-block"> |
| 133 | |
| 134 | <?php |
| 135 | foreach ( $modules as $key => $module ) { |
| 136 | // ELEMENT: Modules. |
| 137 | $this->render( |
| 138 | 'admin/commons/sui-listing/elements/module', |
| 139 | array( |
| 140 | 'module' => $module, |
| 141 | 'module_type' => $module_type, |
| 142 | 'smallcaps_singular' => $smallcaps_singular, |
| 143 | 'capitalize_singular' => $capitalize_singular, |
| 144 | 'tracking_types' => $module->get_tracking_types(), |
| 145 | ) |
| 146 | ); |
| 147 | } |
| 148 | |
| 149 | if ( ! count( $modules ) ) { |
| 150 | // ELEMENT: Empty Search Message. |
| 151 | $this->render( |
| 152 | 'admin/commons/sui-listing/elements/empty-search', |
| 153 | array( |
| 154 | 'capitalize_plural' => $capitalize_plural, |
| 155 | 'search_keyword' => $is_search, |
| 156 | ) |
| 157 | ); |
| 158 | } |
| 159 | ?> |
| 160 | |
| 161 | </div> |
| 162 | |
| 163 | <?php |
| 164 | // ELEMENT: Pagination. |
| 165 | if ( count( $modules ) ) { |
| 166 | echo '<div style="margin-top: 20px;">'; // Spacing correction. |
| 167 | |
| 168 | $this->render( |
| 169 | 'admin/commons/sui-listing/elements/pagination', |
| 170 | array( |
| 171 | 'module_type' => $module_type, |
| 172 | 'items' => $modules, |
| 173 | 'total' => $total, |
| 174 | 'entries_per_page' => $entries_per_page, |
| 175 | 'is_bottom' => true, |
| 176 | ) |
| 177 | ); |
| 178 | |
| 179 | echo '</div>'; |
| 180 | } |
| 181 | ?> |
| 182 | |
| 183 | <?php } else { ?> |
| 184 | |
| 185 | <?php |
| 186 | // ELEMENT: Empty Message. |
| 187 | $this->render( |
| 188 | 'admin/commons/sui-listing/elements/empty-message', |
| 189 | array( |
| 190 | 'count' => $total, |
| 191 | 'is_free' => $is_free, |
| 192 | 'capability' => $capability, |
| 193 | 'message' => $page_message, |
| 194 | ) |
| 195 | ); |
| 196 | } |
| 197 | |
| 198 | // ELEMENT: Footer. |
| 199 | $this->render( 'admin/global/sui-components/sui-footer' ); |
| 200 | |
| 201 | // DIALOG: Create module. |
| 202 | $this->render( |
| 203 | 'admin/commons/sui-listing/dialogs/create-module', |
| 204 | array( |
| 205 | 'capitalize_singular' => $capitalize_singular, |
| 206 | 'smallcaps_singular' => $smallcaps_singular, |
| 207 | ) |
| 208 | ); |
| 209 | |
| 210 | // DIALOG: Import module. |
| 211 | $this->render( |
| 212 | 'admin/commons/sui-listing/dialogs/import-module', |
| 213 | array( |
| 214 | 'capitalize_singular' => $capitalize_singular, |
| 215 | 'smallcaps_singular' => $smallcaps_singular, |
| 216 | ) |
| 217 | ); |
| 218 | |
| 219 | // DIALOG: Delete module. |
| 220 | $this->render( |
| 221 | 'admin/commons/sui-listing/dialogs/delete-module', |
| 222 | array() |
| 223 | ); |
| 224 | |
| 225 | // DIALOG: Manage tracking. |
| 226 | if ( isset( $multiple_charts ) ) { |
| 227 | |
| 228 | $this->render( |
| 229 | 'admin/commons/sui-listing/dialogs/manage-tracking', |
| 230 | array( |
| 231 | 'multiple_charts' => isset( $multiple_charts ) ? $multiple_charts : false, |
| 232 | ) |
| 233 | ); |
| 234 | } |
| 235 | |
| 236 | // DIALOG: Ugrade to pro. |
| 237 | if ( Opt_In_Utils::is_free() ) { |
| 238 | $this->render( 'admin/commons/sui-listing/dialogs/pro-upgrade' ); |
| 239 | } |
| 240 | |
| 241 | // DIALOG: Dissmiss migrate tracking notice modal confirmation. |
| 242 | if ( Hustle_Notifications::is_show_migrate_tracking_notice() ) { |
| 243 | $this->render( 'admin/dialogs/migrate-dismiss-confirmation' ); |
| 244 | } |
| 245 | |
| 246 | // Preview. |
| 247 | $this->render( 'admin/dialogs/modal-preview', array( 'module_type' => $capitalize_singular ) ); |
| 248 | ?> |
| 249 |