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
},
};

4
admin/css/blocks.css Normal file
View File

@ -0,0 +1,4 @@
.components-panel__row .components-range-control .components-base-control__label {
max-width: 100%;
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJsb2Nrcy5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFDRSxlQUFlO0FBQ2pCIiwiZmlsZSI6ImJsb2Nrcy5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIuY29tcG9uZW50cy1wYW5lbF9fcm93IC5jb21wb25lbnRzLXJhbmdlLWNvbnRyb2wgLmNvbXBvbmVudHMtYmFzZS1jb250cm9sX19sYWJlbCB7XG4gIG1heC13aWR0aDogMTAwJTtcbn0iXX0= */

1
admin/css/blocks.min.css vendored Normal file
View File

@ -0,0 +1 @@
.components-panel__row .components-range-control .components-base-control__label{max-width:100%}

14
admin/css/settings.css Normal file
View File

@ -0,0 +1,14 @@
.submit .aux-buttons {
display: block;
float: right;
}
select,
input {
margin-top: -0.1em;
}
input[type=number] {
width: 5em;
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNldHRpbmdzLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFLGNBQWM7RUFDZCxZQUFZO0FBQ2Q7O0FBRUE7O0VBRUUsa0JBQWtCO0FBQ3BCOztBQUVBO0VBQ0UsVUFBVTtBQUNaIiwiZmlsZSI6InNldHRpbmdzLmNzcyIsInNvdXJjZXNDb250ZW50IjpbIi5zdWJtaXQgLmF1eC1idXR0b25zIHtcbiAgZGlzcGxheTogYmxvY2s7XG4gIGZsb2F0OiByaWdodDtcbn1cblxuc2VsZWN0LFxuaW5wdXQge1xuICBtYXJnaW4tdG9wOiAtMC4xZW07XG59XG5cbmlucHV0W3R5cGU9bnVtYmVyXSB7XG4gIHdpZHRoOiA1ZW07XG59Il19 */

1
admin/css/settings.min.css vendored Normal file
View File

@ -0,0 +1 @@
.submit .aux-buttons{display:block;float:right}select,input{margin-top:-0.1em}input[type=number]{width:5em}

View File

@ -0,0 +1,30 @@
<?php
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018 Peter Putzer.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***
*
* @package mundschenk-at/avatar-privacy
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
if ( ! empty( $description ) ) : ?>
<p><?php echo \esc_html( $description ); ?></p>
<?php endif; ?>
<?php

View File

@ -0,0 +1,42 @@
<?php
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018-2019 Peter Putzer.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***
*
* @package mundschenk-at/avatar-privacy
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
use Avatar_Privacy\Components\Network_Settings_Page;
?><div class='wrap'>
<h1><?php \esc_html_e( 'Avatar Privacy Network Settings', 'avatar-privacy' ); ?></h1>
<form method="post" action="<?php echo \esc_url( 'edit.php?action=' . Network_Settings_Page::ACTION ); ?>">
<?php \settings_fields( Network_Settings_Page::OPTION_GROUP ); ?>
<?php \do_settings_sections( Network_Settings_Page::OPTION_GROUP ); ?>
<p class="submit">
<?php \submit_button( \__( 'Save Changes', 'avatar-privacy' ), 'primary', 'save_changes', false, [ 'tabindex' => 1 ] ); ?>
</p><!-- .submit -->
</form>
</div><!-- .wrap -->
<?php

View File

@ -0,0 +1,53 @@
<?php
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018-2019 Peter Putzer.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***
*
* @package mundschenk-at/avatar-privacy
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
/**
* Required template variables:
*
* @var string $nonce The nonce itself.
* @var string $action The nonce action.
* @var string $field_name The name of the checkbox `<input>` element.
* @var string $value The checkbox value.
*/
?>
<tr class="avatar-privacy-allow-anonymous">
<th scope="row"><?php \esc_html_e( 'Logged-out Commenting', 'avatar-privacy' ); ?></th>
<td>
<?php \wp_nonce_field( $action, $nonce ); ?>
<input
id="<?php echo \esc_attr( $field_name ); ?>"
name="<?php echo \esc_attr( $field_name ); ?>"
type="checkbox"
value="true"
<?php \checked( $value ); ?>
/>
<label for="<?php echo \esc_attr( $field_name ); ?>"><?php \esc_html_e( 'Allow logged-out comments with my profile picture.', 'avatar-privacy' ); ?></label><br />
<p class="description">
<?php \esc_html_e( 'Check this box if you want to be able to use your profile picture while logged-out.', 'avatar-privacy' ); ?>
</p>
</td>
</tr>
<?php

View File

@ -0,0 +1,58 @@
<?php
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018-2021 Peter Putzer.
* Copyright 2012-2013 Johannes Freudendahl.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***
*
* @package mundschenk-at/avatar-privacy
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
use Avatar_Privacy\Tools\Template as T;
/**
* Required template variables:
*
* @var T $template The templating helper.
* @var string $nonce The nonce itself.
* @var string $action The nonce action.
* @var string $field_name The name of the checkbox `<input>` element.
* @var string $value The checkbox value.
*/
?>
<tr class="avatar-privacy-use-gravatar">
<th scope="row"><?php \esc_html_e( 'Gravatars', 'avatar-privacy' ); ?></th>
<td>
<?php \wp_nonce_field( $action, $nonce ); ?>
<input
id="<?php echo \esc_attr( $field_name ); ?>"
name="<?php echo \esc_attr( $field_name ); ?>"
type="checkbox"
value="true"
<?php \checked( $value ); ?>
/>
<label for="<?php echo \esc_attr( $field_name ); ?>"><?php echo \wp_kses( $template->get_use_gravatar_label( 'user' ), T::ALLOWED_HTML_LABEL ); ?></label><br />
<p class="description">
<?php \esc_html_e( "Uncheck this box if you don't want to display the gravatar for your e-mail address (or don't have an account on Gravatar.com).", 'avatar-privacy' ); ?>
<?php \esc_html_e( 'This setting will only take effect if you have not uploaded a local profile picture.', 'avatar-privacy' ); ?>
</p>
</td>
</tr>
<?php

View File

@ -0,0 +1,69 @@
<?php
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018-2021 Peter Putzer.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***
*
* @package mundschenk-at/avatar-privacy
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
use Avatar_Privacy\Core;
use Avatar_Privacy\Tools\Template as T;
/**
* Required template variables:
*
* @var int $user_id The ID of the edited user.
* @var T $template The templating helper.
* @var string $nonce The nonce itself.
* @var string $action The nonce action.
* @var string $upload_field The name of the uploader `<input>` element.
* @var string $erase_field The name of the erase checkbox `<input>` element.
* @var bool $uploads_disabled Whether the uploads system has been disabled completely..
* @var bool $can_upload Whether the currently active user can upload files.
* @var bool $has_local_avatar Whether a local avatar has been uploaded.
* @var int $size The width/height of the avatar preview image (in pixels).
* @var bool $show_description Whether the field description should be shown.
*/
?>
<tr class="avatar-privacy-user-avatar-upload">
<th scope="row"><?php \esc_html_e( 'Profile Picture', 'avatar-privacy' ); ?></th>
<td>
<?php echo \get_avatar( $user_id, $size, '', '', [ 'upload_timestamp' => true ] ); ?>
<?php if ( $can_upload ) : ?>
<p class="avatar-privacy-upload-fields">
<?php \wp_nonce_field( $action, $nonce ); ?>
<input type="file" id="<?php echo \esc_attr( $upload_field ); ?>" name="<?php echo \esc_attr( $upload_field ); ?>" accept="image/*" />
<?php if ( $has_local_avatar ) : ?>
<input type="checkbox" id="<?php echo \esc_attr( $erase_field ); ?>" name="<?php echo \esc_attr( $erase_field ); ?>" value="true" />
<label for="<?php echo \esc_attr( $erase_field ); ?>"><?php \esc_html_e( 'Delete local avatar picture.', 'avatar-privacy' ); ?></label><br />
<?php endif; ?>
</p>
<?php endif; ?>
<?php if ( ! $uploads_disabled && $show_description ) : ?>
<p class="description">
<?php echo \wp_kses( $template->get_uploader_description( $can_upload, $has_local_avatar ), T::ALLOWED_HTML_LABEL ); ?>
</p>
<?php endif; ?>
</td>
</tr>
<?php

View File

@ -0,0 +1,39 @@
<?php
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018 Peter Putzer.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***
*
* @package mundschenk-at/avatar-privacy
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
?>
<script type="text/javascript">
(function($){
var parent = $( '#show_avatars' ),
hideChildren = $( '.avatar-settings-disabled' ),
showChildren = $( '.avatar-settings-enabled' );
parent.change(function(){
hideChildren.toggleClass( 'hide-if-js', this.checked );
showChildren.toggleClass( 'hide-if-js', ! this.checked );
});
})(jQuery);
</script>
<?php

View File

@ -0,0 +1,39 @@
<?php
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018-2019 Peter Putzer.
* Copyright 2012-2013 Johannes Freudendahl.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***
*
* @package mundschenk-at/avatar-privacy
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
$show_avatars_class = empty( $show_avatars ) ? '' : ' hide-if-js';
?>
<div class="avatar-settings-disabled<?php echo $show_avatars_class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>">
<p>
<?php \esc_html_e( "The Avatar Privacy plugin modifies the display of avatars. You have not enabled avatars, so this plugin can't do anything for you. :-)", 'avatar-privacy' ); ?>
</p>
<p>
<?php \esc_html_e( 'You can enable profile pictures for users and commenters by selecting "Show Avatars" above. Then you will also see the features enabled by the Avatar Privacy plugin here.', 'avatar-privacy' ); ?>
</p>
</div>
<?php

View File

@ -0,0 +1,42 @@
<?php
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018-2019 Peter Putzer.
* Copyright 2012-2013 Johannes Freudendahl.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***
*
* @package mundschenk-at/avatar-privacy
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
$show_avatars_class = ! empty( $show_avatars ) ? '' : ' hide-if-js';
$allowed_html = [ 'strong' => [] ];
?>
<div class="avatar-settings-enabled<?php echo $show_avatars_class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>">
<p>
<?php \esc_html_e( 'To protect the privacy of your users, visitors and commenters, the Avatar Privacy plugin has enabled the following features:', 'avatar-privacy' ); ?>
</p>
<ul class="ul-disc">
<li><strong><?php \esc_html_e( 'Consent:', 'avatar-privacy' ); ?></strong> <?php \esc_html_e( 'We only try to load an avatar from Gravatar.com when users and commenters have explicitly consented.', 'avatar-privacy' ); ?></li>
<li><strong><?php \esc_html_e( 'Check:', 'avatar-privacy' ); ?></strong> <?php \esc_html_e( 'Even when people opt-in, we check if they really have a gravatar associated with their e-mail address.', 'avatar-privacy' ); ?></li>
<li><strong><?php \esc_html_e( 'Cache:', 'avatar-privacy' ); ?></strong> <?php \esc_html_e( 'To prevent tracking of your visitors, gravatars are cached locally and all default images are hosted on your server.', 'avatar-privacy' ); ?></li>
</ul>
</div>
<?php