@@ -170,32 +170,18 @@ public function get_columns() {
170170 $ columns = array (
171171 'date ' => __ ( 'Date ' , 'aryo-activity-log ' ),
172172 'author ' => __ ( 'User ' , 'aryo-activity-log ' ),
173- 'ip ' => __ ( 'IP ' , 'aryo-activity-log ' ),
174173 'source ' => __ ( 'Source ' , 'aryo-activity-log ' ),
175174 'type ' => __ ( 'Topic ' , 'aryo-activity-log ' ),
176175 'label ' => __ ( 'Context ' , 'aryo-activity-log ' ),
177176 'description ' => __ ( 'Meta ' , 'aryo-activity-log ' ),
178177 'action ' => __ ( 'Action ' , 'aryo-activity-log ' ),
179178 );
180179
181- if ( ! $ this ->is_store_ip_address () ) {
182- unset( $ columns ['ip ' ] );
183- }
184-
185- if ( ! AAL_Maintenance::is_schema_ready ( '1.1 ' ) ) {
186- unset( $ columns ['source ' ] );
187- }
188-
189180 return $ columns ;
190181 }
191182
192- private function is_store_ip_address () {
193- return 'no-collect-ip ' !== AAL_Main::instance ()->settings ->get_option ( 'log_visitor_ip_source ' );
194- }
195-
196183 public function get_sortable_columns () {
197184 return array (
198- 'ip ' => array ( 'hist_ip ' , 'desc ' ),
199185 'date ' => array ( 'hist_time ' , true ),
200186 );
201187 }
@@ -344,10 +330,6 @@ public function column_default( $item, $column_name ) {
344330 $ return .= '<br /> ' . date_i18n ( get_option ( 'time_format ' ), $ item ->hist_time );
345331 break ;
346332
347- case 'ip ' :
348- $ return = '<a href=" ' . $ this ->get_filtered_link ( 'filter_ip ' , $ item ->hist_ip ) . '"> ' . esc_html ( $ item ->hist_ip ) . '</a> ' ;
349- break ;
350-
351333 default :
352334 if ( isset ( $ item ->$ column_name ) ) {
353335 $ return = $ item ->$ column_name ;
@@ -381,39 +363,46 @@ public function column_author( $item ) {
381363 }
382364
383365 public function column_source ( $ item ) {
384- $ raw = isset ( $ item ->request_source ) ? $ item ->request_source : '' ;
385- if ( '' === $ raw ) {
386- return '' ;
387- }
366+ $ parts = array ();
388367
389- $ parsed = AAL_API ::parse_request_source ( $ raw );
390- $ badges = '' ;
391- $ channel_labels = AAL_API ::get_channel_labels ();
368+ $ raw = isset ( $ item ->request_source ) ? $ item ->request_source : '' ;
369+ if ( '' !== $ raw ) {
370+ $ parsed = AAL_API ::parse_request_source ( $ raw );
371+ $ channel_labels = AAL_API ::get_channel_labels ();
372+
373+ if ( ! empty ( $ parsed ['channel ' ] ) && isset ( $ channel_labels [ $ parsed ['channel ' ] ] ) ) {
374+ $ parts [] = sprintf (
375+ '<a href="%s" class="aal-source-badge aal-source-badge--channel">%s</a> ' ,
376+ esc_url ( $ this ->get_filtered_link ( 'sourceshow ' , $ parsed ['channel ' ] ) ),
377+ esc_html ( $ channel_labels [ $ parsed ['channel ' ] ] )
378+ );
379+ }
392380
393- if ( ! empty ( $ parsed ['channel ' ] ) && isset ( $ channel_labels [ $ parsed ['channel ' ] ] ) ) {
394- $ badges .= sprintf (
395- '<a href="%s" class="aal-source-badge aal-source-badge--channel">%s</a> ' ,
396- esc_url ( $ this ->get_filtered_link ( 'sourceshow ' , $ parsed ['channel ' ] ) ),
397- esc_html ( $ channel_labels [ $ parsed ['channel ' ] ] )
398- );
381+ if ( ! empty ( $ parsed ['app_name ' ] ) ) {
382+ $ parts [] = sprintf (
383+ '<a href="%s" class="aal-source-badge aal-source-badge--app" title="%s">%s</a> ' ,
384+ esc_url ( $ this ->get_filtered_link ( 'sourceshow ' , 'app_password ' ) ),
385+ esc_attr__ ( 'Application Password ' , 'aryo-activity-log ' ),
386+ esc_html ( $ parsed ['app_name ' ] )
387+ );
388+ } elseif ( '' === $ parsed ['app_name ' ] && false !== strpos ( $ raw , 'app: ' ) ) {
389+ $ parts [] = sprintf (
390+ '<a href="%s" class="aal-source-badge aal-source-badge--app">%s</a> ' ,
391+ esc_url ( $ this ->get_filtered_link ( 'sourceshow ' , 'app_password ' ) ),
392+ esc_html__ ( 'App Password ' , 'aryo-activity-log ' )
393+ );
394+ }
399395 }
400396
401- if ( ! empty ( $ parsed ['app_name ' ] ) ) {
402- $ badges .= sprintf (
403- '<a href="%s" class="aal-source-badge aal-source-badge--app" title="%s">%s</a> ' ,
404- esc_url ( $ this ->get_filtered_link ( 'sourceshow ' , 'app_password ' ) ),
405- esc_attr__ ( 'Application Password ' , 'aryo-activity-log ' ),
406- esc_html ( $ parsed ['app_name ' ] )
407- );
408- } elseif ( '' === $ parsed ['app_name ' ] && false !== strpos ( $ raw , 'app: ' ) ) {
409- $ badges .= sprintf (
410- '<a href="%s" class="aal-source-badge aal-source-badge--app">%s</a> ' ,
411- esc_url ( $ this ->get_filtered_link ( 'sourceshow ' , 'app_password ' ) ),
412- esc_html__ ( 'App Password ' , 'aryo-activity-log ' )
397+ if ( ! empty ( $ item ->hist_ip ) && 'no-collect-ip ' !== AAL_Main::instance ()->settings ->get_option ( 'log_visitor_ip_source ' ) ) {
398+ $ parts [] = sprintf (
399+ '<a href="%s">%s</a> ' ,
400+ esc_url ( $ this ->get_filtered_link ( 'filter_ip ' , $ item ->hist_ip ) ),
401+ esc_html ( $ item ->hist_ip )
413402 );
414403 }
415404
416- return $ badges ;
405+ return implode ( ' <br> ' , $ parts ) ;
417406 }
418407
419408 public function column_type ( $ item ) {
@@ -838,7 +827,7 @@ public function prepare_items() {
838827
839828 if ( isset ( $ _REQUEST ['s ' ] ) ) {
840829 $ search_esc_like = '% ' . $ wpdb ->esc_like ( $ _REQUEST ['s ' ] ) . '% ' ;
841- $ where .= $ wpdb ->prepare ( ' AND (`object_name` LIKE %s OR `object_subtype` LIKE %s) ' , $ search_esc_like , $ search_esc_like );
830+ $ where .= $ wpdb ->prepare ( ' AND (`object_name` LIKE %s OR `object_subtype` LIKE %s OR `hist_ip` LIKE %s) ' , $ search_esc_like , $ search_esc_like , $ search_esc_like );
842831 }
843832
844833 $ offset = ( $ this ->get_pagenum () - 1 ) * $ items_per_page ;
0 commit comments