diff --git a/wp-content/plugins/activitypub/.distignore b/wp-content/plugins/activitypub/.distignore index 871e8074..e864dd8d 100644 --- a/wp-content/plugins/activitypub/.distignore +++ b/wp-content/plugins/activitypub/.distignore @@ -14,6 +14,7 @@ LINGUAS Makefile README.md readme.md +CHANGELOG.md CODE_OF_CONDUCT.md FEDERATION.md SECURITY.md diff --git a/wp-content/plugins/activitypub/activitypub.php b/wp-content/plugins/activitypub/activitypub.php index 851d554c..791a59c4 100644 --- a/wp-content/plugins/activitypub/activitypub.php +++ b/wp-content/plugins/activitypub/activitypub.php @@ -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)|(?<=

)|(?<=
)|^)#([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', "[ap_title]\n\n[ap_content]\n\n[ap_hashtags]\n\n[ap_shortlink]" ); +\defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "

[ap_title]

\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']; diff --git a/wp-content/plugins/activitypub/build/follow-me/block.json b/wp-content/plugins/activitypub/build/follow-me/block.json index 8dcb824d..6e685671 100644 --- a/wp-content/plugins/activitypub/build/follow-me/block.json +++ b/wp-content/plugins/activitypub/build/follow-me/block.json @@ -41,7 +41,7 @@ "editorScript": "file:./index.js", "viewScript": "file:./view.js", "style": [ - "file:./style-index.css", + "file:./style-view.css", "wp-components" ] } \ No newline at end of file diff --git a/wp-content/plugins/activitypub/build/follow-me/index.asset.php b/wp-content/plugins/activitypub/build/follow-me/index.asset.php index ac15b343..80facf25 100644 --- a/wp-content/plugins/activitypub/build/follow-me/index.asset.php +++ b/wp-content/plugins/activitypub/build/follow-me/index.asset.php @@ -1 +1 @@ - array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'c7c2319cdfac52a18445'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '0708145714d72862bff0'); diff --git a/wp-content/plugins/activitypub/build/follow-me/index.js b/wp-content/plugins/activitypub/build/follow-me/index.js index d95484d4..12897d8b 100644 --- a/wp-content/plugins/activitypub/build/follow-me/index.js +++ b/wp-content/plugins/activitypub/build/follow-me/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,t={454:(e,t,n)=>{const o=window.wp.blocks,r=window.wp.element,l=window.wp.primitives,i=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.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"})),a=window.wp.blockEditor,c=window.wp.i18n,u=window.wp.components,s=window.wp.data,p=window._activityPubOptions?.enabled,v=window.wp.apiFetch;var m=n.n(v);const d=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(l.Path,{d:"M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"})),f=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(l.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),b=function({icon:e,size:t=24,...n}){return(0,r.cloneElement)(e,{width:t,height:t,...n})},w=window.wp.compose;function y(e){return`var(--wp--preset--color--${e})`}function _(e){if("string"!=typeof e)return null;if(e.match(/^#/))return e.substring(0,7);const[,,t]=e.split("|");return y(t)}function h(e,t,n=null,o=""){return n?`${e}${o} { ${t}: ${n}; }\n`:""}function g(e,t,n,o){return h(e,"background-color",t)+h(e,"color",n)+h(e,"background-color",o,":hover")+h(e,"background-color",o,":focus")}function E({selector:e,style:t,backgroundColor:n}){const o=function(e,t,n){const o=`${e} .components-button`,r=("string"==typeof(l=n)?y(l):l?.color?.background||null)||t?.color?.background;var l;return g(o,_(t?.elements?.link?.color?.text),r,_(t?.elements?.link?.[":hover"]?.color?.text))}(e,t,n);return(0,r.createElement)("style",null,o)}const{namespace:k}=window._activityPubOptions,x={avatar:"",webfinger:"@well@hello.dolly",name:(0,c.__)("Hello Dolly Fan Account","activitypub"),url:"#"};function C(e){if(!e)return x;const t={...x,...e};return t.avatar=t?.icon?.url,t}function O({profile:e,popupStyles:t,userId:n}){const{avatar:o,name:l,webfinger:i}=e;return(0,r.createElement)("div",{className:"activitypub-profile"},(0,r.createElement)("img",{className:"activitypub-profile__avatar",src:o,alt:l}),(0,r.createElement)("div",{className:"activitypub-profile__content"},(0,r.createElement)("div",{className:"activitypub-profile__name"},l),(0,r.createElement)("div",{className:"activitypub-profile__handle",title:i},i)),(0,r.createElement)(S,{profile:e,popupStyles:t,userId:n}))}function S({profile:e,popupStyles:t,userId:n}){const[o,l]=(0,r.useState)(!1),i=(0,c.sprintf)((0,c.__)("Follow %s","activitypub"),e?.name);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(u.Button,{className:"activitypub-profile__follow",onClick:()=>l(!0)},(0,c.__)("Follow","activitypub")),o&&(0,r.createElement)(u.Modal,{className:"activitypub-profile__confirm activitypub__modal",onRequestClose:()=>l(!1),title:i},(0,r.createElement)($,{profile:e,userId:n}),(0,r.createElement)("style",null,t)))}function N(e){try{return new URL(e),!0}catch(e){return!1}}function $({profile:e,userId:t}){const{webfinger:n}=e,o=(0,c.__)("Follow","activitypub"),l=(0,c.__)("Loading...","activitypub"),i=(0,c.__)("Opening...","activitypub"),a=(0,c.__)("Error","activitypub"),s=(0,c.__)("Invalid","activitypub"),[p,v]=(0,r.useState)(o),[y,_]=(0,r.useState)(d),h=(0,w.useCopyToClipboard)(n,(()=>{_(f),setTimeout((()=>_(d)),1e3)})),[g,E]=(0,r.useState)(""),x=(0,r.useCallback)((()=>{let e;if(!N(g)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&N(`https://${t[1]}`)}(g))return v(s),e=setTimeout((()=>v(o)),2e3),()=>clearTimeout(e);const n=`/${k}/users/${t}/remote-follow?resource=${g}`;v(l),m()({path:n}).then((({url:e})=>{v(i),setTimeout((()=>{window.open(e,"_blank"),v(o)}),200)})).catch((()=>{v(a),setTimeout((()=>v(o)),2e3)}))}),[g]);return(0,r.createElement)("div",{className:"activitypub__dialog"},(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,c.__)("My Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog-description"},(0,c.__)("Copy and paste my profile into the search field of your favorite fediverse app or server.","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:n,readOnly:!0}),(0,r.createElement)(u.Button,{ref:h},(0,r.createElement)(b,{icon:y}),(0,c.__)("Copy","activitypub")))),(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,c.__)("Your Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog__description"},(0,r.createInterpolateElement)((0,c.__)("Or, if you know your own profile, we can start things that way! (eg https://example.com/yourusername or yourusername@example.com)","activitypub"),{code:(0,r.createElement)("code",null)})),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:g,onKeyDown:e=>{"Enter"===e?.code&&x()},onChange:e=>E(e.target.value)}),(0,r.createElement)(u.Button,{onClick:x},p))))}function z({selectedUser:e,style:t,backgroundColor:n,id:o,useId:l=!1,profileData:i=!1}){const[a,c]=(0,r.useState)(C()),u="site"===e?0:e,s=function(e){return g(".apfmd__button-group .components-button",_(e?.elements?.link?.color?.text)||"#111","#fff",_(e?.elements?.link?.[":hover"]?.color?.text)||"#333")}(t),p=l?{id:o}:{};function v(e){c(C(e))}return(0,r.useEffect)((()=>{if(i)return v(i);(function(e){const t={headers:{Accept:"application/activity+json"},path:`/${k}/users/${e}`};return m()(t)})(u).then(v)}),[u,i]),(0,r.createElement)("div",{...p},(0,r.createElement)(E,{selector:`#${o}`,style:t,backgroundColor:n}),(0,r.createElement)(O,{profile:a,userId:u,popupStyles:s}))}(0,o.registerBlockType)("activitypub/follow-me",{edit:function({attributes:e,setAttributes:t}){const n=(0,a.useBlockProps)({className:"activitypub-follow-me-block-wrapper"}),o=function(){const e=p?.users?(0,s.useSelect)((e=>e("core").getUsers({who:"authors"}))):[];return(0,r.useMemo)((()=>{if(!e)return[];const t=p?.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])}(),{selectedUser:l}=e;return(0,r.useEffect)((()=>{o.length&&(o.find((({value:e})=>e===l))||t({selectedUser:o[0].value}))}),[l,o]),(0,r.createElement)("div",{...n},o.length>1&&(0,r.createElement)(a.InspectorControls,{key:"setting"},(0,r.createElement)(u.PanelBody,{title:(0,c.__)("Followers Options","activitypub")},(0,r.createElement)(u.SelectControl,{label:(0,c.__)("Select User","activitypub"),value:e.selectedUser,options:o,onChange:e=>t({selectedUser:e})}))),(0,r.createElement)(z,{...e,id:n.id}))},save:()=>null,icon:i})}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var l=n[e]={exports:{}};return t[e](l,l.exports,o),l.exports}o.m=t,e=[],o.O=(t,n,r,l)=>{if(!n){var i=1/0;for(s=0;s=l)&&Object.keys(o.O).every((e=>o.O[e](n[c])))?n.splice(c--,1):(a=!1,l0&&e[s-1][2]>l;s--)e[s]=e[s-1];e[s]=[n,r,l]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={127:0,740:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var r,l,i=n[0],a=n[1],c=n[2],u=0;if(i.some((t=>0!==e[t]))){for(r in a)o.o(a,r)&&(o.m[r]=a[r]);if(c)var s=c(o)}for(t&&t(n);uo(454)));r=o.O(r)})(); \ No newline at end of file +(()=>{"use strict";var e,t={647:(e,t,n)=>{const o=window.wp.blocks,r=window.React,l=window.wp.primitives,a=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.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"})),i=window.wp.blockEditor,c=window.wp.i18n,u=window.wp.components,s=window.wp.data,p=window.wp.element,d=window._activityPubOptions?.enabled,v=window.wp.apiFetch;var m=n.n(v);function f(e){return`var(--wp--preset--color--${e})`}function w(e){if("string"!=typeof e)return null;if(e.match(/^#/))return e.substring(0,7);const[,,t]=e.split("|");return f(t)}function b(e,t,n=null,o=""){return n?`${e}${o} { ${t}: ${n}; }\n`:""}function y(e,t,n,o){return b(e,"background-color",t)+b(e,"color",n)+b(e,"background-color",o,":hover")+b(e,"background-color",o,":focus")}function _({selector:e,style:t,backgroundColor:n}){const o=function(e,t,n){const o=`${e} .components-button`,r=("string"==typeof(l=n)?f(l):l?.color?.background||null)||t?.color?.background;var l;return y(o,w(t?.elements?.link?.color?.text),r,w(t?.elements?.link?.[":hover"]?.color?.text))}(e,t,n);return(0,r.createElement)("style",null,o)}const h=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(l.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z"})),g=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(l.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),E=(0,p.forwardRef)((function({icon:e,size:t=24,...n},o){return(0,p.cloneElement)(e,{width:t,height:t,...n,ref:o})})),k=window.wp.compose;function x(e){try{return new URL(e),!0}catch(e){return!1}}function C({actionText:e,copyDescription:t,handle:n,resourceUrl:o}){const l=(0,c.__)("Loading...","activitypub"),a=(0,c.__)("Opening...","activitypub"),i=(0,c.__)("Error","activitypub"),s=(0,c.__)("Invalid","activitypub"),[d,v]=(0,p.useState)(e),[f,w]=(0,p.useState)(h),b=(0,k.useCopyToClipboard)(n,(()=>{w(g),setTimeout((()=>w(h)),1e3)})),[y,_]=(0,p.useState)(""),C=(0,p.useCallback)((()=>{let t;if(!x(y)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&x(`https://${t[1]}`)}(y))return v(s),t=setTimeout((()=>v(e)),2e3),()=>clearTimeout(t);const n=o+y;v(l),m()({path:n}).then((({url:t})=>{v(a),setTimeout((()=>{window.open(t,"_blank"),v(e)}),200)})).catch((()=>{v(i),setTimeout((()=>v(e)),2e3)}))}),[y]);return(0,r.createElement)("div",{className:"activitypub__dialog"},(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,c.__)("My Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog-description"},t),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:n,readOnly:!0}),(0,r.createElement)(u.Button,{ref:b},(0,r.createElement)(E,{icon:f}),(0,c.__)("Copy","activitypub")))),(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,c.__)("Your Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog__description"},(0,p.createInterpolateElement)((0,c.__)("Or, if you know your own profile, we can start things that way! (eg https://example.com/yourusername or yourusername@example.com)","activitypub"),{code:(0,r.createElement)("code",null)})),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:y,onKeyDown:e=>{"Enter"===e?.code&&C()},onChange:e=>_(e.target.value)}),(0,r.createElement)(u.Button,{onClick:C},d))))}const{namespace:O}=window._activityPubOptions,S={avatar:"",webfinger:"@well@hello.dolly",name:(0,c.__)("Hello Dolly Fan Account","activitypub"),url:"#"};function N(e){if(!e)return S;const t={...S,...e};return t.avatar=t?.icon?.url,t}function $({profile:e,popupStyles:t,userId:n}){const{avatar:o,name:l,webfinger:a}=e;return(0,r.createElement)("div",{className:"activitypub-profile"},(0,r.createElement)("img",{className:"activitypub-profile__avatar",src:o,alt:l}),(0,r.createElement)("div",{className:"activitypub-profile__content"},(0,r.createElement)("div",{className:"activitypub-profile__name"},l),(0,r.createElement)("div",{className:"activitypub-profile__handle",title:a},a)),(0,r.createElement)(P,{profile:e,popupStyles:t,userId:n}))}function P({profile:e,popupStyles:t,userId:n}){const[o,l]=(0,p.useState)(!1),a=(0,c.sprintf)((0,c.__)("Follow %s","activitypub"),e?.name);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(u.Button,{className:"activitypub-profile__follow",onClick:()=>l(!0)},(0,c.__)("Follow","activitypub")),o&&(0,r.createElement)(u.Modal,{className:"activitypub-profile__confirm activitypub__modal",onRequestClose:()=>l(!1),title:a},(0,r.createElement)(T,{profile:e,userId:n}),(0,r.createElement)("style",null,t)))}function T({profile:e,userId:t}){const{webfinger:n}=e,o=(0,c.__)("Follow","activitypub"),l=`/${O}/users/${t}/remote-follow?resource=`,a=(0,c.__)("Copy and paste my profile into the search field of your favorite fediverse app or server.","activitypub");return(0,r.createElement)(C,{actionText:o,copyDescription:a,handle:n,resourceUrl:l})}function I({selectedUser:e,style:t,backgroundColor:n,id:o,useId:l=!1,profileData:a=!1}){const[i,c]=(0,p.useState)(N()),u="site"===e?0:e,s=function(e){return y(".apfmd__button-group .components-button",w(e?.elements?.link?.color?.text)||"#111","#fff",w(e?.elements?.link?.[":hover"]?.color?.text)||"#333")}(t),d=l?{id:o}:{};function v(e){c(N(e))}return(0,p.useEffect)((()=>{if(a)return v(a);(function(e){const t={headers:{Accept:"application/activity+json"},path:`/${O}/users/${e}`};return m()(t)})(u).then(v)}),[u,a]),(0,r.createElement)("div",{...d},(0,r.createElement)(_,{selector:`#${o}`,style:t,backgroundColor:n}),(0,r.createElement)($,{profile:i,userId:u,popupStyles:s}))}(0,o.registerBlockType)("activitypub/follow-me",{edit:function({attributes:e,setAttributes:t}){const n=(0,i.useBlockProps)({className:"activitypub-follow-me-block-wrapper"}),o=function(){const e=d?.users?(0,s.useSelect)((e=>e("core").getUsers({who:"authors"}))):[];return(0,p.useMemo)((()=>{if(!e)return[];const t=d?.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])}(),{selectedUser:l}=e;return(0,p.useEffect)((()=>{o.length&&(o.find((({value:e})=>e===l))||t({selectedUser:o[0].value}))}),[l,o]),(0,r.createElement)("div",{...n},o.length>1&&(0,r.createElement)(i.InspectorControls,{key:"setting"},(0,r.createElement)(u.PanelBody,{title:(0,c.__)("Followers Options","activitypub")},(0,r.createElement)(u.SelectControl,{label:(0,c.__)("Select User","activitypub"),value:e.selectedUser,options:o,onChange:e=>t({selectedUser:e})}))),(0,r.createElement)(I,{...e,id:n.id}))},save:()=>null,icon:a})}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var l=n[e]={exports:{}};return t[e](l,l.exports,o),l.exports}o.m=t,e=[],o.O=(t,n,r,l)=>{if(!n){var a=1/0;for(s=0;s=l)&&Object.keys(o.O).every((e=>o.O[e](n[c])))?n.splice(c--,1):(i=!1,l0&&e[s-1][2]>l;s--)e[s]=e[s-1];e[s]=[n,r,l]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={338:0,301:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var r,l,[a,i,c]=n,u=0;if(a.some((t=>0!==e[t]))){for(r in i)o.o(i,r)&&(o.m[r]=i[r]);if(c)var s=c(o)}for(t&&t(n);uo(647)));r=o.O(r)})(); \ No newline at end of file diff --git a/wp-content/plugins/activitypub/build/follow-me/style-index.css b/wp-content/plugins/activitypub/build/follow-me/style-index.css deleted file mode 100644 index 859950ec..00000000 --- a/wp-content/plugins/activitypub/build/follow-me/style-index.css +++ /dev/null @@ -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} diff --git a/wp-content/plugins/activitypub/build/follow-me/style-view.css b/wp-content/plugins/activitypub/build/follow-me/style-view.css new file mode 100644 index 00000000..f614aaea --- /dev/null +++ b/wp-content/plugins/activitypub/build/follow-me/style-view.css @@ -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} diff --git a/wp-content/plugins/activitypub/build/follow-me/view.asset.php b/wp-content/plugins/activitypub/build/follow-me/view.asset.php index 15d9b4ca..e02268e8 100644 --- a/wp-content/plugins/activitypub/build/follow-me/view.asset.php +++ b/wp-content/plugins/activitypub/build/follow-me/view.asset.php @@ -1 +1 @@ - array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '1349fc90a3f33dde3595'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'cbc379fca374f5f88e22'); diff --git a/wp-content/plugins/activitypub/build/follow-me/view.js b/wp-content/plugins/activitypub/build/follow-me/view.js index a59d6bc4..3ebc7eab 100644 --- a/wp-content/plugins/activitypub/build/follow-me/view.js +++ b/wp-content/plugins/activitypub/build/follow-me/view.js @@ -1 +1 @@ -(()=>{"use strict";var e,t={703:(e,t,r)=>{const o=window.wp.element,n=window.wp.domReady;var a=r.n(n);const i=window.wp.apiFetch;var l=r.n(i);const c=window.wp.components,u=window.wp.i18n,s=window.wp.primitives,p=(0,o.createElement)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(s.Path,{d:"M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"})),m=(0,o.createElement)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(s.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),d=function({icon:e,size:t=24,...r}){return(0,o.cloneElement)(e,{width:t,height:t,...r})},v=window.wp.compose;function f(e){return`var(--wp--preset--color--${e})`}function y(e){if("string"!=typeof e)return null;if(e.match(/^#/))return e.substring(0,7);const[,,t]=e.split("|");return f(t)}function b(e,t,r=null,o=""){return r?`${e}${o} { ${t}: ${r}; }\n`:""}function w(e,t,r,o){return b(e,"background-color",t)+b(e,"color",r)+b(e,"background-color",o,":hover")+b(e,"background-color",o,":focus")}function _({selector:e,style:t,backgroundColor:r}){const n=function(e,t,r){const o=`${e} .components-button`,n=("string"==typeof(a=r)?f(a):a?.color?.background||null)||t?.color?.background;var a;return w(o,y(t?.elements?.link?.color?.text),n,y(t?.elements?.link?.[":hover"]?.color?.text))}(e,t,r);return(0,o.createElement)("style",null,n)}const{namespace:h}=window._activityPubOptions,g={avatar:"",webfinger:"@well@hello.dolly",name:(0,u.__)("Hello Dolly Fan Account","activitypub"),url:"#"};function E(e){if(!e)return g;const t={...g,...e};return t.avatar=t?.icon?.url,t}function k({profile:e,popupStyles:t,userId:r}){const{avatar:n,name:a,webfinger:i}=e;return(0,o.createElement)("div",{className:"activitypub-profile"},(0,o.createElement)("img",{className:"activitypub-profile__avatar",src:n,alt:a}),(0,o.createElement)("div",{className:"activitypub-profile__content"},(0,o.createElement)("div",{className:"activitypub-profile__name"},a),(0,o.createElement)("div",{className:"activitypub-profile__handle",title:i},i)),(0,o.createElement)(x,{profile:e,popupStyles:t,userId:r}))}function x({profile:e,popupStyles:t,userId:r}){const[n,a]=(0,o.useState)(!1),i=(0,u.sprintf)((0,u.__)("Follow %s","activitypub"),e?.name);return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.Button,{className:"activitypub-profile__follow",onClick:()=>a(!0)},(0,u.__)("Follow","activitypub")),n&&(0,o.createElement)(c.Modal,{className:"activitypub-profile__confirm activitypub__modal",onRequestClose:()=>a(!1),title:i},(0,o.createElement)(C,{profile:e,userId:r}),(0,o.createElement)("style",null,t)))}function O(e){try{return new URL(e),!0}catch(e){return!1}}function C({profile:e,userId:t}){const{webfinger:r}=e,n=(0,u.__)("Follow","activitypub"),a=(0,u.__)("Loading...","activitypub"),i=(0,u.__)("Opening...","activitypub"),s=(0,u.__)("Error","activitypub"),f=(0,u.__)("Invalid","activitypub"),[y,b]=(0,o.useState)(n),[w,_]=(0,o.useState)(p),g=(0,v.useCopyToClipboard)(r,(()=>{_(m),setTimeout((()=>_(p)),1e3)})),[E,k]=(0,o.useState)(""),x=(0,o.useCallback)((()=>{let e;if(!O(E)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&O(`https://${t[1]}`)}(E))return b(f),e=setTimeout((()=>b(n)),2e3),()=>clearTimeout(e);const r=`/${h}/users/${t}/remote-follow?resource=${E}`;b(a),l()({path:r}).then((({url:e})=>{b(i),setTimeout((()=>{window.open(e,"_blank"),b(n)}),200)})).catch((()=>{b(s),setTimeout((()=>b(n)),2e3)}))}),[E]);return(0,o.createElement)("div",{className:"activitypub__dialog"},(0,o.createElement)("div",{className:"activitypub-dialog__section"},(0,o.createElement)("h4",null,(0,u.__)("My Profile","activitypub")),(0,o.createElement)("div",{className:"activitypub-dialog-description"},(0,u.__)("Copy and paste my profile into the search field of your favorite fediverse app or server.","activitypub")),(0,o.createElement)("div",{className:"activitypub-dialog__button-group"},(0,o.createElement)("input",{type:"text",value:r,readOnly:!0}),(0,o.createElement)(c.Button,{ref:g},(0,o.createElement)(d,{icon:w}),(0,u.__)("Copy","activitypub")))),(0,o.createElement)("div",{className:"activitypub-dialog__section"},(0,o.createElement)("h4",null,(0,u.__)("Your Profile","activitypub")),(0,o.createElement)("div",{className:"activitypub-dialog__description"},(0,o.createInterpolateElement)((0,u.__)("Or, if you know your own profile, we can start things that way! (eg https://example.com/yourusername or yourusername@example.com)","activitypub"),{code:(0,o.createElement)("code",null)})),(0,o.createElement)("div",{className:"activitypub-dialog__button-group"},(0,o.createElement)("input",{type:"text",value:E,onKeyDown:e=>{"Enter"===e?.code&&x()},onChange:e=>k(e.target.value)}),(0,o.createElement)(c.Button,{onClick:x},y))))}function N({selectedUser:e,style:t,backgroundColor:r,id:n,useId:a=!1,profileData:i=!1}){const[c,u]=(0,o.useState)(E()),s="site"===e?0:e,p=function(e){return w(".apfmd__button-group .components-button",y(e?.elements?.link?.color?.text)||"#111","#fff",y(e?.elements?.link?.[":hover"]?.color?.text)||"#333")}(t),m=a?{id:n}:{};function d(e){u(E(e))}return(0,o.useEffect)((()=>{if(i)return d(i);(function(e){const t={headers:{Accept:"application/activity+json"},path:`/${h}/users/${e}`};return l()(t)})(s).then(d)}),[s,i]),(0,o.createElement)("div",{...m},(0,o.createElement)(_,{selector:`#${n}`,style:t,backgroundColor:r}),(0,o.createElement)(k,{profile:c,userId:s,popupStyles:p}))}let S=1;a()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-follow-me-block-wrapper"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,o.render)((0,o.createElement)(N,{...t,id:"activitypub-follow-me-block-"+S++,useId:!0}),e)}))}))}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,o),a.exports}o.m=t,e=[],o.O=(t,r,n,a)=>{if(!r){var i=1/0;for(s=0;s=a)&&Object.keys(o.O).every((e=>o.O[e](r[c])))?r.splice(c--,1):(l=!1,a0&&e[s-1][2]>a;s--)e[s]=e[s-1];e[s]=[r,n,a]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={529:0,740:0};o.O.j=t=>0===e[t];var t=(t,r)=>{var n,a,i=r[0],l=r[1],c=r[2],u=0;if(i.some((t=>0!==e[t]))){for(n in l)o.o(l,n)&&(o.m[n]=l[n]);if(c)var s=c(o)}for(t&&t(r);uo(703)));n=o.O(n)})(); \ No newline at end of file +(()=>{"use strict";var e,t={421:(e,t,o)=>{const r=window.React,n=window.wp.element,a=window.wp.domReady;var i=o.n(a);const l=window.wp.apiFetch;var c=o.n(l);const u=window.wp.components,s=window.wp.i18n;function p(e){return`var(--wp--preset--color--${e})`}function d(e){if("string"!=typeof e)return null;if(e.match(/^#/))return e.substring(0,7);const[,,t]=e.split("|");return p(t)}function m(e,t,o=null,r=""){return o?`${e}${r} { ${t}: ${o}; }\n`:""}function v(e,t,o,r){return m(e,"background-color",t)+m(e,"color",o)+m(e,"background-color",r,":hover")+m(e,"background-color",r,":focus")}function f({selector:e,style:t,backgroundColor:o}){const n=function(e,t,o){const r=`${e} .components-button`,n=("string"==typeof(a=o)?p(a):a?.color?.background||null)||t?.color?.background;var a;return v(r,d(t?.elements?.link?.color?.text),n,d(t?.elements?.link?.[":hover"]?.color?.text))}(e,t,o);return(0,r.createElement)("style",null,n)}const y=window.wp.primitives,b=(0,r.createElement)(y.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(y.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z"})),w=(0,r.createElement)(y.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(y.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),_=(0,n.forwardRef)((function({icon:e,size:t=24,...o},r){return(0,n.cloneElement)(e,{width:t,height:t,...o,ref:r})})),h=window.wp.compose;function g(e){try{return new URL(e),!0}catch(e){return!1}}function E({actionText:e,copyDescription:t,handle:o,resourceUrl:a}){const i=(0,s.__)("Loading...","activitypub"),l=(0,s.__)("Opening...","activitypub"),p=(0,s.__)("Error","activitypub"),d=(0,s.__)("Invalid","activitypub"),[m,v]=(0,n.useState)(e),[f,y]=(0,n.useState)(b),E=(0,h.useCopyToClipboard)(o,(()=>{y(w),setTimeout((()=>y(b)),1e3)})),[k,x]=(0,n.useState)(""),O=(0,n.useCallback)((()=>{let t;if(!g(k)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&g(`https://${t[1]}`)}(k))return v(d),t=setTimeout((()=>v(e)),2e3),()=>clearTimeout(t);const o=a+k;v(i),c()({path:o}).then((({url:t})=>{v(l),setTimeout((()=>{window.open(t,"_blank"),v(e)}),200)})).catch((()=>{v(p),setTimeout((()=>v(e)),2e3)}))}),[k]);return(0,r.createElement)("div",{className:"activitypub__dialog"},(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,s.__)("My Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog-description"},t),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:o,readOnly:!0}),(0,r.createElement)(u.Button,{ref:E},(0,r.createElement)(_,{icon:f}),(0,s.__)("Copy","activitypub")))),(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,s.__)("Your Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog__description"},(0,n.createInterpolateElement)((0,s.__)("Or, if you know your own profile, we can start things that way! (eg https://example.com/yourusername or yourusername@example.com)","activitypub"),{code:(0,r.createElement)("code",null)})),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:k,onKeyDown:e=>{"Enter"===e?.code&&O()},onChange:e=>x(e.target.value)}),(0,r.createElement)(u.Button,{onClick:O},m))))}const{namespace:k}=window._activityPubOptions,x={avatar:"",webfinger:"@well@hello.dolly",name:(0,s.__)("Hello Dolly Fan Account","activitypub"),url:"#"};function O(e){if(!e)return x;const t={...x,...e};return t.avatar=t?.icon?.url,t}function N({profile:e,popupStyles:t,userId:o}){const{avatar:n,name:a,webfinger:i}=e;return(0,r.createElement)("div",{className:"activitypub-profile"},(0,r.createElement)("img",{className:"activitypub-profile__avatar",src:n,alt:a}),(0,r.createElement)("div",{className:"activitypub-profile__content"},(0,r.createElement)("div",{className:"activitypub-profile__name"},a),(0,r.createElement)("div",{className:"activitypub-profile__handle",title:i},i)),(0,r.createElement)(C,{profile:e,popupStyles:t,userId:o}))}function C({profile:e,popupStyles:t,userId:o}){const[a,i]=(0,n.useState)(!1),l=(0,s.sprintf)((0,s.__)("Follow %s","activitypub"),e?.name);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(u.Button,{className:"activitypub-profile__follow",onClick:()=>i(!0)},(0,s.__)("Follow","activitypub")),a&&(0,r.createElement)(u.Modal,{className:"activitypub-profile__confirm activitypub__modal",onRequestClose:()=>i(!1),title:l},(0,r.createElement)(S,{profile:e,userId:o}),(0,r.createElement)("style",null,t)))}function S({profile:e,userId:t}){const{webfinger:o}=e,n=(0,s.__)("Follow","activitypub"),a=`/${k}/users/${t}/remote-follow?resource=`,i=(0,s.__)("Copy and paste my profile into the search field of your favorite fediverse app or server.","activitypub");return(0,r.createElement)(E,{actionText:n,copyDescription:i,handle:o,resourceUrl:a})}function $({selectedUser:e,style:t,backgroundColor:o,id:a,useId:i=!1,profileData:l=!1}){const[u,s]=(0,n.useState)(O()),p="site"===e?0:e,m=function(e){return v(".apfmd__button-group .components-button",d(e?.elements?.link?.color?.text)||"#111","#fff",d(e?.elements?.link?.[":hover"]?.color?.text)||"#333")}(t),y=i?{id:a}:{};function b(e){s(O(e))}return(0,n.useEffect)((()=>{if(l)return b(l);(function(e){const t={headers:{Accept:"application/activity+json"},path:`/${k}/users/${e}`};return c()(t)})(p).then(b)}),[p,l]),(0,r.createElement)("div",{...y},(0,r.createElement)(f,{selector:`#${a}`,style:t,backgroundColor:o}),(0,r.createElement)(N,{profile:u,userId:p,popupStyles:m}))}let I=1;i()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-follow-me-block-wrapper"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,n.render)((0,r.createElement)($,{...t,id:"activitypub-follow-me-block-"+I++,useId:!0}),e)}))}))}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.m=t,e=[],r.O=(t,o,n,a)=>{if(!o){var i=1/0;for(s=0;s=a)&&Object.keys(r.O).every((e=>r.O[e](o[c])))?o.splice(c--,1):(l=!1,a0&&e[s-1][2]>a;s--)e[s]=e[s-1];e[s]=[o,n,a]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={41:0,301:0};r.O.j=t=>0===e[t];var t=(t,o)=>{var n,a,[i,l,c]=o,u=0;if(i.some((t=>0!==e[t]))){for(n in l)r.o(l,n)&&(r.m[n]=l[n]);if(c)var s=c(r)}for(t&&t(o);ur(421)));n=r.O(n)})(); \ No newline at end of file diff --git a/wp-content/plugins/activitypub/build/followers/index.asset.php b/wp-content/plugins/activitypub/build/followers/index.asset.php index a6b5db01..b9383244 100644 --- a/wp-content/plugins/activitypub/build/followers/index.asset.php +++ b/wp-content/plugins/activitypub/build/followers/index.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'c338a0364a63e21934ae'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '536d43b3eaab93a5c9ef'); diff --git a/wp-content/plugins/activitypub/build/followers/index.js b/wp-content/plugins/activitypub/build/followers/index.js index 4871225b..f10e58ff 100644 --- a/wp-content/plugins/activitypub/build/followers/index.js +++ b/wp-content/plugins/activitypub/build/followers/index.js @@ -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{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.__)(" 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 ","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})})()})(); \ No newline at end of file +(()=>{var e={942:(e,t)=>{var a;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e="",t=0;t{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.__)(" 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 ","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})})()})(); \ No newline at end of file diff --git a/wp-content/plugins/activitypub/build/followers/view.asset.php b/wp-content/plugins/activitypub/build/followers/view.asset.php index 47972bbf..c11c39ca 100644 --- a/wp-content/plugins/activitypub/build/followers/view.asset.php +++ b/wp-content/plugins/activitypub/build/followers/view.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'ed5a13e66f8b10323435'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '23bc54443801976420cd'); diff --git a/wp-content/plugins/activitypub/build/followers/view.js b/wp-content/plugins/activitypub/build/followers/view.js index 6c42c39f..97227046 100644 --- a/wp-content/plugins/activitypub/build/followers/view.js +++ b/wp-content/plugins/activitypub/build/followers/view.js @@ -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.__)(" 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 ","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{if(!a){var i=1/0;for(p=0;p=l)&&Object.keys(r.O).every((e=>r.O[e](a[c])))?a.splice(c--,1):(o=!1,l0&&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);sr(142)));n=r.O(n)})(); \ No newline at end of file +(()=>{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.__)(" 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 ","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{if(!a){var o=1/0;for(p=0;p=l)&&Object.keys(r.O).every((e=>r.O[e](a[c])))?a.splice(c--,1):(i=!1,l0&&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);sr(250)));n=r.O(n)})(); \ No newline at end of file diff --git a/wp-content/plugins/activitypub/build/remote-reply/index.asset.php b/wp-content/plugins/activitypub/build/remote-reply/index.asset.php index 0e5d8d1a..31d03481 100644 --- a/wp-content/plugins/activitypub/build/remote-reply/index.asset.php +++ b/wp-content/plugins/activitypub/build/remote-reply/index.asset.php @@ -1 +1 @@ - array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '0235743f089d22122d70'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '9aee45886ecf2680fbd4'); diff --git a/wp-content/plugins/activitypub/build/remote-reply/index.js b/wp-content/plugins/activitypub/build/remote-reply/index.js index fa6d0e65..5373b0fa 100644 --- a/wp-content/plugins/activitypub/build/remote-reply/index.js +++ b/wp-content/plugins/activitypub/build/remote-reply/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,t={664:(e,t,n)=>{const o=window.wp.element,a=window.wp.domReady;var i=n.n(a);const r=window.wp.apiFetch;var c=n.n(r);const l=window.wp.components,u=window.wp.i18n,s=window.wp.primitives,p=(0,o.createElement)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(s.Path,{d:"M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"})),m=(0,o.createElement)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(s.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),d=function({icon:e,size:t=24,...n}){return(0,o.cloneElement)(e,{width:t,height:t,...n})},v=window.wp.compose,{namespace:y}=window._activityPubOptions;function _(e){try{return new URL(e),!0}catch(e){return!1}}function w({selectedComment:e,commentId:t}){const n=(0,u.__)("Reply","activitypub"),a=(0,u.__)("Loading...","activitypub"),i=(0,u.__)("Opening...","activitypub"),r=(0,u.__)("Error","activitypub"),s=(0,u.__)("Invalid","activitypub"),[w,b]=(0,o.useState)(n),[h,f]=(0,o.useState)(p),E=(0,v.useCopyToClipboard)(e,(()=>{f(m),setTimeout((()=>f(p)),1e3)})),[g,C]=(0,o.useState)(""),O=(0,o.useCallback)((()=>{let e;if(!_(g)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&_(`https://${t[1]}`)}(g))return b(s),e=setTimeout((()=>b(n)),2e3),()=>clearTimeout(e);const o=`/${y}/comments/${t}/remote-reply?resource=${g}`;b(a),c()({path:o}).then((({url:e})=>{b(i),setTimeout((()=>{window.open(e,"_blank"),b(n)}),200)})).catch((()=>{b(r),setTimeout((()=>b(n)),2e3)}))}),[g]);return(0,o.createElement)("div",{className:"activitypub__dialog"},(0,o.createElement)("div",{className:"activitypub-dialog__section"},(0,o.createElement)("h4",null,(0,u.__)("The Comment-URL","activitypub")),(0,o.createElement)("div",{className:"activitypub-dialog__description"},(0,u.__)("Copy and paste the Comment-URL into the search field of your favorite fediverse app or server to reply to this Comment.","activitypub")),(0,o.createElement)("div",{className:"activitypub-dialog__button-group"},(0,o.createElement)("input",{type:"text",value:e,readOnly:!0}),(0,o.createElement)(l.Button,{ref:E},(0,o.createElement)(d,{icon:h}),(0,u.__)("Copy","activitypub")))),(0,o.createElement)("div",{className:"activitypub-dialog__section"},(0,o.createElement)("h4",null,(0,u.__)("Your Profile","activitypub")),(0,o.createElement)("div",{className:"activitypub-dialog__description"},(0,o.createInterpolateElement)((0,u.__)("Or, if you know your own profile, we can start things that way! (eg https://example.com/yourusername or yourusername@example.com)","activitypub"),{code:(0,o.createElement)("code",null)})),(0,o.createElement)("div",{className:"activitypub-dialog__button-group"},(0,o.createElement)("input",{type:"text",value:g,onKeyDown:e=>{"Enter"===e?.code&&O()},onChange:e=>C(e.target.value)}),(0,o.createElement)(l.Button,{onClick:O},w))))}function b({selectedComment:e,commentId:t}){const[n,a]=(0,o.useState)(!1),i=(0,u.__)("Remote Reply","activitypub");return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(l.Button,{isLink:!0,className:"comment-reply-link activitypub-remote-reply__button",onClick:()=>a(!0)},(0,u.__)("Reply on the Fediverse","activitypub")),n&&(0,o.createElement)(l.Modal,{className:"activitypub-remote-reply__modal activitypub__modal",onRequestClose:()=>a(!1),title:i},(0,o.createElement)(w,{selectedComment:e,commentId:t})))}let h=1;i()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-remote-reply"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,o.createRoot)(e).render((0,o.createElement)(b,{...t,id:"activitypub-remote-reply-link-"+h++,useId:!0}))}))}))}},n={};function o(e){var a=n[e];if(void 0!==a)return a.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.m=t,e=[],o.O=(t,n,a,i)=>{if(!n){var r=1/0;for(s=0;s=i)&&Object.keys(o.O).every((e=>o.O[e](n[l])))?n.splice(l--,1):(c=!1,i0&&e[s-1][2]>i;s--)e[s]=e[s-1];e[s]=[n,a,i]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={805:0,881:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var a,i,r=n[0],c=n[1],l=n[2],u=0;if(r.some((t=>0!==e[t]))){for(a in c)o.o(c,a)&&(o.m[a]=c[a]);if(l)var s=l(o)}for(t&&t(n);uo(664)));a=o.O(a)})(); \ No newline at end of file +(()=>{"use strict";var e,t={202:(e,t,a)=>{const n=window.React,o=window.wp.element,r=window.wp.domReady;var i=a.n(r);const c=window.wp.components,l=window.wp.i18n,u=window.wp.apiFetch;var s=a.n(u);const p=window.wp.primitives,m=(0,n.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z"})),d=(0,n.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),v=(0,o.forwardRef)((function({icon:e,size:t=24,...a},n){return(0,o.cloneElement)(e,{width:t,height:t,...a,ref:n})})),y=window.wp.compose;function w(e){try{return new URL(e),!0}catch(e){return!1}}function _({actionText:e,copyDescription:t,handle:a,resourceUrl:r}){const i=(0,l.__)("Loading...","activitypub"),u=(0,l.__)("Opening...","activitypub"),p=(0,l.__)("Error","activitypub"),_=(0,l.__)("Invalid","activitypub"),[b,h]=(0,o.useState)(e),[f,E]=(0,o.useState)(m),g=(0,y.useCopyToClipboard)(a,(()=>{E(d),setTimeout((()=>E(m)),1e3)})),[O,C]=(0,o.useState)(""),x=(0,o.useCallback)((()=>{let t;if(!w(O)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&w(`https://${t[1]}`)}(O))return h(_),t=setTimeout((()=>h(e)),2e3),()=>clearTimeout(t);const a=r+O;h(i),s()({path:a}).then((({url:t})=>{h(u),setTimeout((()=>{window.open(t,"_blank"),h(e)}),200)})).catch((()=>{h(p),setTimeout((()=>h(e)),2e3)}))}),[O]);return(0,n.createElement)("div",{className:"activitypub__dialog"},(0,n.createElement)("div",{className:"activitypub-dialog__section"},(0,n.createElement)("h4",null,(0,l.__)("My Profile","activitypub")),(0,n.createElement)("div",{className:"activitypub-dialog-description"},t),(0,n.createElement)("div",{className:"activitypub-dialog__button-group"},(0,n.createElement)("input",{type:"text",value:a,readOnly:!0}),(0,n.createElement)(c.Button,{ref:g},(0,n.createElement)(v,{icon:f}),(0,l.__)("Copy","activitypub")))),(0,n.createElement)("div",{className:"activitypub-dialog__section"},(0,n.createElement)("h4",null,(0,l.__)("Your Profile","activitypub")),(0,n.createElement)("div",{className:"activitypub-dialog__description"},(0,o.createInterpolateElement)((0,l.__)("Or, if you know your own profile, we can start things that way! (eg https://example.com/yourusername or yourusername@example.com)","activitypub"),{code:(0,n.createElement)("code",null)})),(0,n.createElement)("div",{className:"activitypub-dialog__button-group"},(0,n.createElement)("input",{type:"text",value:O,onKeyDown:e=>{"Enter"===e?.code&&x()},onChange:e=>C(e.target.value)}),(0,n.createElement)(c.Button,{onClick:x},b))))}const{namespace:b}=window._activityPubOptions;function h({selectedComment:e,commentId:t}){const a=(0,l.__)("Reply","activitypub"),o=`/${b}/comments/${t}/remote-reply?resource=`,r=(0,l.__)("Copy and paste the Comment URL into the search field of your favorite fediverse app or server.","activitypub");return(0,n.createElement)(_,{actionText:a,copyDescription:r,handle:e,resourceUrl:o})}function f({selectedComment:e,commentId:t}){const[a,r]=(0,o.useState)(!1),i=(0,l.__)("Remote Reply","activitypub");return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(c.Button,{isLink:!0,className:"comment-reply-link activitypub-remote-reply__button",onClick:()=>r(!0)},(0,l.__)("Reply on the Fediverse","activitypub")),a&&(0,n.createElement)(c.Modal,{className:"activitypub-remote-reply__modal activitypub__modal",onRequestClose:()=>r(!1),title:i},(0,n.createElement)(h,{selectedComment:e,commentId:t})))}let E=1;i()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-remote-reply"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,o.createRoot)(e).render((0,n.createElement)(f,{...t,id:"activitypub-remote-reply-link-"+E++,useId:!0}))}))}))}},a={};function n(e){var o=a[e];if(void 0!==o)return o.exports;var r=a[e]={exports:{}};return t[e](r,r.exports,n),r.exports}n.m=t,e=[],n.O=(t,a,o,r)=>{if(!a){var i=1/0;for(s=0;s=r)&&Object.keys(n.O).every((e=>n.O[e](a[l])))?a.splice(l--,1):(c=!1,r0&&e[s-1][2]>r;s--)e[s]=e[s-1];e[s]=[a,o,r]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={227:0,739:0};n.O.j=t=>0===e[t];var t=(t,a)=>{var o,r,[i,c,l]=a,u=0;if(i.some((t=>0!==e[t]))){for(o in c)n.o(c,o)&&(n.m[o]=c[o]);if(l)var s=l(n)}for(t&&t(a);un(202)));o=n.O(o)})(); \ No newline at end of file diff --git a/wp-content/plugins/activitypub/includes/activity/class-actor.php b/wp-content/plugins/activitypub/includes/activity/class-actor.php index 1751aa29..64631888 100644 --- a/wp-content/plugins/activitypub/includes/activity/class-actor.php +++ b/wp-content/plugins/activitypub/includes/activity/class-actor.php @@ -52,7 +52,7 @@ class Actor extends Base_Object { /** * @var string */ - protected $type = 'Person'; + protected $type; /** * A reference to an ActivityStreams OrderedCollection comprised of diff --git a/wp-content/plugins/activitypub/includes/class-activity-dispatcher.php b/wp-content/plugins/activitypub/includes/class-activity-dispatcher.php index 6278c669..16387154 100644 --- a/wp-content/plugins/activitypub/includes/class-activity-dispatcher.php +++ b/wp-content/plugins/activitypub/includes/class-activity-dispatcher.php @@ -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; } diff --git a/wp-content/plugins/activitypub/includes/class-activitypub.php b/wp-content/plugins/activitypub/includes/class-activitypub.php index 1a13d2a2..442cdfa5 100644 --- a/wp-content/plugins/activitypub/includes/class-activitypub.php +++ b/wp-content/plugins/activitypub/includes/class-activitypub.php @@ -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' ); + } + } } diff --git a/wp-content/plugins/activitypub/includes/class-admin.php b/wp-content/plugins/activitypub/includes/class-admin.php index 9443a8bf..5df037d4 100644 --- a/wp-content/plugins/activitypub/includes/class-admin.php +++ b/wp-content/plugins/activitypub/includes/class-admin.php @@ -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; + } } diff --git a/wp-content/plugins/activitypub/includes/class-comment.php b/wp-content/plugins/activitypub/includes/class-comment.php index 317316b6..682fa665 100644 --- a/wp-content/plugins/activitypub/includes/class-comment.php +++ b/wp-content/plugins/activitypub/includes/class-comment.php @@ -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, diff --git a/wp-content/plugins/activitypub/includes/class-http.php b/wp-content/plugins/activitypub/includes/class-http.php index 79519b3b..12755ceb 100644 --- a/wp-content/plugins/activitypub/includes/class-http.php +++ b/wp-content/plugins/activitypub/includes/class-http.php @@ -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. diff --git a/wp-content/plugins/activitypub/includes/class-migration.php b/wp-content/plugins/activitypub/includes/class-migration.php index 5c57f4e9..88737a3c 100644 --- a/wp-content/plugins/activitypub/includes/class-migration.php +++ b/wp-content/plugins/activitypub/includes/class-migration.php @@ -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' ); + } } } diff --git a/wp-content/plugins/activitypub/includes/class-scheduler.php b/wp-content/plugins/activitypub/includes/class-scheduler.php index 0db5fe9f..48a556bc 100644 --- a/wp-content/plugins/activitypub/includes/class-scheduler.php +++ b/wp-content/plugins/activitypub/includes/class-scheduler.php @@ -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; } diff --git a/wp-content/plugins/activitypub/includes/class-shortcodes.php b/wp-content/plugins/activitypub/includes/class-shortcodes.php index 664266d1..b32b91dd 100644 --- a/wp-content/plugins/activitypub/includes/class-shortcodes.php +++ b/wp-content/plugins/activitypub/includes/class-shortcodes.php @@ -271,7 +271,7 @@ class Shortcodes { } return \sprintf( - '%1$s', + '%1$s', \esc_url( \get_permalink( $item->ID ) ) ); } @@ -305,7 +305,7 @@ class Shortcodes { } return \sprintf( - '%1$s', + '%1$s', \esc_url( \wp_get_shortlink( $item->ID ) ) ); } diff --git a/wp-content/plugins/activitypub/includes/collection/class-users.php b/wp-content/plugins/activitypub/includes/collection/class-users.php index ad94297c..a331c203 100644 --- a/wp-content/plugins/activitypub/includes/collection/class-users.php +++ b/wp-content/plugins/activitypub/includes/collection/class-users.php @@ -268,7 +268,7 @@ class Users { public static function get_collection() { $users = \get_users( array( - 'capability__in' => array( 'publish_posts' ), + 'capability__in' => array( 'activitypub' ), ) ); diff --git a/wp-content/plugins/activitypub/includes/functions.php b/wp-content/plugins/activitypub/includes/functions.php index ed516328..7ea3ed9f 100644 --- a/wp-content/plugins/activitypub/includes/functions.php +++ b/wp-content/plugins/activitypub/includes/functions.php @@ -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 ); +} diff --git a/wp-content/plugins/activitypub/includes/rest/class-comment.php b/wp-content/plugins/activitypub/includes/rest/class-comment.php index 70df2a0e..6a062d6c 100644 --- a/wp-content/plugins/activitypub/includes/rest/class-comment.php +++ b/wp-content/plugins/activitypub/includes/rest/class-comment.php @@ -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 ); } diff --git a/wp-content/plugins/activitypub/includes/rest/class-followers.php b/wp-content/plugins/activitypub/includes/rest/class-followers.php index a3f71ada..bbddb004 100644 --- a/wp-content/plugins/activitypub/includes/rest/class-followers.php +++ b/wp-content/plugins/activitypub/includes/rest/class-followers.php @@ -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'; diff --git a/wp-content/plugins/activitypub/includes/rest/class-following.php b/wp-content/plugins/activitypub/includes/rest/class-following.php index 58e4375c..5ff29ec0 100644 --- a/wp-content/plugins/activitypub/includes/rest/class-following.php +++ b/wp-content/plugins/activitypub/includes/rest/class-following.php @@ -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'; diff --git a/wp-content/plugins/activitypub/includes/rest/class-inbox.php b/wp-content/plugins/activitypub/includes/rest/class-inbox.php index c0ef5630..b5ea52eb 100644 --- a/wp-content/plugins/activitypub/includes/rest/class-inbox.php +++ b/wp-content/plugins/activitypub/includes/rest/class-inbox.php @@ -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 diff --git a/wp-content/plugins/activitypub/includes/rest/class-nodeinfo.php b/wp-content/plugins/activitypub/includes/rest/class-nodeinfo.php index 38cbf0c3..02b89b6c 100644 --- a/wp-content/plugins/activitypub/includes/rest/class-nodeinfo.php +++ b/wp-content/plugins/activitypub/includes/rest/class-nodeinfo.php @@ -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(); diff --git a/wp-content/plugins/activitypub/includes/rest/class-outbox.php b/wp-content/plugins/activitypub/includes/rest/class-outbox.php index ab00778a..474f1622 100644 --- a/wp-content/plugins/activitypub/includes/rest/class-outbox.php +++ b/wp-content/plugins/activitypub/includes/rest/class-outbox.php @@ -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, ) diff --git a/wp-content/plugins/activitypub/includes/transformer/class-attachment.php b/wp-content/plugins/activitypub/includes/transformer/class-attachment.php index fc21225e..2fc46350 100644 --- a/wp-content/plugins/activitypub/includes/transformer/class-attachment.php +++ b/wp-content/plugins/activitypub/includes/transformer/class-attachment.php @@ -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'; + } } diff --git a/wp-content/plugins/activitypub/includes/transformer/class-comment.php b/wp-content/plugins/activitypub/includes/transformer/class-comment.php index 209a7ab3..baa268e8 100644 --- a/wp-content/plugins/activitypub/includes/transformer/class-comment.php +++ b/wp-content/plugins/activitypub/includes/transformer/class-comment.php @@ -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; } } diff --git a/wp-content/plugins/activitypub/includes/transformer/class-factory.php b/wp-content/plugins/activitypub/includes/transformer/class-factory.php index 7df78363..33210ca1 100644 --- a/wp-content/plugins/activitypub/includes/transformer/class-factory.php +++ b/wp-content/plugins/activitypub/includes/transformer/class-factory.php @@ -1,6 +1,8 @@ post_type ) { return new Attachment( $object ); diff --git a/wp-content/plugins/activitypub/includes/transformer/class-post.php b/wp-content/plugins/activitypub/includes/transformer/class-post.php index 5338ceaf..1023dfdf 100644 --- a/wp-content/plugins/activitypub/includes/transformer/class-post.php +++ b/wp-content/plugins/activitypub/includes/transformer/class-post.php @@ -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( '//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, '' ); + $content = \explode( '', $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 = "

[ap_title]

\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 ); } diff --git a/wp-content/plugins/activitypub/integration/class-enable-mastodon-apps.php b/wp-content/plugins/activitypub/integration/class-enable-mastodon-apps.php index 69899043..27e1412e 100644 --- a/wp-content/plugins/activitypub/integration/class-enable-mastodon-apps.php +++ b/wp-content/plugins/activitypub/integration/class-enable-mastodon-apps.php @@ -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; + } } diff --git a/wp-content/plugins/activitypub/readme.txt b/wp-content/plugins/activitypub/readme.txt index fa2e3f93..e9344b1a 100644 --- a/wp-content/plugins/activitypub/readme.txt +++ b/wp-content/plugins/activitypub/readme.txt @@ -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 `

` and `
` 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 == diff --git a/wp-content/plugins/activitypub/templates/settings.php b/wp-content/plugins/activitypub/templates/settings.php index b62c7665..2da88a7e 100644 --- a/wp-content/plugins/activitypub/templates/settings.php +++ b/wp-content/plugins/activitypub/templates/settings.php @@ -73,10 +73,40 @@ + + + + + > - - - -
+ + +

+ +

+

+ +

+ +
+

- - -

- -

-

-

- -

-

- -

-