| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
$sort_by = ""; |
| 7 |
$sort_by_options = uwp_get_sort_by_order_list(); |
| 8 |
|
| 9 |
if ( isset( $_REQUEST['uwp_sort_by'] ) && $_REQUEST['uwp_sort_by'] != '' ) { |
| 10 |
$sort_by = strip_tags( $_REQUEST['uwp_sort_by'] ); |
| 11 |
|
| 12 |
if ( ! isset( $sort_by_options[ $sort_by ] ) ) { |
| 13 |
$sort_by = ""; |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
do_action( 'uwp_users_loop_actions' ); |
| 18 |
?> |
| 19 |
<div class="container mb-3 overflow-visible"> |
| 20 |
<div class="row"> |
| 21 |
<div class="col-sm-8 p-0"> |
| 22 |
<?php |
| 23 |
if ( is_uwp_users_page() || is_admin() ) { |
| 24 |
echo do_shortcode( '[uwp_users_search]' ); |
| 25 |
} |
| 26 |
?> |
| 27 |
</div> |
| 28 |
<div class="col-sm-4 p-0"> |
| 29 |
<div class="btn-toolbar justify-content-end" role="toolbar" aria-label="Toolbar with button groups"> |
| 30 |
<div class="btn-group btn-group-sm mr-2 uwp-user-sort" role="group"> |
| 31 |
<?php |
| 32 |
if( ! empty( $sort_by_options[ $sort_by ] ) ) { |
| 33 |
$content = $sort_by_options[ $sort_by ]; |
| 34 |
} else { |
| 35 |
$content = __( "Sort By", "userswp" ); |
| 36 |
} |
| 37 |
|
| 38 |
aui()->button( array( |
| 39 |
'type' => 'button', |
| 40 |
'id' => 'uwp-user-sort', |
| 41 |
'icon' => 'fas fa-sort', |
| 42 |
'class' => 'btn btn-outline-primary rounded-right', |
| 43 |
'content' => esc_html( $content ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 44 |
'extra_attributes' => array('data-toggle'=>'dropdown', 'aria-haspopup'=>'true', 'aria-expanded'=>'false') |
| 45 |
), true ); |
| 46 |
?> |
| 47 |
<div class="dropdown-menu mt-3" aria-labelledby="uwp-user-sort"> |
| 48 |
<h6 class="dropdown-header"><?php esc_html_e( "Sort Options", "userswp" ); ?></h6> |
| 49 |
<?php |
| 50 |
$base_link = uwp_get_page_id( 'users_page', true ); |
| 51 |
|
| 52 |
$query_string = array(); |
| 53 |
$default_query = array('uwp_sort_by'); |
| 54 |
|
| 55 |
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
| 56 |
$query_string_temp = explode( '&',$_SERVER['QUERY_STRING'] ); |
| 57 |
|
| 58 |
if ( ! empty( $query_string_temp ) && is_array( $query_string_temp ) ) { |
| 59 |
foreach ( $query_string_temp as $string ) { |
| 60 |
$string_temp = explode( '=', $string ); |
| 61 |
$key = ! empty( $string_temp[0] ) ? $string_temp[0] : ''; |
| 62 |
$value = ! empty( $string_temp[1] ) ? $string_temp[1] : ''; |
| 63 |
|
| 64 |
if ( ! empty( $key ) && ! empty( $value ) && ! in_array( $key, $default_query ) ) { |
| 65 |
$query_string[ $key ] = ! empty( $value ) ? esc_attr( $value ) : ''; |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
if ( ! empty( $query_string ) ) { |
| 72 |
$base_link = add_query_arg( $query_string, $base_link ); |
| 73 |
} |
| 74 |
|
| 75 |
if ( ! empty( $_REQUEST['uwp_sort_by'] ) ) { |
| 76 |
$base_link = remove_query_arg( array( 'uwp_sort_by' ), $base_link ); |
| 77 |
} |
| 78 |
|
| 79 |
foreach ( $sort_by_options as $key => $val ) { |
| 80 |
$active = isset( $_REQUEST['uwp_sort_by'] ) && $_REQUEST['uwp_sort_by'] == $key ? ' active' : ''; |
| 81 |
|
| 82 |
aui()->button( array( |
| 83 |
'type' => 'a', |
| 84 |
'href' => esc_url_raw( add_query_arg( array( 'uwp_sort_by' => $key ), $base_link ) ), |
| 85 |
'class' => esc_html( 'dropdown-item' . $active ), |
| 86 |
'content' => esc_html( $val ), |
| 87 |
'extra_attributes' => array( 'rel' => 'nofollow' ) |
| 88 |
), true ); |
| 89 |
} |
| 90 |
|
| 91 |
if ( ! empty( $_REQUEST['uwp_sort_by'] ) ) { |
| 92 |
echo '<div class="dropdown-divider"></div>'; |
| 93 |
aui()->button( array( |
| 94 |
'type' => 'a', |
| 95 |
'href' => esc_url_raw( $base_link ), |
| 96 |
'class' => 'dropdown-item', |
| 97 |
'content' => esc_html__( "Clear Sort", "userswp" ), |
| 98 |
'extra_attributes' => array( 'rel' => 'nofollow' ) |
| 99 |
), true ); |
| 100 |
} ?> |
| 101 |
</div> |
| 102 |
</div> |
| 103 |
|
| 104 |
<div class="btn-group btn-group-sm uwp-list-view-select" role="group" aria-label="First group"> |
| 105 |
<div class="btn-group btn-group-sm" role="group"> |
| 106 |
<?php |
| 107 |
aui()->button( array( |
| 108 |
'type' => 'button', |
| 109 |
'id' => 'uwp-list-view-select-grid', |
| 110 |
'class' => 'btn btn-outline-primary rounded-right uwp-list-view-select-grid', |
| 111 |
'icon' => 'fas fa-th', |
| 112 |
'extra_attributes' => array( 'data-toggle' => 'dropdown', 'aria-haspopup' => 'true', 'aria-expanded' => 'false' ) |
| 113 |
), true ); |
| 114 |
?> |
| 115 |
<div class="dropdown-menu dropdown-menu-right mt-3 p-0" aria-labelledby="uwp-list-view-select-grid"> |
| 116 |
<?php |
| 117 |
aui()->button( array( |
| 118 |
'type' => 'button', |
| 119 |
'class' => 'dropdown-item', |
| 120 |
'content' => esc_html( wp_sprintf( __( "Grid %d","userswp" ), 1 ) ), |
| 121 |
'onclick' => 'uwp_list_view_select(1);return false;', |
| 122 |
'extra_attributes' => array( 'data-gridview' => '1' ) |
| 123 |
), true ); |
| 124 |
|
| 125 |
aui()->button( array( |
| 126 |
'type' => 'button', |
| 127 |
'class' => 'dropdown-item', |
| 128 |
'content' => esc_html( wp_sprintf( __( "Grid %d","userswp" ), 2 ) ), |
| 129 |
'onclick' => 'uwp_list_view_select(2);return false;', |
| 130 |
'extra_attributes' => array( 'data-gridview' => '2' ) |
| 131 |
), true ); |
| 132 |
|
| 133 |
aui()->button( array( |
| 134 |
'type' => 'button', |
| 135 |
'class' => 'dropdown-item', |
| 136 |
'content' => esc_html( wp_sprintf( __( "Grid %d","userswp" ), 3 ) ), |
| 137 |
'onclick' => 'uwp_list_view_select(3);return false;', |
| 138 |
'extra_attributes' => array( 'data-gridview' => '3' ) |
| 139 |
), true ); |
| 140 |
|
| 141 |
aui()->button( array( |
| 142 |
'type' => 'button', |
| 143 |
'class' => 'dropdown-item', |
| 144 |
'content' => esc_html( wp_sprintf( __( "Grid %d","userswp" ), 4 ) ), |
| 145 |
'onclick' => 'uwp_list_view_select(4);return false;', |
| 146 |
'extra_attributes' => array( 'data-gridview' => '4' ) |
| 147 |
), true ); |
| 148 |
|
| 149 |
aui()->button( array( |
| 150 |
'type' => 'button', |
| 151 |
'class' => 'dropdown-item', |
| 152 |
'content' => esc_html( wp_sprintf( __( "Grid %d","userswp" ), 5 ) ), |
| 153 |
'onclick' => 'uwp_list_view_select(5);return false;', |
| 154 |
'extra_attributes' => array( 'data-gridview' => '5' ) |
| 155 |
), true ); |
| 156 |
?> |
| 157 |
</div> |
| 158 |
</div> |
| 159 |
</div> |
| 160 |
</div> |
| 161 |
</div> |
| 162 |
<?php do_action( 'uwp_advanced_search_form' ); ?> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
<?php do_action( 'uwp_after_users_loop_actions' ); ?> |