updated plugin ActivityPub
version 3.3.3
This commit is contained in:
@ -3,11 +3,13 @@
|
||||
* Inspired by the PHP ActivityPub Library by @Landrok
|
||||
*
|
||||
* @link https://github.com/landrok/activitypub
|
||||
*
|
||||
* @package Activitypub
|
||||
*/
|
||||
|
||||
namespace Activitypub\Activity;
|
||||
|
||||
use Activitypub\Activity\Base_Object;
|
||||
use Activitypub\Link;
|
||||
|
||||
/**
|
||||
* \Activitypub\Activity\Activity implements the common
|
||||
@ -22,6 +24,8 @@ class Activity extends Base_Object {
|
||||
);
|
||||
|
||||
/**
|
||||
* The type of the object.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Activity';
|
||||
@ -90,6 +94,21 @@ class Activity extends Base_Object {
|
||||
*/
|
||||
protected $result;
|
||||
|
||||
/**
|
||||
* Identifies a Collection containing objects considered to be responses
|
||||
* to this object.
|
||||
* WordPress has a strong core system of approving replies. We only include
|
||||
* approved replies here.
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-replies
|
||||
*
|
||||
* @var array
|
||||
* | ObjectType
|
||||
* | Link
|
||||
* | null
|
||||
*/
|
||||
protected $replies;
|
||||
|
||||
/**
|
||||
* An indirect object of the activity from which the
|
||||
* activity is directed.
|
||||
@ -128,45 +147,49 @@ class Activity extends Base_Object {
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitypub/#object-without-create
|
||||
*
|
||||
* @param string|Base_Objectr|Link|null $object
|
||||
* @param array|string|Base_Object|Link|null $data Activity object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_object( $object ) {
|
||||
// convert array to object
|
||||
if ( is_array( $object ) ) {
|
||||
$object = self::init_from_array( $object );
|
||||
public function set_object( $data ) {
|
||||
// Convert array to object.
|
||||
if ( is_array( $data ) ) {
|
||||
$data = self::init_from_array( $data );
|
||||
}
|
||||
|
||||
// set object
|
||||
$this->set( 'object', $object );
|
||||
// Set object.
|
||||
$this->set( 'object', $data );
|
||||
|
||||
if ( ! is_object( $object ) ) {
|
||||
if ( ! is_object( $data ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( array( 'to', 'bto', 'cc', 'bcc', 'audience' ) as $i ) {
|
||||
$this->set( $i, $object->get( $i ) );
|
||||
$this->set( $i, $data->get( $i ) );
|
||||
}
|
||||
|
||||
if ( $object->get_published() && ! $this->get_published() ) {
|
||||
$this->set( 'published', $object->get_published() );
|
||||
if ( $data->get_published() && ! $this->get_published() ) {
|
||||
$this->set( 'published', $data->get_published() );
|
||||
}
|
||||
|
||||
if ( $object->get_updated() && ! $this->get_updated() ) {
|
||||
$this->set( 'updated', $object->get_updated() );
|
||||
if ( $data->get_updated() && ! $this->get_updated() ) {
|
||||
$this->set( 'updated', $data->get_updated() );
|
||||
}
|
||||
|
||||
if ( $object->get_attributed_to() && ! $this->get_actor() ) {
|
||||
$this->set( 'actor', $object->get_attributed_to() );
|
||||
if ( $data->get_attributed_to() && ! $this->get_actor() ) {
|
||||
$this->set( 'actor', $data->get_attributed_to() );
|
||||
}
|
||||
|
||||
if ( $object->get_id() && ! $this->get_id() ) {
|
||||
$id = strtok( $object->get_id(), '#' );
|
||||
if ( $object->get_updated() ) {
|
||||
$updated = $object->get_updated();
|
||||
if ( $data->get_in_reply_to() ) {
|
||||
$this->set( 'in_reply_to', $data->get_in_reply_to() );
|
||||
}
|
||||
|
||||
if ( $data->get_id() && ! $this->get_id() ) {
|
||||
$id = strtok( $data->get_id(), '#' );
|
||||
if ( $data->get_updated() ) {
|
||||
$updated = $data->get_updated();
|
||||
} else {
|
||||
$updated = $object->get_published();
|
||||
$updated = $data->get_published();
|
||||
}
|
||||
$this->set( 'id', $id . '#activity-' . strtolower( $this->get_type() ) . '-' . $updated );
|
||||
}
|
||||
@ -181,7 +204,7 @@ class Activity extends Base_Object {
|
||||
if ( $this->object instanceof Base_Object ) {
|
||||
$class = get_class( $this->object );
|
||||
if ( $class && $class::JSON_LD_CONTEXT ) {
|
||||
// Without php 5.6 support this could be just: 'return $this->object::JSON_LD_CONTEXT;'
|
||||
// Without php 5.6 support this could be just: 'return $this->object::JSON_LD_CONTEXT;'.
|
||||
return $class::JSON_LD_CONTEXT;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
* Inspired by the PHP ActivityPub Library by @Landrok
|
||||
*
|
||||
* @link https://github.com/landrok/activitypub
|
||||
*
|
||||
* @package Activitypub
|
||||
*/
|
||||
|
||||
namespace Activitypub\Activity;
|
||||
@ -22,34 +24,34 @@ class Actor extends Base_Object {
|
||||
'https://w3id.org/security/v1',
|
||||
'https://purl.archive.org/socialweb/webfinger',
|
||||
array(
|
||||
'schema' => 'http://schema.org#',
|
||||
'toot' => 'http://joinmastodon.org/ns#',
|
||||
'webfinger' => 'https://webfinger.net/#',
|
||||
'lemmy' => 'https://join-lemmy.org/ns#',
|
||||
'schema' => 'http://schema.org#',
|
||||
'toot' => 'http://joinmastodon.org/ns#',
|
||||
'lemmy' => 'https://join-lemmy.org/ns#',
|
||||
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
||||
'PropertyValue' => 'schema:PropertyValue',
|
||||
'value' => 'schema:value',
|
||||
'Hashtag' => 'as:Hashtag',
|
||||
'featured' => array(
|
||||
'@id' => 'toot:featured',
|
||||
'PropertyValue' => 'schema:PropertyValue',
|
||||
'value' => 'schema:value',
|
||||
'Hashtag' => 'as:Hashtag',
|
||||
'featured' => array(
|
||||
'@id' => 'toot:featured',
|
||||
'@type' => '@id',
|
||||
),
|
||||
'featuredTags' => array(
|
||||
'@id' => 'toot:featuredTags',
|
||||
'featuredTags' => array(
|
||||
'@id' => 'toot:featuredTags',
|
||||
'@type' => '@id',
|
||||
),
|
||||
'moderators' => array(
|
||||
'@id' => 'lemmy:moderators',
|
||||
'moderators' => array(
|
||||
'@id' => 'lemmy:moderators',
|
||||
'@type' => '@id',
|
||||
),
|
||||
'postingRestrictedToMods' => 'lemmy:postingRestrictedToMods',
|
||||
'discoverable' => 'toot:discoverable',
|
||||
'indexable' => 'toot:indexable',
|
||||
'resource' => 'webfinger:resource',
|
||||
'postingRestrictedToMods' => 'lemmy:postingRestrictedToMods',
|
||||
'discoverable' => 'toot:discoverable',
|
||||
'indexable' => 'toot:indexable',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* The type of the object.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
@ -171,4 +173,15 @@ class Actor extends Base_Object {
|
||||
* @var boolean
|
||||
*/
|
||||
protected $manually_approves_followers = false;
|
||||
|
||||
/**
|
||||
* Used to mark an object as containing sensitive content.
|
||||
* Mastodon displays a content warning, requiring users to click
|
||||
* through to view the content.
|
||||
*
|
||||
* @see https://docs.joinmastodon.org/spec/activitypub/#sensitive
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sensitive = null;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
* Inspired by the PHP ActivityPub Library by @Landrok
|
||||
*
|
||||
* @link https://github.com/landrok/activitypub
|
||||
*
|
||||
* @package Activitypub
|
||||
*/
|
||||
|
||||
namespace Activitypub\Activity;
|
||||
@ -30,7 +32,8 @@ class Base_Object {
|
||||
const JSON_LD_CONTEXT = array(
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
array(
|
||||
'Hashtag' => 'as:Hashtag',
|
||||
'Hashtag' => 'as:Hashtag',
|
||||
'sensitive' => 'as:sensitive',
|
||||
),
|
||||
);
|
||||
|
||||
@ -44,6 +47,8 @@ class Base_Object {
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The type of the object.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Object';
|
||||
@ -428,7 +433,7 @@ class Base_Object {
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitypub/#source-property
|
||||
*
|
||||
* @var ObjectType
|
||||
* @var array
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
@ -446,12 +451,21 @@ class Base_Object {
|
||||
protected $replies;
|
||||
|
||||
/**
|
||||
* Magic function to implement getter and setter
|
||||
* Used to mark an object as containing sensitive content.
|
||||
* Mastodon displays a content warning, requiring users to click
|
||||
* through to view the content.
|
||||
*
|
||||
* @see https://docs.joinmastodon.org/spec/activitypub/#sensitive
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sensitive = false;
|
||||
|
||||
/**
|
||||
* Magic function to implement getter and setter.
|
||||
*
|
||||
* @param string $method The method name.
|
||||
* @param string $params The method params.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __call( $method, $params ) {
|
||||
$var = \strtolower( \substr( $method, 4 ) );
|
||||
@ -563,9 +577,9 @@ class Base_Object {
|
||||
/**
|
||||
* Convert JSON input to an array.
|
||||
*
|
||||
* @return string The JSON string.
|
||||
* @param string $json The JSON string.
|
||||
*
|
||||
* @return \Activitypub\Activity\Base_Object An Object built from the JSON string.
|
||||
* @return Base_Object An Object built from the JSON string.
|
||||
*/
|
||||
public static function init_from_json( $json ) {
|
||||
$array = \json_decode( $json, true );
|
||||
@ -578,20 +592,20 @@ class Base_Object {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert JSON input to an array.
|
||||
* Convert input array to a Base_Object.
|
||||
*
|
||||
* @return string The object array.
|
||||
* @param array $data The object array.
|
||||
*
|
||||
* @return \Activitypub\Activity\Base_Object An Object built from the JSON string.
|
||||
* @return Base_Object|WP_Error An Object built from the input array or WP_Error when it's not an array.
|
||||
*/
|
||||
public static function init_from_array( $array ) {
|
||||
if ( ! is_array( $array ) ) {
|
||||
public static function init_from_array( $data ) {
|
||||
if ( ! is_array( $data ) ) {
|
||||
return new WP_Error( 'invalid_array', __( 'Invalid array', 'activitypub' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$object = new static();
|
||||
|
||||
foreach ( $array as $key => $value ) {
|
||||
foreach ( $data as $key => $value ) {
|
||||
$key = camel_to_snake_case( $key );
|
||||
call_user_func( array( $object, 'set_' . $key ), $value );
|
||||
}
|
||||
@ -613,10 +627,10 @@ class Base_Object {
|
||||
/**
|
||||
* Convert JSON input to an array and pre-fill the object.
|
||||
*
|
||||
* @param array $array The array.
|
||||
* @param array $data The array.
|
||||
*/
|
||||
public function from_array( $array ) {
|
||||
foreach ( $array as $key => $value ) {
|
||||
public function from_array( $data ) {
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( $value ) {
|
||||
$key = camel_to_snake_case( $key );
|
||||
call_user_func( array( $this, 'set_' . $key ), $value );
|
||||
@ -639,12 +653,12 @@ class Base_Object {
|
||||
$vars = get_object_vars( $this );
|
||||
|
||||
foreach ( $vars as $key => $value ) {
|
||||
// ignotre all _prefixed keys.
|
||||
// Ignore all _prefixed keys.
|
||||
if ( '_' === substr( $key, 0, 1 ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if value is empty, try to get it from a getter.
|
||||
// If value is empty, try to get it from a getter.
|
||||
if ( ! $value ) {
|
||||
$value = call_user_func( array( $this, 'get_' . $key ) );
|
||||
}
|
||||
@ -653,7 +667,7 @@ class Base_Object {
|
||||
$value = $value->to_array( false );
|
||||
}
|
||||
|
||||
// if value is still empty, ignore it for the array and continue.
|
||||
// If value is still empty, ignore it for the array and continue.
|
||||
if ( isset( $value ) ) {
|
||||
$array[ snake_to_camel_case( $key ) ] = $value;
|
||||
}
|
||||
@ -667,10 +681,28 @@ class Base_Object {
|
||||
$class = new ReflectionClass( $this );
|
||||
$class = strtolower( $class->getShortName() );
|
||||
|
||||
/**
|
||||
* Filter the array of the ActivityPub object.
|
||||
*
|
||||
* @param array $array The array of the ActivityPub object.
|
||||
* @param string $class The class of the ActivityPub object.
|
||||
* @param int $id The ID of the ActivityPub object.
|
||||
* @param Base_Object $object The ActivityPub object.
|
||||
*
|
||||
* @return array The filtered array of the ActivityPub object.
|
||||
*/
|
||||
$array = \apply_filters( 'activitypub_activity_object_array', $array, $class, $this->id, $this );
|
||||
$array = \apply_filters( "activitypub_activity_{$class}_object_array", $array, $this->id, $this );
|
||||
|
||||
return $array;
|
||||
/**
|
||||
* Filter the array of the ActivityPub object by class.
|
||||
*
|
||||
* @param array $array The array of the ActivityPub object.
|
||||
* @param int $id The ID of the ActivityPub object.
|
||||
* @param Base_Object $object The ActivityPub object.
|
||||
*
|
||||
* @return array The filtered array of the ActivityPub object.
|
||||
*/
|
||||
return \apply_filters( "activitypub_activity_{$class}_object_array", $array, $this->id, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -684,11 +716,11 @@ class Base_Object {
|
||||
$array = $this->to_array( $include_json_ld_context );
|
||||
$options = \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT;
|
||||
|
||||
/*
|
||||
* Options to be passed to json_encode()
|
||||
*
|
||||
* @param int $options The current options flags
|
||||
*/
|
||||
/**
|
||||
* Options to be passed to json_encode()
|
||||
*
|
||||
* @param int $options The current options flags.
|
||||
*/
|
||||
$options = \apply_filters( 'activitypub_json_encode_options', $options );
|
||||
|
||||
return \wp_json_encode( $array, $options );
|
||||
|
@ -19,8 +19,8 @@ use Activitypub\Activity\Base_Object;
|
||||
class Event extends Base_Object {
|
||||
// Human friendly minimal context for full Mobilizon compatible ActivityPub events.
|
||||
const JSON_LD_CONTEXT = array(
|
||||
'https://schema.org/', // The base context is schema.org, cause it is used a lot.
|
||||
'https://www.w3.org/ns/activitystreams', // The ActivityStreams context overrides everyting also defined in schema.org.
|
||||
'https://schema.org/', // The base context is schema.org, because it is used a lot.
|
||||
'https://www.w3.org/ns/activitystreams', // The ActivityStreams context overrides everything also defined in schema.org.
|
||||
array( // The keys here override/extend the context even more.
|
||||
'pt' => 'https://joinpeertube.org/ns#',
|
||||
'mz' => 'https://joinmobilizon.org/ns#',
|
||||
@ -51,6 +51,7 @@ class Event extends Base_Object {
|
||||
|
||||
/**
|
||||
* Mobilizon compatible values for repliesModertaionOption.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
const REPLIES_MODERATION_OPTION_TYPES = array( 'allow_all', 'closed' );
|
||||
@ -58,10 +59,11 @@ class Event extends Base_Object {
|
||||
/**
|
||||
* Mobilizon compatible values for joinModeTypes.
|
||||
*/
|
||||
const JOIN_MODE_TYPES = array( 'free', 'restricted', 'external' ); // and 'invite', but not used by mobilizon atm
|
||||
const JOIN_MODE_TYPES = array( 'free', 'restricted', 'external' ); // and 'invite', but not used by mobilizon atm.
|
||||
|
||||
/**
|
||||
* Allowed values for ical VEVENT STATUS.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
const ICAL_EVENT_STATUS_TYPES = array( 'TENTATIVE', 'CONFIRMED', 'CANCELLED' );
|
||||
@ -70,6 +72,7 @@ class Event extends Base_Object {
|
||||
* Default event categories.
|
||||
*
|
||||
* These values currently reflect the default set as proposed by Mobilizon to maximize interoperability.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
const DEFAULT_EVENT_CATEGORIES = array(
|
||||
@ -106,8 +109,7 @@ class Event extends Base_Object {
|
||||
);
|
||||
|
||||
/**
|
||||
* Event is an implementation of one of the
|
||||
* Activity Streams
|
||||
* Event is an implementation of one of the Activity Streams.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
@ -115,11 +117,13 @@ class Event extends Base_Object {
|
||||
|
||||
/**
|
||||
* The Title of the event.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The events contacts
|
||||
* The events contacts.
|
||||
*
|
||||
* @context {
|
||||
* '@id' => 'mz:contacts',
|
||||
@ -142,12 +146,16 @@ class Event extends Base_Object {
|
||||
protected $comments_enabled;
|
||||
|
||||
/**
|
||||
* Timezone of the event.
|
||||
*
|
||||
* @context https://joinmobilizon.org/ns#timezone
|
||||
* @var string
|
||||
*/
|
||||
protected $timezone;
|
||||
|
||||
/**
|
||||
* Moderation option for replies.
|
||||
*
|
||||
* @context https://joinmobilizon.org/ns#repliesModerationOption
|
||||
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#repliesmoderation
|
||||
* @var string
|
||||
@ -155,6 +163,8 @@ class Event extends Base_Object {
|
||||
protected $replies_moderation_option;
|
||||
|
||||
/**
|
||||
* Whether anonymous participation is enabled.
|
||||
*
|
||||
* @context https://joinmobilizon.org/ns#anonymousParticipationEnabled
|
||||
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#anonymousparticipationenabled
|
||||
* @var bool
|
||||
@ -162,26 +172,34 @@ class Event extends Base_Object {
|
||||
protected $anonymous_participation_enabled;
|
||||
|
||||
/**
|
||||
* The event's category.
|
||||
*
|
||||
* @context https://schema.org/category
|
||||
* @var enum
|
||||
* @var string
|
||||
*/
|
||||
protected $category;
|
||||
|
||||
/**
|
||||
* Language of the event.
|
||||
*
|
||||
* @context https://schema.org/inLanguage
|
||||
* @var
|
||||
* @var string
|
||||
*/
|
||||
protected $in_language;
|
||||
|
||||
/**
|
||||
* Whether the event is online.
|
||||
*
|
||||
* @context https://joinmobilizon.org/ns#isOnline
|
||||
* @var bool
|
||||
*/
|
||||
protected $is_online;
|
||||
|
||||
/**
|
||||
* The event's status.
|
||||
*
|
||||
* @context https://www.w3.org/2002/12/cal/ical#status
|
||||
* @var enum
|
||||
* @var string
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
@ -196,25 +214,33 @@ class Event extends Base_Object {
|
||||
protected $actor;
|
||||
|
||||
/**
|
||||
* The external participation URL.
|
||||
*
|
||||
* @context https://joinmobilizon.org/ns#externalParticipationUrl
|
||||
* @var string
|
||||
*/
|
||||
protected $external_participation_url;
|
||||
|
||||
/**
|
||||
* Indicator of how new members may be able to join.
|
||||
*
|
||||
* @context https://joinmobilizon.org/ns#joinMode
|
||||
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#joinmode
|
||||
* @var
|
||||
* @var string
|
||||
*/
|
||||
protected $join_mode;
|
||||
|
||||
/**
|
||||
* The participant count of the event.
|
||||
*
|
||||
* @context https://joinmobilizon.org/ns#participantCount
|
||||
* @var int
|
||||
*/
|
||||
protected $participant_count;
|
||||
|
||||
/**
|
||||
* How many places there can be for an event.
|
||||
*
|
||||
* @context https://schema.org/maximumAttendeeCapacity
|
||||
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#maximumattendeecapacity
|
||||
* @var int
|
||||
@ -222,6 +248,8 @@ class Event extends Base_Object {
|
||||
protected $maximum_attendee_capacity;
|
||||
|
||||
/**
|
||||
* The number of attendee places for an event that remain unallocated.
|
||||
*
|
||||
* @context https://schema.org/remainingAttendeeCapacity
|
||||
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#remainignattendeecapacity
|
||||
* @var int
|
||||
@ -234,6 +262,7 @@ class Event extends Base_Object {
|
||||
* The passed timezone is only set when it is a valid one, otherwise the site's timezone is used.
|
||||
*
|
||||
* @param string $timezone The timezone string to be set, e.g. 'Europe/Berlin'.
|
||||
* @return Event
|
||||
*/
|
||||
public function set_timezone( $timezone ) {
|
||||
if ( in_array( $timezone, timezone_identifiers_list(), true ) ) {
|
||||
@ -246,14 +275,16 @@ class Event extends Base_Object {
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom setter for repliesModerationOption which also directy sets commentsEnabled accordingly.
|
||||
* Custom setter for repliesModerationOption which also directly sets commentsEnabled accordingly.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $type The type of the replies moderation option.
|
||||
*
|
||||
* @return Event
|
||||
*/
|
||||
public function set_replies_moderation_option( $type ) {
|
||||
if ( in_array( $type, self::REPLIES_MODERATION_OPTION_TYPES, true ) ) {
|
||||
$this->replies_moderation_option = $type;
|
||||
$this->comments_enabled = ( 'allow_all' === $type ) ? true : false;
|
||||
$this->comments_enabled = ( 'allow_all' === $type ) ? true : false;
|
||||
} else {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
@ -268,11 +299,13 @@ class Event extends Base_Object {
|
||||
/**
|
||||
* Custom setter for commentsEnabled which also directly sets repliesModerationOption accordingly.
|
||||
*
|
||||
* @param bool $comments_enabled
|
||||
* @param bool $comments_enabled Whether comments are enabled.
|
||||
*
|
||||
* @return Event
|
||||
*/
|
||||
public function set_comments_enabled( $comments_enabled ) {
|
||||
if ( is_bool( $comments_enabled ) ) {
|
||||
$this->comments_enabled = $comments_enabled;
|
||||
$this->comments_enabled = $comments_enabled;
|
||||
$this->replies_moderation_option = $comments_enabled ? 'allow_all' : 'closed';
|
||||
} else {
|
||||
_doing_it_wrong(
|
||||
@ -288,7 +321,9 @@ class Event extends Base_Object {
|
||||
/**
|
||||
* Custom setter for the ical status that checks whether the status is an ical event status.
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $status The status of the event.
|
||||
*
|
||||
* @return Event
|
||||
*/
|
||||
public function set_status( $status ) {
|
||||
if ( in_array( $status, self::ICAL_EVENT_STATUS_TYPES, true ) ) {
|
||||
@ -309,8 +344,10 @@ class Event extends Base_Object {
|
||||
*
|
||||
* Falls back to Mobilizons default category.
|
||||
*
|
||||
* @param string $category
|
||||
* @param bool $mobilizon_compatibilty Whether the category must be compatibly with Mobilizon.
|
||||
* @param string $category The category of the event.
|
||||
* @param bool $mobilizon_compatibilty Optional. Whether the category must be compatibly with Mobilizon. Default true.
|
||||
*
|
||||
* @return Event
|
||||
*/
|
||||
public function set_category( $category, $mobilizon_compatibilty = true ) {
|
||||
if ( $mobilizon_compatibilty ) {
|
||||
@ -327,12 +364,14 @@ class Event extends Base_Object {
|
||||
*
|
||||
* Automatically sets the joinMode to true if called.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $url The URL for external participation.
|
||||
*
|
||||
* @return Event
|
||||
*/
|
||||
public function set_external_participation_url( $url ) {
|
||||
if ( preg_match( '/^https?:\/\/.*/i', $url ) ) {
|
||||
$this->external_participation_url = $url;
|
||||
$this->join_mode = 'external';
|
||||
$this->join_mode = 'external';
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -63,22 +63,34 @@ class Place extends Base_Object {
|
||||
protected $longitude;
|
||||
|
||||
/**
|
||||
* The radius from the given latitude and longitude for a Place.
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-radius
|
||||
* @var float
|
||||
*/
|
||||
protected $radius;
|
||||
|
||||
/**
|
||||
* Specifies the measurement units for the `radius` and `altitude` properties.
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-units
|
||||
* @var string
|
||||
*/
|
||||
protected $units;
|
||||
|
||||
/**
|
||||
* @var Postal_Address|string
|
||||
* The address of the place.
|
||||
*
|
||||
* @see https://schema.org/PostalAddress
|
||||
* @var array|string
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
/**
|
||||
* Set the address of the place.
|
||||
*
|
||||
* @param array|string $address The address of the place.
|
||||
*/
|
||||
public function set_address( $address ) {
|
||||
if ( is_string( $address ) || is_array( $address ) ) {
|
||||
$this->address = $address;
|
||||
|
Reference in New Issue
Block a user