| @@ -1,0 +1,158 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Logs template | |
| 4 | + * | |
| 5 | + * This template can be overridden by copying it to yourtheme/gamipress/logs.php | |
| 6 | + * To override a specific log type just copy it as yourtheme/gamipress/logs-{log-type}.php | |
| 7 | + */ | |
| 8 | +global $gamipress_template_args; | |
| 9 | + | |
| 10 | +// Shorthand | |
| 11 | +$a = $gamipress_template_args; | |
| 12 | + | |
| 13 | +// Execute the query | |
| 14 | +$logs = $a['query']->get_results(); | |
| 15 | +?> | |
| 16 | + | |
| 17 | +<div class="gamipress-logs"> | |
| 18 | + | |
| 19 | + <div class="gamipress-logs-atts"> | |
| 20 | + | |
| 21 | + <?php | |
| 22 | + /** | |
| 23 | + * Before render logs atts | |
| 24 | + * | |
| 25 | + * @since 1.4.9 | |
| 26 | + * | |
| 27 | + * @param array $template_args Template received arguments | |
| 28 | + */ | |
| 29 | + do_action( 'gamipress_before_render_logs_atts', $a ); ?> | |
| 30 | + | |
| 31 | + <?php // Hidden fields for ajax request | |
| 32 | + echo gamipress_array_as_hidden_inputs( $a, array( 'query' ) ); ?> | |
| 33 | + | |
| 34 | + <?php | |
| 35 | + /** | |
| 36 | + * After render logs atts | |
| 37 | + * | |
| 38 | + * @since 1.4.9 | |
| 39 | + * | |
| 40 | + * @param array $template_args Template received arguments | |
| 41 | + */ | |
| 42 | + do_action( 'gamipress_after_render_logs_atts', $a ); ?> | |
| 43 | + | |
| 44 | + </div> | |
| 45 | + | |
| 46 | + <div class="gamipress-logs-list"> | |
| 47 | + | |
| 48 | + <?php | |
| 49 | + /** | |
| 50 | + * Before render logs list | |
| 51 | + * | |
| 52 | + * @since 1.0.0 | |
| 53 | + * | |
| 54 | + * @param array $template_args Template received arguments | |
| 55 | + */ | |
| 56 | + do_action( 'gamipress_before_render_logs_list', $a ); ?> | |
| 57 | + | |
| 58 | + <?php if( $a['query']->found_results > 0 ) : ?> | |
| 59 | + | |
| 60 | + <?php foreach( $logs as $log ) : ?> | |
| 61 | + | |
| 62 | + <?php | |
| 63 | + /** | |
| 64 | + * Before render log | |
| 65 | + * | |
| 66 | + * @since 1.0.0 | |
| 67 | + * | |
| 68 | + * @param integer $log_id The Log ID | |
| 69 | + * @param array $template_args Template received arguments | |
| 70 | + */ | |
| 71 | + do_action( 'gamipress_before_render_log', $log->log_id, $a ); | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * Filters the log title | |
| 75 | + * | |
| 76 | + * @since 1.0.0 | |
| 77 | + * | |
| 78 | + * @param string $log_title The Log title to render | |
| 79 | + * @param integer $log_id The Log ID | |
| 80 | + * @param array $template_args Template received arguments | |
| 81 | + * | |
| 82 | + * @return string | |
| 83 | + */ | |
| 84 | + $log_title = apply_filters( 'gamipress_render_log_title', $log->title, $log->log_id, $a ); ?> | |
| 85 | + | |
| 86 | + <div id="gamipress-log-<?php echo esc_attr( $log->log_id ); ?>" class="gamipress-log"><?php echo $log_title; ?></div> | |
| 87 | + | |
| 88 | + <?php | |
| 89 | + /** | |
| 90 | + * After render log | |
| 91 | + * | |
| 92 | + * @since 1.0.0 | |
| 93 | + * | |
| 94 | + * @param integer $log_id The Log ID | |
| 95 | + * @param array $template_args Template received arguments | |
| 96 | + */ | |
| 97 | + do_action( 'gamipress_after_render_log', $log->log_id, $a ); ?> | |
| 98 | + | |
| 99 | + <?php endforeach; ?> | |
| 100 | + | |
| 101 | + <?php else : ?> | |
| 102 | + | |
| 103 | + <p id="gamipress-logs-no-results"><?php echo __( 'You have no logs registered yet.', 'gamipress' ); ?></p> | |
| 104 | + | |
| 105 | + <?php endif; ?> | |
| 106 | + | |
| 107 | + <?php | |
| 108 | + /** | |
| 109 | + * After render logs list | |
| 110 | + * | |
| 111 | + * @since 1.0.0 | |
| 112 | + * | |
| 113 | + * @param array $template_args Template received arguments | |
| 114 | + */ | |
| 115 | + do_action( 'gamipress_after_render_logs_list', $a ); ?> | |
| 116 | + | |
| 117 | + </div> | |
| 118 | + | |
| 119 | + <?php // Pagination | |
| 120 | + if( $a['pagination'] === 'yes' ) : ?> | |
| 121 | + | |
| 122 | + <?php | |
| 123 | + /** | |
| 124 | + * Before render logs list pagination | |
| 125 | + * | |
| 126 | + * @since 1.4.9 | |
| 127 | + * | |
| 128 | + * @param array $template_args Template received arguments | |
| 129 | + */ | |
| 130 | + do_action( 'gamipress_before_render_logs_list_pagination', $a ); ?> | |
| 131 | + | |
| 132 | + <div id="gamipress-logs-pagination" class="gamipress-logs-pagination navigation"> | |
| 133 | + | |
| 134 | + <?php echo paginate_links( array( | |
| 135 | + 'base' => str_replace( 999999, '%#%', esc_url( get_pagenum_link( 999999 ) ) ), | |
| 136 | + 'format' => '?paged=%#%', | |
| 137 | + 'current' => max( 1, get_query_var( 'paged' ) ), | |
| 138 | + 'total' => ceil( $a['query']->found_results / $a['limit'] ) | |
| 139 | + ) ); ?> | |
| 140 | + | |
| 141 | + </div> | |
| 142 | + | |
| 143 | + <?php | |
| 144 | + /** | |
| 145 | + * After render logs list pagination | |
| 146 | + * | |
| 147 | + * @since 1.4.9 | |
| 148 | + * | |
| 149 | + * @param array $template_args Template received arguments | |
| 150 | + */ | |
| 151 | + do_action( 'gamipress_after_render_logs_list_pagination', $a ); ?> | |
| 152 | + | |
| 153 | + <?php // Loading spinner ?> | |
| 154 | + <div id="gamipress-logs-spinner" class="gamipress-spinner" style="display: none;"></div> | |
| 155 | + | |
| 156 | + <?php endif; ?> | |
| 157 | + | |
| 158 | +</div> | |