| 1 |
<?php |
| 2 |
/** |
| 3 |
* HTML for the cloud search tab |
| 4 |
* |
| 5 |
* @package Code_Snippets |
| 6 |
* @subpackage Views |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Code_Snippets; |
| 10 |
|
| 11 |
/** |
| 12 |
* Loaded from manage menu. |
| 13 |
* |
| 14 |
* @var Manage_Menu $this |
| 15 |
*/ |
| 16 |
|
| 17 |
$search_query = isset( $_REQUEST['cloud_search'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['cloud_search'] ) ) : ''; |
| 18 |
$cloud_select = sanitize_key( wp_unslash( $_REQUEST['cloud_select'] ?? '' ) ); |
| 19 |
|
| 20 |
?> |
| 21 |
|
| 22 |
<p class="cloud-search-info"> |
| 23 |
<?php esc_html_e( 'Use the search bar below to search cloud snippets by entering either the name of a codevault or keywords.', 'code-snippets' ); ?> |
| 24 |
|
| 25 |
<small> |
| 26 |
<?php esc_html_e( '(Note: codevault name is case and spelling sensitive and only public snippets will be shown)', 'code-snippets' ); ?> |
| 27 |
</small> |
| 28 |
</p> |
| 29 |
|
| 30 |
<form method="get" action="" id="cloud-search-form"> |
| 31 |
<?php List_Table::required_form_fields( 'search_box' ); ?> |
| 32 |
<label class="screen-reader-text" for="cloud_search"> |
| 33 |
<?php esc_html_e( 'Search cloud snippets', 'code-snippets' ); ?> |
| 34 |
</label> |
| 35 |
<?php |
| 36 |
if ( isset( $_REQUEST['type'] ) ) { |
| 37 |
printf( '<input type="hidden" name="type" value="%s">', esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ) ) ); |
| 38 |
} |
| 39 |
?> |
| 40 |
<div class="heading-box"> |
| 41 |
<p class="cloud-search-heading"> |
| 42 |
<label for="cloud-select-prepend"><?php esc_html_e( 'Search Cloud', 'code-snippets' ); ?></label> |
| 43 |
</p> |
| 44 |
</div> |
| 45 |
<div class="input-group"> |
| 46 |
<select id="cloud-select-prepend" class="select-prepend" name="cloud_select"> |
| 47 |
<option value="term"<?php selected( $cloud_select, 'term' ); ?>> |
| 48 |
<?php esc_html_e( 'Search by keyword(s)', 'code-snippets' ); ?> |
| 49 |
</option> |
| 50 |
<option value="codevault"<?php selected( $cloud_select, 'codevault' ); ?>> |
| 51 |
<?php esc_html_e( 'Name of codevault', 'code-snippets' ); ?> |
| 52 |
</option> |
| 53 |
</select> |
| 54 |
|
| 55 |
<input type="text" id="cloud_search" name="cloud_search" class="cloud_search" |
| 56 |
value="<?php echo esc_html( $search_query ); ?>" |
| 57 |
placeholder="<?php esc_html_e( 'e.g. Remove unused javascript…', 'code-snippets' ); ?>"> |
| 58 |
|
| 59 |
<button type="submit" id="cloud-search-submit" class="button"> |
| 60 |
<?php esc_html_e( 'Search Cloud', 'code-snippets' ); ?> |
| 61 |
<span class="dashicons dashicons-search cloud-search"></span> |
| 62 |
</button> |
| 63 |
</div> |
| 64 |
</form> |
| 65 |
<form method="post" action="" id="cloud-search-results"> |
| 66 |
<input type="hidden" |
| 67 |
id="code_snippets_ajax_nonce" |
| 68 |
value="<?php echo esc_attr( wp_create_nonce( 'code_snippets_manage_ajax' ) ); ?>"> |
| 69 |
<?php |
| 70 |
|
| 71 |
List_Table::required_form_fields(); |
| 72 |
|
| 73 |
if ( $search_query ) { |
| 74 |
$this->cloud_search_list_table->display(); |
| 75 |
} |
| 76 |
|
| 77 |
?> |
| 78 |
</form> |
| 79 |
|