summaryrefslogtreecommitdiff
blob: e5336c5bdbb9d6db6e35a74e2320d5ebf742e630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

if( ! class_exists( 'WP_Comments_List_Table' ) )
	require_once( ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php' );

class Jetpack_Omnisearch_Comments extends WP_Comments_List_Table {
	static $instance;
	public $checkbox = false;

	function __construct() {
		self::$instance = $this;
		add_filter( 'omnisearch_results', array( $this, 'search'), 10, 2 );
	}

	function search( $results, $search_term ) {
		$search_url = esc_url( admin_url( sprintf( 'edit-comments.php?s=%s', urlencode( $search_term ) ) ) );
		$search_link = sprintf( ' <a href="%s" class="add-new-h2">%s</a>', $search_url, esc_html__('Search Comments', 'jetpack') );
		$html = '<h2>' . esc_html__('Comments', 'jetpack') . $search_link . '</h2>';
		parent::__construct();

		ob_start();
		$this->prepare_items();
		$this->_column_headers = array( $this->get_columns(), array(), array() );
		$this->display();
		$html .= ob_get_clean();

		$label = __( 'Comments', 'jetpack' );
		$results[ $label ] = $html;
		return $results;
	}

	function get_per_page( $comment_status = 'all' ) {
		/** This action is documented in modules/omnisearch/omnisearch-core.php */
		return apply_filters( 'omnisearch_num_results', 5 );
	}

	function get_sortable_columns() {
		return array();
	}

	function get_bulk_actions() {
		return array();
	}

	function pagination( $which ) {}

	function extra_tablenav( $which ) {}
}