Skip to content

Commit

Permalink
* Refactor code to use namespace and improve security.
Browse files Browse the repository at this point in the history
 * Add custom avatar upload to settings page.
 * Update language file.
 * Update readme txt and md files.
  • Loading branch information
azurecurve committed Mar 1, 2022
1 parent bae6b98 commit 19873c5
Show file tree
Hide file tree
Showing 17 changed files with 983 additions and 426 deletions.
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Description

Change the default avatar and allow users to upload their own.
Upload a new avatar and set as the default avatar and allow users to upload their own avatar and override the default.

Admin setting allows only use of local avatars; prevents use of Gravatars; if user doesn't upload their own avatar, a local default is used instead.

Expand All @@ -20,14 +20,58 @@ This plugin is multisite compatible; each site will need settings to be configur

**azurecurve** was one of the first plugin developers to start developing for Classicpress; all plugins are available from [azurecurve Development](https://development.azurecurve.co.uk/) and are integrated with the [Update Manager plugin](https://directory.classicpress.net/plugins/update-manager) for fully integrated, no hassle, updates.

Some of the other plugins available from **azurecurve** are:
The other plugins available from **azurecurve** are:
* Add Open Graph Tags - [details](https://development.azurecurve.co.uk/classicpress-plugins/add-open-graph-tags/) / [download](https://github.com/azurecurve/azrcrv-add-open-graph-tags/releases/latest/)
* Add Twitter Cards - [details](https://development.azurecurve.co.uk/classicpress-plugins/add-twitter-cards/) / [download](https://github.com/azurecurve/azrcrv-add-twitter-cards/releases/latest/)
* BBCode - [details](https://development.azurecurve.co.uk/classicpress-plugins/bbcode/) / [download](https://github.com/azurecurve/azrcrv-bbcode/releases/latest/)
* Breadcrumbs - [details](https://development.azurecurve.co.uk/classicpress-plugins/breadcrumbs/) / [download](https://github.com/azurecurve/azrcrv-breadcrumbs/releases/latest/)
* Call-out Boxes - [details](https://development.azurecurve.co.uk/classicpress-plugins/call-out-boxes/) / [download](https://github.com/azurecurve/azrcrv-call-out-boxes/releases/latest/)
* Check Plugin Status - [details](https://development.azurecurve.co.uk/classicpress-plugins/check-plugin-status/) / [download](https://github.com/azurecurve/azrcrv-check-plugin-status/releases/latest/)
* Code - [details](https://development.azurecurve.co.uk/classicpress-plugins/code/) / [download](https://github.com/azurecurve/azrcrv-code/releases/latest/)
* Comment Validator - [details](https://development.azurecurve.co.uk/classicpress-plugins/comment-validator/) / [download](https://github.com/azurecurve/azrcrv-comment-validator/releases/latest/)
* Conditional Links - [details](https://development.azurecurve.co.uk/classicpress-plugins/conditional-links/) / [download](https://github.com/azurecurve/azrcrv-conditional-links/releases/latest/)
* Contact Forms - [details](https://development.azurecurve.co.uk/classicpress-plugins/contact-forms/) / [download](https://github.com/azurecurve/azrcrv-contact-forms/releases/latest/)
* Disable FLoC - [details](https://development.azurecurve.co.uk/classicpress-plugins/disable-floc/) / [download](https://github.com/azurecurve/azrcrv-disable-floc/releases/latest/)
* Display After Post Content - [details](https://development.azurecurve.co.uk/classicpress-plugins/display-after-post-content/) / [download](https://github.com/azurecurve/azrcrv-display-after-post-content/releases/latest/)
* Estimated Read Time - [details](https://development.azurecurve.co.uk/classicpress-plugins/estimated-read-time/) / [download](https://github.com/azurecurve/azrcrv-estimated-read-time/releases/latest/)
* Events - [details](https://development.azurecurve.co.uk/classicpress-plugins/events/) / [download](https://github.com/azurecurve/azrcrv-events/releases/latest/)
* Filtered Categories - [details](https://development.azurecurve.co.uk/classicpress-plugins/filtered-categories/) / [download](https://github.com/azurecurve/azrcrv-filtered-categories/releases/latest/)
* Flags - [details](https://development.azurecurve.co.uk/classicpress-plugins/flags/) / [download](https://github.com/azurecurve/azrcrv-flags/releases/latest/)
* Floating Featured Image - [details](https://development.azurecurve.co.uk/classicpress-plugins/floating-featured-image/) / [download](https://github.com/azurecurve/azrcrv-floating-featured-image/releases/latest/)
* From Twitter - [details](https://development.azurecurve.co.uk/classicpress-plugins/from-twitter/) / [download](https://github.com/azurecurve/azrcrv-from-twitter/releases/latest/)
* Gallery From Folder - [details](https://development.azurecurve.co.uk/classicpress-plugins/gallery-from-folder/) / [download](https://github.com/azurecurve/azrcrv-gallery-from-folder/releases/latest/)
* Get GitHub File - [details](https://development.azurecurve.co.uk/classicpress-plugins/get-github-file/) / [download](https://github.com/azurecurve/azrcrv-get-github-file/releases/latest/)
* Icons - [details](https://development.azurecurve.co.uk/classicpress-plugins/icons/) / [download](https://github.com/azurecurve/azrcrv-icons/releases/latest/)
* Images - [details](https://development.azurecurve.co.uk/classicpress-plugins/images/) / [download](https://github.com/azurecurve/azrcrv-images/releases/latest/)
* Insult Generator - [details](https://development.azurecurve.co.uk/classicpress-plugins/insult-generator/) / [download](https://github.com/azurecurve/azrcrv-insult-generator/releases/latest/)
* Load Admin CSS - [details](https://development.azurecurve.co.uk/classicpress-plugins/load-admin-css/) / [download](https://github.com/azurecurve/azrcrv-load-admin-css/releases/latest/)
* Loop Injection - [details](https://development.azurecurve.co.uk/classicpress-plugins/loop-injection/) / [download](https://github.com/azurecurve/azrcrv-loop-injection/releases/latest/)
* Maintenance Mode - [details](https://development.azurecurve.co.uk/classicpress-plugins/maintenance-mode/) / [download](https://github.com/azurecurve/azrcrv-maintenance-mode/releases/latest/)
* Markdown - [details](https://development.azurecurve.co.uk/classicpress-plugins/markdown/) / [download](https://github.com/azurecurve/azrcrv-markdown/releases/latest/)
* Mobile Detection - [details](https://development.azurecurve.co.uk/classicpress-plugins/mobile-detection/) / [download](https://github.com/azurecurve/azrcrv-mobile-detection/releases/latest/)
* Multisite Favicon - [details](https://development.azurecurve.co.uk/classicpress-plugins/multisite-favicon/) / [download](https://github.com/azurecurve/azrcrv-multisite-favicon/releases/latest/)
* Nearby - [details](https://development.azurecurve.co.uk/classicpress-plugins/nearby/) / [download](https://github.com/azurecurve/azrcrv-nearby/releases/latest/)
* Page Index - [details](https://development.azurecurve.co.uk/classicpress-plugins/page-index/) / [download](https://github.com/azurecurve/azrcrv-page-index/releases/latest/)
* Post Archive - [details](https://development.azurecurve.co.uk/classicpress-plugins/post-archive/) / [download](https://github.com/azurecurve/azrcrv-post-archive/releases/latest/)
* Redirect - [details](https://development.azurecurve.co.uk/classicpress-plugins/redirect/) / [download](https://github.com/azurecurve/azrcrv-redirect/releases/latest/)
* Remove Revisions - [details](https://development.azurecurve.co.uk/classicpress-plugins/remove-revisions/) / [download](https://github.com/azurecurve/azrcrv-remove-revisions/releases/latest/)
* RSS Feed - [details](https://development.azurecurve.co.uk/classicpress-plugins/rss-feed/) / [download](https://github.com/azurecurve/azrcrv-rss-feed/releases/latest/)
* RSS Suffix - [details](https://development.azurecurve.co.uk/classicpress-plugins/rss-suffix/) / [download](https://github.com/azurecurve/azrcrv-rss-suffix/releases/latest/)
* Series Index - [details](https://development.azurecurve.co.uk/classicpress-plugins/series-index/) / [download](https://github.com/azurecurve/azrcrv-series-index/releases/latest/)
* Shortcodes in Comments - [details](https://development.azurecurve.co.uk/classicpress-plugins/shortcodes-in-comments/) / [download](https://github.com/azurecurve/azrcrv-shortcodes-in-comments/releases/latest/)
* Shortcodes in Widgets - [details](https://development.azurecurve.co.uk/classicpress-plugins/shortcodes-in-widgets/) / [download](https://github.com/azurecurve/azrcrv-shortcodes-in-widgets/releases/latest/)
* Sidebar Login - [details](https://development.azurecurve.co.uk/classicpress-plugins/sidebar-login/) / [download](https://github.com/azurecurve/azrcrv-sidebar-login/releases/latest/)
* SMTP - [details](https://development.azurecurve.co.uk/classicpress-plugins/smtp/) / [download](https://github.com/azurecurve/azrcrv-smtp/releases/latest/)
* Snippets - [details](https://development.azurecurve.co.uk/classicpress-plugins/snippets/) / [download](https://github.com/azurecurve/azrcrv-snippets/releases/latest/)
* Strong Password Generator - [details](https://development.azurecurve.co.uk/classicpress-plugins/strong-password-generator/) / [download](https://github.com/azurecurve/azrcrv-strong-password-generator/releases/latest/)
* Tag Cloud - [details](https://development.azurecurve.co.uk/classicpress-plugins/tag-cloud/) / [download](https://github.com/azurecurve/azrcrv-tag-cloud/releases/latest/)
* Taxonomy Index - [details](https://development.azurecurve.co.uk/classicpress-plugins/taxonomy-index/) / [download](https://github.com/azurecurve/azrcrv-taxonomy-index/releases/latest/)
* Taxonomy Order - [details](https://development.azurecurve.co.uk/classicpress-plugins/taxonomy-order/) / [download](https://github.com/azurecurve/azrcrv-taxonomy-order/releases/latest/)
* Theme Switcher - [details](https://development.azurecurve.co.uk/classicpress-plugins/theme-switcher/) / [download](https://github.com/azurecurve/azrcrv-theme-switcher/releases/latest/)
* Timelines - [details](https://development.azurecurve.co.uk/classicpress-plugins/timelines/) / [download](https://github.com/azurecurve/azrcrv-timelines/releases/latest/)
* To Twitter - [details](https://development.azurecurve.co.uk/classicpress-plugins/to-twitter/) / [download](https://github.com/azurecurve/azrcrv-to-twitter/releases/latest/)
* Toggle Show/Hide - [details](https://development.azurecurve.co.uk/classicpress-plugins/toggle-showhide/) / [download](https://github.com/azurecurve/azrcrv-toggle-showhide/releases/latest/)
* Update Admin Menu - [details](https://development.azurecurve.co.uk/classicpress-plugins/update-admin-menu/) / [download](https://github.com/azurecurve/azrcrv-update-admin-menu/releases/latest/)
* URL Shortener - [details](https://development.azurecurve.co.uk/classicpress-plugins/url-shortener/) / [download](https://github.com/azurecurve/azrcrv-url-shortener/releases/latest/)
* Username Protection - [details](https://development.azurecurve.co.uk/classicpress-plugins/username-protection/) / [download](https://github.com/azurecurve/azrcrv-username-protection/releases/latest/)
* Widget Announcements - [details](https://development.azurecurve.co.uk/classicpress-plugins/widget-announcements/) / [download](https://github.com/azurecurve/azrcrv-widget-announcements/releases/latest/)
83 changes: 83 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
plugin setting styles
*/
.azrcrv-ui-tabs {
display: block;
position: relative;
margin-bottom: 6px;
overflow: auto;
}
.azrcrv-ui-tabs .azrcrv-ui-tabs-nav {
display: flex;
flex-wrap: wrap;
justify-content: left;
background: transparent;
border: none;
font-size: 1.3em;
}
.azrcrv-ui-tabs-nav .azrcrv-ui-state-default a{
border: 1px solid grey;
border-bottom: 4px solid grey;
color: grey;
background: transparent;
font-weight: 700;
padding: 6px;
}
.azrcrv-ui-tabs-nav .azrcrv-ui-state-active a{
border: 1px solid #007FFF;
border-bottom: 4px solid #007FFF;
color: #007FFF;
background: transparent;
font-weight: 700;
padding: 6px;
}
.azrcrv-ui-tabs-nav .azrcrv-ui-state-default a:hover{
border: 1px solid #0000ff;
border-bottom: 4px solid #0000ff;
color: #0000ff;
background: transparent;
font-weight: 700;
padding: 6px;
}
.azrcrv-ui-tabs-scroll {
margin-top: -12px;
border: 1px solid grey;
padding: 12px;
}
.azrcrv-ui-tabs-hidden{
display: none;
}
table.azrcrv-settings{
}
th.azrcrv-settings-section-heading {
margin: 0;
padding: 0;
padding-left: 6px;
line-height: 1em;
border-bottom: 5px solid #007fff;
}
h2.azrcrv-settings-section-heading {
line-height: 1em;
}
table.azrcrv.settings th {
padding-left: 12px;
}
div.azrcrv-donate {
color: #007fff;
font-size: 1.25em;
font-weight: 700;
text-align: center;
float:right;
width: 300px;
}
div.azrcrv-donate span {
font-size: 1em;
color: #000;
font-weight: 400;
}
/*
other styles
*/
tr.user-profile-picture{
display: none;
}
2 changes: 1 addition & 1 deletion assets/css/index.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
// Whereof one cannot speak, thereof one must be silent.
// Whereof one cannot speak, thereof one must be silent.
3 changes: 0 additions & 3 deletions assets/css/style.css

This file was deleted.

2 changes: 1 addition & 1 deletion assets/index.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
// Whereof one cannot speak, thereof one must be silent.
// Whereof one cannot speak, thereof one must be silent.
91 changes: 91 additions & 0 deletions assets/jquery/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Tabs
*/
jQuery(
function($) {
'use strict';

$( '#tabs ul li a' ).on(
'keyup click',
function(e) {
if (e.key === 'Enter' || e.type === 'click') {
var id = $( this ).attr( 'href' );
$( '.azrcrv-ui-state-active' ).removeClass( 'azrcrv-ui-state-active' ).attr( 'aria-selected', 'false' ).attr( 'aria-expanded', 'false' );
$( this ).parent( 'li' ).addClass( 'azrcrv-ui-state-active' ).attr( 'aria-selected', 'true' ).attr( 'aria-expanded', 'true' );
$( this ).closest( 'ul' ).siblings().addClass( 'azrcrv-ui-tabs-hidden' ).attr( 'aria-hidden', 'true' );
$( id ).removeClass( 'azrcrv-ui-tabs-hidden' ).attr( 'aria-hidden', 'false' );
e.preventDefault();
}
}
);

$( '#tabs ul li a' ).hover(
function() { $( this ).addClass( 'azrcrv-ui-state-hover' ); },
function() { $( this ).removeClass( 'azrcrv-ui-state-hover' ); }
);
}
);

/*
* Adapted from: http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/
*/
jQuery( document ).ready(
function($){
// remove standard avatar display
// jQuery('table.form-table tr.user-profile-picture').remove();

// Uploading files
var file_frame;

$( '#azrcrv-a-upload-avatar' ).on(
'click',
function( event ){

event.preventDefault();

// If the media frame already exists, reopen it.
if ( file_frame ) {
file_frame.open();
return;
}

// Create the media frame.
file_frame = wp.media.frames.file_frame = wp.media(
{
title: $( this ).data( 'uploader_title' ),
button: {
text: $( this ).data( 'uploader_button_text' ),
},
multiple: false // Set to true to allow multiple files to be selected
}
);

// When an image is selected, run a callback.
file_frame.on(
'select',
function() {
// We set multiple to false so only get one image from the uploader
attachment = file_frame.state().get( 'selection' ).first().toJSON();

// Do something with attachment.id and/or attachment.url here
jQuery( '#custom-default-avatar' ).attr( 'value',attachment.url );
jQuery( '#custom-default-avatar-src' ).attr( 'src',attachment.url );
}
);

// Finally, open the modal
file_frame.open();
}
);
$( '#azrcrv-a-remove-avatar' ).on(
'click',
function( event ){

// remove image and url
jQuery( '#custom-default-avatar' ).attr( 'value','' );
jQuery( '#custom-default-avatar-src' ).attr( 'src','' );

}
);
}
);
2 changes: 1 addition & 1 deletion assets/jquery/index.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
// Whereof one cannot speak, thereof one must be silent.
// Whereof one cannot speak, thereof one must be silent.
51 changes: 0 additions & 51 deletions assets/jquery/jquery.js

This file was deleted.

2 changes: 1 addition & 1 deletion assets/pluginimages/index.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
// Whereof one cannot speak, thereof one must be silent.
// Whereof one cannot speak, thereof one must be silent.

0 comments on commit 19873c5

Please sign in to comment.