-
Notifications
You must be signed in to change notification settings - Fork 83
Add: Vary header settings
#1552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e8e6bea
Add: `Vary` header settings
pfefferle 6bbf67e
Add changelog
matticbot 6317d02
add some slashes
pfefferle fa798a9
Merge branch 'trunk' into add/vary-header-settings
pfefferle d487ed9
fix phpcs
pfefferle 2d69379
fix phpcs
pfefferle 6faf34e
create options class
pfefferle 30ea0c1
load action class and re-order inits
pfefferle 536ef36
add some slashes
pfefferle 68eee8e
Add phpdoc
pfefferle 00aa38e
ensure to run migration as early as possible
pfefferle c03c62f
optimize wording
pfefferle 81ec296
Merge branch 'trunk' into add/vary-header-settings
obenland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: changed | ||
|
|
||
| Add option to enable/disable the `Vary` Header to the "Advanced Settings". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| <?php | ||
| /** | ||
| * Options file. | ||
| * | ||
| * @package ActivityPub | ||
| */ | ||
|
|
||
| namespace ActivityPub; | ||
|
|
||
| /** | ||
| * Options class. | ||
| * | ||
| * @package ActivityPub | ||
| */ | ||
| class Options { | ||
|
|
||
| /** | ||
| * Initialize the options. | ||
| */ | ||
| public static function init() { | ||
| \add_filter( 'pre_option_activitypub_actor_mode', array( self::class, 'pre_option_activitypub_actor_mode' ) ); | ||
| \add_filter( 'pre_option_activitypub_authorized_fetch', array( self::class, 'pre_option_activitypub_authorized_fetch' ) ); | ||
| \add_filter( 'pre_option_activitypub_shared_inbox', array( self::class, 'pre_option_activitypub_shared_inbox' ) ); | ||
| \add_filter( 'pre_option_activitypub_vary_header', array( self::class, 'pre_option_activitypub_vary_header' ) ); | ||
|
|
||
| \add_filter( 'pre_option_activitypub_allow_likes', array( self::class, 'maybe_disable_interactions' ) ); | ||
| \add_filter( 'pre_option_activitypub_allow_replies', array( self::class, 'maybe_disable_interactions' ) ); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Pre-get option filter for the Actor-Mode. | ||
| * | ||
| * @param string|false $pre The pre-get option value. | ||
| * | ||
| * @return string|false The actor mode or false if it should not be filtered. | ||
| */ | ||
| public static function pre_option_activitypub_actor_mode( $pre ) { | ||
| if ( \defined( 'ACTIVITYPUB_SINGLE_USER_MODE' ) && ACTIVITYPUB_SINGLE_USER_MODE ) { | ||
| return ACTIVITYPUB_BLOG_MODE; | ||
| } | ||
|
|
||
| if ( \defined( 'ACTIVITYPUB_DISABLE_USER' ) && ACTIVITYPUB_DISABLE_USER ) { | ||
| return ACTIVITYPUB_BLOG_MODE; | ||
| } | ||
|
|
||
| if ( \defined( 'ACTIVITYPUB_DISABLE_BLOG_USER' ) && ACTIVITYPUB_DISABLE_BLOG_USER ) { | ||
| return ACTIVITYPUB_ACTOR_MODE; | ||
| } | ||
|
|
||
| return $pre; | ||
| } | ||
|
|
||
| /** | ||
| * Pre-get option filter for the Authorized Fetch. | ||
| * | ||
| * @param string $pre The pre-get option value. | ||
| * | ||
| * @return string If the constant is defined, return the value, otherwise return the pre-get option value. | ||
| */ | ||
| public static function pre_option_activitypub_authorized_fetch( $pre ) { | ||
| if ( ! \defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) ) { | ||
| return $pre; | ||
| } | ||
|
|
||
| if ( ACTIVITYPUB_AUTHORIZED_FETCH ) { | ||
| return '1'; | ||
| } | ||
|
|
||
| return '0'; | ||
| } | ||
|
|
||
| /** | ||
| * Pre-get option filter for the Shared Inbox. | ||
| * | ||
| * @param string $pre The pre-get option value. | ||
| * | ||
| * @return string If the constant is defined, return the value, otherwise return the pre-get option value. | ||
| */ | ||
| public static function pre_option_activitypub_shared_inbox( $pre ) { | ||
| if ( ! \defined( 'ACTIVITYPUB_SHARED_INBOX_FEATURE' ) ) { | ||
| return $pre; | ||
| } | ||
|
|
||
| if ( ACTIVITYPUB_SHARED_INBOX_FEATURE ) { | ||
| return '1'; | ||
| } | ||
|
|
||
| return '0'; | ||
| } | ||
|
|
||
| /** | ||
| * Pre-get option filter for the Vary Header. | ||
| * | ||
| * @param string $pre The pre-get option value. | ||
| * | ||
| * @return string If the constant is defined, return the value, otherwise return the pre-get option value. | ||
| */ | ||
| public static function pre_option_activitypub_vary_header( $pre ) { | ||
| if ( ! \defined( 'ACTIVITYPUB_SEND_VARY_HEADER' ) ) { | ||
| return $pre; | ||
| } | ||
|
|
||
| if ( ACTIVITYPUB_SEND_VARY_HEADER ) { | ||
| return '1'; | ||
| } | ||
|
|
||
| return '0'; | ||
| } | ||
|
|
||
| /** | ||
| * Disallow interactions if the constant is set. | ||
| * | ||
| * @param bool $pre_option The value of the option. | ||
| * @return bool|string The value of the option. | ||
| */ | ||
| public static function maybe_disable_interactions( $pre_option ) { | ||
| if ( ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS ) { | ||
| return '0'; | ||
| } | ||
|
|
||
| return $pre_option; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.