| @@ -37,12 +37,10 @@ | ||
| 37 | 37 | class Activity extends Base_Object { |
| 38 | 38 | const JSON_LD_CONTEXT = array( |
| 39 | 39 | 'https://www.w3.org/ns/activitystreams', |
| 40 | 40 | array( |
| 41 | - 'toot' => 'http://joinmastodon.org/ns#', | |
| 42 | - 'QuoteRequest' => 'toot:QuoteRequest', | |
| 43 | - 'blurhash' => 'toot:blurhash', | |
| 44 | - 'FeatureRequest' => 'https://w3id.org/fep/7aa9#FeatureRequest', | |
| 41 | + 'toot' => 'http://joinmastodon.org/ns#', | |
| 42 | + 'QuoteRequest' => 'toot:QuoteRequest', | |
| 45 | 43 | ), |
| 46 | 44 | ); |
| 47 | 45 | |
| 48 | 46 | /** |
| @@ -71,9 +69,8 @@ | ||
| 71 | 69 | 'Listen', |
| 72 | 70 | 'Move', |
| 73 | 71 | 'Offer', |
| 74 | 72 | 'QuoteRequest', // @see https://codeberg.org/fediverse/fep/src/branch/main/fep/044f/fep-044f.md |
| 75 | - 'FeatureRequest', // @see https://w3id.org/fep/7aa9 (FEP-7aa9 draft) | |
| 76 | 73 | 'Read', |
| 77 | 74 | 'Reject', |
| 78 | 75 | 'Remove', |
| 79 | 76 | 'TentativeAccept', |
| @@ -190,11 +187,11 @@ | ||
| 190 | 187 | public function set_object( $data ) { |
| 191 | 188 | $object = $data; |
| 192 | 189 | |
| 193 | 190 | // Convert array to appropriate object type. |
| 194 | - if ( \is_array( $data ) ) { | |
| 195 | - if ( \array_is_list( $data ) ) { | |
| 196 | - $object = \array_map( array( $this, 'maybe_convert_to_object' ), $data ); | |
| 191 | + if ( is_array( $data ) ) { | |
| 192 | + if ( array_is_list( $data ) ) { | |
| 193 | + $object = array_map( array( $this, 'maybe_convert_to_object' ), $data ); | |
| 197 | 194 | } else { |
| 198 | 195 | $object = $this->maybe_convert_to_object( $data ); |
| 199 | 196 | } |
| 200 | 197 | } |
| @@ -209,16 +206,16 @@ | ||
| 209 | 206 | public function pre_fill_activity_from_object() { |
| 210 | 207 | $object = $this->get_object(); |
| 211 | 208 | |
| 212 | 209 | // Check if `$object` is a URL and use it to generate an ID then. |
| 213 | - if ( \is_string( $object ) && \filter_var( $object, FILTER_VALIDATE_URL ) && ! $this->get_id() ) { | |
| 214 | - $this->set( 'id', $object . '#activity-' . \strtolower( $this->get_type() ) . '-' . \time() ); | |
| 210 | + if ( is_string( $object ) && filter_var( $object, FILTER_VALIDATE_URL ) && ! $this->get_id() ) { | |
| 211 | + $this->set( 'id', $object . '#activity-' . strtolower( $this->get_type() ) . '-' . time() ); | |
| 215 | 212 | |
| 216 | 213 | return; |
| 217 | 214 | } |
| 218 | 215 | |
| 219 | 216 | // Check if `$object` is an object and copy some properties otherwise do nothing. |
| 220 | - if ( ! \is_object( $object ) ) { | |
| 217 | + if ( ! is_object( $object ) ) { | |
| 221 | 218 | return; |
| 222 | 219 | } |
| 223 | 220 | |
| 224 | 221 | foreach ( array( 'to', 'bto', 'cc', 'bcc', 'audience' ) as $i ) { |
| @@ -248,17 +245,17 @@ | ||
| 248 | 245 | $this->set( 'interaction_policy', $object->get_interaction_policy() ); |
| 249 | 246 | } |
| 250 | 247 | |
| 251 | 248 | if ( $object->get_id() && ! $this->get_id() ) { |
| 252 | - $id = \strtok( $object->get_id(), '#' ); | |
| 249 | + $id = strtok( $object->get_id(), '#' ); | |
| 253 | 250 | if ( $object->get_updated() ) { |
| 254 | 251 | $updated = $object->get_updated(); |
| 255 | 252 | } elseif ( $object->get_published() ) { |
| 256 | 253 | $updated = $object->get_published(); |
| 257 | 254 | } else { |
| 258 | - $updated = \time(); | |
| 255 | + $updated = time(); | |
| 259 | 256 | } |
| 260 | - $this->set( 'id', $id . '#activity-' . \strtolower( $this->get_type() ) . '-' . $updated ); | |
| 257 | + $this->set( 'id', $id . '#activity-' . strtolower( $this->get_type() ) . '-' . $updated ); | |
| 261 | 258 | } |
| 262 | 259 | } |
| 263 | 260 | |
| 264 | 261 | /** |
| @@ -267,9 +264,9 @@ | ||
| 267 | 264 | * @return array $context A compacted JSON-LD context. |
| 268 | 265 | */ |
| 269 | 266 | public function get_json_ld_context() { |
| 270 | 267 | if ( \is_object( $this->object ) ) { |
| 271 | - $class = \get_class( $this->object ); | |
| 268 | + $class = get_class( $this->object ); | |
| 272 | 269 | if ( $class && $class::JSON_LD_CONTEXT ) { |
| 273 | 270 | // Without php 5.6 support this could be just: 'return $this->object::JSON_LD_CONTEXT;'. |
| 274 | 271 | return $class::JSON_LD_CONTEXT; |
| 275 | 272 | } |
| @@ -285,19 +282,19 @@ | ||
| 285 | 282 | * |
| 286 | 283 | * @return Activity|Actor|Base_Object|Generic_Object|string|\WP_Error|null The converted object or original data. |
| 287 | 284 | */ |
| 288 | 285 | private function maybe_convert_to_object( $data ) { |
| 289 | - if ( ! \is_array( $data ) ) { | |
| 286 | + if ( ! is_array( $data ) ) { | |
| 290 | 287 | return $data; |
| 291 | 288 | } |
| 292 | 289 | |
| 293 | 290 | $type = $data['type'] ?? null; |
| 294 | 291 | |
| 295 | - if ( \in_array( $type, self::TYPES, true ) ) { | |
| 292 | + if ( in_array( $type, self::TYPES, true ) ) { | |
| 296 | 293 | $object = self::init_from_array( $data ); |
| 297 | - } elseif ( \in_array( $type, Actor::TYPES, true ) ) { | |
| 294 | + } elseif ( in_array( $type, Actor::TYPES, true ) ) { | |
| 298 | 295 | $object = Actor::init_from_array( $data ); |
| 299 | - } elseif ( \in_array( $type, Base_Object::TYPES, true ) ) { | |
| 296 | + } elseif ( in_array( $type, Base_Object::TYPES, true ) ) { | |
| 300 | 297 | switch ( $type ) { |
| 301 | 298 | case 'Event': |
| 302 | 299 | $object = Event::init_from_array( $data ); |
| 303 | 300 | break; |