updated plugin ActivityPub
version 2.3.0
This commit is contained in:
parent
34dbbce9b4
commit
620280b550
@ -14,6 +14,7 @@ LINGUAS
|
||||
Makefile
|
||||
README.md
|
||||
readme.md
|
||||
CHANGELOG.md
|
||||
CODE_OF_CONDUCT.md
|
||||
FEDERATION.md
|
||||
SECURITY.md
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Plugin Name: ActivityPub
|
||||
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
|
||||
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
|
||||
* Version: 2.2.0
|
||||
* Version: 2.3.0
|
||||
* Author: Matthias Pfefferle & Automattic
|
||||
* Author URI: https://automattic.com/
|
||||
* License: MIT
|
||||
@ -21,6 +21,8 @@ use function Activitypub\site_supports_blocks;
|
||||
require_once __DIR__ . '/includes/compat.php';
|
||||
require_once __DIR__ . '/includes/functions.php';
|
||||
|
||||
\define( 'ACTIVITYPUB_PLUGIN_VERSION', '2.3.0' );
|
||||
|
||||
/**
|
||||
* Initialize the plugin constants.
|
||||
*/
|
||||
@ -30,13 +32,14 @@ require_once __DIR__ . '/includes/functions.php';
|
||||
\defined( 'ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS' ) || \define( 'ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS', 3 );
|
||||
\defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|(?<=<p>)|(?<=<br>)|^)#([A-Za-z0-9_]+)(?:(?=\s|[[:punct:]]|$))' );
|
||||
\defined( 'ACTIVITYPUB_USERNAME_REGEXP' ) || \define( 'ACTIVITYPUB_USERNAME_REGEXP', '(?:([A-Za-z0-9\._-]+)@((?:[A-Za-z0-9_-]+\.)+[A-Za-z]+))' );
|
||||
\defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "<strong>[ap_title]</strong>\n\n[ap_content]\n\n[ap_hashtags]\n\n[ap_shortlink]" );
|
||||
\defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "<h2>[ap_title]</h2>\n\n[ap_content]\n\n[ap_hashtags]\n\n[ap_shortlink]" );
|
||||
\defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) || \define( 'ACTIVITYPUB_AUTHORIZED_FETCH', false );
|
||||
\defined( 'ACTIVITYPUB_DISABLE_REWRITES' ) || \define( 'ACTIVITYPUB_DISABLE_REWRITES', false );
|
||||
\defined( 'ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS' ) || \define( 'ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS', false );
|
||||
\defined( 'ACTIVITYPUB_DISABLE_OUTGOING_INTERACTIONS' ) || \define( 'ACTIVITYPUB_DISABLE_OUTGOING_INTERACTIONS', false );
|
||||
\defined( 'ACTIVITYPUB_SHARED_INBOX_FEATURE' ) || \define( 'ACTIVITYPUB_SHARED_INBOX_FEATURE', false );
|
||||
\defined( 'ACTIVITYPUB_SEND_VARY_HEADER' ) || \define( 'ACTIVITYPUB_SEND_VARY_HEADER', false );
|
||||
\defined( 'ACTIVITYPUB_DEFAULT_OBJECT_TYPE' ) || \define( 'ACTIVITYPUB_DEFAULT_OBJECT_TYPE', 'note' );
|
||||
|
||||
\define( 'ACTIVITYPUB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
\define( 'ACTIVITYPUB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||
@ -100,6 +103,7 @@ function plugin_init() {
|
||||
}
|
||||
\add_action( 'plugins_loaded', __NAMESPACE__ . '\plugin_init' );
|
||||
|
||||
|
||||
/**
|
||||
* Class Autoloader
|
||||
*/
|
||||
@ -217,6 +221,10 @@ function get_plugin_meta( $default_headers = array() ) {
|
||||
* Plugin Version Number used for caching.
|
||||
*/
|
||||
function get_plugin_version() {
|
||||
if ( \defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) ) {
|
||||
return ACTIVITYPUB_PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
$meta = get_plugin_meta( array( 'Version' => 'Version' ) );
|
||||
|
||||
return $meta['Version'];
|
||||
|
@ -41,7 +41,7 @@
|
||||
"editorScript": "file:./index.js",
|
||||
"viewScript": "file:./view.js",
|
||||
"style": [
|
||||
"file:./style-index.css",
|
||||
"file:./style-view.css",
|
||||
"wp-components"
|
||||
]
|
||||
}
|
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'c7c2319cdfac52a18445');
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '0708145714d72862bff0');
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
.activitypub-follow-me-block-wrapper{width:100%}.activitypub-follow-me-block-wrapper.has-background .activitypub-profile,.activitypub-follow-me-block-wrapper.has-border-color .activitypub-profile{padding-left:1rem;padding-right:1rem}.activitypub-follow-me-block-wrapper .activitypub-profile{align-items:center;display:flex;padding:1rem 0}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__avatar{border-radius:50%;height:75px;margin-right:1rem;width:75px}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__content{flex:1;min-width:0}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__handle,.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__name{line-height:1.2;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__name{font-size:1.25em}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__follow{align-self:center;background-color:var(--wp--preset--color--black);color:var(--wp--preset--color--white);margin-left:1rem}.activitypub__modal.components-modal__frame{background-color:#f7f7f7;color:#333}.activitypub__modal.components-modal__frame .components-modal__header-heading,.activitypub__modal.components-modal__frame h4{color:#333;letter-spacing:inherit;word-spacing:inherit}.activitypub__modal.components-modal__frame .components-modal__header .components-button:hover{color:var(--wp--preset--color--white)}.activitypub__dialog{max-width:40em}.activitypub__dialog h4{line-height:1;margin:0}.activitypub__dialog .activitypub-dialog__section{margin-bottom:2em}.activitypub__dialog .activitypub-dialog__description{font-size:var(--wp--preset--font-size--normal,.75rem);margin:.33em 0 1em}.activitypub__dialog .activitypub-dialog__button-group{align-items:flex-end;display:flex;justify-content:flex-end}.activitypub__dialog .activitypub-dialog__button-group svg{height:21px;margin-right:.5em;width:21px}.activitypub__dialog .activitypub-dialog__button-group input{background-color:var(--wp--preset--color--white);border:1px solid var(--wp--preset--color--black);border-radius:inherit 0;color:var(--wp--preset--color--black);flex:1;padding:6px 12px}.activitypub__dialog .activitypub-dialog__button-group button{align-self:center;background-color:var(--wp--preset--color--black);color:var(--wp--preset--color--white);margin-left:0;text-decoration:none}
|
@ -0,0 +1 @@
|
||||
.activitypub__modal.components-modal__frame{background-color:#f7f7f7;color:#333}.activitypub__modal.components-modal__frame .components-modal__header-heading,.activitypub__modal.components-modal__frame h4{color:#333;letter-spacing:inherit;word-spacing:inherit}.activitypub__modal.components-modal__frame .components-modal__header .components-button:hover{color:var(--wp--preset--color--white)}.activitypub__dialog{max-width:40em}.activitypub__dialog h4{line-height:1;margin:0}.activitypub__dialog .activitypub-dialog__section{margin-bottom:2em}.activitypub__dialog .activitypub-dialog__description{font-size:var(--wp--preset--font-size--normal,.75rem);margin:.33em 0 1em}.activitypub__dialog .activitypub-dialog__button-group{align-items:flex-end;display:flex;justify-content:flex-end}.activitypub__dialog .activitypub-dialog__button-group svg{height:21px;margin-right:.5em;width:21px}.activitypub__dialog .activitypub-dialog__button-group input{background-color:var(--wp--preset--color--white);border:1px solid var(--wp--preset--color--black);border-radius:inherit 0;color:var(--wp--preset--color--black);flex:1;padding:6px 12px}.activitypub__dialog .activitypub-dialog__button-group button{align-self:center;background-color:var(--wp--preset--color--black);color:var(--wp--preset--color--white);margin-left:0;text-decoration:none}.activitypub-follow-me-block-wrapper{width:100%}.activitypub-follow-me-block-wrapper.has-background .activitypub-profile,.activitypub-follow-me-block-wrapper.has-border-color .activitypub-profile{padding-left:1rem;padding-right:1rem}.activitypub-follow-me-block-wrapper .activitypub-profile{align-items:center;display:flex;padding:1rem 0}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__avatar{border-radius:50%;height:75px;margin-right:1rem;width:75px}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__content{flex:1;min-width:0}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__handle,.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__name{line-height:1.2;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__name{font-size:1.25em}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__follow{align-self:center;background-color:var(--wp--preset--color--black);color:var(--wp--preset--color--white);margin-left:1rem}
|
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '1349fc90a3f33dde3595');
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'cbc379fca374f5f88e22');
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'c338a0364a63e21934ae');
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '536d43b3eaab93a5c9ef');
|
||||
|
@ -1,3 +1,3 @@
|
||||
(()=>{var e={184:(e,t)=>{var a;!function(){"use strict";var l={}.hasOwnProperty;function n(){for(var e=[],t=0;t<arguments.length;t++){var a=arguments[t];if(a){var r=typeof a;if("string"===r||"number"===r)e.push(a);else if(Array.isArray(a)){if(a.length){var o=n.apply(null,a);o&&e.push(o)}}else if("object"===r){if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]")){e.push(a.toString());continue}for(var i in a)l.call(a,i)&&a[i]&&e.push(i)}}}return e.join(" ")}e.exports?(n.default=n,e.exports=n):void 0===(a=function(){return n}.apply(t,[]))||(e.exports=a)}()}},t={};function a(l){var n=t[l];if(void 0!==n)return n.exports;var r=t[l]={exports:{}};return e[l](r,r.exports,a),r.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.blocks,t=window.wp.element,l=window.wp.primitives,n=(0,t.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,t.createElement)(l.Path,{d:"M15.5 9.5a1 1 0 100-2 1 1 0 000 2zm0 1.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm-2.25 6v-2a2.75 2.75 0 00-2.75-2.75h-4A2.75 2.75 0 003.75 15v2h1.5v-2c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v2h1.5zm7-2v2h-1.5v-2c0-.69-.56-1.25-1.25-1.25H15v-1.5h2.5A2.75 2.75 0 0120.25 15zM9.5 8.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z",fillRule:"evenodd"})),r=window.wp.components,o=window.wp.blockEditor,i=window.wp.i18n,c=window.React,s=window.wp.apiFetch;var p=a.n(s);const u=window.wp.url;var v=a(184),m=a.n(v);function w({active:e,children:a,page:l,pageClick:n,className:r}){const o=m()("wp-block activitypub-pager",r,{current:e});return(0,t.createElement)("a",{className:o,onClick:t=>{t.preventDefault(),!e&&n(l)}},a)}const b={outlined:"outlined",minimal:"minimal"};function d({compact:e,nextLabel:a,page:l,pageClick:n,perPage:r,prevLabel:o,total:i,variant:c=b.outlined}){const s=((e,t)=>{let a=[1,e-2,e-1,e,e+1,e+2,t];a.sort(((e,t)=>e-t)),a=a.filter(((e,a,l)=>e>=1&&e<=t&&l.lastIndexOf(e)===a));for(let e=a.length-2;e>=0;e--)a[e]===a[e+1]&&a.splice(e+1,1);return a})(l,Math.ceil(i/r)),p=m()("alignwide wp-block-query-pagination is-content-justification-space-between is-layout-flex wp-block-query-pagination-is-layout-flex",`is-${c}`,{"is-compact":e});return(0,t.createElement)("nav",{className:p},o&&(0,t.createElement)(w,{key:"prev",page:l-1,pageClick:n,active:1===l,"aria-label":o,className:"wp-block-query-pagination-previous block-editor-block-list__block"},o),!e&&(0,t.createElement)("div",{className:"block-editor-block-list__block wp-block wp-block-query-pagination-numbers"},s.map((e=>(0,t.createElement)(w,{key:e,page:e,pageClick:n,active:e===l,className:"page-numbers"},e)))),a&&(0,t.createElement)(w,{key:"next",page:l+1,pageClick:n,active:l===Math.ceil(i/r),"aria-label":a,className:"wp-block-query-pagination-next block-editor-block-list__block"},a))}const{namespace:g}=window._activityPubOptions;function f({selectedUser:e,per_page:a,order:l,title:n,page:r,setPage:o,className:s="",followLinks:v=!0,followerData:m=!1}){const w="site"===e?0:e,[b,f]=(0,c.useState)([]),[h,k]=(0,c.useState)(0),[E,_]=(0,c.useState)(0),[x,C]=function(){const[e,t]=(0,c.useState)(1);return[e,t]}(),S=r||x,N=o||C,P=(0,t.createInterpolateElement)(/* translators: arrow for previous followers link */
|
||||
(0,i.__)("<span>←</span> Less","activitypub"),{span:(0,t.createElement)("span",{class:"wp-block-query-pagination-previous-arrow is-arrow-arrow","aria-hidden":"true"})}),L=(0,t.createInterpolateElement)(/* translators: arrow for next followers link */
|
||||
(0,i.__)("More <span>→</span>","activitypub"),{span:(0,t.createElement)("span",{class:"wp-block-query-pagination-next-arrow is-arrow-arrow","aria-hidden":"true"})}),O=(e,t)=>{f(e),_(t),k(Math.ceil(t/a))};return(0,c.useEffect)((()=>{if(m&&1===S)return O(m.followers,m.total);const e=function(e,t,a,l){const n=`/${g}/users/${e}/followers`,r={per_page:t,order:a,page:l,context:"full"};return(0,u.addQueryArgs)(n,r)}(w,a,l,S);p()({path:e}).then((e=>O(e.orderedItems,e.totalItems))).catch((()=>{}))}),[w,a,l,S,m]),(0,t.createElement)("div",{className:"activitypub-follower-block "+s},(0,t.createElement)("h3",null,n),(0,t.createElement)("ul",null,b&&b.map((e=>(0,t.createElement)("li",{key:e.url},(0,t.createElement)(y,{...e,followLinks:v}))))),h>1&&(0,t.createElement)(d,{page:S,perPage:a,total:E,pageClick:N,nextLabel:L,prevLabel:P,compact:"is-style-compact"===s}))}function y({name:e,icon:a,url:l,preferredUsername:n,followLinks:o=!0}){const i=`@${n}`,c={};return o||(c.onClick=e=>e.preventDefault()),(0,t.createElement)(r.ExternalLink,{className:"activitypub-link",href:l,title:i,...c},(0,t.createElement)("img",{width:"40",height:"40",src:a.url,class:"avatar activitypub-avatar",alt:e}),(0,t.createElement)("span",{class:"activitypub-actor"},(0,t.createElement)("strong",{className:"activitypub-name"},e),(0,t.createElement)("span",{class:"sep"},"/"),(0,t.createElement)("span",{class:"activitypub-handle"},i)))}const h=window.wp.data,k=window._activityPubOptions?.enabled;(0,e.registerBlockType)("activitypub/followers",{edit:function({attributes:e,setAttributes:a}){const{order:l,per_page:n,selectedUser:c,title:s}=e,p=(0,o.useBlockProps)(),[u,v]=(0,t.useState)(1),m=[{label:(0,i.__)("New to old","activitypub"),value:"desc"},{label:(0,i.__)("Old to new","activitypub"),value:"asc"}],w=function(){const e=k?.users?(0,h.useSelect)((e=>e("core").getUsers({who:"authors"}))):[];return(0,t.useMemo)((()=>{if(!e)return[];const t=k?.site?[{label:(0,i.__)("Whole Site","activitypub"),value:"site"}]:[];return e.reduce(((e,t)=>(e.push({label:t.name,value:`${t.id}`}),e)),t)}),[e])}(),b=e=>t=>{v(1),a({[e]:t})};return(0,t.useEffect)((()=>{w.length&&(w.find((({value:e})=>e===c))||a({selectedUser:w[0].value}))}),[c,w]),(0,t.createElement)("div",{...p},(0,t.createElement)(o.InspectorControls,{key:"setting"},(0,t.createElement)(r.PanelBody,{title:(0,i.__)("Followers Options","activitypub")},(0,t.createElement)(r.TextControl,{label:(0,i.__)("Title","activitypub"),help:(0,i.__)("Title to display above the list of followers. Blank for none.","activitypub"),value:s,onChange:e=>a({title:e})}),w.length>1&&(0,t.createElement)(r.SelectControl,{label:(0,i.__)("Select User","activitypub"),value:c,options:w,onChange:b("selectedUser")}),(0,t.createElement)(r.SelectControl,{label:(0,i.__)("Sort","activitypub"),value:l,options:m,onChange:b("order")}),(0,t.createElement)(r.RangeControl,{label:(0,i.__)("Number of Followers","activitypub"),value:n,onChange:b("per_page"),min:1,max:10}))),(0,t.createElement)(f,{...e,page:u,setPage:v,followLinks:!1}))},save:()=>null,icon:n})})()})();
|
||||
(()=>{var e={942:(e,t)=>{var a;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e="",t=0;t<arguments.length;t++){var a=arguments[t];a&&(e=o(e,l(a)))}return e}function l(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return r.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var a in e)n.call(e,a)&&e[a]&&(t=o(t,a));return t}function o(e,t){return t?e?e+" "+t:e+t:e}e.exports?(r.default=r,e.exports=r):void 0===(a=function(){return r}.apply(t,[]))||(e.exports=a)}()}},t={};function a(n){var r=t[n];if(void 0!==r)return r.exports;var l=t[n]={exports:{}};return e[n](l,l.exports,a),l.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.blocks,t=window.React,n=window.wp.primitives,r=(0,t.createElement)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,t.createElement)(n.Path,{d:"M15.5 9.5a1 1 0 100-2 1 1 0 000 2zm0 1.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm-2.25 6v-2a2.75 2.75 0 00-2.75-2.75h-4A2.75 2.75 0 003.75 15v2h1.5v-2c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v2h1.5zm7-2v2h-1.5v-2c0-.69-.56-1.25-1.25-1.25H15v-1.5h2.5A2.75 2.75 0 0120.25 15zM9.5 8.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z",fillRule:"evenodd"})),l=window.wp.components,o=window.wp.element,i=window.wp.blockEditor,c=window.wp.i18n,s=window.wp.apiFetch;var p=a.n(s);const u=window.wp.url;var v=a(942),m=a.n(v);function w({active:e,children:a,page:n,pageClick:r,className:l}){const o=m()("wp-block activitypub-pager",l,{current:e});return(0,t.createElement)("a",{className:o,onClick:t=>{t.preventDefault(),!e&&r(n)}},a)}const b={outlined:"outlined",minimal:"minimal"};function d({compact:e,nextLabel:a,page:n,pageClick:r,perPage:l,prevLabel:o,total:i,variant:c=b.outlined}){const s=((e,t)=>{let a=[1,e-2,e-1,e,e+1,e+2,t];a.sort(((e,t)=>e-t)),a=a.filter(((e,a,n)=>e>=1&&e<=t&&n.lastIndexOf(e)===a));for(let e=a.length-2;e>=0;e--)a[e]===a[e+1]&&a.splice(e+1,1);return a})(n,Math.ceil(i/l)),p=m()("alignwide wp-block-query-pagination is-content-justification-space-between is-layout-flex wp-block-query-pagination-is-layout-flex",`is-${c}`,{"is-compact":e});return(0,t.createElement)("nav",{className:p},o&&(0,t.createElement)(w,{key:"prev",page:n-1,pageClick:r,active:1===n,"aria-label":o,className:"wp-block-query-pagination-previous block-editor-block-list__block"},o),!e&&(0,t.createElement)("div",{className:"block-editor-block-list__block wp-block wp-block-query-pagination-numbers"},s.map((e=>(0,t.createElement)(w,{key:e,page:e,pageClick:r,active:e===n,className:"page-numbers"},e)))),a&&(0,t.createElement)(w,{key:"next",page:n+1,pageClick:r,active:n===Math.ceil(i/l),"aria-label":a,className:"wp-block-query-pagination-next block-editor-block-list__block"},a))}const{namespace:f}=window._activityPubOptions;function g({selectedUser:e,per_page:a,order:n,title:r,page:l,setPage:i,className:s="",followLinks:v=!0,followerData:m=!1}){const w="site"===e?0:e,[b,g]=(0,t.useState)([]),[k,h]=(0,t.useState)(0),[E,_]=(0,t.useState)(0),[x,C]=function(){const[e,a]=(0,t.useState)(1);return[e,a]}(),S=l||x,N=i||C,P=(0,o.createInterpolateElement)(/* translators: arrow for previous followers link */ /* translators: arrow for previous followers link */
|
||||
(0,c.__)("<span>←</span> Less","activitypub"),{span:(0,t.createElement)("span",{class:"wp-block-query-pagination-previous-arrow is-arrow-arrow","aria-hidden":"true"})}),L=(0,o.createInterpolateElement)(/* translators: arrow for next followers link */ /* translators: arrow for next followers link */
|
||||
(0,c.__)("More <span>→</span>","activitypub"),{span:(0,t.createElement)("span",{class:"wp-block-query-pagination-next-arrow is-arrow-arrow","aria-hidden":"true"})}),O=(e,t)=>{g(e),_(t),h(Math.ceil(t/a))};return(0,t.useEffect)((()=>{if(m&&1===S)return O(m.followers,m.total);const e=function(e,t,a,n){const r=`/${f}/users/${e}/followers`,l={per_page:t,order:a,page:n,context:"full"};return(0,u.addQueryArgs)(r,l)}(w,a,n,S);p()({path:e}).then((e=>O(e.orderedItems,e.totalItems))).catch((()=>{}))}),[w,a,n,S,m]),(0,t.createElement)("div",{className:"activitypub-follower-block "+s},(0,t.createElement)("h3",null,r),(0,t.createElement)("ul",null,b&&b.map((e=>(0,t.createElement)("li",{key:e.url},(0,t.createElement)(y,{...e,followLinks:v}))))),k>1&&(0,t.createElement)(d,{page:S,perPage:a,total:E,pageClick:N,nextLabel:L,prevLabel:P,compact:"is-style-compact"===s}))}function y({name:e,icon:a,url:n,preferredUsername:r,followLinks:o=!0}){const i=`@${r}`,c={};return o||(c.onClick=e=>e.preventDefault()),(0,t.createElement)(l.ExternalLink,{className:"activitypub-link",href:n,title:i,...c},(0,t.createElement)("img",{width:"40",height:"40",src:a.url,class:"avatar activitypub-avatar",alt:e}),(0,t.createElement)("span",{class:"activitypub-actor"},(0,t.createElement)("strong",{className:"activitypub-name"},e),(0,t.createElement)("span",{class:"sep"},"/"),(0,t.createElement)("span",{class:"activitypub-handle"},i)))}const k=window.wp.data,h=window._activityPubOptions?.enabled;(0,e.registerBlockType)("activitypub/followers",{edit:function({attributes:e,setAttributes:a}){const{order:n,per_page:r,selectedUser:s,title:p}=e,u=(0,i.useBlockProps)(),[v,m]=(0,o.useState)(1),w=[{label:(0,c.__)("New to old","activitypub"),value:"desc"},{label:(0,c.__)("Old to new","activitypub"),value:"asc"}],b=function(){const e=h?.users?(0,k.useSelect)((e=>e("core").getUsers({who:"authors"}))):[];return(0,o.useMemo)((()=>{if(!e)return[];const t=h?.site?[{label:(0,c.__)("Whole Site","activitypub"),value:"site"}]:[];return e.reduce(((e,t)=>(e.push({label:t.name,value:`${t.id}`}),e)),t)}),[e])}(),d=e=>t=>{m(1),a({[e]:t})};return(0,o.useEffect)((()=>{b.length&&(b.find((({value:e})=>e===s))||a({selectedUser:b[0].value}))}),[s,b]),(0,t.createElement)("div",{...u},(0,t.createElement)(i.InspectorControls,{key:"setting"},(0,t.createElement)(l.PanelBody,{title:(0,c.__)("Followers Options","activitypub")},(0,t.createElement)(l.TextControl,{label:(0,c.__)("Title","activitypub"),help:(0,c.__)("Title to display above the list of followers. Blank for none.","activitypub"),value:p,onChange:e=>a({title:e})}),b.length>1&&(0,t.createElement)(l.SelectControl,{label:(0,c.__)("Select User","activitypub"),value:s,options:b,onChange:d("selectedUser")}),(0,t.createElement)(l.SelectControl,{label:(0,c.__)("Sort","activitypub"),value:n,options:w,onChange:d("order")}),(0,t.createElement)(l.RangeControl,{label:(0,c.__)("Number of Followers","activitypub"),value:r,onChange:d("per_page"),min:1,max:10}))),(0,t.createElement)(g,{...e,page:v,setPage:m,followLinks:!1}))},save:()=>null,icon:r})})()})();
|
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'ed5a13e66f8b10323435');
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '23bc54443801976420cd');
|
||||
|
@ -1,3 +1,3 @@
|
||||
(()=>{var e,t={142:(e,t,a)=>{"use strict";const r=window.wp.element,n=window.React,l=window.wp.apiFetch;var i=a.n(l);const o=window.wp.url,c=window.wp.i18n;var s=a(184),p=a.n(s);function u({active:e,children:t,page:a,pageClick:n,className:l}){const i=p()("wp-block activitypub-pager",l,{current:e});return(0,r.createElement)("a",{className:i,onClick:t=>{t.preventDefault(),!e&&n(a)}},t)}const m={outlined:"outlined",minimal:"minimal"};function f({compact:e,nextLabel:t,page:a,pageClick:n,perPage:l,prevLabel:i,total:o,variant:c=m.outlined}){const s=((e,t)=>{let a=[1,e-2,e-1,e,e+1,e+2,t];a.sort(((e,t)=>e-t)),a=a.filter(((e,a,r)=>e>=1&&e<=t&&r.lastIndexOf(e)===a));for(let e=a.length-2;e>=0;e--)a[e]===a[e+1]&&a.splice(e+1,1);return a})(a,Math.ceil(o/l)),f=p()("alignwide wp-block-query-pagination is-content-justification-space-between is-layout-flex wp-block-query-pagination-is-layout-flex",`is-${c}`,{"is-compact":e});return(0,r.createElement)("nav",{className:f},i&&(0,r.createElement)(u,{key:"prev",page:a-1,pageClick:n,active:1===a,"aria-label":i,className:"wp-block-query-pagination-previous block-editor-block-list__block"},i),!e&&(0,r.createElement)("div",{className:"block-editor-block-list__block wp-block wp-block-query-pagination-numbers"},s.map((e=>(0,r.createElement)(u,{key:e,page:e,pageClick:n,active:e===a,className:"page-numbers"},e)))),t&&(0,r.createElement)(u,{key:"next",page:a+1,pageClick:n,active:a===Math.ceil(o/l),"aria-label":t,className:"wp-block-query-pagination-next block-editor-block-list__block"},t))}const v=window.wp.components,{namespace:d}=window._activityPubOptions;function b({selectedUser:e,per_page:t,order:a,title:l,page:s,setPage:p,className:u="",followLinks:m=!0,followerData:v=!1}){const b="site"===e?0:e,[g,k]=(0,n.useState)([]),[y,h]=(0,n.useState)(0),[E,x]=(0,n.useState)(0),[_,O]=function(){const[e,t]=(0,n.useState)(1);return[e,t]}(),N=s||_,S=p||O,C=(0,r.createInterpolateElement)(/* translators: arrow for previous followers link */
|
||||
(0,c.__)("<span>←</span> Less","activitypub"),{span:(0,r.createElement)("span",{class:"wp-block-query-pagination-previous-arrow is-arrow-arrow","aria-hidden":"true"})}),L=(0,r.createInterpolateElement)(/* translators: arrow for next followers link */
|
||||
(0,c.__)("More <span>→</span>","activitypub"),{span:(0,r.createElement)("span",{class:"wp-block-query-pagination-next-arrow is-arrow-arrow","aria-hidden":"true"})}),j=(e,a)=>{k(e),x(a),h(Math.ceil(a/t))};return(0,n.useEffect)((()=>{if(v&&1===N)return j(v.followers,v.total);const e=function(e,t,a,r){const n=`/${d}/users/${e}/followers`,l={per_page:t,order:a,page:r,context:"full"};return(0,o.addQueryArgs)(n,l)}(b,t,a,N);i()({path:e}).then((e=>j(e.orderedItems,e.totalItems))).catch((()=>{}))}),[b,t,a,N,v]),(0,r.createElement)("div",{className:"activitypub-follower-block "+u},(0,r.createElement)("h3",null,l),(0,r.createElement)("ul",null,g&&g.map((e=>(0,r.createElement)("li",{key:e.url},(0,r.createElement)(w,{...e,followLinks:m}))))),y>1&&(0,r.createElement)(f,{page:N,perPage:t,total:E,pageClick:S,nextLabel:L,prevLabel:C,compact:"is-style-compact"===u}))}function w({name:e,icon:t,url:a,preferredUsername:n,followLinks:l=!0}){const i=`@${n}`,o={};return l||(o.onClick=e=>e.preventDefault()),(0,r.createElement)(v.ExternalLink,{className:"activitypub-link",href:a,title:i,...o},(0,r.createElement)("img",{width:"40",height:"40",src:t.url,class:"avatar activitypub-avatar",alt:e}),(0,r.createElement)("span",{class:"activitypub-actor"},(0,r.createElement)("strong",{className:"activitypub-name"},e),(0,r.createElement)("span",{class:"sep"},"/"),(0,r.createElement)("span",{class:"activitypub-handle"},i)))}const g=window.wp.domReady;a.n(g)()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-follower-block"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,r.render)((0,r.createElement)(b,{...t}),e)}))}))},184:(e,t)=>{var a;!function(){"use strict";var r={}.hasOwnProperty;function n(){for(var e=[],t=0;t<arguments.length;t++){var a=arguments[t];if(a){var l=typeof a;if("string"===l||"number"===l)e.push(a);else if(Array.isArray(a)){if(a.length){var i=n.apply(null,a);i&&e.push(i)}}else if("object"===l){if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]")){e.push(a.toString());continue}for(var o in a)r.call(a,o)&&a[o]&&e.push(o)}}}return e.join(" ")}e.exports?(n.default=n,e.exports=n):void 0===(a=function(){return n}.apply(t,[]))||(e.exports=a)}()}},a={};function r(e){var n=a[e];if(void 0!==n)return n.exports;var l=a[e]={exports:{}};return t[e](l,l.exports,r),l.exports}r.m=t,e=[],r.O=(t,a,n,l)=>{if(!a){var i=1/0;for(p=0;p<e.length;p++){a=e[p][0],n=e[p][1],l=e[p][2];for(var o=!0,c=0;c<a.length;c++)(!1&l||i>=l)&&Object.keys(r.O).every((e=>r.O[e](a[c])))?a.splice(c--,1):(o=!1,l<i&&(i=l));if(o){e.splice(p--,1);var s=n();void 0!==s&&(t=s)}}return t}l=l||0;for(var p=e.length;p>0&&e[p-1][2]>l;p--)e[p]=e[p-1];e[p]=[a,n,l]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={638:0,962:0};r.O.j=t=>0===e[t];var t=(t,a)=>{var n,l,i=a[0],o=a[1],c=a[2],s=0;if(i.some((t=>0!==e[t]))){for(n in o)r.o(o,n)&&(r.m[n]=o[n]);if(c)var p=c(r)}for(t&&t(a);s<i.length;s++)l=i[s],r.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return r.O(p)},a=self.webpackChunkwordpress_activitypub=self.webpackChunkwordpress_activitypub||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})();var n=r.O(void 0,[962],(()=>r(142)));n=r.O(n)})();
|
||||
(()=>{var e,t={250:(e,t,a)=>{"use strict";const r=window.React,n=window.wp.apiFetch;var l=a.n(n);const o=window.wp.url,i=window.wp.element,c=window.wp.i18n;var s=a(942),p=a.n(s);function u({active:e,children:t,page:a,pageClick:n,className:l}){const o=p()("wp-block activitypub-pager",l,{current:e});return(0,r.createElement)("a",{className:o,onClick:t=>{t.preventDefault(),!e&&n(a)}},t)}const m={outlined:"outlined",minimal:"minimal"};function f({compact:e,nextLabel:t,page:a,pageClick:n,perPage:l,prevLabel:o,total:i,variant:c=m.outlined}){const s=((e,t)=>{let a=[1,e-2,e-1,e,e+1,e+2,t];a.sort(((e,t)=>e-t)),a=a.filter(((e,a,r)=>e>=1&&e<=t&&r.lastIndexOf(e)===a));for(let e=a.length-2;e>=0;e--)a[e]===a[e+1]&&a.splice(e+1,1);return a})(a,Math.ceil(i/l)),f=p()("alignwide wp-block-query-pagination is-content-justification-space-between is-layout-flex wp-block-query-pagination-is-layout-flex",`is-${c}`,{"is-compact":e});return(0,r.createElement)("nav",{className:f},o&&(0,r.createElement)(u,{key:"prev",page:a-1,pageClick:n,active:1===a,"aria-label":o,className:"wp-block-query-pagination-previous block-editor-block-list__block"},o),!e&&(0,r.createElement)("div",{className:"block-editor-block-list__block wp-block wp-block-query-pagination-numbers"},s.map((e=>(0,r.createElement)(u,{key:e,page:e,pageClick:n,active:e===a,className:"page-numbers"},e)))),t&&(0,r.createElement)(u,{key:"next",page:a+1,pageClick:n,active:a===Math.ceil(i/l),"aria-label":t,className:"wp-block-query-pagination-next block-editor-block-list__block"},t))}const v=window.wp.components,{namespace:b}=window._activityPubOptions;function d({selectedUser:e,per_page:t,order:a,title:n,page:s,setPage:p,className:u="",followLinks:m=!0,followerData:v=!1}){const d="site"===e?0:e,[g,y]=(0,r.useState)([]),[k,h]=(0,r.useState)(0),[E,x]=(0,r.useState)(0),[_,O]=function(){const[e,t]=(0,r.useState)(1);return[e,t]}(),N=s||_,S=p||O,C=(0,i.createInterpolateElement)(/* translators: arrow for previous followers link */ /* translators: arrow for previous followers link */
|
||||
(0,c.__)("<span>←</span> Less","activitypub"),{span:(0,r.createElement)("span",{class:"wp-block-query-pagination-previous-arrow is-arrow-arrow","aria-hidden":"true"})}),L=(0,i.createInterpolateElement)(/* translators: arrow for next followers link */ /* translators: arrow for next followers link */
|
||||
(0,c.__)("More <span>→</span>","activitypub"),{span:(0,r.createElement)("span",{class:"wp-block-query-pagination-next-arrow is-arrow-arrow","aria-hidden":"true"})}),q=(e,a)=>{y(e),x(a),h(Math.ceil(a/t))};return(0,r.useEffect)((()=>{if(v&&1===N)return q(v.followers,v.total);const e=function(e,t,a,r){const n=`/${b}/users/${e}/followers`,l={per_page:t,order:a,page:r,context:"full"};return(0,o.addQueryArgs)(n,l)}(d,t,a,N);l()({path:e}).then((e=>q(e.orderedItems,e.totalItems))).catch((()=>{}))}),[d,t,a,N,v]),(0,r.createElement)("div",{className:"activitypub-follower-block "+u},(0,r.createElement)("h3",null,n),(0,r.createElement)("ul",null,g&&g.map((e=>(0,r.createElement)("li",{key:e.url},(0,r.createElement)(w,{...e,followLinks:m}))))),k>1&&(0,r.createElement)(f,{page:N,perPage:t,total:E,pageClick:S,nextLabel:L,prevLabel:C,compact:"is-style-compact"===u}))}function w({name:e,icon:t,url:a,preferredUsername:n,followLinks:l=!0}){const o=`@${n}`,i={};return l||(i.onClick=e=>e.preventDefault()),(0,r.createElement)(v.ExternalLink,{className:"activitypub-link",href:a,title:o,...i},(0,r.createElement)("img",{width:"40",height:"40",src:t.url,class:"avatar activitypub-avatar",alt:e}),(0,r.createElement)("span",{class:"activitypub-actor"},(0,r.createElement)("strong",{className:"activitypub-name"},e),(0,r.createElement)("span",{class:"sep"},"/"),(0,r.createElement)("span",{class:"activitypub-handle"},o)))}const g=window.wp.domReady;a.n(g)()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-follower-block"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,i.render)((0,r.createElement)(d,{...t}),e)}))}))},942:(e,t)=>{var a;!function(){"use strict";var r={}.hasOwnProperty;function n(){for(var e="",t=0;t<arguments.length;t++){var a=arguments[t];a&&(e=o(e,l(a)))}return e}function l(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var a in e)r.call(e,a)&&e[a]&&(t=o(t,a));return t}function o(e,t){return t?e?e+" "+t:e+t:e}e.exports?(n.default=n,e.exports=n):void 0===(a=function(){return n}.apply(t,[]))||(e.exports=a)}()}},a={};function r(e){var n=a[e];if(void 0!==n)return n.exports;var l=a[e]={exports:{}};return t[e](l,l.exports,r),l.exports}r.m=t,e=[],r.O=(t,a,n,l)=>{if(!a){var o=1/0;for(p=0;p<e.length;p++){for(var[a,n,l]=e[p],i=!0,c=0;c<a.length;c++)(!1&l||o>=l)&&Object.keys(r.O).every((e=>r.O[e](a[c])))?a.splice(c--,1):(i=!1,l<o&&(o=l));if(i){e.splice(p--,1);var s=n();void 0!==s&&(t=s)}}return t}l=l||0;for(var p=e.length;p>0&&e[p-1][2]>l;p--)e[p]=e[p-1];e[p]=[a,n,l]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={996:0,528:0};r.O.j=t=>0===e[t];var t=(t,a)=>{var n,l,[o,i,c]=a,s=0;if(o.some((t=>0!==e[t]))){for(n in i)r.o(i,n)&&(r.m[n]=i[n]);if(c)var p=c(r)}for(t&&t(a);s<o.length;s++)l=o[s],r.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return r.O(p)},a=globalThis.webpackChunkwordpress_activitypub=globalThis.webpackChunkwordpress_activitypub||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})();var n=r.O(void 0,[528],(()=>r(250)));n=r.O(n)})();
|
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '0235743f089d22122d70');
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '9aee45886ecf2680fbd4');
|
||||
|
File diff suppressed because one or more lines are too long
@ -52,7 +52,7 @@ class Actor extends Base_Object {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Person';
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* A reference to an ActivityStreams OrderedCollection comprised of
|
||||
|
@ -44,9 +44,6 @@ class Activity_Dispatcher {
|
||||
* @return void
|
||||
*/
|
||||
public static function send_activity_or_announce( $wp_object, $type ) {
|
||||
// check if a migration is needed before sending new posts
|
||||
Migration::maybe_migrate();
|
||||
|
||||
if ( is_user_type_disabled( 'blog' ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -38,8 +38,9 @@ class Activitypub {
|
||||
\add_action( 'untrash_post', array( self::class, 'untrash_post' ), 1 );
|
||||
|
||||
\add_action( 'init', array( self::class, 'add_rewrite_rules' ), 11 );
|
||||
\add_action( 'init', array( self::class, 'theme_compat' ), 11 );
|
||||
|
||||
\add_action( 'after_setup_theme', array( self::class, 'theme_compat' ), 99 );
|
||||
\add_action( 'user_register', array( self::class, 'user_register' ) );
|
||||
|
||||
\add_action( 'in_plugin_update_message-' . ACTIVITYPUB_PLUGIN_BASENAME, array( self::class, 'plugin_update_message' ) );
|
||||
|
||||
@ -202,14 +203,16 @@ class Activitypub {
|
||||
$avatar = self::get_avatar_url( $id_or_email->comment_ID );
|
||||
|
||||
if ( $avatar ) {
|
||||
if ( ! isset( $args['class'] ) || ! \is_array( $args['class'] ) ) {
|
||||
$args['class'] = array( 'u-photo' );
|
||||
} else {
|
||||
$args['class'][] = 'u-photo';
|
||||
$args['class'] = \array_unique( $args['class'] );
|
||||
if ( empty( $args['class'] ) ) {
|
||||
$args['class'] = array();
|
||||
} elseif ( \is_string( $args['class'] ) ) {
|
||||
$args['class'] = \explode( ' ', $args['class'] );
|
||||
}
|
||||
|
||||
$args['url'] = $avatar;
|
||||
$args['class'][] = 'avatar-activitypub';
|
||||
$args['class'][] = 'u-photo';
|
||||
$args['class'] = \array_unique( $args['class'] );
|
||||
}
|
||||
|
||||
return $args;
|
||||
@ -334,6 +337,23 @@ class Activitypub {
|
||||
);
|
||||
add_theme_support( 'custom-header', $custom_header_args );
|
||||
}
|
||||
|
||||
// We assume that you want to use Post-Formats when enabling the setting
|
||||
if ( 'wordpress-post-format' === \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ) ) {
|
||||
if ( ! get_theme_support( 'post-formats' ) ) {
|
||||
// Add support for the Aside, Gallery Post Formats...
|
||||
add_theme_support(
|
||||
'post-formats',
|
||||
array(
|
||||
'gallery',
|
||||
'status',
|
||||
'image',
|
||||
'video',
|
||||
'audio',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -437,4 +457,17 @@ class Activitypub {
|
||||
|
||||
\do_action( 'activitypub_after_register_post_type' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the 'activitypub' query variable so WordPress won't mangle it.
|
||||
*
|
||||
* @param int $user_id User ID.
|
||||
* @param array $userdata The raw array of data passed to wp_insert_user().
|
||||
*/
|
||||
public static function user_register( $user_id ) {
|
||||
if ( \user_can( $user_id, 'publish_posts' ) ) {
|
||||
$user = \get_user_by( 'id', $user_id );
|
||||
$user->add_cap( 'activitypub' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,15 @@ class Admin {
|
||||
\add_action( 'personal_options_update', array( self::class, 'save_user_description' ) );
|
||||
\add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_scripts' ) );
|
||||
\add_action( 'admin_notices', array( self::class, 'admin_notices' ) );
|
||||
|
||||
\add_filter( 'comment_row_actions', array( self::class, 'comment_row_actions' ), 10, 2 );
|
||||
\add_filter( 'manage_edit-comments_columns', array( static::class, 'manage_comment_columns' ) );
|
||||
\add_filter( 'manage_comments_custom_column', array( static::class, 'manage_comments_custom_column' ), 9, 2 );
|
||||
|
||||
\add_filter( 'manage_users_columns', array( self::class, 'manage_users_columns' ), 10, 1 );
|
||||
\add_filter( 'manage_users_custom_column', array( self::class, 'manage_users_custom_column' ), 10, 3 );
|
||||
\add_filter( 'bulk_actions-users', array( self::class, 'user_bulk_options' ) );
|
||||
\add_filter( 'handle_bulk_actions-users', array( self::class, 'handle_bulk_request' ), 10, 3 );
|
||||
|
||||
if ( ! is_user_disabled( get_current_user_id() ) ) {
|
||||
\add_action( 'show_user_profile', array( self::class, 'add_profile' ) );
|
||||
@ -61,7 +69,7 @@ class Admin {
|
||||
public static function admin_notices() {
|
||||
$permalink_structure = \get_option( 'permalink_structure' );
|
||||
if ( empty( $permalink_structure ) ) {
|
||||
$admin_notice = \__( 'You are using the ActivityPub plugin without setting a permalink structure. This will prevent ActivityPub from working. Please set a permalink structure.', 'activitypub' );
|
||||
$admin_notice = \__( 'You are using the ActivityPub plugin with a permalink structure of "plain". This will prevent ActivityPub from working. Please go to "Settings" / "Permalinks" and choose a permalink structure other than "plain".', 'activitypub' );
|
||||
self::show_admin_notice( $admin_notice, 'error' );
|
||||
}
|
||||
}
|
||||
@ -175,7 +183,6 @@ class Admin {
|
||||
'schema' => array(
|
||||
'enum' => array(
|
||||
'note',
|
||||
'article',
|
||||
'wordpress-post-format',
|
||||
),
|
||||
),
|
||||
@ -346,4 +353,120 @@ class Admin {
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a column "activitypub"
|
||||
*
|
||||
* This column shows if the user has the capability to use ActivityPub.
|
||||
*
|
||||
* @param array $columns The columns.
|
||||
*
|
||||
* @return array The columns extended by the activitypub.
|
||||
*/
|
||||
public static function manage_users_columns( $columns ) {
|
||||
$columns['activitypub'] = __( 'ActivityPub', 'activitypub' );
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add "comment-type" and "protocol" as column in WP-Admin
|
||||
*
|
||||
* @param array $columns the list of column names
|
||||
*/
|
||||
public static function manage_comment_columns( $columns ) {
|
||||
$columns['comment_type'] = esc_attr__( 'Comment-Type', 'activitypub' );
|
||||
$columns['comment_protocol'] = esc_attr__( 'Protocol', 'activitypub' );
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add "comment-type" and "protocol" as column in WP-Admin
|
||||
*
|
||||
* @param array $column The column to implement
|
||||
* @param int $comment_id The comment id
|
||||
*/
|
||||
public static function manage_comments_custom_column( $column, $comment_id ) {
|
||||
if ( 'comment_type' === $column && ! defined( 'WEBMENTION_PLUGIN_DIR' ) ) {
|
||||
echo esc_attr( ucfirst( get_comment_type( $comment_id ) ) );
|
||||
} elseif ( 'comment_protocol' === $column ) {
|
||||
$protocol = get_comment_meta( $comment_id, 'protocol', true );
|
||||
|
||||
if ( $protocol ) {
|
||||
echo esc_attr( ucfirst( str_replace( 'activitypub', 'ActivityPub', $protocol ) ) );
|
||||
} else {
|
||||
esc_attr_e( 'Local', 'activitypub' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the results for the activitypub column.
|
||||
*
|
||||
* @param string $output Custom column output. Default empty.
|
||||
* @param string $column_name Column name.
|
||||
* @param int $user_id ID of the currently-listed user.
|
||||
*
|
||||
* @return string The column contents.
|
||||
*/
|
||||
public static function manage_users_custom_column( $output, $column_name, $user_id ) {
|
||||
if ( 'activitypub' !== $column_name ) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
if ( \user_can( $user_id, 'activitypub' ) ) {
|
||||
return '✓';
|
||||
} else {
|
||||
return '✗';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add options to the Bulk dropdown on the users page
|
||||
*
|
||||
* @param array $actions The existing bulk options.
|
||||
*
|
||||
* @return array The extended bulk options.
|
||||
*/
|
||||
public static function user_bulk_options( $actions ) {
|
||||
$actions['add_activitypub_cap'] = __( 'Enable for ActivityPub', 'activitypub' );
|
||||
$actions['remove_activitypub_cap'] = __( 'Disable for ActivityPub', 'activitypub' );
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle bulk activitypub requests
|
||||
*
|
||||
* * `add_activitypub_cap` - Add the activitypub capability to the selected users.
|
||||
* * `remove_activitypub_cap` - Remove the activitypub capability from the selected users.
|
||||
*
|
||||
* @param string $sendback The URL to send the user back to.
|
||||
* @param string $action The requested action.
|
||||
* @param array $users The selected users.
|
||||
*
|
||||
* @return string The URL to send the user back to.
|
||||
*/
|
||||
public static function handle_bulk_request( $sendback, $action, $users ) {
|
||||
if (
|
||||
'remove_activitypub_cap' !== $action &&
|
||||
'add_activitypub_cap' !== $action
|
||||
) {
|
||||
return $sendback;
|
||||
}
|
||||
|
||||
foreach ( $users as $user_id ) {
|
||||
$user = new \WP_User( $user_id );
|
||||
if (
|
||||
'add_activitypub_cap' === $action &&
|
||||
user_can( $user_id, 'publish_posts' )
|
||||
) {
|
||||
$user->add_cap( 'activitypub' );
|
||||
} elseif ( 'remove_activitypub_cap' === $action ) {
|
||||
$user->remove_cap( 'activitypub' );
|
||||
}
|
||||
}
|
||||
|
||||
return $sendback;
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
namespace Activitypub;
|
||||
|
||||
use Activitypub\Collection\Users;
|
||||
use WP_Comment_Query;
|
||||
|
||||
use function Activitypub\is_user_disabled;
|
||||
use function Activitypub\is_single_user;
|
||||
|
||||
/**
|
||||
* ActivityPub Comment Class
|
||||
@ -37,6 +39,11 @@ class Comment {
|
||||
*/
|
||||
public static function comment_reply_link( $link, $args, $comment ) {
|
||||
if ( self::are_comments_allowed( $comment ) ) {
|
||||
$user_id = get_current_user_id();
|
||||
if ( $user_id && self::was_received( $comment ) && \user_can( $user_id, 'activitypub' ) ) {
|
||||
return self::create_fediverse_reply_link( $link, $args );
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
@ -53,6 +60,27 @@ class Comment {
|
||||
return apply_filters( 'activitypub_comment_reply_link', $div );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a link to reply to a federated comment.
|
||||
* This function adds a title attribute to the reply link to inform the user
|
||||
* that the comment was received from the fediverse and the reply will be sent
|
||||
* to the original author.
|
||||
*
|
||||
* @param string $link The HTML markup for the comment reply link.
|
||||
* @param array $args The args provided by the `comment_reply_link` filter.
|
||||
*
|
||||
* @return string The modified HTML markup for the comment reply link.
|
||||
*/
|
||||
private static function create_fediverse_reply_link( $link, $args ) {
|
||||
$str_to_replace = sprintf( '>%s<', $args['reply_text'] );
|
||||
$replace_with = sprintf(
|
||||
' title="%s">%s<',
|
||||
esc_attr__( 'This comment was received from the fediverse and your reply will be sent to the original author', 'activitypub' ),
|
||||
esc_html__( 'Reply with federation', 'activitypub' )
|
||||
);
|
||||
return str_replace( $str_to_replace, $replace_with, $link );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it is allowed to comment to a comment.
|
||||
*
|
||||
@ -75,6 +103,11 @@ class Comment {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( is_single_user() && \user_can( $current_user, 'publish_posts' ) ) {
|
||||
// On a single user site, comments by users with the `publish_posts` capability will be federated as the blog user
|
||||
$current_user = Users::BLOG_USER_ID;
|
||||
}
|
||||
|
||||
$is_user_disabled = is_user_disabled( $current_user );
|
||||
|
||||
if ( $is_user_disabled ) {
|
||||
@ -180,6 +213,11 @@ class Comment {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( is_single_user() && \user_can( $user_id, 'publish_posts' ) ) {
|
||||
// On a single user site, comments by users with the `publish_posts` capability will be federated as the blog user
|
||||
$user_id = Users::BLOG_USER_ID;
|
||||
}
|
||||
|
||||
$is_user_disabled = is_user_disabled( $user_id );
|
||||
|
||||
// user is disabled for federation
|
||||
@ -330,12 +368,14 @@ class Comment {
|
||||
* @return string ActivityPub URI for comment
|
||||
*/
|
||||
public static function generate_id( $comment ) {
|
||||
$comment = get_comment( $comment );
|
||||
$comment = \get_comment( $comment );
|
||||
$comment_meta = \get_comment_meta( $comment->comment_ID );
|
||||
|
||||
// show external comment ID if it exists
|
||||
$source_id = get_comment_meta( $comment->comment_ID, 'source_id', true );
|
||||
if ( ! empty( $source_id ) ) {
|
||||
return $source_id;
|
||||
if ( ! empty( $comment_meta['source_id'][0] ) ) {
|
||||
return $comment_meta['source_id'][0];
|
||||
} elseif ( ! empty( $comment_meta['source_url'][0] ) ) {
|
||||
return $comment_meta['source_url'][0];
|
||||
}
|
||||
|
||||
// generate URI based on comment ID
|
||||
@ -347,13 +387,59 @@ class Comment {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a post has remote comments
|
||||
*
|
||||
* @param int $post_id The post ID.
|
||||
*
|
||||
* @return bool True if the post has remote comments, false otherwise.
|
||||
*/
|
||||
private static function post_has_remote_comments( $post_id ) {
|
||||
$comments = \get_comments(
|
||||
array(
|
||||
'post_id' => $post_id,
|
||||
'meta_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => 'protocol',
|
||||
'value' => 'activitypub',
|
||||
'compare' => '=',
|
||||
),
|
||||
array(
|
||||
'key' => 'source_id',
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
return ! empty( $comments );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts for remote comments
|
||||
*/
|
||||
public static function enqueue_scripts() {
|
||||
if ( ! is_singular() ) {
|
||||
if ( ! \is_singular() || \is_user_logged_in() ) {
|
||||
// only on single pages, only for logged out users
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! \post_type_supports( \get_post_type(), 'activitypub' ) ) {
|
||||
// post type does not support ActivityPub
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! \comments_open() || ! \get_comments_number() ) {
|
||||
// no comments, no need to load the script
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! self::post_has_remote_comments( \get_the_ID() ) ) {
|
||||
// no remote comments, no need to load the script
|
||||
return;
|
||||
}
|
||||
|
||||
$handle = 'activitypub-remote-reply';
|
||||
$data = array(
|
||||
'namespace' => ACTIVITYPUB_REST_NAMESPACE,
|
||||
|
@ -4,6 +4,8 @@ namespace Activitypub;
|
||||
use WP_Error;
|
||||
use Activitypub\Collection\Users;
|
||||
|
||||
use function Activitypub\get_masked_wp_version;
|
||||
|
||||
/**
|
||||
* ActivityPub HTTP Class
|
||||
*
|
||||
@ -26,7 +28,7 @@ class Http {
|
||||
$digest = Signature::generate_digest( $body );
|
||||
$signature = Signature::generate_signature( $user_id, 'post', $url, $date, $digest );
|
||||
|
||||
$wp_version = \get_bloginfo( 'version' );
|
||||
$wp_version = get_masked_wp_version();
|
||||
|
||||
/**
|
||||
* Filter the HTTP headers user agent.
|
||||
@ -75,7 +77,7 @@ class Http {
|
||||
$date = \gmdate( 'D, d M Y H:i:s T' );
|
||||
$signature = Signature::generate_signature( Users::APPLICATION_USER_ID, 'get', $url, $date );
|
||||
|
||||
$wp_version = \get_bloginfo( 'version' );
|
||||
$wp_version = get_masked_wp_version();
|
||||
|
||||
/**
|
||||
* Filter the HTTP headers user agent.
|
||||
|
@ -15,7 +15,9 @@ class Migration {
|
||||
* Initialize the class, registering WordPress hooks
|
||||
*/
|
||||
public static function init() {
|
||||
\add_action( 'activitypub_schedule_migration', array( self::class, 'maybe_migrate' ) );
|
||||
\add_action( 'activitypub_migrate', array( self::class, 'async_migration' ) );
|
||||
|
||||
self::maybe_migrate();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,18 +110,28 @@ class Migration {
|
||||
|
||||
$version_from_db = self::get_version();
|
||||
|
||||
// check for inital migration
|
||||
if ( ! $version_from_db ) {
|
||||
self::add_default_settings();
|
||||
$version_from_db = self::get_target_version();
|
||||
}
|
||||
|
||||
// schedule the async migration
|
||||
if ( ! \wp_next_scheduled( 'activitypub_migrate', $version_from_db ) ) {
|
||||
\wp_schedule_single_event( \time(), 'activitypub_migrate', $version_from_db );
|
||||
}
|
||||
if ( version_compare( $version_from_db, '0.17.0', '<' ) ) {
|
||||
self::migrate_from_0_16();
|
||||
}
|
||||
if ( version_compare( $version_from_db, '1.0.0', '<' ) ) {
|
||||
self::migrate_from_0_17();
|
||||
}
|
||||
if ( version_compare( $version_from_db, '1.3.0', '<' ) ) {
|
||||
self::migrate_from_1_2_0();
|
||||
}
|
||||
if ( version_compare( $version_from_db, '2.1.0', '<' ) ) {
|
||||
self::migrate_from_2_0_0();
|
||||
}
|
||||
if ( version_compare( $version_from_db, '2.3.0', '<' ) ) {
|
||||
self::migrate_from_2_2_0();
|
||||
}
|
||||
|
||||
update_option( 'activitypub_db_version', self::get_target_version() );
|
||||
|
||||
@ -127,23 +139,14 @@ class Migration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the DB-schema of the followers-list
|
||||
* Asynchronously migrates the database structure.
|
||||
*
|
||||
* @return void
|
||||
* @param string $version_from_db The version from which to migrate.
|
||||
*/
|
||||
private static function migrate_from_0_17() {
|
||||
// migrate followers
|
||||
foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
|
||||
$followers = get_user_meta( $user_id, 'activitypub_followers', true );
|
||||
|
||||
if ( $followers ) {
|
||||
foreach ( $followers as $actor ) {
|
||||
Followers::add_follower( $user_id, $actor );
|
||||
}
|
||||
}
|
||||
public static function async_migration( $version_from_db ) {
|
||||
if ( version_compare( $version_from_db, '1.0.0', '<' ) ) {
|
||||
self::migrate_from_0_17();
|
||||
}
|
||||
|
||||
Activitypub::flush_rewrite_rules();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,13 +186,33 @@ class Migration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the DB-schema of the followers-list
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function migrate_from_0_17() {
|
||||
// migrate followers
|
||||
foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
|
||||
$followers = get_user_meta( $user_id, 'activitypub_followers', true );
|
||||
|
||||
if ( $followers ) {
|
||||
foreach ( $followers as $actor ) {
|
||||
Followers::add_follower( $user_id, $actor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Activitypub::flush_rewrite_rules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cache after updating to 1.3.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function migrate_from_1_2_0() {
|
||||
$user_ids = get_users(
|
||||
$user_ids = \get_users(
|
||||
array(
|
||||
'fields' => 'ID',
|
||||
'capability__in' => array( 'publish_posts' ),
|
||||
@ -214,5 +237,51 @@ class Migration {
|
||||
wp_unschedule_hook( 'activitypub_send_post_activity' );
|
||||
wp_unschedule_hook( 'activitypub_send_update_activity' );
|
||||
wp_unschedule_hook( 'activitypub_send_delete_activity' );
|
||||
|
||||
$object_type = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
|
||||
if ( 'article' === $object_type ) {
|
||||
\update_option( 'activitypub_object_type', 'wordpress-post-format' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the ActivityPub capability to all users that can publish posts
|
||||
* Delete old meta to store followers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function migrate_from_2_2_0() {
|
||||
// add the ActivityPub capability to all users that can publish posts
|
||||
self::add_activitypub_capability();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the defaults needed for the plugin to work
|
||||
*
|
||||
* * Add the ActivityPub capability to all users that can publish posts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function add_default_settings() {
|
||||
self::add_activitypub_capability();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the ActivityPub capability to all users that can publish posts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function add_activitypub_capability() {
|
||||
// get all WP_User objects that can publish posts
|
||||
$users = \get_users(
|
||||
array(
|
||||
'capability__in' => array( 'publish_posts' ),
|
||||
)
|
||||
);
|
||||
|
||||
// add ActivityPub capability to all users that can publish posts
|
||||
foreach ( $users as $user ) {
|
||||
$user->add_cap( 'activitypub' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,6 @@ class Scheduler {
|
||||
\add_action( 'activitypub_update_followers', array( self::class, 'update_followers' ) );
|
||||
\add_action( 'activitypub_cleanup_followers', array( self::class, 'cleanup_followers' ) );
|
||||
|
||||
// Migration
|
||||
\add_action( 'admin_init', array( self::class, 'schedule_migration' ) );
|
||||
|
||||
// profile updates for blog options
|
||||
if ( ! is_user_type_disabled( 'blog' ) ) {
|
||||
\add_action( 'update_option_site_icon', array( self::class, 'blog_user_update' ) );
|
||||
@ -265,17 +262,6 @@ class Scheduler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule migration if DB-Version is not up to date.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function schedule_migration() {
|
||||
if ( ! \wp_next_scheduled( 'activitypub_schedule_migration' ) && ! Migration::is_latest_version() ) {
|
||||
\wp_schedule_single_event( \time(), 'activitypub_schedule_migration' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a profile update when relevant user meta is updated.
|
||||
*
|
||||
@ -287,7 +273,7 @@ class Scheduler {
|
||||
*/
|
||||
public static function user_meta_update( $meta_id, $user_id, $meta_key ) {
|
||||
// don't bother if the user can't publish
|
||||
if ( ! \user_can( $user_id, 'publish_posts' ) ) {
|
||||
if ( ! \user_can( $user_id, 'activitypub' ) ) {
|
||||
return;
|
||||
}
|
||||
// the user meta fields that affect a profile.
|
||||
@ -311,7 +297,7 @@ class Scheduler {
|
||||
*/
|
||||
public static function user_update( $user_id ) {
|
||||
// don't bother if the user can't publish
|
||||
if ( ! \user_can( $user_id, 'publish_posts' ) ) {
|
||||
if ( ! \user_can( $user_id, 'activitypub' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ class Shortcodes {
|
||||
}
|
||||
|
||||
return \sprintf(
|
||||
'<a href="%1$s">%1$s</a>',
|
||||
'<a href="%1$s" class="status-link unhandled-link">%1$s</a>',
|
||||
\esc_url( \get_permalink( $item->ID ) )
|
||||
);
|
||||
}
|
||||
@ -305,7 +305,7 @@ class Shortcodes {
|
||||
}
|
||||
|
||||
return \sprintf(
|
||||
'<a href="%1$s">%1$s</a>',
|
||||
'<a href="%1$s" class="status-link unhandled-link">%1$s</a>',
|
||||
\esc_url( \wp_get_shortlink( $item->ID ) )
|
||||
);
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ class Users {
|
||||
public static function get_collection() {
|
||||
$users = \get_users(
|
||||
array(
|
||||
'capability__in' => array( 'publish_posts' ),
|
||||
'capability__in' => array( 'activitypub' ),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -384,7 +384,7 @@ function is_user_disabled( $user_id ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! \user_can( $user_id, 'publish_posts' ) ) {
|
||||
if ( ! \user_can( $user_id, 'activitypub' ) ) {
|
||||
$return = true;
|
||||
break;
|
||||
}
|
||||
@ -644,7 +644,7 @@ function get_total_users() {
|
||||
|
||||
$users = \get_users(
|
||||
array(
|
||||
'capability__in' => array( 'publish_posts' ),
|
||||
'capability__in' => array( 'activitypub' ),
|
||||
)
|
||||
);
|
||||
|
||||
@ -827,3 +827,19 @@ function get_post_type_description( $post_type ) {
|
||||
|
||||
return apply_filters( 'activitypub_post_type_description', $description, $post_type->name, $post_type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the masked WordPress version to only show the major and minor version.
|
||||
*
|
||||
* @return string The masked version.
|
||||
*/
|
||||
function get_masked_wp_version() {
|
||||
// only show the major and minor version
|
||||
$version = get_bloginfo( 'version' );
|
||||
// strip the RC or beta part
|
||||
$version = preg_replace( '/-.*$/', '', $version );
|
||||
$version = explode( '.', $version );
|
||||
$version = array_slice( $version, 0, 2 );
|
||||
|
||||
return implode( '.', $version );
|
||||
}
|
||||
|
@ -75,9 +75,13 @@ class Comment {
|
||||
return $template;
|
||||
}
|
||||
|
||||
$resource = \get_comment_meta( $comment_id, 'source_id', true );
|
||||
$comment_meta = \get_comment_meta( $comment_id );
|
||||
|
||||
if ( ! $resource ) {
|
||||
if ( ! empty( $comment_meta['source_id'][0] ) ) {
|
||||
$resource = $comment_meta['source_id'][0];
|
||||
} elseif ( ! empty( $comment_meta['source_url'][0] ) ) {
|
||||
$resource = $comment_meta['source_url'][0];
|
||||
} else {
|
||||
$resource = Comment_Utils::generate_id( $comment );
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ use Activitypub\Collection\Users as User_Collection;
|
||||
use Activitypub\Collection\Followers as Follower_Collection;
|
||||
|
||||
use function Activitypub\get_rest_url_by_path;
|
||||
use function Activitypub\get_masked_wp_version;
|
||||
|
||||
/**
|
||||
* ActivityPub Followers REST-Class
|
||||
@ -74,7 +75,7 @@ class Followers {
|
||||
$json->{'@context'} = \Activitypub\get_context();
|
||||
|
||||
$json->id = get_rest_url_by_path( sprintf( 'users/%d/followers', $user->get__id() ) );
|
||||
$json->generator = 'http://wordpress.org/?v=' . \get_bloginfo_rss( 'version' );
|
||||
$json->generator = 'http://wordpress.org/?v=' . get_masked_wp_version();
|
||||
$json->actor = $user->get_id();
|
||||
$json->type = 'OrderedCollectionPage';
|
||||
|
||||
|
@ -6,6 +6,7 @@ use Activitypub\Collection\Users as User_Collection;
|
||||
|
||||
use function Activitypub\is_single_user;
|
||||
use function Activitypub\get_rest_url_by_path;
|
||||
use function Activitypub\get_masked_wp_version;
|
||||
|
||||
/**
|
||||
* ActivityPub Following REST-Class
|
||||
@ -67,7 +68,7 @@ class Following {
|
||||
$json->{'@context'} = \Activitypub\get_context();
|
||||
|
||||
$json->id = get_rest_url_by_path( sprintf( 'users/%d/following', $user->get__id() ) );
|
||||
$json->generator = 'http://wordpress.org/?v=' . \get_bloginfo_rss( 'version' );
|
||||
$json->generator = 'http://wordpress.org/?v=' . get_masked_wp_version();
|
||||
$json->actor = $user->get_id();
|
||||
$json->type = 'OrderedCollectionPage';
|
||||
|
||||
|
@ -11,6 +11,7 @@ use function Activitypub\get_context;
|
||||
use function Activitypub\object_to_uri;
|
||||
use function Activitypub\url_to_authorid;
|
||||
use function Activitypub\get_rest_url_by_path;
|
||||
use function Activitypub\get_masked_wp_version;
|
||||
use function Activitypub\extract_recipients_from_activity;
|
||||
|
||||
/**
|
||||
@ -90,7 +91,7 @@ class Inbox {
|
||||
|
||||
$json->{'@context'} = get_context();
|
||||
$json->id = get_rest_url_by_path( sprintf( 'users/%d/inbox', $user->get__id() ) );
|
||||
$json->generator = 'http://wordpress.org/?v=' . \get_bloginfo_rss( 'version' );
|
||||
$json->generator = 'http://wordpress.org/?v=' . get_masked_wp_version();
|
||||
$json->type = 'OrderedCollectionPage';
|
||||
$json->partOf = get_rest_url_by_path( sprintf( 'users/%d/inbox', $user->get__id() ) ); // phpcs:ignore
|
||||
$json->totalItems = 0; // phpcs:ignore
|
||||
|
@ -6,6 +6,7 @@ use WP_REST_Response;
|
||||
use function Activitypub\get_total_users;
|
||||
use function Activitypub\get_active_users;
|
||||
use function Activitypub\get_rest_url_by_path;
|
||||
use function Activitypub\get_masked_wp_version;
|
||||
|
||||
/**
|
||||
* ActivityPub NodeInfo REST-Class
|
||||
@ -81,7 +82,7 @@ class Nodeinfo {
|
||||
$nodeinfo['version'] = '2.0';
|
||||
$nodeinfo['software'] = array(
|
||||
'name' => 'wordpress',
|
||||
'version' => \get_bloginfo( 'version' ),
|
||||
'version' => get_masked_wp_version(),
|
||||
);
|
||||
|
||||
$posts = \wp_count_posts();
|
||||
@ -134,7 +135,7 @@ class Nodeinfo {
|
||||
'baseUrl' => \home_url( '/' ),
|
||||
'name' => \get_bloginfo( 'name' ),
|
||||
'software' => 'wordpress',
|
||||
'version' => \get_bloginfo( 'version' ),
|
||||
'version' => get_masked_wp_version(),
|
||||
);
|
||||
|
||||
$posts = \wp_count_posts();
|
||||
|
@ -11,6 +11,7 @@ use Activitypub\Collection\Users as User_Collection;
|
||||
|
||||
use function Activitypub\get_context;
|
||||
use function Activitypub\get_rest_url_by_path;
|
||||
use function Activitypub\get_masked_wp_version;
|
||||
|
||||
/**
|
||||
* ActivityPub Outbox REST-Class
|
||||
@ -72,15 +73,20 @@ class Outbox {
|
||||
|
||||
$json->{'@context'} = get_context();
|
||||
$json->id = get_rest_url_by_path( sprintf( 'users/%d/outbox', $user_id ) );
|
||||
$json->generator = 'http://wordpress.org/?v=' . \get_bloginfo_rss( 'version' );
|
||||
$json->generator = 'http://wordpress.org/?v=' . get_masked_wp_version();
|
||||
$json->actor = $user->get_id();
|
||||
$json->type = 'OrderedCollectionPage';
|
||||
$json->partOf = get_rest_url_by_path( sprintf( 'users/%d/outbox', $user_id ) ); // phpcs:ignore
|
||||
$json->totalItems = 0; // phpcs:ignore
|
||||
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$count_posts = \wp_count_posts( $post_type );
|
||||
$json->totalItems += \intval( $count_posts->publish ); // phpcs:ignore
|
||||
if ( $user_id > 0 ) {
|
||||
$count_posts = \count_user_posts( $user_id, $post_types, true );
|
||||
$json->totalItems = \intval( $count_posts ); // phpcs:ignore
|
||||
} else {
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$count_posts = \wp_count_posts( $post_type );
|
||||
$json->totalItems += \intval( $count_posts->publish ); // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
$json->first = \add_query_arg( 'page', 1, $json->partOf ); // phpcs:ignore
|
||||
@ -98,7 +104,7 @@ class Outbox {
|
||||
$posts = \get_posts(
|
||||
array(
|
||||
'posts_per_page' => 10,
|
||||
'author' => $user_id,
|
||||
'author' => $user_id > 0 ? $user_id : null,
|
||||
'paged' => $page,
|
||||
'post_type' => $post_types,
|
||||
)
|
||||
|
@ -46,4 +46,16 @@ class Attachment extends Post {
|
||||
|
||||
return $attachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ActivityStreams 2.0 Object-Type for a Post based on the
|
||||
* settings and the Post-Type.
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitystreams-vocabulary/#activity-types
|
||||
*
|
||||
* @return string The Object-Type.
|
||||
*/
|
||||
protected function get_type() {
|
||||
return 'Note';
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ class Comment extends Base {
|
||||
|
||||
$mentions = $this->get_mentions();
|
||||
if ( $mentions ) {
|
||||
foreach ( $mentions as $mention => $url ) {
|
||||
foreach ( $mentions as $url ) {
|
||||
$cc[] = $url;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Activitypub\Transformer;
|
||||
|
||||
use WP_Error;
|
||||
use Activitypub\Transformer\Base;
|
||||
use Activitypub\Transformer\Post;
|
||||
use Activitypub\Transformer\Comment;
|
||||
use Activitypub\Transformer\Attachment;
|
||||
@ -10,6 +12,12 @@ use Activitypub\Transformer\Attachment;
|
||||
*/
|
||||
class Factory {
|
||||
public static function get_transformer( $object ) {
|
||||
if ( ! \is_object( $object ) ) {
|
||||
return new WP_Error( 'invalid_object', __( 'Invalid object', 'activitypub' ) );
|
||||
}
|
||||
|
||||
$class = \get_class( $object );
|
||||
|
||||
/**
|
||||
* Filter the transformer for a given object.
|
||||
*
|
||||
@ -39,14 +47,21 @@ class Factory {
|
||||
*
|
||||
* @return mixed The transformer to use.
|
||||
*/
|
||||
$transformer = apply_filters( 'activitypub_transformer', null, $object, get_class( $object ) );
|
||||
$transformer = \apply_filters( 'activitypub_transformer', null, $object, $class );
|
||||
|
||||
if ( $transformer ) {
|
||||
if (
|
||||
! \is_object( $transformer ) ||
|
||||
! $transformer instanceof Base
|
||||
) {
|
||||
return new WP_Error( 'invalid_transformer', __( 'Invalid transformer', 'activitypub' ) );
|
||||
}
|
||||
|
||||
return $transformer;
|
||||
}
|
||||
|
||||
// use default transformer
|
||||
switch ( get_class( $object ) ) {
|
||||
switch ( $class ) {
|
||||
case 'WP_Post':
|
||||
if ( 'attachment' === $object->post_type ) {
|
||||
return new Attachment( $object );
|
||||
|
@ -139,13 +139,19 @@ class Post extends Base {
|
||||
protected function get_attachment() {
|
||||
// Once upon a time we only supported images, but we now support audio/video as well.
|
||||
// We maintain the image-centric naming for backwards compatibility.
|
||||
$max_media = intval( \apply_filters( 'activitypub_max_image_attachments', \get_option( 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ) ) );
|
||||
$max_media = \intval( \apply_filters( 'activitypub_max_image_attachments', \get_option( 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ) ) );
|
||||
|
||||
if ( site_supports_blocks() && \has_blocks( $this->wp_object->post_content ) ) {
|
||||
return $this->get_block_attachments( $max_media );
|
||||
$media = $this->get_block_attachments( $max_media );
|
||||
} else {
|
||||
$media = $this->get_classic_editor_images( $max_media );
|
||||
}
|
||||
|
||||
return $this->get_classic_editor_images( $max_media );
|
||||
$unique_ids = \array_unique( \array_column( $media, 'id' ) );
|
||||
$media = \array_intersect_key( $media, $unique_ids );
|
||||
$media = \array_slice( $media, 0, $max_media );
|
||||
|
||||
return \array_filter( \array_map( array( self::class, 'wp_attachment_to_activity_attachment' ), $media ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,19 +169,23 @@ class Post extends Base {
|
||||
|
||||
$id = $this->wp_object->ID;
|
||||
|
||||
$media_ids = array();
|
||||
$media = array(
|
||||
'image' => array(),
|
||||
'audio' => array(),
|
||||
'video' => array(),
|
||||
);
|
||||
|
||||
// list post thumbnail first if this post has one
|
||||
if ( \function_exists( 'has_post_thumbnail' ) && \has_post_thumbnail( $id ) ) {
|
||||
$media_ids[] = \get_post_thumbnail_id( $id );
|
||||
$media['image'][] = array( 'id' => \get_post_thumbnail_id( $id ) );
|
||||
}
|
||||
|
||||
if ( $max_media > 0 ) {
|
||||
$blocks = \parse_blocks( $this->wp_object->post_content );
|
||||
$media_ids = self::get_media_ids_from_blocks( $blocks, $media_ids, $max_media );
|
||||
$media = self::get_media_from_blocks( $blocks, $media );
|
||||
}
|
||||
|
||||
return \array_filter( \array_map( array( self::class, 'wp_attachment_to_activity_attachment' ), $media_ids ) );
|
||||
return self::filter_media_by_object_type( $media, \get_post_format( $this->wp_object ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,7 +202,7 @@ class Post extends Base {
|
||||
if ( $max_images <= 0 ) {
|
||||
return array();
|
||||
}
|
||||
$image_ids = array();
|
||||
$images = array();
|
||||
$query = new \WP_Query(
|
||||
array(
|
||||
'post_parent' => $this->wp_object->ID,
|
||||
@ -205,11 +215,12 @@ class Post extends Base {
|
||||
)
|
||||
);
|
||||
foreach ( $query->get_posts() as $attachment ) {
|
||||
if ( ! \in_array( $attachment->ID, $image_ids, true ) ) {
|
||||
$image_ids[] = $attachment->ID;
|
||||
if ( ! \in_array( $attachment->ID, $images, true ) ) {
|
||||
$images[] = array( 'id' => $attachment->ID );
|
||||
}
|
||||
}
|
||||
return $image_ids;
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,7 +228,7 @@ class Post extends Base {
|
||||
*
|
||||
* @param int $max_images The maximum number of images to return.
|
||||
*
|
||||
* @return array The attachment IDs.
|
||||
* @return array The attachments.
|
||||
*/
|
||||
protected function get_classic_editor_image_embeds( $max_images ) {
|
||||
// if someone calls that function directly, bail
|
||||
@ -230,15 +241,15 @@ class Post extends Base {
|
||||
return array();
|
||||
}
|
||||
|
||||
$image_ids = array();
|
||||
$base = \wp_get_upload_dir()['baseurl'];
|
||||
$content = \get_post_field( 'post_content', $this->wp_object );
|
||||
$tags = new \WP_HTML_Tag_Processor( $content );
|
||||
$images = array();
|
||||
$base = \wp_get_upload_dir()['baseurl'];
|
||||
$content = \get_post_field( 'post_content', $this->wp_object );
|
||||
$tags = new \WP_HTML_Tag_Processor( $content );
|
||||
|
||||
// This linter warning is a false positive - we have to
|
||||
// re-count each time here as we modify $image_ids.
|
||||
// re-count each time here as we modify $images.
|
||||
// phpcs:ignore Squiz.PHP.DisallowSizeFunctionsInLoops.Found
|
||||
while ( $tags->next_tag( 'img' ) && ( \count( $image_ids ) < $max_images ) ) {
|
||||
while ( $tags->next_tag( 'img' ) && ( \count( $images ) < $max_images ) ) {
|
||||
$src = $tags->get_attribute( 'src' );
|
||||
|
||||
// If the img source is in our uploads dir, get the
|
||||
@ -266,13 +277,15 @@ class Post extends Base {
|
||||
}
|
||||
|
||||
if ( 0 !== $img_id ) {
|
||||
if ( ! \in_array( $img_id, $image_ids, true ) ) {
|
||||
$image_ids[] = $img_id;
|
||||
}
|
||||
$images[] = array(
|
||||
'id' => $img_id,
|
||||
'alt' => $tags->get_attribute( 'alt' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $image_ids;
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,91 +304,125 @@ class Post extends Base {
|
||||
|
||||
$id = $this->wp_object->ID;
|
||||
|
||||
$image_ids = array();
|
||||
$images = array();
|
||||
|
||||
// list post thumbnail first if this post has one
|
||||
if ( \function_exists( 'has_post_thumbnail' ) && \has_post_thumbnail( $id ) ) {
|
||||
$image_ids[] = \get_post_thumbnail_id( $id );
|
||||
$images[] = \get_post_thumbnail_id( $id );
|
||||
}
|
||||
|
||||
if ( \count( $image_ids ) < $max_images ) {
|
||||
if ( \count( $images ) < $max_images ) {
|
||||
if ( \class_exists( '\WP_HTML_Tag_Processor' ) ) {
|
||||
$image_ids = \array_merge( $image_ids, $this->get_classic_editor_image_embeds( $max_images ) );
|
||||
$images = \array_merge( $images, $this->get_classic_editor_image_embeds( $max_images ) );
|
||||
} else {
|
||||
$image_ids = \array_merge( $image_ids, $this->get_classic_editor_image_attachments( $max_images ) );
|
||||
$images = \array_merge( $images, $this->get_classic_editor_image_attachments( $max_images ) );
|
||||
}
|
||||
}
|
||||
// unique then slice as the thumbnail may duplicate another image
|
||||
$image_ids = \array_slice( \array_unique( $image_ids ), 0, $max_images );
|
||||
|
||||
return \array_filter( \array_map( array( self::class, 'wp_attachment_to_activity_attachment' ), $image_ids ) );
|
||||
return $images;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively get media IDs from blocks.
|
||||
* @param array $blocks The blocks to search for media IDs
|
||||
* @param array $media_ids The media IDs to append new IDs to
|
||||
* @param array $media The media IDs to append new IDs to
|
||||
* @param int $max_media The maximum number of media to return.
|
||||
*
|
||||
* @return array The image IDs.
|
||||
*/
|
||||
protected static function get_media_ids_from_blocks( $blocks, $media_ids, $max_media ) {
|
||||
protected static function get_media_from_blocks( $blocks, $media ) {
|
||||
|
||||
foreach ( $blocks as $block ) {
|
||||
// recurse into inner blocks
|
||||
if ( ! empty( $block['innerBlocks'] ) ) {
|
||||
$media_ids = self::get_media_ids_from_blocks( $block['innerBlocks'], $media_ids, $max_media );
|
||||
$media = self::get_media_from_blocks( $block['innerBlocks'], $media );
|
||||
}
|
||||
|
||||
switch ( $block['blockName'] ) {
|
||||
case 'core/image':
|
||||
case 'core/cover':
|
||||
if ( ! empty( $block['attrs']['id'] ) ) {
|
||||
$alt = '';
|
||||
$check = preg_match( '/<img.*?alt=[\"\'](.*?)[\"\'].*>/i', $block['innerHTML'], $match );
|
||||
|
||||
if ( $check ) {
|
||||
$alt = $match[1];
|
||||
}
|
||||
|
||||
$media['image'][] = array(
|
||||
'id' => $block['attrs']['id'],
|
||||
'alt' => $alt,
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'core/audio':
|
||||
if ( ! empty( $block['attrs']['id'] ) ) {
|
||||
$media['audio'][] = array( 'id' => $block['attrs']['id'] );
|
||||
}
|
||||
break;
|
||||
case 'core/video':
|
||||
case 'videopress/video':
|
||||
if ( ! empty( $block['attrs']['id'] ) ) {
|
||||
$media_ids[] = $block['attrs']['id'];
|
||||
$media['video'][] = array( 'id' => $block['attrs']['id'] );
|
||||
}
|
||||
break;
|
||||
case 'jetpack/slideshow':
|
||||
case 'jetpack/tiled-gallery':
|
||||
if ( ! empty( $block['attrs']['ids'] ) ) {
|
||||
$media_ids = array_merge( $media_ids, $block['attrs']['ids'] );
|
||||
$media['image'] = array_merge(
|
||||
$media['image'],
|
||||
array_map(
|
||||
function ( $id ) {
|
||||
return array( 'id' => $id );
|
||||
},
|
||||
$block['attrs']['ids']
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'jetpack/image-compare':
|
||||
if ( ! empty( $block['attrs']['beforeImageId'] ) ) {
|
||||
$media_ids[] = $block['attrs']['beforeImageId'];
|
||||
$media['image'][] = array( 'id' => $block['attrs']['beforeImageId'] );
|
||||
}
|
||||
if ( ! empty( $block['attrs']['afterImageId'] ) ) {
|
||||
$media_ids[] = $block['attrs']['afterImageId'];
|
||||
$media['image'][] = array( 'id' => $block['attrs']['afterImageId'] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// depupe
|
||||
$media_ids = \array_unique( $media_ids );
|
||||
|
||||
// stop doing unneeded work
|
||||
if ( count( $media_ids ) >= $max_media ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// still need to slice it because one gallery could knock us over the limit
|
||||
return array_slice( $media_ids, 0, $max_media );
|
||||
return $media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter media IDs by object type.
|
||||
*
|
||||
* @param array $media The media array grouped by type.
|
||||
* @param array $type The object type.
|
||||
*
|
||||
* @return array The filtered media IDs.
|
||||
*/
|
||||
protected static function filter_media_by_object_type( $media, $type ) {
|
||||
$type = \apply_filters( 'filter_media_by_object_type', \strtolower( $type ) );
|
||||
|
||||
if ( ! empty( $media[ $type ] ) ) {
|
||||
return $media[ $type ];
|
||||
}
|
||||
|
||||
return array_merge( array(), ...array_values( $media ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a WordPress Attachment to an ActivityPub Attachment.
|
||||
*
|
||||
* @param int $id The Attachment ID.
|
||||
* @param array $media The Attachment array.
|
||||
*
|
||||
* @return array The ActivityPub Attachment.
|
||||
*/
|
||||
public static function wp_attachment_to_activity_attachment( $id ) {
|
||||
$attachment = array();
|
||||
$mime_type = \get_post_mime_type( $id );
|
||||
public static function wp_attachment_to_activity_attachment( $media ) {
|
||||
$id = $media['id'];
|
||||
$attachment = array();
|
||||
$mime_type = \get_post_mime_type( $id );
|
||||
$mime_type_parts = \explode( '/', $mime_type );
|
||||
// switching on image/audio/video
|
||||
switch ( $mime_type_parts[0] ) {
|
||||
@ -397,16 +444,21 @@ class Post extends Base {
|
||||
);
|
||||
|
||||
if ( $thumbnail ) {
|
||||
$alt = \get_post_meta( $id, '_wp_attachment_image_alt', true );
|
||||
$image = array(
|
||||
'type' => 'Image',
|
||||
'url' => $thumbnail[0],
|
||||
'mediaType' => $mime_type,
|
||||
'url' => \esc_url( $thumbnail[0] ),
|
||||
'mediaType' => \esc_attr( $mime_type ),
|
||||
);
|
||||
|
||||
if ( $alt ) {
|
||||
$image['name'] = $alt;
|
||||
if ( ! empty( $media['alt'] ) ) {
|
||||
$image['name'] = \esc_attr( $media['alt'] );
|
||||
} else {
|
||||
$alt = \get_post_meta( $id, '_wp_attachment_image_alt', true );
|
||||
if ( $alt ) {
|
||||
$image['name'] = \esc_attr( $alt );
|
||||
}
|
||||
}
|
||||
|
||||
$attachment = $image;
|
||||
}
|
||||
break;
|
||||
@ -415,15 +467,15 @@ class Post extends Base {
|
||||
case 'video':
|
||||
$attachment = array(
|
||||
'type' => 'Document',
|
||||
'mediaType' => $mime_type,
|
||||
'url' => \wp_get_attachment_url( $id ),
|
||||
'name' => \get_the_title( $id ),
|
||||
'mediaType' => \esc_attr( $mime_type ),
|
||||
'url' => \esc_url( \wp_get_attachment_url( $id ) ),
|
||||
'name' => \esc_attr( \get_the_title( $id ) ),
|
||||
);
|
||||
$meta = wp_get_attachment_metadata( $id );
|
||||
// height and width for videos
|
||||
if ( isset( $meta['width'] ) && isset( $meta['height'] ) ) {
|
||||
$attachment['width'] = $meta['width'];
|
||||
$attachment['height'] = $meta['height'];
|
||||
$attachment['width'] = \esc_attr( $meta['width'] );
|
||||
$attachment['height'] = \esc_attr( $meta['height'] );
|
||||
}
|
||||
// @todo: add `icon` support for audio/video attachments. Maybe use post thumbnail?
|
||||
break;
|
||||
@ -471,32 +523,39 @@ class Post extends Base {
|
||||
* @return string The Object-Type.
|
||||
*/
|
||||
protected function get_type() {
|
||||
if ( 'wordpress-post-format' !== \get_option( 'activitypub_object_type', 'note' ) ) {
|
||||
return \ucfirst( \get_option( 'activitypub_object_type', 'note' ) );
|
||||
$post_format_setting = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
|
||||
|
||||
if ( 'wordpress-post-format' !== $post_format_setting ) {
|
||||
return \ucfirst( $post_format_setting );
|
||||
}
|
||||
|
||||
$has_title = post_type_supports( $this->wp_object->post_type, 'title' );
|
||||
|
||||
if ( ! $has_title ) {
|
||||
return 'Note';
|
||||
}
|
||||
|
||||
// Default to Article.
|
||||
$object_type = 'Article';
|
||||
$post_format = 'standard';
|
||||
|
||||
if ( \get_theme_support( 'post-formats' ) ) {
|
||||
$post_format = \get_post_format( $this->wp_object );
|
||||
}
|
||||
|
||||
$post_type = \get_post_type( $this->wp_object );
|
||||
switch ( $post_type ) {
|
||||
case 'post':
|
||||
$post_format = \get_post_format( $this->wp_object );
|
||||
switch ( $post_format ) {
|
||||
case 'aside':
|
||||
case 'status':
|
||||
case 'quote':
|
||||
case 'note':
|
||||
$object_type = 'Note';
|
||||
break;
|
||||
case 'gallery':
|
||||
case 'image':
|
||||
$object_type = 'Image';
|
||||
break;
|
||||
case 'video':
|
||||
$object_type = 'Video';
|
||||
break;
|
||||
case 'audio':
|
||||
$object_type = 'Audio';
|
||||
$object_type = 'Note';
|
||||
break;
|
||||
default:
|
||||
$object_type = 'Article';
|
||||
@ -506,21 +565,6 @@ class Post extends Base {
|
||||
case 'page':
|
||||
$object_type = 'Page';
|
||||
break;
|
||||
case 'attachment':
|
||||
$mime_type = \get_post_mime_type();
|
||||
$media_type = \preg_replace( '/(\/[a-zA-Z]+)/i', '', $mime_type );
|
||||
switch ( $media_type ) {
|
||||
case 'audio':
|
||||
$object_type = 'Audio';
|
||||
break;
|
||||
case 'video':
|
||||
$object_type = 'Video';
|
||||
break;
|
||||
case 'image':
|
||||
$object_type = 'Image';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$object_type = 'Article';
|
||||
break;
|
||||
@ -586,6 +630,65 @@ class Post extends Base {
|
||||
return $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the summary for the ActivityPub Item.
|
||||
*
|
||||
* The summary will be generated based on the user settings and only if the
|
||||
* object type is not set to `note`.
|
||||
*
|
||||
* @return string|null The summary or null if the object type is `note`.
|
||||
*/
|
||||
protected function get_summary() {
|
||||
if ( 'Note' === $this->get_type() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = \get_post_field( 'post_content', $this->wp_object->ID );
|
||||
$content = \html_entity_decode( $content );
|
||||
$content = \wp_strip_all_tags( $content );
|
||||
$content = \trim( $content );
|
||||
$content = \preg_replace( '/\R+/m', "\n\n", $content );
|
||||
$content = \preg_replace( '/[\r\t]/', '', $content );
|
||||
|
||||
$excerpt_more = \apply_filters( 'activitypub_excerpt_more', '[...]' );
|
||||
$length = 500;
|
||||
$length = $length - strlen( $excerpt_more );
|
||||
|
||||
if ( \strlen( $content ) > $length ) {
|
||||
$content = \wordwrap( $content, $length, '</activitypub-summary>' );
|
||||
$content = \explode( '</activitypub-summary>', $content, 2 );
|
||||
$content = $content[0];
|
||||
}
|
||||
|
||||
return $content . ' ' . $excerpt_more;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title for the ActivityPub Item.
|
||||
*
|
||||
* The title will be generated based on the user settings and only if the
|
||||
* object type is not set to `note`.
|
||||
*
|
||||
* @return string|null The title or null if the object type is `note`.
|
||||
*/
|
||||
protected function get_name() {
|
||||
if ( 'Note' === $this->get_type() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$title = \get_the_title( $this->wp_object->ID );
|
||||
|
||||
if ( $title ) {
|
||||
return \wp_strip_all_tags(
|
||||
\html_entity_decode(
|
||||
$title
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content for the ActivityPub Item.
|
||||
*
|
||||
@ -641,7 +744,7 @@ class Post extends Base {
|
||||
$template = "[ap_excerpt]\n\n[ap_permalink type=\"html\"]";
|
||||
break;
|
||||
case 'title':
|
||||
$template = "[ap_title]\n\n[ap_permalink type=\"html\"]";
|
||||
$template = "<h2>[ap_title]</h2>\n\n[ap_permalink type=\"html\"]";
|
||||
break;
|
||||
case 'content':
|
||||
$template = "[ap_content]\n\n[ap_permalink type=\"html\"]\n\n[ap_hashtags]";
|
||||
@ -651,6 +754,12 @@ class Post extends Base {
|
||||
break;
|
||||
}
|
||||
|
||||
$post_format_setting = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
|
||||
|
||||
if ( 'wordpress-post-format' === $post_format_setting ) {
|
||||
$template = '[ap_content]';
|
||||
}
|
||||
|
||||
return apply_filters( 'activitypub_object_content_template', $template, $this->wp_object );
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,9 @@ class Enable_Mastodon_Apps {
|
||||
*/
|
||||
public static function init() {
|
||||
\add_filter( 'mastodon_api_account_followers', array( self::class, 'api_account_followers' ), 10, 2 );
|
||||
\add_filter( 'mastodon_api_account', array( self::class, 'api_account_add_followers' ), 20, 2 );
|
||||
\add_filter( 'mastodon_api_account', array( self::class, 'api_account' ), 20, 2 );
|
||||
\add_filter( 'mastodon_api_account', array( self::class, 'api_account_external' ), 10, 2 );
|
||||
\add_filter( 'mastodon_api_search', array( self::class, 'api_search' ), 40, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,36 +49,35 @@ class Enable_Mastodon_Apps {
|
||||
$acct = $item->get_url();
|
||||
}
|
||||
|
||||
$activitypub_follower = array(
|
||||
'id' => \strval( $item->get__id() ),
|
||||
'username' => $item->get_preferred_username(),
|
||||
'acct' => $acct,
|
||||
'display_name' => $item->get_name(),
|
||||
'url' => $item->get_url(),
|
||||
'uri' => $item->get_id(),
|
||||
'avatar' => $item->get_icon_url(),
|
||||
'avatar_static' => $item->get_icon_url(),
|
||||
'created_at' => gmdate( DATE_W3C, strtotime( $item->get_published() ) ),
|
||||
'last_status_at' => gmdate( DATE_W3C, strtotime( $item->get_published() ) ),
|
||||
'note' => $item->get_summary(),
|
||||
'header' => $item->get_image_url(),
|
||||
'header_static' => $item->get_image_url(),
|
||||
'followers_count' => 0,
|
||||
'following_count' => 0,
|
||||
'statuses_count' => 0,
|
||||
'bot' => false,
|
||||
'locked' => false,
|
||||
'group' => false,
|
||||
'discoversable' => false,
|
||||
'indexable' => false,
|
||||
'hide_collections' => false,
|
||||
'noindex' => false,
|
||||
'fields' => array(),
|
||||
'emojis' => array(),
|
||||
'roles' => array(),
|
||||
);
|
||||
$account = new Account();
|
||||
$account->id = \strval( $item->get__id() );
|
||||
$account->username = $item->get_preferred_username();
|
||||
$account->acct = $acct;
|
||||
$account->display_name = $item->get_name();
|
||||
$account->url = $item->get_url();
|
||||
$account->uri = $item->get_id();
|
||||
$account->avatar = $item->get_icon_url();
|
||||
$account->avatar_static = $item->get_icon_url();
|
||||
$account->created_at = new DateTime( $item->get_published() );
|
||||
$account->last_status_at = new DateTime( $item->get_published() );
|
||||
$account->note = $item->get_summary();
|
||||
$account->header = $item->get_image_url();
|
||||
$account->header_static = $item->get_image_url();
|
||||
$account->followers_count = 0;
|
||||
$account->following_count = 0;
|
||||
$account->statuses_count = 0;
|
||||
$account->bot = false;
|
||||
$account->locked = false;
|
||||
$account->group = false;
|
||||
$account->discoversable = false;
|
||||
$account->indexable = false;
|
||||
$account->hide_collections = false;
|
||||
$account->noindex = false;
|
||||
$account->fields = array();
|
||||
$account->emojis = array();
|
||||
$account->roles = array();
|
||||
|
||||
return $activitypub_follower;
|
||||
return $account;
|
||||
},
|
||||
$activitypub_followers
|
||||
);
|
||||
@ -95,7 +95,7 @@ class Enable_Mastodon_Apps {
|
||||
*
|
||||
* @return Enable_Mastodon_Apps\Entity\Account The filtered Account
|
||||
*/
|
||||
public static function api_account_add_followers( $account, $user_id ) {
|
||||
public static function api_account( $account, $user_id ) {
|
||||
if ( ! $account instanceof Account ) {
|
||||
return $account;
|
||||
}
|
||||
@ -106,6 +106,23 @@ class Enable_Mastodon_Apps {
|
||||
return $account;
|
||||
}
|
||||
|
||||
$header = $user->get_image();
|
||||
if ( $header ) {
|
||||
$account->header = $header['url'];
|
||||
$account->header_static = $header['url'];
|
||||
}
|
||||
|
||||
foreach ( $user->get_attachment() as $attachment ) {
|
||||
if ( 'PropertyValue' === $attachment['type'] ) {
|
||||
$account->fields[] = array(
|
||||
'name' => $attachment['name'],
|
||||
'value' => $attachment['value'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$account->acct = $user->get_webfinger();
|
||||
$account->note = $user->get_summary();
|
||||
$account->followers_count = Followers::count_followers( $user_id );
|
||||
return $account;
|
||||
}
|
||||
@ -169,4 +186,51 @@ class Enable_Mastodon_Apps {
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
public static function api_search( $search_data, $request ) {
|
||||
$user_id = \get_current_user_id();
|
||||
if ( ! $user_id ) {
|
||||
return $search_data;
|
||||
}
|
||||
|
||||
$q = $request->get_param( 'q' );
|
||||
if ( ! $q ) {
|
||||
return $search_data;
|
||||
}
|
||||
$q = sanitize_text_field( wp_unslash( $q ) );
|
||||
|
||||
$followers = Followers::get_followers( $user_id, 40, null, array( 's' => $q ) );
|
||||
if ( ! $followers ) {
|
||||
return $search_data;
|
||||
}
|
||||
|
||||
foreach ( $followers as $follower ) {
|
||||
$acct = Webfinger_Util::uri_to_acct( $follower->get_id() );
|
||||
|
||||
if ( $acct && ! is_wp_error( $acct ) ) {
|
||||
$acct = \str_replace( 'acct:', '', $acct );
|
||||
} else {
|
||||
$acct = $follower->get_url();
|
||||
}
|
||||
|
||||
$account = new Account();
|
||||
$account->id = \strval( $follower->get__id() );
|
||||
$account->username = $follower->get_preferred_username();
|
||||
$account->acct = $acct;
|
||||
$account->display_name = $follower->get_name();
|
||||
$account->url = $follower->get_url();
|
||||
$account->uri = $follower->get_id();
|
||||
$account->avatar = $follower->get_icon_url();
|
||||
$account->avatar_static = $follower->get_icon_url();
|
||||
$account->created_at = new DateTime( $follower->get_published() );
|
||||
$account->last_status_at = new DateTime( $follower->get_published() );
|
||||
$account->note = $follower->get_summary();
|
||||
$account->header = $follower->get_image_url();
|
||||
$account->header_static = $follower->get_image_url();
|
||||
|
||||
$search_data['accounts'][] = $account;
|
||||
}
|
||||
|
||||
return $search_data;
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
Contributors: automattic, pfefferle, mediaformat, mattwiebe, akirk, jeherve, nuriapena, cavalierlife
|
||||
Tags: OStatus, fediverse, activitypub, activitystream
|
||||
Requires at least: 5.5
|
||||
Tested up to: 6.4
|
||||
Stable tag: 2.2.0
|
||||
Tested up to: 6.5
|
||||
Stable tag: 2.3.0
|
||||
Requires PHP: 5.6
|
||||
License: MIT
|
||||
License URI: http://opensource.org/licenses/MIT
|
||||
@ -133,7 +133,25 @@ For reasons of data protection, it is not possible to see the followers of other
|
||||
|
||||
== Changelog ==
|
||||
|
||||
Project maintained on GitHub at [automattic/wordpress-activitypub](https://github.com/automattic/wordpress-activitypub).
|
||||
= 2.3.0 =
|
||||
|
||||
* Added: Mark links as "unhandled-link" and "status-link", for a better UX in the Mastodon App
|
||||
* Added: Enable-Mastodon-Apps: Provide followers
|
||||
* Added: Enable-Mastodon-Apps: Extend account with ActivityPub data
|
||||
* Added: Enable-Mastodon-Apps: Search in followers
|
||||
* Added: Add `alt` support for images (for Block and Classic-Editor)
|
||||
* Fixed: Counter for system users outbox
|
||||
* Fixed: Don't set a default actor type in the actor class
|
||||
* Fixed: Outbox collection for blog and application user
|
||||
* Changed: A better default content handling based on the Object Type
|
||||
* Changed: Improve User management
|
||||
* Changed: Federated replies: Improved UX for "your reply will federate"
|
||||
* Changed: Comment reply federation: support `is_single_user` sites
|
||||
* Changed: Mask WordPress version number
|
||||
* Changed: Improve remote reply handling
|
||||
* Changed: Remote Reply: limit enqueue to when needed
|
||||
* Changed: Abstract shared Dialog code
|
||||
|
||||
|
||||
= 2.2.0 =
|
||||
|
||||
@ -141,418 +159,7 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu
|
||||
* Added: Support `application/ld+json` mime-type with AP profile in WebFinger
|
||||
* Fixed: Prevent scheduler overload
|
||||
|
||||
= 2.1.1 =
|
||||
|
||||
* Added: Add `@` prefix to Follow-Block
|
||||
* Added: Apply `comment_text` filter to Activity
|
||||
|
||||
= 2.1.0 =
|
||||
|
||||
* Fixed: Some Federated Comment improvements
|
||||
* Fixed: Remove old/abandoned Crons
|
||||
* Added: Various endpoints for the "Enable Mastodon Apps" plugin
|
||||
* Added: Event Objects
|
||||
* Added: Send notification to all Repliers if a new Comment is added
|
||||
* Added: Vary-Header support behind feature flag
|
||||
|
||||
= 2.0.1 =
|
||||
|
||||
* Fixed: Comment `Update` Federation
|
||||
* Workaround: Re-Added Post Model Class because of some weird caching issues
|
||||
* Fixed: WebFinger check
|
||||
* Fixed: Classic editor image finding for large images
|
||||
|
||||
= 2.0.0 =
|
||||
|
||||
* Added: Bidirectional Comment Federation
|
||||
* Removed: Deprecated Classes
|
||||
* Fixed: Normalize attributes that can have mixed value types
|
||||
* Added: URL support for WebFinger
|
||||
* Added: Make Post-Template filterable
|
||||
* Added: CSS class for ActivityPub comments to allow custom designs
|
||||
* Added: FEP-2677: Identifying the Application Actor
|
||||
* Added: FEP-2c59: Discovery of a Webfinger address from an ActivityPub actor
|
||||
* Added: Profile Update Activities
|
||||
* Improved: WebFinger endpoints
|
||||
|
||||
= 1.3.0 =
|
||||
|
||||
* Added: Threaded-Comments support
|
||||
* Improved: alt text for avatars in Follow Me/Followers blocks
|
||||
* Improved: `Delete`, `Update` and `Follow` Activities
|
||||
* Improved: better/more effective handling of `Delete` Activities
|
||||
* Improved: allow `<p />` and `<br />` for Comments
|
||||
* Fixed: removed default limit of WP_Query to send updates to all Inboxes and not only to the first 10
|
||||
|
||||
= 1.2.0 =
|
||||
|
||||
* Add: Search and order followerer lists
|
||||
* Add: Have a filter to defer signature verification
|
||||
* Improved: "Follow Me" styles for dark themes
|
||||
* Improved: Allow `p` and `br` tags only for AP comments
|
||||
* Fixed: Deduplicate attachments earlier to prevent incorrect max_media
|
||||
|
||||
|
||||
= 1.1.0 =
|
||||
|
||||
* Improved: audio and video attachments are now supported!
|
||||
* Improved: better error messages if remote profile is not accessible
|
||||
* Improved: PHP 8.1 compatibility
|
||||
* Fixed: don't try to parse mentions or hashtags for very large (>1MB) posts to prevent timeouts
|
||||
* Fixed: better handling of ISO-639-1 locale codes
|
||||
* Improved: more reliable [ap_author], props @uk3
|
||||
* Improved: NodeInfo statistics
|
||||
|
||||
= 1.0.10 =
|
||||
|
||||
* Improved: better error messages if remote profile is not accessible
|
||||
|
||||
= 1.0.9 =
|
||||
|
||||
* Fixed: broken following endpoint
|
||||
|
||||
= 1.0.8 =
|
||||
|
||||
* Fixed: blocking of HEAD requests
|
||||
* Fixed: PHP fatal error
|
||||
* Fixed: several typos
|
||||
* Fixed: error codes
|
||||
* Improved: loading of shortcodes
|
||||
* Updated: caching of followers
|
||||
* Updated: Application-User is no longer "indexable"
|
||||
* Updated: more consistent usage of the `application/activity+json` Content-Type
|
||||
* Removed: featured tags endpoint
|
||||
|
||||
= 1.0.7 =
|
||||
|
||||
* Fixed: broken function call
|
||||
* Add: filter to hook into "is blog public" check
|
||||
|
||||
= 1.0.6 =
|
||||
|
||||
* Fixed: more restrictive request verification
|
||||
|
||||
= 1.0.5 =
|
||||
|
||||
* Fixed: compatibility with WebFinger and NodeInfo plugin
|
||||
|
||||
= 1.0.4 =
|
||||
|
||||
* Fixed: Constants were not loaded early enough, resulting in a race condition
|
||||
* Fixed: Featured image was ignored when using the block editor
|
||||
|
||||
= 1.0.3 =
|
||||
|
||||
* Fixed: compatibility with older WordPress/PHP versions
|
||||
* Update: refactoring of the Plugin init process
|
||||
* Update: better frontend UX and improved theme compat for blocks
|
||||
* Compatibility: add a ACTIVITYPUB_DISABLE_REWRITES constant
|
||||
* Compatibility: add pre-fetch hook to allow plugins to hang filters on
|
||||
|
||||
= 1.0.2 =
|
||||
|
||||
* Updated: improved hashtag visibility in default template
|
||||
* Updated: reduced number of followers to be checked/updated via Cron, when System Cron is not set up
|
||||
* Updated: check if username of Blog-User collides with an Authors name
|
||||
* Compatibility: improved Group meta informations
|
||||
* Fixed: detection of single user mode
|
||||
* Fixed: remote delete
|
||||
* Fixed: styles in Follow-Me block
|
||||
* Fixed: various encoding and formatting issues
|
||||
* Fixed: (health) check Author URLs only if Authors are enabled
|
||||
|
||||
= 1.0.1 =
|
||||
|
||||
* Update: improve image attachment detection using the block editor
|
||||
* Update: better error code handling for API responses
|
||||
* Update: use a tag stack instead of regex for protecting tags for Hashtags and @-Mentions
|
||||
* Compatibility: better signature support for subpath-installations
|
||||
* Compatibility: allow deactivating blocks registered by the plugin
|
||||
* Compatibility: avoid Fatal Errors when using ClassicPress
|
||||
* Compatibility: improve the Group-Actor to play nicely with existing implementations
|
||||
* Fixed: truncate long blog titles and handles for the "Follow me" block
|
||||
* Fixed: ensure that only a valid user can be selected for the "Follow me" block
|
||||
* Fixed: fix a typo in a hook name
|
||||
* Fixed: a problem with signatures when running WordPress in a sub-path
|
||||
|
||||
= 1.0.0 =
|
||||
|
||||
* Add: blog-wide Account (catchall, like `example.com@example.com`)
|
||||
* Add: a Follow Me block (help visitors to follow your Profile)
|
||||
* Add: Signature Verification: https://docs.joinmastodon.org/spec/security/
|
||||
* Add: a Followers Block (show off your Followers)
|
||||
* Add: Simple caching
|
||||
* Add: Collection endpoints for Featured Tags and Featured Posts
|
||||
* Add: Better handling of Hashtags in mobile apps
|
||||
* Update: Complete rewrite of the Follower-System based on Custom Post Types
|
||||
* Update: Improved linter (PHPCS)
|
||||
* Compatibility: Add a new conditional, `\Activitypub\is_activitypub_request()`, to allow third-party plugins to detect ActivityPub requests
|
||||
* Compatibility: Add hooks to allow modifying images returned in ActivityPub requests
|
||||
* Compatibility: Indicate that the plugin is compatible and has been tested with the latest version of WordPress, 6.3
|
||||
* Compatibility: Avoid PHP notice on sites using PHP 8.2
|
||||
* Fixed: Load the plugin later in the WordPress code lifecycle to avoid errors in some requests
|
||||
* Fixed: Updating posts
|
||||
* Fixed: Hashtag now support CamelCase and UTF-8
|
||||
|
||||
= 0.17.0 =
|
||||
|
||||
* Fix type-selector
|
||||
* Allow more HTML elements in Activity-Objects
|
||||
|
||||
= 0.16.5 =
|
||||
|
||||
* Return empty content/excerpt on password protected posts/pages
|
||||
|
||||
= 0.16.4 =
|
||||
|
||||
* Remove scripts later in the queue, to also handle scripts added by blocks
|
||||
* Add published date to author profiles
|
||||
|
||||
= 0.16.3 =
|
||||
|
||||
* "cc", "to", ... fields can either be an array or a string
|
||||
* Remove "style" and "script" HTML elements from content
|
||||
|
||||
= 0.16.2 =
|
||||
|
||||
* Fix fatal error in outbox
|
||||
|
||||
= 0.16.1 =
|
||||
|
||||
* Fix "update and create, posts appear blank on Mastodon" issue
|
||||
|
||||
= 0.16.0 =
|
||||
|
||||
* Add "Outgoing Mentions" ([#213](https://github.com/pfefferle/wordpress-activitypub/pull/213)) props [@akirk](https://github.com/akirk)
|
||||
* Add configuration item for number of images to attach ([#248](https://github.com/pfefferle/wordpress-activitypub/pull/248)) props [@mexon](https://github.com/mexon)
|
||||
* Use shortcodes instead of custom templates, to setup the Activity Post-Content ([#250](https://github.com/pfefferle/wordpress-activitypub/pull/250)) props [@toolstack](https://github.com/toolstack)
|
||||
* Remove custom REST Server, because the needed changes are now merged into Core.
|
||||
* Fix hashtags ([#261](https://github.com/pfefferle/wordpress-activitypub/pull/261)) props [@akirk](https://github.com/akirk)
|
||||
* Change priorites, to maybe fix the hashtag issue
|
||||
|
||||
= 0.15.0 =
|
||||
|
||||
* Enable ActivityPub only for users that can `publish_posts`
|
||||
* Persist only public Activities
|
||||
* Fix remote-delete
|
||||
|
||||
= 0.14.3 =
|
||||
|
||||
* Better error handling. props [@akirk](https://github.com/akirk)
|
||||
|
||||
= 0.14.2 =
|
||||
|
||||
* Fix Critical error when using Friends Plugin and adding new URL to follow. props [@akirk](https://github.com/akirk)
|
||||
|
||||
= 0.14.1 =
|
||||
|
||||
* Fix "WebFinger not compatible with PHP < 8.0". props [@mexon](https://github.com/mexon)
|
||||
|
||||
= 0.14.0 =
|
||||
|
||||
* Friends support: https://wordpress.org/plugins/friends/ props [@akirk](https://github.com/akirk)
|
||||
* Massive guidance improvements. props [mediaformat](https://github.com/mediaformat) & [@akirk](https://github.com/akirk)
|
||||
* Add Custom Post Type support to outbox API. props [blueset](https://github.com/blueset)
|
||||
* Better hash-tag support. props [bocops](https://github.com/bocops)
|
||||
* Fix user-count (NodeInfo). props [mediaformat](https://github.com/mediaformat)
|
||||
|
||||
= 0.13.4 =
|
||||
|
||||
* fix webfinger for email identifiers
|
||||
|
||||
= 0.13.3 =
|
||||
|
||||
* fix: Create and Note should not have the same ActivityPub ID
|
||||
|
||||
= 0.13.2 =
|
||||
|
||||
* fix Follow issue AGAIN
|
||||
|
||||
= 0.13.1 =
|
||||
|
||||
* fix Inbox issue
|
||||
|
||||
= 0.13.0 =
|
||||
|
||||
* add Autor URL and WebFinger health checks
|
||||
* fix NodeInfo endpoint
|
||||
|
||||
= 0.12.0 =
|
||||
|
||||
* use "pre_option_require_name_email" filter instead of "check_comment_flood". props [@akirk](https://github.com/akirk)
|
||||
* save only comments/replies
|
||||
* check for an explicit "undo -> follow" action. see https://wordpress.org/support/topic/qs-after-latest/
|
||||
|
||||
= 0.11.2 =
|
||||
|
||||
* fix inconsistent `%tags%` placeholder
|
||||
|
||||
= 0.11.1 =
|
||||
|
||||
* fix follow/unfollow actions
|
||||
|
||||
= 0.11.0 =
|
||||
|
||||
* add support for customizable post-content
|
||||
* first try of a delete activity
|
||||
* do not require email for AP entries. props [@akirk](https://github.com/akirk)
|
||||
* fix [timezones](https://github.com/pfefferle/wordpress-activitypub/issues/63) bug. props [@mediaformat](https://github.com/mediaformat)
|
||||
* fix [digest header](https://github.com/pfefferle/wordpress-activitypub/issues/104) bug. props [@mediaformat](https://github.com/mediaformat)
|
||||
|
||||
|
||||
= 0.10.1 =
|
||||
|
||||
* fix inbox activities, like follow
|
||||
* fix debug
|
||||
|
||||
= 0.10.0 =
|
||||
|
||||
* add image alt text to the ActivityStreams attachment property in a format that Mastodon can read. props [@BenLubar](https://github.com/BenLubar)
|
||||
* use the "summary" property for a title as Mastodon does. props [@BenLubar](https://github.com/BenLubar)
|
||||
* support authorized fetch to avoid having comments from "Anonymous". props [@BenLubar](https://github.com/BenLubar)
|
||||
* add new post type: "title and link only". props [@bgcarlisle](https://github.com/bgcarlisle)
|
||||
|
||||
= 0.9.1 =
|
||||
|
||||
* disable shared inbox
|
||||
* disable delete activity
|
||||
|
||||
= 0.9.0 =
|
||||
|
||||
* some code refactorings
|
||||
* fix #73
|
||||
|
||||
= 0.8.3 =
|
||||
|
||||
* fixed accept header bug
|
||||
|
||||
= 0.8.2 =
|
||||
|
||||
* add all required accept header
|
||||
* better/simpler accept-header handling
|
||||
* add debugging mechanism
|
||||
* Add setting to enable AP for different (public) Post-Types
|
||||
* explicit use of global functions
|
||||
|
||||
= 0.8.1 =
|
||||
|
||||
* fixed PHP warnings
|
||||
|
||||
= 0.8.0 =
|
||||
|
||||
* Moved followers list to user-menu
|
||||
|
||||
= 0.7.4 =
|
||||
|
||||
* added admin_email to metadata, to be able to "Manage your instance" on https://fediverse.network/manage/
|
||||
|
||||
= 0.7.3 =
|
||||
|
||||
* refactorings
|
||||
* fixed PHP warnings
|
||||
* better hashtag regex
|
||||
|
||||
= 0.7.2 =
|
||||
|
||||
* fixed JSON representation of posts https://merveilles.town/@xuv/101907542498716956
|
||||
|
||||
= 0.7.1 =
|
||||
|
||||
* fixed inbox problems with pleroma
|
||||
|
||||
= 0.7.0 =
|
||||
|
||||
* finally fixed pleroma compatibility
|
||||
* added "following" endpoint
|
||||
* simplified "followers" endpoint
|
||||
* fixed default value problem
|
||||
|
||||
= 0.6.0 =
|
||||
|
||||
* add tags as hashtags to the end of each activity
|
||||
* fixed pleroma following issue
|
||||
* followers-list improvements
|
||||
|
||||
= 0.5.1 =
|
||||
|
||||
* fixed name-collision that caused an infinite loop
|
||||
|
||||
= 0.5.0 =
|
||||
|
||||
* complete refactoring
|
||||
* fixed bug #30: Password-protected posts are federated
|
||||
* only send Activites when ActivityPub is enabled for this post-type
|
||||
|
||||
= 0.4.4 =
|
||||
|
||||
* show avatars
|
||||
|
||||
= 0.4.3 =
|
||||
|
||||
* finally fixed backlink in excerpt/summary posts
|
||||
|
||||
= 0.4.2 =
|
||||
|
||||
* fixed backlink in excerpt/summary posts (thanks @depone)
|
||||
|
||||
= 0.4.1 =
|
||||
|
||||
* finally fixed contact list
|
||||
|
||||
= 0.4.0 =
|
||||
|
||||
* added settings to enable/disable hashtag support
|
||||
* fixed follower list
|
||||
* send activities only for new posts, otherwise send updates
|
||||
|
||||
= 0.3.2 =
|
||||
|
||||
* added "followers" endpoint
|
||||
* change activity content from blog 'excerpt' to blog 'content'
|
||||
|
||||
= 0.3.1 =
|
||||
|
||||
* better json encoding
|
||||
|
||||
= 0.3.0 =
|
||||
|
||||
* basic hashtag support
|
||||
* temporarily deactivated likes and boosts
|
||||
* added support for actor objects
|
||||
* fixed encoding issue
|
||||
|
||||
= 0.2.1 =
|
||||
|
||||
* customizable backlink (permalink or shorturl)
|
||||
* show profile-identifiers also on profile settings
|
||||
|
||||
= 0.2.0 =
|
||||
|
||||
* added option to switch between content and excerpt
|
||||
* removed html and duplicate new-lines
|
||||
|
||||
= 0.1.1 =
|
||||
|
||||
* fixed "excerpt" in AS JSON
|
||||
* added settings for the activity-summary and for the activity-object-type
|
||||
|
||||
= 0.1.0 =
|
||||
|
||||
* added basic WebFinger support
|
||||
* added basic NodeInfo support
|
||||
* fully functional "follow" activity
|
||||
* send new posts to your followers
|
||||
* receive comments from your followers
|
||||
|
||||
= 0.0.2 =
|
||||
|
||||
* refactoring
|
||||
* functional inbox
|
||||
* nicer profile views
|
||||
|
||||
= 0.0.1 =
|
||||
|
||||
* initial
|
||||
See full Changelog on [GitHub](https://github.com/Automattic/wordpress-activitypub/blob/master/CHANGELOG.md).
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
|
@ -73,10 +73,40 @@
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?php \esc_html_e( 'Activity-Object-Type', 'activitypub' ); ?>
|
||||
</th>
|
||||
<td>
|
||||
<p>
|
||||
<label for="activitypub_object_type_note">
|
||||
<input type="radio" name="activitypub_object_type" id="activitypub_object_type_note" value="note" <?php echo \checked( 'note', \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ) ); ?> />
|
||||
<?php \esc_html_e( 'Note (default)', 'activitypub' ); ?>
|
||||
-
|
||||
<span class="description">
|
||||
<?php \esc_html_e( 'Should work with most platforms.', 'activitypub' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<input type="radio" name="activitypub_object_type" id="activitypub_object_type" value="wordpress-post-format" <?php echo \checked( 'wordpress-post-format', \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ) ); ?> />
|
||||
<?php \esc_html_e( 'WordPress Post-Format', 'activitypub' ); ?>
|
||||
-
|
||||
<span class="description">
|
||||
<?php \esc_html_e( 'Maps the WordPress Post-Format to the ActivityPub Object Type.', 'activitypub' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>
|
||||
<tr <?php if ( 'wordpress-post-format' === \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ) ) { echo 'style="display: none"'; } ?>>
|
||||
<th scope="row">
|
||||
<?php \esc_html_e( 'Post content', 'activitypub' ); ?>
|
||||
</th>
|
||||
<td>
|
||||
<p><strong><?php \esc_html_e( 'These settings only apply if you use the "Note" Object-Type setting above.', 'activitypub' ); ?></strong></p>
|
||||
<p>
|
||||
<label for="activitypub_post_content_type_title_link">
|
||||
<input type="radio" name="activitypub_post_content_type" id="activitypub_post_content_type_title_link" value="title" <?php echo \checked( 'title', \get_option( 'activitypub_post_content_type', 'content' ) ); ?> />
|
||||
@ -163,44 +193,6 @@
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?php \esc_html_e( 'Activity-Object-Type', 'activitypub' ); ?>
|
||||
</th>
|
||||
<td>
|
||||
<p>
|
||||
<label for="activitypub_object_type_note">
|
||||
<input type="radio" name="activitypub_object_type" id="activitypub_object_type_note" value="note" <?php echo \checked( 'note', \get_option( 'activitypub_object_type', 'note' ) ); ?> />
|
||||
<?php \esc_html_e( 'Note (default)', 'activitypub' ); ?>
|
||||
-
|
||||
<span class="description">
|
||||
<?php \esc_html_e( 'Should work with most platforms.', 'activitypub' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</p>
|
||||
<p><strong><?php \esc_html_e( 'Please note that the following "Activity-Object-Type" options may cause your texts to be displayed differently on each platform and/or parts may be completely ignored. Mastodon, for example, displays all content that is not of the "Note" type as links only.', 'activitypub' ); ?></strong></p>
|
||||
<p>
|
||||
<label for="activitypub_object_type_article">
|
||||
<input type="radio" name="activitypub_object_type" id="activitypub_object_type_article" value="article" <?php echo \checked( 'article', \get_option( 'activitypub_object_type', 'note' ) ); ?> />
|
||||
<?php \esc_html_e( 'Article', 'activitypub' ); ?>
|
||||
-
|
||||
<span class="description">
|
||||
<?php \esc_html_e( 'The presentation of the "Article" might change on different platforms.', 'activitypub' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<input type="radio" name="activitypub_object_type" id="activitypub_object_type" value="wordpress-post-format" <?php echo \checked( 'wordpress-post-format', \get_option( 'activitypub_object_type', 'note' ) ); ?> />
|
||||
<?php \esc_html_e( 'WordPress Post-Format', 'activitypub' ); ?>
|
||||
-
|
||||
<span class="description">
|
||||
<?php \esc_html_e( 'Maps the WordPress Post-Format to the ActivityPub Object Type.', 'activitypub' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php \esc_html_e( 'Supported post types', 'activitypub' ); ?></th>
|
||||
<td>
|
||||
|
Loading…
Reference in New Issue
Block a user