first commit

This commit is contained in:
2023-09-01 00:37:57 -07:00
commit 9caab8ce68
602 changed files with 33485 additions and 0 deletions

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('wp-blocks', 'wp-components', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '2226b124181394cb78e7');

View File

@ -0,0 +1,2 @@
!function(){"use strict";var e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{metadata:function(){return v},name:function(){return f},settings:function(){return m}});var r={};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!==a(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!==a(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===a(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}e.r(r),e.d(r,{metadata:function(){return y},name:function(){return b},settings:function(){return _}});var i=window.wp.blocks,o=window.wp.i18n,u=window.wp.element,l=window.wp.components,c=window.wp.serverSideRender,s=e.n(c),p=window.wp.editor,v=JSON.parse('{"name":"avatar-privacy/form","title":"Avatar Privacy Form","category":"common","icon":"id-alt","description":"Inserts a form to upload a local avatar and manage related settings.","keywords":["avatar","upload","frontend"],"textdomain":"avatar-privacy","attributes":{"avatar_size":{"type":"integer","default":96},"show_descriptions":{"type":"boolean","default":true}}}'),f=v.name,m={title:(0,o.__)("Avatar Privacy Form","avatar-privacy"),supports:{html:!1,multiple:!1,reusable:!1},edit:function(e){var t=e.attributes,r=e.className,a=e.setAttributes;return(0,u.createElement)(u.Fragment,null,(0,u.createElement)(p.InspectorControls,null,(0,u.createElement)(l.PanelBody,{title:(0,o.__)("Form","avatar-privacy")},(0,u.createElement)(l.PanelRow,null,(0,u.createElement)(l.RangeControl,{label:(0,o.__)("Avatar Size","avatar-privacy"),value:t.avatar_size,initialPosition:t.avatar_size,onChange:function(e){return a({avatar_size:e})},min:48,max:240})),(0,u.createElement)(l.PanelRow,null,(0,u.createElement)(l.ToggleControl,{label:(0,o.__)("Show Descriptions","avatar-privacy"),checked:!!t.show_descriptions,onChange:function(){return a({show_descriptions:!t.show_descriptions})}})))),(0,u.createElement)(s(),{block:"avatar-privacy/form",attributes:{avatar_size:t.avatar_size,show_descriptions:t.show_descriptions,className:r,preview:!0}}))},save:function(){}},d=(0,window.wp.data.withSelect)((function(e){return{users:e("core").getAuthors()}}))((function(e){var t=e.attributes,r=e.setAttributes,a=e.users;if(!a||a.length<1)return(0,o.__)("Loading…","avatar-privacy");t.user_id=t.user_id||a[0].id;var n=function(e){return a.find((function(t){return parseInt(e)===t.id}))},i=n(t.user_id);return t.user=t.user||i,(0,u.createElement)(u.Fragment,null,(0,u.createElement)(p.InspectorControls,null,(0,u.createElement)(l.PanelBody,{title:(0,o.__)("Avatar","avatar-privacy")},(0,u.createElement)(l.PanelRow,null,(0,u.createElement)(l.SelectControl,{label:(0,o.__)("User","avatar-privacy"),value:t.user_id,options:a.map((function(e){return{label:e.name,value:e.id}})),onChange:function(e){return r({user_id:parseInt(e),user:n(e)})}})),(0,u.createElement)(l.PanelRow,null,(0,u.createElement)(l.RangeControl,{label:(0,o.__)("Avatar Size","avatar-privacy"),value:t.avatar_size,initialPosition:t.avatar_size,onChange:function(e){return r({avatar_size:e})},min:48,max:240})))),(0,u.createElement)("img",{width:t.avatar_size,src:t.user.avatar_urls[96],alt:(0,o.sprintf)(/* translators: user display name */
(0,o.__)("Avatar of %s","avatar-privacy"),t.user.name)}))})),y=JSON.parse('{"name":"avatar-privacy/avatar","title":"Avatar","category":"common","icon":"admin-users","description":"Displays a user\'s avatar.","keywords":["avatar","user","icon"],"textdomain":"avatar-privacy","attributes":{"avatar_size":{"type":"integer","default":96},"user_id":{"type":"integer","default":0},"align":{"type":"string","default":""},"user":{"type":"object","source":"attribute","selector":"*","default":null}}}'),b=y.name,_={title:(0,o.__)("Avatar","avatar-privacy"),supports:{align:["left","center","right"],html:!1},edit:d,save:function(){}};function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}[t,r].forEach((function(e){if(e){var t=e.metadata,r=e.settings,a=e.name;(0,i.registerBlockType)(a,g(g({},t),r))}}))}();

View File

@ -0,0 +1,29 @@
{
"name": "avatar-privacy/avatar",
"title": "Avatar",
"category": "common",
"icon": "admin-users",
"description": "Displays a user's avatar.",
"keywords": [ "avatar", "user", "icon" ],
"textdomain": "avatar-privacy",
"attributes": {
"avatar_size": {
"type": "integer",
"default": 96
},
"user_id": {
"type": "integer",
"default": 0
},
"align": {
"type": "string",
"default": ""
},
"user": {
"type": "object",
"source": "attribute",
"selector": "*",
"default": null
}
}
}

View File

@ -0,0 +1,101 @@
/**
* Avatar block for the WordPress block editor.
*
* This file is part of Avatar Privacy.
*
* @file This file provides the edit method for the Avatar block.
* @author Peter Putzer <github@mundschenk.at>
* @license GPL-2.0-or-later
* @since 2.3.0
*/
'use strict';
/**
* WordPress dependencies
*/
import {
PanelBody,
PanelRow,
RangeControl,
SelectControl,
} from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { InspectorControls } from '@wordpress/editor';
import { Fragment } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
/**
* Renders the markup for editing the block attributes of the Avatar block.
*
* @param {Object} props The block properties.
* @param {Object} props.attributes The block attributes.
* @param {Object} props.setAttributes The attribute setter function.
* @return {Object} ECMAScript JSX Markup for the editor
*/
export default withSelect(
// Retrieve WordPress authors.
( select ) => ( { users: select( 'core' ).getAuthors() } )
)( ( { attributes, setAttributes, users } ) => {
// The authors list has not finished loading yet.
if ( ! users || users.length < 1 ) {
return __( 'Loading…', 'avatar-privacy' );
}
// Set default for user_id.
attributes.user_id = attributes.user_id || users[ 0 ].id;
// Find the current user object.
const findUser = ( userID ) =>
users.find( ( user ) => parseInt( userID ) === user.id );
const currentUser = findUser( attributes.user_id );
// Set the user attribute if missing.
attributes.user = attributes.user || currentUser;
return (
<Fragment>
<InspectorControls>
<PanelBody title={ __( 'Avatar', 'avatar-privacy' ) }>
<PanelRow>
<SelectControl
label={ __( 'User', 'avatar-privacy' ) }
value={ attributes.user_id }
options={ users.map( ( user ) => ( {
label: user.name,
value: user.id,
} ) ) }
onChange={ ( newUser ) =>
setAttributes( {
user_id: parseInt( newUser ),
user: findUser( newUser ),
} )
}
/>
</PanelRow>
<PanelRow>
<RangeControl
label={ __( 'Avatar Size', 'avatar-privacy' ) }
value={ attributes.avatar_size }
initialPosition={ attributes.avatar_size }
onChange={ ( newSize ) =>
setAttributes( { avatar_size: newSize } )
}
min={ 48 }
max={ 240 }
/>
</PanelRow>
</PanelBody>
</InspectorControls>
<img
width={ attributes.avatar_size }
src={ attributes.user.avatar_urls[ 96 ] }
alt={ sprintf(
/* translators: user display name */
__( 'Avatar of %s', 'avatar-privacy' ),
attributes.user.name
) }
/>
</Fragment>
);
} );

View File

@ -0,0 +1,46 @@
/**
* Avatar block for the WordPress block editor.
*
* This file is part of Avatar Privacy.
*
* @file This file provides the Avatar block.
* @author Peter Putzer <github@mundschenk.at>
* @license GPL-2.0-or-later
* @since 2.3.0
*/
'use strict';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import edit from './edit';
import metadata from './block.json';
const { name } = metadata;
export { metadata, name };
/**
* The Avatar block.
*
* The block is rendered server-side to be current (avatars can change frequently).
*/
export const settings = {
title: __( 'Avatar', 'avatar-privacy' ),
supports: {
align: [ 'left', 'center', 'right' ],
html: false,
},
edit,
save: () => {
// Intentionally empty because this is a dynamic block
},
};

View File

@ -0,0 +1,38 @@
/**
* Blocks for the WordPress block editor.
*
* This file is part of Avatar Privacy.
*
* @file This file registers the blocks included with the Avatar Privacy plugin.
* @author Peter Putzer <github@mundschenk.at>
* @license GPL-2.0-or-later
* @since 2.3.0
* @requires Gutenberg 4.3
*/
'use strict';
/**
* WordPress dependencies
*/
import { registerBlockType } from '@wordpress/blocks';
/**
* Internal dependencies
*/
import * as frontendForm from './frontend-form';
import * as avatar from './avatar';
/**
* Registers all our blocks.
*/
[ frontendForm, avatar ].forEach( ( block ) => {
if ( ! block ) {
return;
}
const { metadata, settings, name } = block;
registerBlockType( name, {
...metadata,
...settings,
} );
} );

View File

@ -0,0 +1,19 @@
{
"name": "avatar-privacy/form",
"title": "Avatar Privacy Form",
"category": "common",
"icon": "id-alt",
"description": "Inserts a form to upload a local avatar and manage related settings.",
"keywords": [ "avatar", "upload", "frontend" ],
"textdomain": "avatar-privacy",
"attributes": {
"avatar_size": {
"type": "integer",
"default": 96
},
"show_descriptions": {
"type": "boolean",
"default": true
}
}
}

View File

@ -0,0 +1,82 @@
/**
* Frontend Form block for the WordPress block editor.
*
* This file is part of Avatar Privacy.
*
* @file This file provides the edit method for the Avatar block.
* @author Peter Putzer <github@mundschenk.at>
* @license GPL-2.0-or-later
* @since 2.3.0
*/
'use strict';
/**
* WordPress dependencies
*/
import {
PanelBody,
PanelRow,
RangeControl,
ToggleControl,
} from '@wordpress/components';
import ServerSideRender from '@wordpress/server-side-render';
import { InspectorControls } from '@wordpress/editor';
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
/**
* Renders the markup for editing the block attributes of the Avatar block.
*
* @param {Object} props The block properties.
* @param {Object} props.attributes The block attributes.
* @param {string} props.className The CSS class to use.
* @param {Object} props.setAttributes The attribute setter function.
* @return {Object} ECMAScript JSX Markup for the editor
*/
export default ( { attributes, className, setAttributes } ) => {
return (
<Fragment>
<InspectorControls>
<PanelBody title={ __( 'Form', 'avatar-privacy' ) }>
<PanelRow>
<RangeControl
label={ __( 'Avatar Size', 'avatar-privacy' ) }
value={ attributes.avatar_size }
initialPosition={ attributes.avatar_size }
onChange={ ( newSize ) =>
setAttributes( { avatar_size: newSize } )
}
min={ 48 }
max={ 240 }
/>
</PanelRow>
<PanelRow>
<ToggleControl
label={ __(
'Show Descriptions',
'avatar-privacy'
) }
checked={ !! attributes.show_descriptions }
onChange={ () =>
setAttributes( {
show_descriptions:
! attributes.show_descriptions,
} )
}
/>
</PanelRow>
</PanelBody>
</InspectorControls>
<ServerSideRender
block="avatar-privacy/form"
attributes={ {
avatar_size: attributes.avatar_size,
show_descriptions: attributes.show_descriptions,
className,
preview: true,
} }
/>
</Fragment>
);
};

View File

@ -0,0 +1,47 @@
/**
* Frontend Form block for the WordPress block editor.
*
* This file is part of Avatar Privacy.
*
* @file This file provides the Frontend Form block.
* @author Peter Putzer <github@mundschenk.at>
* @license GPL-2.0-or-later
* @since 2.3.0
*/
'use strict';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import edit from './edit';
import metadata from './block.json';
const { name } = metadata;
export { metadata, name };
/**
* The Frontend Form block.
*
* The block is rendered server-side to be current (avatars can change frequently).
*/
export const settings = {
title: __( 'Avatar Privacy Form', 'avatar-privacy' ),
supports: {
html: false,
multiple: false,
reusable: false,
},
edit,
save: () => {
// Intentionally empty because this is a dynamic block
},
};