| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin constants. |
| 4 |
* |
| 5 |
* @package Activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
// The following constants can be defined in your wp-config.php file to override the default values. |
| 9 |
|
| 10 |
defined( 'ACTIVITYPUB_REST_NAMESPACE' ) || define( 'ACTIVITYPUB_REST_NAMESPACE', 'activitypub/1.0' ); |
| 11 |
defined( 'ACTIVITYPUB_EXCERPT_LENGTH' ) || define( 'ACTIVITYPUB_EXCERPT_LENGTH', 400 ); |
| 12 |
defined( 'ACTIVITYPUB_NOTE_LENGTH' ) || define( 'ACTIVITYPUB_NOTE_LENGTH', 500 ); |
| 13 |
defined( 'ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS' ) || define( 'ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS', 4 ); |
| 14 |
defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|(?<=<p>)|(?<=<br>)|^)#([A-Za-z0-9_]+)(?:(?=\s|[[:punct:]]|$))' ); |
| 15 |
defined( 'ACTIVITYPUB_USERNAME_REGEXP' ) || define( 'ACTIVITYPUB_USERNAME_REGEXP', '(?:([A-Za-z0-9\._-]+)@((?:[A-Za-z0-9_-]+\.)+[A-Za-z]+))' ); |
| 16 |
defined( 'ACTIVITYPUB_URL_REGEXP' ) || define( 'ACTIVITYPUB_URL_REGEXP', '(https?:|www\.)\S+[\w\/]' ); |
| 17 |
defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "[ap_title type=\"html\"]\n\n[ap_content]\n\n[ap_hashtags]" ); |
| 18 |
defined( 'ACTIVITYPUB_DISABLE_REWRITES' ) || define( 'ACTIVITYPUB_DISABLE_REWRITES', false ); |
| 19 |
defined( 'ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS' ) || define( 'ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS', false ); |
| 20 |
defined( 'ACTIVITYPUB_DISABLE_OUTGOING_INTERACTIONS' ) || define( 'ACTIVITYPUB_DISABLE_OUTGOING_INTERACTIONS', false ); |
| 21 |
defined( 'ACTIVITYPUB_DEFAULT_OBJECT_TYPE' ) || define( 'ACTIVITYPUB_DEFAULT_OBJECT_TYPE', 'wordpress-post-format' ); |
| 22 |
defined( 'ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE' ) || define( 'ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE', 100 ); |
| 23 |
defined( 'ACTIVITYPUB_DISTRIBUTION_MODE' ) || define( 'ACTIVITYPUB_DISTRIBUTION_MODE', false ); |
| 24 |
// Backwards compatibility: map old ACTIVITYPUB_DISABLE_SIDELOADING to ACTIVITYPUB_DISABLE_REMOTE_CACHE. |
| 25 |
if ( ! defined( 'ACTIVITYPUB_DISABLE_REMOTE_CACHE' ) && defined( 'ACTIVITYPUB_DISABLE_SIDELOADING' ) ) { |
| 26 |
define( 'ACTIVITYPUB_DISABLE_REMOTE_CACHE', ACTIVITYPUB_DISABLE_SIDELOADING ); |
| 27 |
} |
| 28 |
defined( 'ACTIVITYPUB_DISABLE_REMOTE_CACHE' ) || define( 'ACTIVITYPUB_DISABLE_REMOTE_CACHE', false ); |
| 29 |
|
| 30 |
// The following constants are invariable and define values used throughout the plugin. |
| 31 |
|
| 32 |
/* |
| 33 |
* Mastodon HTML sanitizer. |
| 34 |
* |
| 35 |
* @see https://docs.joinmastodon.org/spec/activitypub/#sanitization |
| 36 |
*/ |
| 37 |
define( |
| 38 |
'ACTIVITYPUB_MASTODON_HTML_SANITIZER', |
| 39 |
array( |
| 40 |
'p' => array(), |
| 41 |
'span' => array( 'class' => true ), |
| 42 |
'br' => array(), |
| 43 |
'a' => array( |
| 44 |
'href' => true, |
| 45 |
'rel' => true, |
| 46 |
'class' => true, |
| 47 |
), |
| 48 |
'del' => array(), |
| 49 |
'pre' => array(), |
| 50 |
'code' => array(), |
| 51 |
'em' => array(), |
| 52 |
'strong' => array(), |
| 53 |
'b' => array(), |
| 54 |
'i' => array(), |
| 55 |
'u' => array(), |
| 56 |
'ul' => array(), |
| 57 |
'ol' => array( |
| 58 |
'start' => true, |
| 59 |
'reversed' => true, |
| 60 |
), |
| 61 |
'li' => array( 'value' => true ), |
| 62 |
'blockquote' => array(), |
| 63 |
'h1' => array(), |
| 64 |
'h2' => array(), |
| 65 |
'h3' => array(), |
| 66 |
'h4' => array(), |
| 67 |
) |
| 68 |
); |
| 69 |
|
| 70 |
define( 'ACTIVITYPUB_DATE_TIME_RFC3339', 'Y-m-d\TH:i:s\Z' ); |
| 71 |
|
| 72 |
// Define Actor-Modes for the plugin. |
| 73 |
define( 'ACTIVITYPUB_ACTOR_MODE', 'actor' ); |
| 74 |
define( 'ACTIVITYPUB_BLOG_MODE', 'blog' ); |
| 75 |
define( 'ACTIVITYPUB_ACTOR_AND_BLOG_MODE', 'actor_blog' ); |
| 76 |
|
| 77 |
// Post visibility constants. |
| 78 |
define( 'ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC', '' ); |
| 79 |
define( 'ACTIVITYPUB_CONTENT_VISIBILITY_QUIET_PUBLIC', 'quiet_public' ); |
| 80 |
define( 'ACTIVITYPUB_CONTENT_VISIBILITY_PRIVATE', 'private' ); |
| 81 |
define( 'ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL', 'local' ); |
| 82 |
|
| 83 |
// Object state constants (stored in activitypub_status meta). |
| 84 |
define( 'ACTIVITYPUB_OBJECT_STATE_PENDING', 'pending' ); |
| 85 |
define( 'ACTIVITYPUB_OBJECT_STATE_FEDERATED', 'federated' ); |
| 86 |
define( 'ACTIVITYPUB_OBJECT_STATE_FAILED', 'failed' ); |
| 87 |
define( 'ACTIVITYPUB_OBJECT_STATE_DELETED', 'deleted' ); |
| 88 |
|
| 89 |
// Interaction policy constants. |
| 90 |
define( 'ACTIVITYPUB_INTERACTION_POLICY_ANYONE', 'anyone' ); |
| 91 |
define( 'ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS', 'followers' ); |
| 92 |
define( 'ACTIVITYPUB_INTERACTION_POLICY_ME', 'me' ); |
| 93 |
|
| 94 |
// Identifiers that mark an Activity as Public. |
| 95 |
define( |
| 96 |
'ACTIVITYPUB_PUBLIC_AUDIENCE_IDENTIFIERS', |
| 97 |
array( |
| 98 |
'https://www.w3.org/ns/activitystreams#Public', |
| 99 |
'as:Public', |
| 100 |
'Public', // For backwards compatibility. |
| 101 |
) |
| 102 |
); |
| 103 |
|
| 104 |
/* |
| 105 |
* HTTP error codes that indicate temporary/retriable failures. |
| 106 |
* |
| 107 |
* These errors suggest the server may recover quickly, so they get |
| 108 |
* shorter cache durations and qualify for automatic retries. |
| 109 |
* |
| 110 |
* @see https://github.com/tfredrich/RestApiTutorial.com/blob/master/content/advanced/responses/retries.md |
| 111 |
*/ |
| 112 |
define( 'ACTIVITYPUB_RETRY_ERROR_CODES', array( 408, 429, 500, 502, 503, 504 ) ); |
| 113 |
|
| 114 |
// Default purge retention periods (in days). |
| 115 |
define( 'ACTIVITYPUB_OUTBOX_PURGE_DAYS', 180 ); |
| 116 |
define( 'ACTIVITYPUB_INBOX_PURGE_DAYS', 180 ); |
| 117 |
define( 'ACTIVITYPUB_AP_POST_PURGE_DAYS', 30 ); |
| 118 |
|