@@ -71,7 +71,7 @@ |
||
71 | 71 | */ |
72 | 72 | include_once WORDPOINTS_DIR . 'components/points/includes/deprecated.php'; |
73 | 73 | |
74 | -if ( is_admin() ) { |
|
74 | +if (is_admin()) { |
|
75 | 75 | |
76 | 76 | // We are on the administration side of the site. |
77 | 77 |
@@ -43,17 +43,17 @@ discard block |
||
43 | 43 | * @param object $log Points log. |
44 | 44 | * @param WordPoints_Points_Logs_Viewing_RestrictionI[] $restrictions Restrictions. |
45 | 45 | */ |
46 | - public function __construct( $log, array $restrictions = array() ) { |
|
46 | + public function __construct($log, array $restrictions = array()) { |
|
47 | 47 | |
48 | 48 | $this->log = $log; |
49 | 49 | |
50 | - foreach ( $restrictions as $restriction ) { |
|
50 | + foreach ($restrictions as $restriction) { |
|
51 | 51 | |
52 | - if ( ! $restriction instanceof WordPoints_Points_Logs_Viewing_RestrictionI ) { |
|
52 | + if ( ! $restriction instanceof WordPoints_Points_Logs_Viewing_RestrictionI) { |
|
53 | 53 | continue; |
54 | 54 | } |
55 | 55 | |
56 | - if ( ! $restriction->applies() ) { |
|
56 | + if ( ! $restriction->applies()) { |
|
57 | 57 | continue; |
58 | 58 | } |
59 | 59 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | $descriptions = array(); |
70 | 70 | |
71 | - foreach ( $this->restrictions as $restriction ) { |
|
71 | + foreach ($this->restrictions as $restriction) { |
|
72 | 72 | |
73 | 73 | $descriptions = array_merge( |
74 | 74 | $descriptions |
@@ -83,28 +83,28 @@ discard block |
||
83 | 83 | * @since 2.2.0 |
84 | 84 | */ |
85 | 85 | public function applies() { |
86 | - return ! empty( $this->restrictions ); |
|
86 | + return ! empty($this->restrictions); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | 90 | * @since 2.2.0 |
91 | 91 | */ |
92 | - public function user_can( $user_id ) { |
|
92 | + public function user_can($user_id) { |
|
93 | 93 | |
94 | - if ( $this->log->blog_id && get_current_blog_id() !== $this->log->blog_id ) { |
|
95 | - $switched = switch_to_blog( $this->log->blog_id ); |
|
94 | + if ($this->log->blog_id && get_current_blog_id() !== $this->log->blog_id) { |
|
95 | + $switched = switch_to_blog($this->log->blog_id); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $user_can = true; |
99 | 99 | |
100 | - foreach ( $this->restrictions as $restriction ) { |
|
101 | - if ( ! $restriction->user_can( $user_id ) ) { |
|
100 | + foreach ($this->restrictions as $restriction) { |
|
101 | + if ( ! $restriction->user_can($user_id)) { |
|
102 | 102 | $user_can = false; |
103 | 103 | break; |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - if ( isset( $switched ) ) { |
|
107 | + if (isset($switched)) { |
|
108 | 108 | restore_current_blog(); |
109 | 109 | } |
110 | 110 |
@@ -32,24 +32,24 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @since 2.2.0 |
34 | 34 | */ |
35 | - public function __construct( $log ) { |
|
35 | + public function __construct($log) { |
|
36 | 36 | |
37 | - $events = wordpoints_hooks()->get_sub_app( 'events' ); |
|
37 | + $events = wordpoints_hooks()->get_sub_app('events'); |
|
38 | 38 | |
39 | 39 | $log_id = $log->id; |
40 | 40 | $event_slug = $log->log_type; |
41 | - $is_reversal = ( 'reverse-' === substr( $log->log_type, 0, 8 ) ); |
|
41 | + $is_reversal = ('reverse-' === substr($log->log_type, 0, 8)); |
|
42 | 42 | |
43 | - if ( $is_reversal ) { |
|
44 | - $event_slug = substr( $log->log_type, 8 ); |
|
43 | + if ($is_reversal) { |
|
44 | + $event_slug = substr($log->log_type, 8); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | // If this is not a log from an event, this doesn't apply. |
48 | - if ( ! $events->is_registered( $event_slug ) ) { |
|
48 | + if ( ! $events->is_registered($event_slug)) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | - if ( $is_reversal ) { |
|
52 | + if ($is_reversal) { |
|
53 | 53 | $log_id = wordpoints_get_points_log_meta( |
54 | 54 | $log_id |
55 | 55 | , 'original_log_id' |
@@ -58,31 +58,31 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | /** @var WordPoints_Entity_Restrictions $entity_restrictions */ |
61 | - $entity_restrictions = wordpoints_entities()->get_sub_app( 'restrictions' ); |
|
61 | + $entity_restrictions = wordpoints_entities()->get_sub_app('restrictions'); |
|
62 | 62 | |
63 | 63 | /** @var WordPoints_Hook_ArgI $arg */ |
64 | - foreach ( $events->get_sub_app( 'args' )->get_children( $event_slug ) as $slug => $arg ) { |
|
64 | + foreach ($events->get_sub_app('args')->get_children($event_slug) as $slug => $arg) { |
|
65 | 65 | |
66 | - $value = wordpoints_get_points_log_meta( $log_id, "{$slug}_guid", true ); |
|
66 | + $value = wordpoints_get_points_log_meta($log_id, "{$slug}_guid", true); |
|
67 | 67 | |
68 | - if ( ! $value ) { |
|
69 | - $value = wordpoints_get_points_log_meta( $log_id, $slug, true ); |
|
68 | + if ( ! $value) { |
|
69 | + $value = wordpoints_get_points_log_meta($log_id, $slug, true); |
|
70 | 70 | |
71 | 71 | // If we don't find the value it may mean that a new arg has been |
72 | 72 | // registered or something. Just skip over it. |
73 | - if ( ! $value ) { |
|
73 | + if ( ! $value) { |
|
74 | 74 | continue; |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | 78 | $entity_slug = $arg->get_entity_slug(); |
79 | - $restriction = $entity_restrictions->get( $value, $entity_slug, 'view' ); |
|
79 | + $restriction = $entity_restrictions->get($value, $entity_slug, 'view'); |
|
80 | 80 | |
81 | - if ( ! $restriction->applies() ) { |
|
81 | + if ( ! $restriction->applies()) { |
|
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - $this->restrictions[ $entity_slug ] = $restriction; |
|
85 | + $this->restrictions[$entity_slug] = $restriction; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | |
102 | 102 | $descriptions = array(); |
103 | 103 | |
104 | - foreach ( $this->restrictions as $entity_slug => $restriction ) { |
|
104 | + foreach ($this->restrictions as $entity_slug => $restriction) { |
|
105 | 105 | |
106 | - $entity = $entities->get( $entity_slug ); |
|
106 | + $entity = $entities->get($entity_slug); |
|
107 | 107 | |
108 | - if ( ! $entity instanceof WordPoints_Entity ) { |
|
108 | + if ( ! $entity instanceof WordPoints_Entity) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - $descriptions[] = sprintf( $string, $entity->get_title() ); |
|
112 | + $descriptions[] = sprintf($string, $entity->get_title()); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return $descriptions; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * @since 2.2.0 |
120 | 120 | */ |
121 | - public function user_can( $user_id ) { |
|
121 | + public function user_can($user_id) { |
|
122 | 122 | |
123 | - foreach ( $this->restrictions as $restriction ) { |
|
124 | - if ( ! $restriction->user_can( $user_id ) ) { |
|
123 | + foreach ($this->restrictions as $restriction) { |
|
124 | + if ( ! $restriction->user_can($user_id)) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @since 2.2.0 |
134 | 134 | */ |
135 | 135 | public function applies() { |
136 | - return ! empty( $this->restrictions ); |
|
136 | + return ! empty($this->restrictions); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @since 2.2.0 |
47 | 47 | */ |
48 | - public function __construct( $log ) { |
|
48 | + public function __construct($log) { |
|
49 | 49 | |
50 | 50 | $this->log = $log; |
51 | 51 | |
52 | 52 | $this->post_id = $this->get_post_id(); |
53 | 53 | |
54 | - if ( ! $this->post_id ) { |
|
54 | + if ( ! $this->post_id) { |
|
55 | 55 | |
56 | 56 | // We remove any reference to the post from the log when it is deleted, |
57 | 57 | // so it is OK to show it publicly. |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | } else { |
61 | 61 | |
62 | 62 | $post_status = get_post_status_object( |
63 | - get_post_status( $this->post_id ) |
|
63 | + get_post_status($this->post_id) |
|
64 | 64 | ); |
65 | 65 | |
66 | - if ( $post_status && $post_status->public ) { |
|
66 | + if ($post_status && $post_status->public) { |
|
67 | 67 | $this->is_public = true; |
68 | 68 | } |
69 | 69 | } |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | * @since 2.2.0 |
74 | 74 | */ |
75 | 75 | public function get_description() { |
76 | - return __( 'This log entry is only visible to users who can view the post.', 'wordpoints' ); |
|
76 | + return __('This log entry is only visible to users who can view the post.', 'wordpoints'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @since 2.2.0 |
81 | 81 | */ |
82 | - public function user_can( $user_id ) { |
|
82 | + public function user_can($user_id) { |
|
83 | 83 | |
84 | - if ( $this->is_public ) { |
|
84 | + if ($this->is_public) { |
|
85 | 85 | return true; |
86 | 86 | } |
87 | 87 | |
88 | 88 | // If the post doesn't have a public status, fall back to the caps API. |
89 | - return user_can( $user_id, 'read_post', $this->post_id ); |
|
89 | + return user_can($user_id, 'read_post', $this->post_id); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @since 2.2.0 |
20 | 20 | */ |
21 | 21 | public function get_description() { |
22 | - return __( 'This log entry is only visible to users who can view the post that the comment is on.', 'wordpoints' ); |
|
22 | + return __('This log entry is only visible to users who can view the post that the comment is on.', 'wordpoints'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | , true |
34 | 34 | ); |
35 | 35 | |
36 | - if ( $comment_id && ( $comment = get_comment( $comment_id ) ) ) { |
|
36 | + if ($comment_id && ($comment = get_comment($comment_id))) { |
|
37 | 37 | return $comment->comment_post_ID; |
38 | 38 | } |
39 | 39 |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return WordPoints_Points_Logs_Viewing_RestrictionI Restriction for this log. |
33 | 33 | */ |
34 | - public function get_restriction( $log ) { |
|
34 | + public function get_restriction($log) { |
|
35 | 35 | |
36 | - if ( $log->blog_id && get_current_blog_id() !== $log->blog_id ) { |
|
37 | - $switched = switch_to_blog( $log->blog_id ); |
|
36 | + if ($log->blog_id && get_current_blog_id() !== $log->blog_id) { |
|
37 | + $switched = switch_to_blog($log->blog_id); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $restrictions = array(); |
41 | 41 | |
42 | - foreach ( array( 'all', $log->log_type ) as $slug ) { |
|
42 | + foreach (array('all', $log->log_type) as $slug) { |
|
43 | 43 | |
44 | - if ( isset( $this->classes[ $slug ] ) ) { |
|
44 | + if (isset($this->classes[$slug])) { |
|
45 | 45 | |
46 | 46 | $restrictions = array_merge( |
47 | 47 | $restrictions |
48 | - , array_values( $this->get_children( $slug, array( $log ) ) ) |
|
48 | + , array_values($this->get_children($slug, array($log))) |
|
49 | 49 | ); |
50 | 50 | } |
51 | 51 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | , $restrictions |
56 | 56 | ); |
57 | 57 | |
58 | - if ( isset( $switched ) ) { |
|
58 | + if (isset($switched)) { |
|
59 | 59 | restore_current_blog(); |
60 | 60 | } |
61 | 61 | |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return bool Whether the legacy filters say the user can view the points log. |
74 | 74 | */ |
75 | - public function apply_legacy_filters( $user_id, $log ) { |
|
75 | + public function apply_legacy_filters($user_id, $log) { |
|
76 | 76 | |
77 | - if ( $log->blog_id && get_current_blog_id() !== $log->blog_id ) { |
|
78 | - $switched = switch_to_blog( $log->blog_id ); |
|
77 | + if ($log->blog_id && get_current_blog_id() !== $log->blog_id) { |
|
78 | + $switched = switch_to_blog($log->blog_id); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $current_user = wp_get_current_user(); |
82 | 82 | |
83 | 83 | // Back-compat for WordPoints pre-2.1.0, when the below filter assumed that |
84 | 84 | // the user in question was the current user. |
85 | - if ( $user_id !== $current_user->ID ) { |
|
86 | - wp_set_current_user( $user_id ); |
|
85 | + if ($user_id !== $current_user->ID) { |
|
86 | + wp_set_current_user($user_id); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | */ |
105 | 105 | $can_view = apply_filters_deprecated( |
106 | 106 | "wordpoints_user_can_view_points_log-{$log->log_type}" |
107 | - , array( true, $log, $user_id ) |
|
107 | + , array(true, $log, $user_id) |
|
108 | 108 | , '2.2.0' |
109 | 109 | , false |
110 | 110 | , 'Use the points logs viewing restrictions API instead.' |
111 | 111 | ); |
112 | 112 | |
113 | 113 | // Restore the current user after the temporary override above. |
114 | - if ( $user_id !== $current_user->ID ) { |
|
115 | - wp_set_current_user( $current_user->ID ); |
|
114 | + if ($user_id !== $current_user->ID) { |
|
115 | + wp_set_current_user($current_user->ID); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | */ |
128 | 128 | $can_view = apply_filters_deprecated( |
129 | 129 | 'wordpoints_user_can_view_points_log' |
130 | - , array( $can_view, $user_id, $log ) |
|
130 | + , array($can_view, $user_id, $log) |
|
131 | 131 | , '2.2.0' |
132 | 132 | , false |
133 | 133 | , 'Use the points logs viewing restrictions API instead.' |
134 | 134 | ); |
135 | 135 | |
136 | - if ( isset( $switched ) ) { |
|
136 | + if (isset($switched)) { |
|
137 | 137 | restore_current_blog(); |
138 | 138 | } |
139 | 139 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @param object $log The object for the points log the restriction is for. |
21 | 21 | */ |
22 | - public function __construct( $log ); |
|
22 | + public function __construct($log); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Get a description of this restriction. |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return bool Whether the user can view the points log. |
50 | 50 | */ |
51 | - public function user_can( $user_id ); |
|
51 | + public function user_can($user_id); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | // EOF |
@@ -40,35 +40,35 @@ discard block |
||
40 | 40 | */ |
41 | 41 | protected function before() { |
42 | 42 | |
43 | - wp_enqueue_style( 'wordpoints-points-logs' ); |
|
43 | + wp_enqueue_style('wordpoints-points-logs'); |
|
44 | 44 | |
45 | - $this->current_time = current_time( 'timestamp', true ); |
|
45 | + $this->current_time = current_time('timestamp', true); |
|
46 | 46 | |
47 | 47 | $this->column_headings = array( |
48 | - 'user' => _x( 'User', 'points logs table heading', 'wordpoints' ), |
|
49 | - 'points' => _x( 'Points', 'points logs table heading', 'wordpoints' ), |
|
50 | - 'description' => _x( 'Description', 'points logs table heading', 'wordpoints' ), |
|
51 | - 'time' => _x( 'Time', 'points logs table heading', 'wordpoints' ), |
|
48 | + 'user' => _x('User', 'points logs table heading', 'wordpoints'), |
|
49 | + 'points' => _x('Points', 'points logs table heading', 'wordpoints'), |
|
50 | + 'description' => _x('Description', 'points logs table heading', 'wordpoints'), |
|
51 | + 'time' => _x('Time', 'points logs table heading', 'wordpoints'), |
|
52 | 52 | ); |
53 | 53 | |
54 | - $points_type = $this->logs_query->get_arg( 'points_type' ); |
|
54 | + $points_type = $this->logs_query->get_arg('points_type'); |
|
55 | 55 | |
56 | - if ( ! empty( $points_type ) ) { |
|
56 | + if ( ! empty($points_type)) { |
|
57 | 57 | |
58 | 58 | $points_type_name = wordpoints_get_points_type_setting( |
59 | 59 | $points_type |
60 | 60 | , 'name' |
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! empty( $points_type_name ) ) { |
|
63 | + if ( ! empty($points_type_name)) { |
|
64 | 64 | $this->column_headings['points'] = $points_type_name; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | 68 | $extra_classes = array(); |
69 | 69 | |
70 | - foreach ( array( 'searchable', 'paginate' ) as $arg ) { |
|
71 | - if ( $this->args[ $arg ] ) { |
|
70 | + foreach (array('searchable', 'paginate') as $arg) { |
|
71 | + if ($this->args[$arg]) { |
|
72 | 72 | $extra_classes[] = $arg; |
73 | 73 | } |
74 | 74 | } |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | ?> |
93 | 93 | |
94 | 94 | <div class="wordpoints-points-logs-wrapper"> |
95 | - <?php if ( $this->args['searchable'] ) : ?> |
|
95 | + <?php if ($this->args['searchable']) : ?> |
|
96 | 96 | <?php $this->search_box(); ?> |
97 | 97 | <?php endif; ?> |
98 | 98 | |
99 | - <table class="wordpoints-points-logs widefat <?php echo esc_attr( implode( ' ', $extra_classes ) ); ?>"> |
|
99 | + <table class="wordpoints-points-logs widefat <?php echo esc_attr(implode(' ', $extra_classes)); ?>"> |
|
100 | 100 | <thead> |
101 | 101 | <tr> |
102 | - <?php if ( $this->args['show_users'] ) : ?> |
|
103 | - <th scope="col"><?php echo esc_html( $this->column_headings['user'] ); ?></th> |
|
102 | + <?php if ($this->args['show_users']) : ?> |
|
103 | + <th scope="col"><?php echo esc_html($this->column_headings['user']); ?></th> |
|
104 | 104 | <?php endif; ?> |
105 | - <th scope="col"><?php echo esc_html( $this->column_headings['points'] ); ?></th> |
|
106 | - <th scope="col"><?php echo esc_html( $this->column_headings['description'] ); ?></th> |
|
107 | - <th scope="col"><?php echo esc_html( $this->column_headings['time'] ); ?></th> |
|
105 | + <th scope="col"><?php echo esc_html($this->column_headings['points']); ?></th> |
|
106 | + <th scope="col"><?php echo esc_html($this->column_headings['description']); ?></th> |
|
107 | + <th scope="col"><?php echo esc_html($this->column_headings['time']); ?></th> |
|
108 | 108 | </tr> |
109 | 109 | </thead> |
110 | 110 | <tbody> |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | |
119 | 119 | ?> |
120 | 120 | <tr> |
121 | - <td colspan="<?php echo ( $this->args['show_users'] ) ? 4 : 3; ?>"> |
|
122 | - <?php esc_html_e( 'No matching logs found.', 'wordpoints' ); ?> |
|
121 | + <td colspan="<?php echo ($this->args['show_users']) ? 4 : 3; ?>"> |
|
122 | + <?php esc_html_e('No matching logs found.', 'wordpoints'); ?> |
|
123 | 123 | </td> |
124 | 124 | </tr> |
125 | 125 | <?php |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * @since 2.2.0 |
130 | 130 | */ |
131 | - protected function log( $log ) { |
|
131 | + protected function log($log) { |
|
132 | 132 | |
133 | - $user = get_userdata( $log->user_id ); |
|
133 | + $user = get_userdata($log->user_id); |
|
134 | 134 | |
135 | 135 | ?> |
136 | 136 | |
137 | - <tr class="wordpoints-log-id-<?php echo (int) $log->id; ?> <?php echo ( $this->i % 2 ) ? 'odd' : 'even'; ?>"> |
|
138 | - <?php if ( $this->args['show_users'] ) : ?> |
|
137 | + <tr class="wordpoints-log-id-<?php echo (int) $log->id; ?> <?php echo ($this->i % 2) ? 'odd' : 'even'; ?>"> |
|
138 | + <?php if ($this->args['show_users']) : ?> |
|
139 | 139 | <td> |
140 | - <?php echo get_avatar( $user->ID, 32 ); ?> |
|
140 | + <?php echo get_avatar($user->ID, 32); ?> |
|
141 | 141 | <?php |
142 | 142 | |
143 | 143 | /** |
@@ -155,33 +155,33 @@ discard block |
||
155 | 155 | */ |
156 | 156 | $name = apply_filters( |
157 | 157 | 'wordpoints_points_logs_table_username' |
158 | - , sanitize_user_field( 'display_name', $user->display_name, $log->user_id, 'display' ) |
|
158 | + , sanitize_user_field('display_name', $user->display_name, $log->user_id, 'display') |
|
159 | 159 | , $user |
160 | 160 | , $log |
161 | 161 | ); |
162 | 162 | |
163 | - echo wp_kses( $name, 'wordpoints_points_logs_username' ); |
|
163 | + echo wp_kses($name, 'wordpoints_points_logs_username'); |
|
164 | 164 | |
165 | 165 | ?> |
166 | 166 | </td> |
167 | 167 | <?php endif; ?> |
168 | - <td><?php echo wordpoints_format_points( $log->points, $log->points_type, 'logs' ); ?></td> |
|
168 | + <td><?php echo wordpoints_format_points($log->points, $log->points_type, 'logs'); ?></td> |
|
169 | 169 | <td> |
170 | 170 | <div class="wordpoints-log-text"> |
171 | - <?php echo wp_kses( $log->text, 'wordpoints_points_log' ); ?> |
|
171 | + <?php echo wp_kses($log->text, 'wordpoints_points_log'); ?> |
|
172 | 172 | </div> |
173 | - <?php if ( $this->restriction->applies() ) : ?> |
|
173 | + <?php if ($this->restriction->applies()) : ?> |
|
174 | 174 | <div class="wordpoints-log-viewing-restrictions"> |
175 | - <?php foreach ( (array) $this->restriction->get_description() as $description ) : ?> |
|
175 | + <?php foreach ((array) $this->restriction->get_description() as $description) : ?> |
|
176 | 176 | <div class="wordpoints-log-viewing-restriction"> |
177 | - <?php echo esc_html( $description ); ?> |
|
177 | + <?php echo esc_html($description); ?> |
|
178 | 178 | </div> |
179 | 179 | <?php endforeach; ?> |
180 | 180 | </div> |
181 | 181 | <?php endif; ?> |
182 | 182 | </td> |
183 | - <td title="<?php echo esc_attr( $log->date ); ?> <?php /* translators: coordinated universal time */ esc_attr_e( 'UTC', 'wordpoints' ); ?>"> |
|
184 | - <?php echo esc_html( human_time_diff( strtotime( $log->date ), $this->current_time ) ); ?> |
|
183 | + <td title="<?php echo esc_attr($log->date); ?> <?php /* translators: coordinated universal time */ esc_attr_e('UTC', 'wordpoints'); ?>"> |
|
184 | + <?php echo esc_html(human_time_diff(strtotime($log->date), $this->current_time)); ?> |
|
185 | 185 | </td> |
186 | 186 | </tr> |
187 | 187 | |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | </tbody> |
198 | 198 | <tfoot> |
199 | 199 | <tr> |
200 | - <?php if ( $this->args['show_users'] ) : ?> |
|
201 | - <th scope="col"><?php echo esc_html( $this->column_headings['user'] ); ?></th> |
|
200 | + <?php if ($this->args['show_users']) : ?> |
|
201 | + <th scope="col"><?php echo esc_html($this->column_headings['user']); ?></th> |
|
202 | 202 | <?php endif; ?> |
203 | - <th scope="col"><?php echo esc_html( $this->column_headings['points'] ); ?></th> |
|
204 | - <th scope="col"><?php echo esc_html( $this->column_headings['description'] ); ?></th> |
|
205 | - <th scope="col"><?php echo esc_html( $this->column_headings['time'] ); ?></th> |
|
203 | + <th scope="col"><?php echo esc_html($this->column_headings['points']); ?></th> |
|
204 | + <th scope="col"><?php echo esc_html($this->column_headings['description']); ?></th> |
|
205 | + <th scope="col"><?php echo esc_html($this->column_headings['time']); ?></th> |
|
206 | 206 | </tr> |
207 | 207 | </tfoot> |
208 | 208 | </table> |
209 | 209 | |
210 | - <?php if ( $this->args['paginate'] ) : ?> |
|
210 | + <?php if ($this->args['paginate']) : ?> |
|
211 | 211 | <?php $this->pagination(); ?> |
212 | 212 | <?php endif; ?> |
213 | 213 | </div> |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | |
223 | 223 | $search_term = ''; |
224 | 224 | |
225 | - if ( isset( $_POST['wordpoints_points_logs_search'] ) ) { // WPCS: CSRF OK |
|
225 | + if (isset($_POST['wordpoints_points_logs_search'])) { // WPCS: CSRF OK |
|
226 | 226 | $search_term = trim( |
227 | 227 | sanitize_text_field( |
228 | - wp_unslash( $_POST['wordpoints_points_logs_search'] ) // WPCS: CSRF OK |
|
228 | + wp_unslash($_POST['wordpoints_points_logs_search']) // WPCS: CSRF OK |
|
229 | 229 | ) |
230 | 230 | ); |
231 | 231 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | $page = 1; |
244 | 244 | |
245 | 245 | if ( |
246 | - isset( $_GET['wordpoints_points_logs_page'] ) |
|
247 | - && wordpoints_posint( $_GET['wordpoints_points_logs_page'] ) |
|
246 | + isset($_GET['wordpoints_points_logs_page']) |
|
247 | + && wordpoints_posint($_GET['wordpoints_points_logs_page']) |
|
248 | 248 | ) { |
249 | 249 | $page = (int) $_GET['wordpoints_points_logs_page']; |
250 | 250 | } |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | $per_page = 25; |
261 | 261 | |
262 | 262 | if ( |
263 | - isset( $_GET['wordpoints_points_logs_per_page'] ) |
|
264 | - && wordpoints_posint( $_GET['wordpoints_points_logs_per_page'] ) |
|
263 | + isset($_GET['wordpoints_points_logs_per_page']) |
|
264 | + && wordpoints_posint($_GET['wordpoints_points_logs_per_page']) |
|
265 | 265 | ) { |
266 | 266 | $per_page = (int) $_GET['wordpoints_points_logs_per_page']; |
267 | 267 | } |
@@ -278,13 +278,13 @@ discard block |
||
278 | 278 | |
279 | 279 | ?> |
280 | 280 | |
281 | - <?php if ( ! empty( $search_term ) ) : ?> |
|
281 | + <?php if ( ! empty($search_term)) : ?> |
|
282 | 282 | <div class="wordpoints-points-logs-searching"> |
283 | 283 | <?php |
284 | 284 | |
285 | 285 | echo esc_html( |
286 | 286 | sprintf( |
287 | - __( 'Searching for “%s”', 'wordpoints' ) |
|
287 | + __('Searching for “%s”', 'wordpoints') |
|
288 | 288 | , $search_term |
289 | 289 | ) |
290 | 290 | ); |
@@ -294,20 +294,20 @@ discard block |
||
294 | 294 | <?php endif; ?> |
295 | 295 | |
296 | 296 | <div class="wordpoints-points-logs-search"> |
297 | - <form method="POST" action="<?php echo esc_url( remove_query_arg( 'wordpoints_points_logs_page' ) ); ?>"> |
|
297 | + <form method="POST" action="<?php echo esc_url(remove_query_arg('wordpoints_points_logs_page')); ?>"> |
|
298 | 298 | <label class="screen-reader-text" for="wordpoints_points_logs_search"> |
299 | - <?php esc_html_e( 'Search Logs:', 'wordpoints' ); ?> |
|
299 | + <?php esc_html_e('Search Logs:', 'wordpoints'); ?> |
|
300 | 300 | </label> |
301 | 301 | <input |
302 | 302 | type="text" |
303 | 303 | name="wordpoints_points_logs_search" |
304 | 304 | id="wordpoints_points_logs_search" |
305 | - value="<?php echo esc_attr( $search_term ); ?>" |
|
305 | + value="<?php echo esc_attr($search_term); ?>" |
|
306 | 306 | /> |
307 | 307 | <input |
308 | 308 | name="" |
309 | 309 | class="button" |
310 | - value="<?php esc_attr_e( 'Search Logs', 'wordpoints' ); ?>" |
|
310 | + value="<?php esc_attr_e('Search Logs', 'wordpoints'); ?>" |
|
311 | 311 | type="submit" |
312 | 312 | /> |
313 | 313 | </form> |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | |
326 | 326 | echo paginate_links( // XSS pass WPCS. |
327 | 327 | array( |
328 | - 'base' => add_query_arg( '%_%', '' ), |
|
328 | + 'base' => add_query_arg('%_%', ''), |
|
329 | 329 | 'format' => 'wordpoints_points_logs_page=%#%', |
330 | - 'total' => ceil( $this->logs_query->count() / $per_page ), |
|
330 | + 'total' => ceil($this->logs_query->count() / $per_page), |
|
331 | 331 | 'current' => $this->get_page_number(), |
332 | 332 | 'add_args' => array( |
333 | 333 | 'wordpoints_points_logs_per_page' => $per_page, |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | $this->slug = $slug; |
111 | 111 | $this->logs_query = $logs_query; |
112 | - $this->args = array_merge( $this->defaults, $args ); |
|
112 | + $this->args = array_merge($this->defaults, $args); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $this->before(); |
125 | 125 | |
126 | - if ( empty( $this->logs ) ) { |
|
126 | + if (empty($this->logs)) { |
|
127 | 127 | $this->no_logs(); |
128 | 128 | } else { |
129 | 129 | $this->logs(); |
@@ -145,28 +145,28 @@ discard block |
||
145 | 145 | */ |
146 | 146 | protected function get_logs() { |
147 | 147 | |
148 | - if ( $this->args['searchable'] ) { |
|
148 | + if ($this->args['searchable']) { |
|
149 | 149 | |
150 | 150 | $search_term = $this->get_search_term(); |
151 | 151 | |
152 | - if ( $search_term ) { |
|
152 | + if ($search_term) { |
|
153 | 153 | |
154 | 154 | global $wpdb; |
155 | 155 | |
156 | - $escaped_search_term = $wpdb->esc_like( $search_term ); |
|
156 | + $escaped_search_term = $wpdb->esc_like($search_term); |
|
157 | 157 | |
158 | 158 | $this->logs_query->set_args( |
159 | - array( 'text' => "%{$escaped_search_term}%" ) |
|
159 | + array('text' => "%{$escaped_search_term}%") |
|
160 | 160 | ); |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - if ( $this->args['paginate'] ) { |
|
164 | + if ($this->args['paginate']) { |
|
165 | 165 | |
166 | 166 | $page = $this->get_page_number(); |
167 | 167 | $per_page = $this->get_per_page(); |
168 | 168 | |
169 | - $logs = $this->logs_query->get_page( $page, $per_page ); |
|
169 | + $logs = $this->logs_query->get_page($page, $per_page); |
|
170 | 170 | |
171 | 171 | } else { |
172 | 172 | |
@@ -187,44 +187,44 @@ discard block |
||
187 | 187 | protected function logs() { |
188 | 188 | |
189 | 189 | /** @var WordPoints_Points_Logs_Viewing_Restrictions $viewing_restrictions */ |
190 | - $viewing_restrictions = wordpoints_component( 'points' ) |
|
191 | - ->get_sub_app( 'logs' ) |
|
192 | - ->get_sub_app( 'viewing_restrictions' ); |
|
190 | + $viewing_restrictions = wordpoints_component('points') |
|
191 | + ->get_sub_app('logs') |
|
192 | + ->get_sub_app('viewing_restrictions'); |
|
193 | 193 | |
194 | 194 | $current_user_id = get_current_user_id(); |
195 | 195 | |
196 | - if ( is_multisite() ) { |
|
196 | + if (is_multisite()) { |
|
197 | 197 | $ms_switched_state = new WordPoints_Multisite_Switched_State(); |
198 | 198 | $current_site_id = $ms_switched_state->backup(); |
199 | 199 | } |
200 | 200 | |
201 | 201 | $this->i = 0; |
202 | 202 | |
203 | - foreach ( $this->logs as $log ) { |
|
203 | + foreach ($this->logs as $log) { |
|
204 | 204 | |
205 | - if ( isset( $current_site_id ) && $current_site_id !== $log->blog_id ) { |
|
206 | - switch_to_blog( $log->blog_id ); |
|
205 | + if (isset($current_site_id) && $current_site_id !== $log->blog_id) { |
|
206 | + switch_to_blog($log->blog_id); |
|
207 | 207 | $current_site_id = $log->blog_id; |
208 | 208 | } |
209 | 209 | |
210 | - $this->restriction = $viewing_restrictions->get_restriction( $log ); |
|
210 | + $this->restriction = $viewing_restrictions->get_restriction($log); |
|
211 | 211 | |
212 | - if ( ! $this->restriction->user_can( $current_user_id ) ) { |
|
212 | + if ( ! $this->restriction->user_can($current_user_id)) { |
|
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | |
216 | 216 | if ( |
217 | - ! $viewing_restrictions->apply_legacy_filters( $current_user_id, $log ) |
|
217 | + ! $viewing_restrictions->apply_legacy_filters($current_user_id, $log) |
|
218 | 218 | ) { |
219 | 219 | continue; |
220 | 220 | } |
221 | 221 | |
222 | 222 | $this->i++; |
223 | 223 | |
224 | - $this->log( $log ); |
|
224 | + $this->log($log); |
|
225 | 225 | } |
226 | 226 | |
227 | - if ( isset( $ms_switched_state ) ) { |
|
227 | + if (isset($ms_switched_state)) { |
|
228 | 228 | $ms_switched_state->restore(); |
229 | 229 | } |
230 | 230 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @param object $log The log object. |
256 | 256 | */ |
257 | - abstract protected function log( $log ); |
|
257 | + abstract protected function log($log); |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Displays content after the logs loop. |