| @@ -1,0 +1,167 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Achievements template | |
| 4 | + * | |
| 5 | + * This template can be overridden by copying it to yourtheme/gamipress/achievements.php | |
| 6 | + * To override a specific achievement type just copy it as yourtheme/gamipress/achievements-{achievement-type}.php | |
| 7 | + */ | |
| 8 | +global $gamipress_template_args; | |
| 9 | + | |
| 10 | +// Shorthand | |
| 11 | +$a = $gamipress_template_args; ?> | |
| 12 | + | |
| 13 | +<div id="gamipress-achievements-list" class="gamipress-achievements-list"> | |
| 14 | + | |
| 15 | + <?php | |
| 16 | + /** | |
| 17 | + * Before render achievements list | |
| 18 | + * | |
| 19 | + * @since 1.0.0 | |
| 20 | + * | |
| 21 | + * @param array $template_args Template received arguments | |
| 22 | + */ | |
| 23 | + do_action( 'gamipress_before_render_achievements_list', $a ); ?> | |
| 24 | + | |
| 25 | + <div id="gamipress-achievements-filters-wrap"> | |
| 26 | + | |
| 27 | + <?php | |
| 28 | + /** | |
| 29 | + * Before render achievements list filters | |
| 30 | + * | |
| 31 | + * @since 1.0.0 | |
| 32 | + * | |
| 33 | + * @param array $template_args Template received arguments | |
| 34 | + */ | |
| 35 | + do_action( 'gamipress_before_render_achievements_list_filters', $a ); ?> | |
| 36 | + | |
| 37 | + <?php // Hidden fields for ajax request | |
| 38 | + echo gamipress_array_as_hidden_inputs( $a, array( 'filter', 'search', 'query' ) ); ?> | |
| 39 | + | |
| 40 | + <?php // Filter | |
| 41 | + if ( $a['filter'] === 'no' ) : ?> | |
| 42 | + | |
| 43 | + <input type="hidden" name="achievements_list_filter" id="achievements_list_filter" value="<?php echo esc_attr( $a['filter_value'] ); ?>"> | |
| 44 | + | |
| 45 | + <?php elseif( is_user_logged_in() ) : ?> | |
| 46 | + | |
| 47 | + <div id="gamipress-achievements-filter"> | |
| 48 | + | |
| 49 | + <label for="achievements_list_filter"><?php _e( 'Filter:', 'gamipress' ); ?></label> | |
| 50 | + | |
| 51 | + <?php | |
| 52 | + $filter_options = array( | |
| 53 | + 'all' => sprintf( __( 'All %s', 'gamipress' ), $a['plural_label'] ), | |
| 54 | + 'completed' => sprintf( __( 'Completed %s', 'gamipress' ), $a['plural_label'] ), | |
| 55 | + 'not-completed' => sprintf( __( 'Not Completed %s', 'gamipress' ), $a['plural_label'] ), | |
| 56 | + ); | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * Achievements list filter options | |
| 60 | + * | |
| 61 | + * @since 1.5.9 | |
| 62 | + * | |
| 63 | + * @param array $filter_options Filter options | |
| 64 | + * @param array $template_args Template received arguments | |
| 65 | + * | |
| 66 | + * @return array | |
| 67 | + */ | |
| 68 | + $filter_options = apply_filters( 'gamipress_achievements_list_filter_options', $filter_options, $a ); | |
| 69 | + ?> | |
| 70 | + | |
| 71 | + <select name="achievements_list_filter" id="achievements_list_filter"> | |
| 72 | + | |
| 73 | + <?php // Loop all filter options | |
| 74 | + foreach( $filter_options as $value => $label ) :?> | |
| 75 | + <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $a['filter_value'], $value ); ?>><?php echo $label; ?></option> | |
| 76 | + <?php endforeach; ?> | |
| 77 | + | |
| 78 | + </select> | |
| 79 | + | |
| 80 | + </div> | |
| 81 | + | |
| 82 | + <?php endif; | |
| 83 | + | |
| 84 | + // Search | |
| 85 | + if ( $a['search'] === 'yes' ) : | |
| 86 | + $search = isset( $_POST['achievements_list_search'] ) ? sanitize_text_field( $_POST['achievements_list_search'] ) : ''; | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * Achievements search button text | |
| 90 | + * | |
| 91 | + * @since 1.4.5 | |
| 92 | + * | |
| 93 | + * @param string $search_button_text The search button text | |
| 94 | + * @param array $template_args Template received arguments | |
| 95 | + * | |
| 96 | + * @return string | |
| 97 | + */ | |
| 98 | + $search_button_text = apply_filters( 'gamipress_achievements_search_button_text', __( 'Go', 'gamipress' ), $a ); ?> | |
| 99 | + | |
| 100 | + <div id="gamipress-achievements-search"> | |
| 101 | + | |
| 102 | + <form id="gamipress-achievements-search-form" action="" method="post"> | |
| 103 | + <label for="achievements_list_search"><?php _e( 'Search:', 'gamipress' ); ?></label> | |
| 104 | + <input type="text" id="gamipress-achievements-search-input" name="achievements_list_search" value="<?php echo esc_attr( $search ); ?>"> | |
| 105 | + <input type="submit" id="gamipress-achievements-search-submit" name="achievements_list_search_go" value="<?php echo esc_attr( $search_button_text ); ?>"> | |
| 106 | + </form> | |
| 107 | + | |
| 108 | + </div> | |
| 109 | + | |
| 110 | + <?php endif; ?> | |
| 111 | + | |
| 112 | + <?php | |
| 113 | + /** | |
| 114 | + * After render achievements list filters | |
| 115 | + * | |
| 116 | + * @since 1.0.0 | |
| 117 | + * | |
| 118 | + * @param array $template_args Template received arguments | |
| 119 | + */ | |
| 120 | + do_action( 'gamipress_after_render_achievements_list_filters', $a ); ?> | |
| 121 | + | |
| 122 | + </div><!-- #gamipress-achievements-filters-wrap --> | |
| 123 | + | |
| 124 | + <?php // Content Container ?> | |
| 125 | + <div id="gamipress-achievements-container" class="gamipress-achievements-container gamipress-columns-<?php echo esc_attr( $a['columns'] ); ?> gamipress-columns-small-<?php echo esc_attr( $a['columns_small'] ); ?>"> | |
| 126 | + <?php echo $a['query']['achievements']; ?> | |
| 127 | + </div> | |
| 128 | + | |
| 129 | + <?php // Hidden fields ?> | |
| 130 | + <input type="hidden" id="gamipress-achievements-offset" value="<?php echo esc_attr( $a['query']['offset'] ); ?>"> | |
| 131 | + <input type="hidden" id="gamipress-achievements-count" value="<?php echo esc_attr( $a['query']['achievement_count'] ); ?>"> | |
| 132 | + | |
| 133 | + <?php // Load More button ?> | |
| 134 | + <?php if ( $a['load_more'] === 'yes' ) : | |
| 135 | + $hide_load_more = $a['query']['query_count'] <= $a['query']['offset']; | |
| 136 | + | |
| 137 | + /** | |
| 138 | + * Achievements load more button text | |
| 139 | + * | |
| 140 | + * @since 1.4.5 | |
| 141 | + * | |
| 142 | + * @param string $load_more_button_text The load more button text | |
| 143 | + * @param array $template_args Template received arguments | |
| 144 | + * | |
| 145 | + * @return string | |
| 146 | + */ | |
| 147 | + $load_more_button_text = apply_filters( 'gamipress_achievements_load_more_button_text', __( 'Load More', 'gamipress' ), $a ); ?> | |
| 148 | + | |
| 149 | + <button type="button" id="gamipress-achievements-load-more" class="gamipress-load-more-button" <?php if( $hide_load_more ) : ?>style="display:none;"<?php endif; ?>><?php echo $load_more_button_text; ?></button> | |
| 150 | + | |
| 151 | + <?php endif; ?> | |
| 152 | + | |
| 153 | + <?php // Loading spinner ?> | |
| 154 | + <div id="gamipress-achievements-spinner" class="gamipress-spinner" style="display: none;"></div> | |
| 155 | + | |
| 156 | + <?php | |
| 157 | + /** | |
| 158 | + * After render achievements list | |
| 159 | + * | |
| 160 | + * @since 1.0.0 | |
| 161 | + * | |
| 162 | + * @param array $template_args Template received arguments | |
| 163 | + */ | |
| 164 | + do_action( 'gamipress_after_render_achievements_list', $a ); ?> | |
| 165 | + | |
| 166 | +</div> | |
| 167 | + | |