@@ -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 | /** |
@@ -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 |
@@ -18,6 +18,7 @@ |
||
| 18 | 18 | * @since 2.2.0 |
| 19 | 19 | * |
| 20 | 20 | * @param object $log The object for the points log the restriction is for. |
| 21 | + * @return void |
|
| 21 | 22 | */ |
| 22 | 23 | public function __construct( $log ); |
| 23 | 24 | |
@@ -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. |
@@ -203,24 +203,24 @@ discard block |
||
| 203 | 203 | $this->legacy_id_base |
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | - if ( ! $this->legacy_handler ) { |
|
| 206 | + if ( ! $this->legacy_handler) { |
|
| 207 | 207 | return; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
| 210 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
| 211 | 211 | $this->hook_mode = 'network'; |
| 212 | 212 | } else { |
| 213 | 213 | $this->hook_mode = 'standard'; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $imported_option = 'wordpoints_imported_points_hooks'; |
| 217 | - $this->imported_hooks = $this->get_array_option( $imported_option ); |
|
| 217 | + $this->imported_hooks = $this->get_array_option($imported_option); |
|
| 218 | 218 | |
| 219 | 219 | $this->points_types_hooks = WordPoints_Points_Hooks::get_points_types_hooks(); |
| 220 | 220 | |
| 221 | - $this->reaction_store = wordpoints_hooks()->get_reaction_store( 'points' ); |
|
| 221 | + $this->reaction_store = wordpoints_hooks()->get_reaction_store('points'); |
|
| 222 | 222 | |
| 223 | - if ( ! $this->reaction_store ) { |
|
| 223 | + if ( ! $this->reaction_store) { |
|
| 224 | 224 | return; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -228,24 +228,24 @@ discard block |
||
| 228 | 228 | $this->hook_mode |
| 229 | 229 | ); |
| 230 | 230 | |
| 231 | - foreach ( $this->legacy_instances as $number => $legacy_instance ) { |
|
| 232 | - $this->import_instance( $legacy_instance, $number ); |
|
| 231 | + foreach ($this->legacy_instances as $number => $legacy_instance) { |
|
| 232 | + $this->import_instance($legacy_instance, $number); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // This means that all of the instances were imported successfully. |
| 236 | - if ( empty( $this->legacy_instances ) ) { |
|
| 236 | + if (empty($this->legacy_instances)) { |
|
| 237 | 237 | |
| 238 | 238 | $option = 'wordpoints_legacy_points_hooks_disabled'; |
| 239 | 239 | |
| 240 | - $disabled = $this->get_array_option( $option ); |
|
| 241 | - $disabled[ $this->legacy_id_base ] = true; |
|
| 240 | + $disabled = $this->get_array_option($option); |
|
| 241 | + $disabled[$this->legacy_id_base] = true; |
|
| 242 | 242 | |
| 243 | - $this->update_option( $option, $disabled ); |
|
| 243 | + $this->update_option($option, $disabled); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - WordPoints_Points_Hooks::save_points_types_hooks( $this->points_types_hooks ); |
|
| 246 | + WordPoints_Points_Hooks::save_points_types_hooks($this->points_types_hooks); |
|
| 247 | 247 | |
| 248 | - $this->update_option( $imported_option, $this->imported_hooks ); |
|
| 248 | + $this->update_option($imported_option, $this->imported_hooks); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -258,15 +258,15 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return bool Whether the instance was successfully converted to a reaction. |
| 260 | 260 | */ |
| 261 | - protected function import_instance( $legacy_instance, $number ) { |
|
| 261 | + protected function import_instance($legacy_instance, $number) { |
|
| 262 | 262 | |
| 263 | 263 | $this->legacy_instance = $legacy_instance; |
| 264 | 264 | |
| 265 | - if ( ! $this->should_import_instance() ) { |
|
| 265 | + if ( ! $this->should_import_instance()) { |
|
| 266 | 266 | return false; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $this->legacy_handler->set_number( $number ); |
|
| 269 | + $this->legacy_handler->set_number($number); |
|
| 270 | 270 | |
| 271 | 271 | $points_type = $this->legacy_handler->points_type( |
| 272 | 272 | 'network' === $this->hook_mode ? "network_{$number}" : $number |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | $order = array_search( |
| 287 | 287 | $this->legacy_handler->get_id() |
| 288 | - , $this->points_types_hooks[ $points_type ] |
|
| 288 | + , $this->points_types_hooks[$points_type] |
|
| 289 | 289 | , true |
| 290 | 290 | ); |
| 291 | 291 | |
@@ -294,21 +294,21 @@ discard block |
||
| 294 | 294 | $order |
| 295 | 295 | ); |
| 296 | 296 | |
| 297 | - if ( ! isset( $reaction_settings['log_text'] ) ) { |
|
| 297 | + if ( ! isset($reaction_settings['log_text'])) { |
|
| 298 | 298 | $reaction_settings['log_text'] = $this->get_log_text_for_instance( |
| 299 | 299 | $points_type |
| 300 | 300 | ); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if ( ! $this->create_reaction( $reaction_settings, $order ) ) { |
|
| 303 | + if ( ! $this->create_reaction($reaction_settings, $order)) { |
|
| 304 | 304 | return false; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - $this->legacy_handler->delete_callback( $number ); |
|
| 307 | + $this->legacy_handler->delete_callback($number); |
|
| 308 | 308 | |
| 309 | 309 | unset( |
| 310 | - $this->points_types_hooks[ $points_type ][ $order ] |
|
| 311 | - , $this->legacy_instances[ $number ] |
|
| 310 | + $this->points_types_hooks[$points_type][$order] |
|
| 311 | + , $this->legacy_instances[$number] |
|
| 312 | 312 | ); |
| 313 | 313 | |
| 314 | 314 | return true; |
@@ -324,16 +324,16 @@ discard block |
||
| 324 | 324 | protected function should_import_instance() { |
| 325 | 325 | |
| 326 | 326 | // We ignore certain settings... |
| 327 | - $ignored = array( '_description' => true ); |
|
| 327 | + $ignored = array('_description' => true); |
|
| 328 | 328 | |
| 329 | 329 | // But if there are any other unexpected ones, we really can't safely import. |
| 330 | - if ( array_diff_key( $this->legacy_instance, $this->expected_settings, $ignored ) ) { |
|
| 330 | + if (array_diff_key($this->legacy_instance, $this->expected_settings, $ignored)) { |
|
| 331 | 331 | return false; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | if ( |
| 335 | 335 | $this->skip_non_reversing_hooks |
| 336 | - && isset( $this->legacy_instance['auto_reverse'] ) |
|
| 336 | + && isset($this->legacy_instance['auto_reverse']) |
|
| 337 | 337 | && ! $this->legacy_instance['auto_reverse'] |
| 338 | 338 | ) { |
| 339 | 339 | return false; |
@@ -352,22 +352,22 @@ discard block |
||
| 352 | 352 | * |
| 353 | 353 | * @return string The log text derived from this instance. |
| 354 | 354 | */ |
| 355 | - protected function get_log_text_for_instance( $points_type, $meta = array() ) { |
|
| 355 | + protected function get_log_text_for_instance($points_type, $meta = array()) { |
|
| 356 | 356 | |
| 357 | - if ( ! method_exists( $this->legacy_handler, 'logs' ) ) { |
|
| 358 | - return $this->legacy_handler->get_option( 'description' ); |
|
| 357 | + if ( ! method_exists($this->legacy_handler, 'logs')) { |
|
| 358 | + return $this->legacy_handler->get_option('description'); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | if ( |
| 362 | - ! isset( $meta['post_type'] ) |
|
| 363 | - && isset( $this->legacy_instance['post_type'] ) |
|
| 362 | + ! isset($meta['post_type']) |
|
| 363 | + && isset($this->legacy_instance['post_type']) |
|
| 364 | 364 | ) { |
| 365 | 365 | $meta['post_type'] = $this->legacy_instance['post_type']; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | if ( |
| 369 | - ! isset( $meta['period'] ) |
|
| 370 | - && isset( $this->legacy_instance['period'] ) |
|
| 369 | + ! isset($meta['period']) |
|
| 370 | + && isset($this->legacy_instance['period']) |
|
| 371 | 371 | ) { |
| 372 | 372 | $meta['period'] = $this->legacy_instance['period']; |
| 373 | 373 | } |
@@ -394,15 +394,15 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return array The modified settings. |
| 396 | 396 | */ |
| 397 | - protected function filter_reaction_settings( $settings, $order ) { |
|
| 397 | + protected function filter_reaction_settings($settings, $order) { |
|
| 398 | 398 | |
| 399 | - if ( 'wordpoints_periodic_points_hook' === $this->legacy_id_base ) { |
|
| 399 | + if ('wordpoints_periodic_points_hook' === $this->legacy_id_base) { |
|
| 400 | 400 | |
| 401 | 401 | $settings['points_legacy_periods'] = array( |
| 402 | 402 | 'fire' => array( |
| 403 | 403 | array( |
| 404 | 404 | 'length' => $this->legacy_instance['period'], |
| 405 | - 'args' => array( array( 'current:user' ) ), |
|
| 405 | + 'args' => array(array('current:user')), |
|
| 406 | 406 | ), |
| 407 | 407 | ), |
| 408 | 408 | ); |
@@ -417,23 +417,23 @@ discard block |
||
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | if ( |
| 420 | - isset( $this->legacy_instance['auto_reverse'] ) |
|
| 420 | + isset($this->legacy_instance['auto_reverse']) |
|
| 421 | 421 | && ! $this->legacy_instance['auto_reverse'] |
| 422 | 422 | ) { |
| 423 | 423 | $settings['blocker']['toggle_off'] = true; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if ( isset( $this->legacy_instance['post_type'] ) ) { |
|
| 426 | + if (isset($this->legacy_instance['post_type'])) { |
|
| 427 | 427 | |
| 428 | 428 | $post_type = $this->legacy_instance['post_type']; |
| 429 | 429 | |
| 430 | - if ( 'ALL' === $post_type ) { |
|
| 430 | + if ('ALL' === $post_type) { |
|
| 431 | 431 | |
| 432 | - $post_type_slugs = get_post_types( array( 'public' => true ) ); |
|
| 432 | + $post_type_slugs = get_post_types(array('public' => true)); |
|
| 433 | 433 | |
| 434 | - $post_type = array_pop( $post_type_slugs ); |
|
| 434 | + $post_type = array_pop($post_type_slugs); |
|
| 435 | 435 | |
| 436 | - foreach ( $post_type_slugs as $post_type_slug ) { |
|
| 436 | + foreach ($post_type_slugs as $post_type_slug) { |
|
| 437 | 437 | |
| 438 | 438 | $this->create_reaction( |
| 439 | 439 | $this->format_settings_for_post_type( |
@@ -464,14 +464,14 @@ discard block |
||
| 464 | 464 | * |
| 465 | 465 | * @return array The settings modified for this particular post type. |
| 466 | 466 | */ |
| 467 | - protected function format_settings_for_post_type( $post_type, $settings ) { |
|
| 467 | + protected function format_settings_for_post_type($post_type, $settings) { |
|
| 468 | 468 | |
| 469 | 469 | if ( |
| 470 | 470 | 'post_publish\post' === $settings['event'] |
| 471 | 471 | || 'points_legacy_post_publish\post' === $settings['event'] |
| 472 | 472 | ) { |
| 473 | 473 | |
| 474 | - if ( 'attachment' === $post_type ) { |
|
| 474 | + if ('attachment' === $post_type) { |
|
| 475 | 475 | |
| 476 | 476 | $settings['event'] = 'media_upload'; |
| 477 | 477 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | $settings['log_text'] = $this->get_log_text_for_instance( |
| 499 | 499 | $settings['points_type'] |
| 500 | - , array( 'post_type' => $post_type ) |
|
| 500 | + , array('post_type' => $post_type) |
|
| 501 | 501 | ); |
| 502 | 502 | |
| 503 | 503 | return $settings; |
@@ -513,11 +513,11 @@ discard block |
||
| 513 | 513 | * |
| 514 | 514 | * @return WordPoints_Hook_ReactionI|false The reaction, or false. |
| 515 | 515 | */ |
| 516 | - protected function create_reaction( $settings, $order ) { |
|
| 516 | + protected function create_reaction($settings, $order) { |
|
| 517 | 517 | |
| 518 | - $reaction = $this->reaction_store->create_reaction( $settings ); |
|
| 518 | + $reaction = $this->reaction_store->create_reaction($settings); |
|
| 519 | 519 | |
| 520 | - if ( ! $reaction instanceof WordPoints_Hook_ReactionI ) { |
|
| 520 | + if ( ! $reaction instanceof WordPoints_Hook_ReactionI) { |
|
| 521 | 521 | return false; |
| 522 | 522 | } |
| 523 | 523 | |
@@ -542,12 +542,12 @@ discard block |
||
| 542 | 542 | * |
| 543 | 543 | * @return bool Whether the option was updated successfully. |
| 544 | 544 | */ |
| 545 | - protected function update_option( $option, $value ) { |
|
| 545 | + protected function update_option($option, $value) { |
|
| 546 | 546 | |
| 547 | - if ( 'network' === $this->hook_mode ) { |
|
| 548 | - return update_site_option( $option, $value ); |
|
| 547 | + if ('network' === $this->hook_mode) { |
|
| 548 | + return update_site_option($option, $value); |
|
| 549 | 549 | } else { |
| 550 | - return update_option( $option, $value ); |
|
| 550 | + return update_option($option, $value); |
|
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | * |
| 561 | 561 | * @return array The option value. |
| 562 | 562 | */ |
| 563 | - protected function get_array_option( $option ) { |
|
| 563 | + protected function get_array_option($option) { |
|
| 564 | 564 | |
| 565 | 565 | return wordpoints_get_maybe_network_array_option( |
| 566 | 566 | $option |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * @since 2.1.0 |
| 25 | 25 | */ |
| 26 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
| 26 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
| 27 | 27 | |
| 28 | 28 | // Normally we wouldn't let the hit occur if there is nothing to reverse. |
| 29 | - if ( ! parent::should_hit( $fire ) ) { |
|
| 29 | + if ( ! parent::should_hit($fire)) { |
|
| 30 | 30 | |
| 31 | 31 | // But in this case we want to check the points logs as well. |
| 32 | - $logs = $this->get_points_logs_to_be_reversed( $fire ); |
|
| 32 | + $logs = $this->get_points_logs_to_be_reversed($fire); |
|
| 33 | 33 | |
| 34 | 34 | // If there are logs to reverse, we'll let the hit happen. |
| 35 | - return count( $logs ) > 0; |
|
| 35 | + return count($logs) > 0; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return true; |
@@ -41,16 +41,16 @@ discard block |
||
| 41 | 41 | /** |
| 42 | 42 | * @since 2.1.0 |
| 43 | 43 | */ |
| 44 | - public function after_miss( WordPoints_Hook_Fire $fire ) { |
|
| 44 | + public function after_miss(WordPoints_Hook_Fire $fire) { |
|
| 45 | 45 | |
| 46 | - parent::after_miss( $fire ); |
|
| 46 | + parent::after_miss($fire); |
|
| 47 | 47 | |
| 48 | - if ( ! $this->get_settings_from_fire( $fire ) ) { |
|
| 48 | + if ( ! $this->get_settings_from_fire($fire)) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - foreach ( $this->get_points_logs_to_be_reversed( $fire ) as $log ) { |
|
| 53 | - wordpoints_add_points_log_meta( $log->id, 'auto_reversed', 0 ); |
|
| 52 | + foreach ($this->get_points_logs_to_be_reversed($fire) as $log) { |
|
| 53 | + wordpoints_add_points_log_meta($log->id, 'auto_reversed', 0); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return array The points logs to be reversed. |
| 65 | 65 | */ |
| 66 | - protected function get_points_logs_to_be_reversed( WordPoints_Hook_Fire $fire ) { |
|
| 66 | + protected function get_points_logs_to_be_reversed(WordPoints_Hook_Fire $fire) { |
|
| 67 | 67 | |
| 68 | - if ( isset( $fire->data[ $this->slug ]['points_logs'] ) ) { |
|
| 69 | - return $fire->data[ $this->slug ]['points_logs']; |
|
| 68 | + if (isset($fire->data[$this->slug]['points_logs'])) { |
|
| 69 | + return $fire->data[$this->slug]['points_logs']; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $meta_queries = array( |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | ), |
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | - $meta_key = $fire->reaction->get_meta( 'legacy_meta_key' ); |
|
| 81 | + $meta_key = $fire->reaction->get_meta('legacy_meta_key'); |
|
| 82 | 82 | |
| 83 | - if ( $meta_key ) { |
|
| 83 | + if ($meta_key) { |
|
| 84 | 84 | |
| 85 | 85 | $entities = $fire->event_args->get_signature_args(); |
| 86 | 86 | |
| 87 | - if ( ! $entities ) { |
|
| 88 | - $fire->data[ $this->slug ]['points_logs'] = array(); |
|
| 87 | + if ( ! $entities) { |
|
| 88 | + $fire->data[$this->slug]['points_logs'] = array(); |
|
| 89 | 89 | return array(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Legacy hooks only ever related to a single entity. |
| 93 | - $entity = reset( $entities ); |
|
| 93 | + $entity = reset($entities); |
|
| 94 | 94 | |
| 95 | 95 | $meta_queries[] = array( |
| 96 | 96 | 'key' => $meta_key, |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | ); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $log_type = $fire->reaction->get_meta( 'legacy_log_type' ); |
|
| 101 | + $log_type = $fire->reaction->get_meta('legacy_log_type'); |
|
| 102 | 102 | |
| 103 | - if ( ! $log_type ) { |
|
| 103 | + if ( ! $log_type) { |
|
| 104 | 104 | $log_type = $fire->reaction->get_event_slug(); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $logs = $query->get(); |
| 115 | 115 | |
| 116 | - if ( ! $logs ) { |
|
| 116 | + if ( ! $logs) { |
|
| 117 | 117 | $logs = array(); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $fire->data[ $this->slug ]['points_logs'] = $logs; |
|
| 120 | + $fire->data[$this->slug]['points_logs'] = $logs; |
|
| 121 | 121 | |
| 122 | 122 | return $logs; |
| 123 | 123 | } |