| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template form search author field for custom post type of course. |
| 4 |
* |
| 5 |
* @since 4.2.6.9 |
| 6 |
* @version 1.0.0 |
| 7 |
*/ |
| 8 |
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; |
| 9 |
|
| 10 |
// Check condition show field search by author for post. |
| 11 |
$show_search_author_field = 0; |
| 12 |
if ( ! $screen instanceof WP_Screen ) { |
| 13 |
return; |
| 14 |
} |
| 15 |
$course_item_types = learn_press_get_course_item_types(); |
| 16 |
$screens_show_search_author_field = [ |
| 17 |
'edit-' . LP_COURSE_CPT, |
| 18 |
'edit-' . LP_QUESTION_CPT, |
| 19 |
'edit-' . LP_ORDER_CPT, |
| 20 |
]; |
| 21 |
|
| 22 |
foreach ( $course_item_types as $type ) { |
| 23 |
$screens_show_search_author_field[] = 'edit-' . $type; |
| 24 |
} |
| 25 |
|
| 26 |
$show_search_author_field = in_array( $screen->id, $screens_show_search_author_field ) ? 1 : 0; |
| 27 |
if ( ! $show_search_author_field ) { |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* @uses WP_List_Table::search_box() |
| 33 |
* |
| 34 |
* HTML return same search_box method |
| 35 |
*/ |
| 36 |
global $typenow; |
| 37 |
$post_type = $typenow; |
| 38 |
$post_type_object = get_post_type_object( $post_type ); |
| 39 |
|
| 40 |
$input_id = 'post-search-input'; |
| 41 |
|
| 42 |
if ( ! empty( $_REQUEST['orderby'] ) ) { |
| 43 |
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
| 44 |
} |
| 45 |
if ( ! empty( $_REQUEST['order'] ) ) { |
| 46 |
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
| 47 |
} |
| 48 |
if ( ! empty( $_REQUEST['post_mime_type'] ) ) { |
| 49 |
echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
| 50 |
} |
| 51 |
if ( ! empty( $_REQUEST['detached'] ) ) { |
| 52 |
echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
| 53 |
} |
| 54 |
|
| 55 |
$value_search = LP_Request::get_param( 's', '' ); |
| 56 |
?> |
| 57 |
<p class="search-box"> |
| 58 |
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"> |
| 59 |
<?php echo $post_type_object->labels->search_items; ?>: |
| 60 |
</label> |
| 61 |
<input type="search" |
| 62 |
id="<?php echo esc_attr( $input_id ); ?>" |
| 63 |
name="s" |
| 64 |
placeholder="<?php _e( 'Search', 'learnpress' ); ?>" |
| 65 |
value="<?php echo esc_attr( $value_search ) ?>"/> |
| 66 |
<?php submit_button( $post_type_object->labels->search_items, '', '', false, array( 'id' => 'search-submit' ) ); ?> |
| 67 |
</p> |
| 68 |
|