@@ 74-126 (lines=53) @@ | ||
71 | * @since 1.7.0 |
|
72 | * @return void |
|
73 | */ |
|
74 | public function prepare_items() { |
|
75 | global $per_page; |
|
76 | ||
77 | // Handle orderby (needs work) |
|
78 | $orderby = ''; |
|
79 | if ( !empty( $_GET['orderby'] ) ) { |
|
80 | if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
81 | $orderby = esc_html( $_GET['orderby'] ); |
|
82 | } // End If Statement |
|
83 | } |
|
84 | ||
85 | // Handle order |
|
86 | $order = 'ASC'; |
|
87 | if ( !empty( $_GET['order'] ) ) { |
|
88 | $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
89 | } |
|
90 | ||
91 | // Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids |
|
92 | $search = false; |
|
93 | if ( !empty( $_GET['s'] ) ) { |
|
94 | $search = esc_html( $_GET['s'] ); |
|
95 | } // End If Statement |
|
96 | $this->search = $search; |
|
97 | ||
98 | $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
99 | $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
100 | ||
101 | $paged = $this->get_pagenum(); |
|
102 | $offset = 0; |
|
103 | if ( !empty($paged) ) { |
|
104 | $offset = $per_page * ( $paged - 1 ); |
|
105 | } // End If Statement |
|
106 | ||
107 | $args = array( |
|
108 | 'number' => $per_page, |
|
109 | 'offset' => $offset, |
|
110 | 'orderby' => $orderby, |
|
111 | 'order' => $order, |
|
112 | ); |
|
113 | if ( $this->search ) { |
|
114 | $args['search'] = $this->search; |
|
115 | } // End If Statement |
|
116 | ||
117 | $this->items = $this->get_lesson_statuses( $args ); |
|
118 | ||
119 | $total_items = $this->total_items; |
|
120 | $total_pages = ceil( $total_items / $per_page ); |
|
121 | $this->set_pagination_args( array( |
|
122 | 'total_items' => $total_items, |
|
123 | 'total_pages' => $total_pages, |
|
124 | 'per_page' => $per_page |
|
125 | ) ); |
|
126 | } |
|
127 | ||
128 | /** |
|
129 | * Generate a csv report with different parameters, pagination, columns and table elements |
@@ 75-127 (lines=53) @@ | ||
72 | * @since 1.7.0 |
|
73 | * @return void |
|
74 | */ |
|
75 | public function prepare_items() { |
|
76 | global $per_page; |
|
77 | ||
78 | // Handle orderby (needs work) |
|
79 | $orderby = ''; |
|
80 | if ( !empty( $_GET['orderby'] ) ) { |
|
81 | if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
82 | $orderby = esc_html( $_GET['orderby'] ); |
|
83 | } // End If Statement |
|
84 | } |
|
85 | ||
86 | // Handle order |
|
87 | $order = 'ASC'; |
|
88 | if ( !empty( $_GET['order'] ) ) { |
|
89 | $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
90 | } |
|
91 | ||
92 | // Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids |
|
93 | $search = false; |
|
94 | if ( !empty( $_GET['s'] ) ) { |
|
95 | $search = esc_html( $_GET['s'] ); |
|
96 | } // End If Statement |
|
97 | $this->search = $search; |
|
98 | ||
99 | $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
100 | $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
101 | ||
102 | $paged = $this->get_pagenum(); |
|
103 | $offset = 0; |
|
104 | if ( !empty($paged) ) { |
|
105 | $offset = $per_page * ( $paged - 1 ); |
|
106 | } // End If Statement |
|
107 | ||
108 | $args = array( |
|
109 | 'number' => $per_page, |
|
110 | 'offset' => $offset, |
|
111 | 'orderby' => $orderby, |
|
112 | 'order' => $order, |
|
113 | ); |
|
114 | if ( $this->search ) { |
|
115 | $args['search'] = $this->search; |
|
116 | } // End If Statement |
|
117 | ||
118 | $this->items = $this->get_course_statuses( $args ); |
|
119 | ||
120 | $total_items = $this->total_items; |
|
121 | $total_pages = ceil( $total_items / $per_page ); |
|
122 | $this->set_pagination_args( array( |
|
123 | 'total_items' => $total_items, |
|
124 | 'total_pages' => $total_pages, |
|
125 | 'per_page' => $per_page |
|
126 | ) ); |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * Generate a csv report with different parameters, pagination, columns and table elements |