| @@ -70,14 +70,14 @@ | ||
| 70 | 70 | * @param Plugin $plugin Plugin class. |
| 71 | 71 | * @return void |
| 72 | 72 | */ |
| 73 | 73 | public function __construct( $item, $plugin ) { |
| 74 | - $this->plugin = $plugin; | |
| 74 | + $this->plugin = $plugin; | |
| 75 | 75 | |
| 76 | - $this->ID = isset( $item->ID ) ? $item->ID : null; | |
| 77 | - $this->status = isset( $item->status ) ? $item->status : 'wp_stream_disabled'; | |
| 78 | - $this->date = isset( $item->date ) ? $item->date : null; | |
| 79 | - $this->author = isset( $item->author ) ? $item->author : null; | |
| 76 | + $this->ID = isset( $item->ID ) ? $item->ID : null; | |
| 77 | + $this->status = isset( $item->status ) ? $item->status : 'wp_stream_disabled'; | |
| 78 | + $this->date = isset( $item->date ) ? $item->date : null; | |
| 79 | + $this->author = isset( $item->author ) ? $item->author : null; | |
| 80 | 80 | |
| 81 | 81 | $this->alert_type = isset( $item->alert_type ) ? $item->alert_type : null; |
| 82 | 82 | $this->alert_meta = isset( $item->alert_meta ) ? $item->alert_meta : array(); |
| 83 | 83 | } |
| @@ -108,10 +108,10 @@ | ||
| 108 | 108 | $this->ID = $post_id; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $meta = array( |
| 112 | - 'alert_type' => $this->alert_type, | |
| 113 | - 'alert_meta' => $this->alert_meta, | |
| 112 | + 'alert_type' => $this->alert_type, | |
| 113 | + 'alert_meta' => $this->alert_meta, | |
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | 116 | foreach ( $meta as $key => $value ) { |
| 117 | 117 | $this->update_meta( $key, $value ); |
| @@ -128,13 +128,13 @@ | ||
| 128 | 128 | */ |
| 129 | 129 | public function process_settings_form( $data ) { |
| 130 | 130 | |
| 131 | 131 | $args = array( |
| 132 | - 'post_date' => $this->date, | |
| 133 | - 'post_status' => $this->status, | |
| 134 | - 'post_title' => $this->get_title(), | |
| 135 | - 'post_author' => $this->author, | |
| 136 | - 'post_type' => Alerts::POST_TYPE, | |
| 132 | + 'post_date' => $this->date, | |
| 133 | + 'post_status' => $this->status, | |
| 134 | + 'post_title' => $this->get_title(), | |
| 135 | + 'post_author' => $this->author, | |
| 136 | + 'post_type' => Alerts::POST_TYPE, | |
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | 139 | foreach ( $args as $key => $value ) { |
| 140 | 140 | $data[ $key ] = $value; |
| @@ -140,10 +140,10 @@ | ||
| 140 | 140 | $data[ $key ] = $value; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $meta_input = array( |
| 144 | - 'alert_type' => $this->alert_type, | |
| 145 | - 'alert_meta' => $this->alert_meta, | |
| 144 | + 'alert_type' => $this->alert_type, | |
| 145 | + 'alert_meta' => $this->alert_meta, | |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | 148 | foreach ( $meta_input as $key => $value ) { |
| 149 | 149 | $this->update_meta( $key, $value ); |
| @@ -155,15 +155,15 @@ | ||
| 155 | 155 | /** |
| 156 | 156 | * Query record meta |
| 157 | 157 | * |
| 158 | 158 | * @param string $meta_key Meta key to retrieve (optional). Otherwise will |
| 159 | - * grab all meta data for the ID. | |
| 159 | + * grab all meta data for the ID. | |
| 160 | 160 | * @param bool $single Whether to only retrieve the first value (optional). |
| 161 | 161 | * |
| 162 | 162 | * @return mixed Single value if $single is true, array if false. |
| 163 | 163 | */ |
| 164 | 164 | public function get_meta( $meta_key = '', $single = false ) { |
| 165 | - return maybe_unserialize( get_post_meta( $this->ID, $meta_key, $single ) ); | |
| 165 | + return get_post_meta( $this->ID, $meta_key, $single ); | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * Update record meta |
| @@ -182,9 +182,9 @@ | ||
| 182 | 182 | * |
| 183 | 183 | * @todo enhance human readibility |
| 184 | 184 | * @return string The title of the alert |
| 185 | 185 | */ |
| 186 | - function get_title() { | |
| 186 | + public function get_title() { | |
| 187 | 187 | |
| 188 | 188 | $alert_type = $this->get_alert_type_obj()->name; |
| 189 | 189 | |
| 190 | 190 | $output = array(); |
| @@ -192,9 +192,9 @@ | ||
| 192 | 192 | $output[ $trigger_type ] = $this->plugin->alerts->alert_triggers[ $trigger_type ]->get_display_value( 'list_table', $this ); |
| 193 | 193 | } |
| 194 | 194 | $title = ''; |
| 195 | 195 | foreach ( $this->plugin->alerts->alert_triggers as $trigger_type => $trigger_obj ) { |
| 196 | - $value = $trigger_obj->get_display_value( 'list_table', $this ); | |
| 196 | + $value = $trigger_obj->get_display_value( 'list_table', $this ); | |
| 197 | 197 | $title .= $value . ' > '; |
| 198 | 198 | } |
| 199 | 199 | $title = rtrim( $title, ' > ' ); |
| 200 | 200 | return $title; |
| @@ -266,13 +266,15 @@ | ||
| 266 | 266 | } |
| 267 | 267 | if ( empty( $record->ID ) ) { |
| 268 | 268 | return false; |
| 269 | 269 | } |
| 270 | - $record = new Record( $record ); | |
| 270 | + $record = new Record( $record ); | |
| 271 | 271 | $alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true ); |
| 272 | 272 | |
| 273 | 273 | if ( empty( $alerts_triggered ) || ! is_array( $alerts_triggered ) ) { |
| 274 | - $alerts_triggered = array( $alert_slug => $alert_meta ); | |
| 274 | + $alerts_triggered = array( | |
| 275 | + $alert_slug => $alert_meta, | |
| 276 | + ); | |
| 275 | 277 | } elseif ( ! array_key_exists( $alert_slug, $alerts_triggered ) || ! is_array( $alerts_triggered[ $alert_slug ] ) ) { |
| 276 | 278 | $alerts_triggered[ $alert_slug ] = $alert_meta; |
| 277 | 279 | } |
| 278 | 280 | return $record->update_meta( Alerts::ALERTS_TRIGGERED_META_KEY, $alerts_triggered ); |
| @@ -303,9 +305,9 @@ | ||
| 303 | 305 | public function get_single_alert_setting_from_record( $record, $alert_slug, $setting, $default = false ) { |
| 304 | 306 | if ( ! is_object( $record ) || ! is_string( $alert_slug ) || ! is_string( $setting ) ) { |
| 305 | 307 | return false; |
| 306 | 308 | } |
| 307 | - $record = new Record( $record ); | |
| 309 | + $record = new Record( $record ); | |
| 308 | 310 | $alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true ); |
| 309 | 311 | |
| 310 | 312 | // Ensure we have a meta array and that this record has triggered a highlight alert. |
| 311 | 313 | if ( empty( $alerts_triggered ) || ! is_array( $alerts_triggered ) || ! array_key_exists( $alert_slug, $alerts_triggered ) ) { |