From: danix Date: Wed, 4 Jul 2018 15:41:51 +0000 (+0200) Subject: initial commit X-Git-Url: https://git.danix.xyz/?p=danixland-author-signature.git;a=commitdiff_plain;h=e8ea87943791cd08759880c3243316c8bd34983e initial commit --- e8ea87943791cd08759880c3243316c8bd34983e diff --git a/css/dnxasi_admin_style.css b/css/dnxasi_admin_style.css new file mode 100644 index 0000000..67701b4 --- /dev/null +++ b/css/dnxasi_admin_style.css @@ -0,0 +1,29 @@ +.dnxasi_label { + display: block; + float: left; + margin: 0 30px 20px 2px; + position: relative; +} +.dnxasi_label input[type=radio] { + margin-top: -4px; + margin-right: 4px; + float: none; +} +.dnxasi_label span { + display: block; + width: 136px; + padding: 0 2px; +} +.dnxasi_label:nth-of-type(2n) span { + text-align: center; +} +.dnxasi_label:nth-of-type(3n) span { + text-align: right; +} +.dnxasi_label span img { + margin-bottom: -2px; +} +.dnxasi_label span small { + font-style: italic; + font-size: 75%; +} \ No newline at end of file diff --git a/danixland-author-signature.php b/danixland-author-signature.php new file mode 100644 index 0000000..e3ca3a9 --- /dev/null +++ b/danixland-author-signature.php @@ -0,0 +1,123 @@ + __('Select your signature', 'dnxasi'), + 'buttonText' => __('Use Image', 'dnxasi'), + 'placeholder' => plugins_url('/img/placeholder.png', __FILE__) + ); + if ( current_user_can( 'publish_posts' ) ) { + if ( 'profile.php' != $hook ) { + return; + } + wp_enqueue_media(); + wp_localize_script( 'dnxasi_uploader_modal', 'data', $translation ); + wp_enqueue_script( 'dnxasi_uploader_modal', false , array('jquery'), '0.1' ); + } +} +add_action('admin_enqueue_scripts', 'dnxasi_enqueue_scripts'); + +/** + * Adds additional user fields + * more info: http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields + */ +function dnxasi_add_signature( $user ) { + if ( ! current_user_can('publish_posts') ) + return false; + + $imagesrc = get_the_author_meta( 'dnxasi_meta_signature', $user->ID ); + $imagesrc = ( ! empty($imagesrc) ) ? $imagesrc : plugins_url('/img/placeholder.png', __FILE__); +?> + +

+ +

+ + + + + + + + +
+
+ + + + + +
+ +
+' . get_the_author_meta('display_name') . ''; + $content .= $new_content; + } + } + return $content; +} +add_filter( 'the_content', 'dnxasi_display_content' ); diff --git a/danixland-author-signature.pot b/danixland-author-signature.pot new file mode 100644 index 0000000..cb14fc3 --- /dev/null +++ b/danixland-author-signature.pot @@ -0,0 +1,106 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: danixland-author-signature\n" +"POT-Creation-Date: 2016-03-22 15:47+0100\n" +"PO-Revision-Date: 2016-03-22 09:35+0100\n" +"Last-Translator: danix \n" +"Language-Team: \n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.6\n" +"X-Poedit-Basepath: .\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-KeywordsList: __;_e;_n;_x;_ex;_nx;esc_attr__;esc_attr_e;esc_attr_x;" +"esc_html__;esc_html_e;esc_html_x\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPathExcluded-0: *.js\n" + +#: danixland-author-signature.php:33 +msgid "Select your signature" +msgstr "" + +#: danixland-author-signature.php:34 +msgid "Use Image" +msgstr "" + +#: danixland-author-signature.php:60 +msgid "Profile signature" +msgstr "" + +#: danixland-author-signature.php:62 +msgid "" +"if you don't select a signature image nothing will be displayed in the " +"content of your posts or pages." +msgstr "" + +#: danixland-author-signature.php:67 +msgid "add your signature image" +msgstr "" + +#: danixland-author-signature.php:73 +msgid "Select Signature" +msgstr "" + +#: danixland-author-signature.php:75 +msgid "Remove Signature" +msgstr "" + +#: danixland-author-signature.php:76 +msgid "Select and preview your signature image." +msgstr "" + +#: inc/dnxasi-settings.php:26 +msgid "Global Signature positioning and sizing" +msgstr "" + +#: inc/dnxasi-settings.php:33 +msgid "Signature alignment?" +msgstr "" + +#: inc/dnxasi-settings.php:41 +msgid "signature width?" +msgstr "" + +#: inc/dnxasi-settings.php:58 +msgid "left" +msgstr "" + +#: inc/dnxasi-settings.php:65 +msgid "center" +msgstr "" + +#: inc/dnxasi-settings.php:72 +msgid "right (default)" +msgstr "" + +#: inc/dnxasi-settings.php:83 +msgid "pixels" +msgstr "" + +#: inc/dnxasi-settings.php:85 +msgid "" +"set the width in pixels for your signature image and it will be scaled " +"accordingly. If you leave this field empty the default width of " +"300px will be used." +msgstr "" + +#: inc/dnxasi-settings.php:91 +msgid "" +"Choose how you want to position and scale the signature at the bottom of the " +"article." +msgstr "" + +#: inc/dnxasi-settings.php:99 +msgid "danixland Author Signature Settings" +msgstr "" + +#: inc/dnxasi-settings.php:102 +#, php-format +msgid "" +"To upload your signature image go to your profile page, " +"here on this page you can set up the general look of the signature trough " +"the website." +msgstr "" diff --git a/img/placeholder.png b/img/placeholder.png new file mode 100644 index 0000000..6c4afb8 Binary files /dev/null and b/img/placeholder.png differ diff --git a/img/signature-center.png b/img/signature-center.png new file mode 100644 index 0000000..8bd9ad5 Binary files /dev/null and b/img/signature-center.png differ diff --git a/img/signature-left.png b/img/signature-left.png new file mode 100644 index 0000000..dbf5759 Binary files /dev/null and b/img/signature-left.png differ diff --git a/img/signature-right.png b/img/signature-right.png new file mode 100644 index 0000000..4bc6639 Binary files /dev/null and b/img/signature-right.png differ diff --git a/inc/dnxasi-settings.php b/inc/dnxasi-settings.php new file mode 100644 index 0000000..3d03cf8 --- /dev/null +++ b/inc/dnxasi-settings.php @@ -0,0 +1,117 @@ + + + + + + +

300px will be used.', 'dnxasi'); ?>

+ +

+ +

profile page, here on this page you can set up the general look of the signature trough the website.', 'dnxasi'), + admin_url('profile.php') + ); ?>

+ +
+ + + +
+ tag + */ +function dnxasi_is_post_paginated() { + global $multipage; + + if ( 0 !== $multipage) + return true; +} + +/** + * Returns the number of pages in a paginated post + */ +function dnxasi_post_last_page() { + global $pages; + $countpages = count($pages); + + return $countpages; +} \ No newline at end of file diff --git a/js/dnxasi_uploader_modal.js b/js/dnxasi_uploader_modal.js new file mode 100644 index 0000000..4d24d60 --- /dev/null +++ b/js/dnxasi_uploader_modal.js @@ -0,0 +1,48 @@ +/* + * Adapted from: http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/ + */ +jQuery(document).ready(function($){ +// Uploading files +var file_frame; + + $('#dnxasi_uploadimage').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: data.frameTitle, + button: { + text: data.buttonText, + }, + 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 + $('#dnxasi_meta_signature').attr('value', attachment.url); + $('#dnxasi_signature_preview').attr('src', attachment.url); + }); + + // Finally, open the modal + file_frame.open(); + }); + + $('#dnxasi_deleteimage').on( 'click', function(event) { + event.preventDefault(); + + $('#dnxasi_meta_signature').attr('value', ''); + $('#dnxasi_signature_preview').attr('src', data.placeholder); + }); + +}); diff --git a/languages/dnxasi-it_IT.mo b/languages/dnxasi-it_IT.mo new file mode 100644 index 0000000..b34e3d6 Binary files /dev/null and b/languages/dnxasi-it_IT.mo differ diff --git a/languages/it_IT.po b/languages/it_IT.po new file mode 100644 index 0000000..5749148 --- /dev/null +++ b/languages/it_IT.po @@ -0,0 +1,114 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2016-03-22 15:47+0100\n" +"PO-Revision-Date: 2016-03-22 15:48+0100\n" +"Last-Translator: danix \n" +"Language-Team: \n" +"Language: it_IT\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.6\n" +"X-Poedit-Basepath: .\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: danixland-author-signature.php:33 +msgid "Select your signature" +msgstr "Seleziona la tua firma\t" + +#: danixland-author-signature.php:34 +msgid "Use Image" +msgstr "Usa Immagine" + +#: danixland-author-signature.php:60 +msgid "Profile signature" +msgstr "Firma del Profilo" + +#: danixland-author-signature.php:62 +msgid "" +"if you don't select a signature image nothing will be displayed in the " +"content of your posts or pages." +msgstr "" +"Se non selezioni un'immagine per la tua firma, non sarà visualizzato nulla " +"nel contenuto dei tuoi articoli e pagine." + +#: danixland-author-signature.php:67 +msgid "add your signature image" +msgstr "Aggiungi la tua firma" + +#: danixland-author-signature.php:73 +msgid "Select Signature" +msgstr "Seleziona la tua firma" + +#: danixland-author-signature.php:75 +msgid "Remove Signature" +msgstr "Rimuovi la tua firma" + +#: danixland-author-signature.php:76 +msgid "Select and preview your signature image." +msgstr "Seleziona e visualizza un'anteprima della tua firma." + +#: inc/dnxasi-settings.php:26 +msgid "Global Signature positioning and sizing" +msgstr "Posizionamento e dimensioni globali della Firma" + +#: inc/dnxasi-settings.php:33 +msgid "Signature alignment?" +msgstr "Allineamento?" + +#: inc/dnxasi-settings.php:41 +msgid "signature width?" +msgstr "Larghezza?" + +#: inc/dnxasi-settings.php:58 +msgid "left" +msgstr "sinistra" + +#: inc/dnxasi-settings.php:65 +msgid "center" +msgstr "centro" + +#: inc/dnxasi-settings.php:72 +msgid "right (default)" +msgstr "destra (default)" + +#: inc/dnxasi-settings.php:83 +msgid "pixels" +msgstr "pixels" + +#: inc/dnxasi-settings.php:85 +msgid "" +"set the width in pixels for your signature image and it will be scaled " +"accordingly. If you leave this field empty the default width of " +"300px will be used." +msgstr "" +"Imposta la larghezza in pixels per la firma e l'immagine sarà scalata di " +"conseguenza. Se lasci vuoto il campo, sarà utilizzata la larghezza di " +"default, pari a 300px." + +#: inc/dnxasi-settings.php:91 +msgid "" +"Choose how you want to position and scale the signature at the bottom of the " +"article." +msgstr "" +"Scegli come vuoi posizionare e scalare la firma che apparirà in fondo agli " +"articoli." + +#: inc/dnxasi-settings.php:99 +msgid "danixland Author Signature Settings" +msgstr "Impostazioni danixland Author Signature" + +#: inc/dnxasi-settings.php:102 +#, php-format +msgid "" +"To upload your signature image go to your profile page, " +"here on this page you can set up the general look of the signature trough " +"the website." +msgstr "" +"Per caricare la tua firma, visita il tuo profilo, in " +"questa pagina puoi configurare l'aspetto generale delle firme per questo " +"sito." + +#~ msgid "Insert" +#~ msgstr "Inserisci" diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..1847afd --- /dev/null +++ b/readme.txt @@ -0,0 +1,74 @@ +=== danixland author signature === +Contributors: danixland +Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PEBBHUDM8YAF8 +Tags: author, signature, custom, post +Requires at least: 4.0 +Tested up to: 4.5 +Stable tag: 1.1 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +A secure, simple yet powerful contact form for your website. + +== Description == + +**danixland-author-signature** is a very simple plugin that allows you to upload a signature image to be displayed at the bottom of blog posts in single view. + +The entire plugin is **translation ready** and ships with an italian translation, together with a .POT file to help you translate it in every language you may need. + +== Installation == + +1. Upload the plugin files to the `/wp-content/plugins/danixland-author-signature` directory, or install the plugin through the WordPress plugins screen directly. +1. Activate the plugin through the 'Plugins' screen in WordPress +1. Go to your profile page to upload your signature image. +1. browse to `Settings -> Author Signature` to setup the look and feel of the signature image as it will be displayed in single blog posts. + + +== Frequently Asked Questions == + += How can I style the plugin to look like my theme? = + +every tag that's output by the plugin has either a class or an id attached to it, so that you can style it the way you want it. + += I'm stuck with your plugin and don't seem to be able to customize it/make it work, can you help me? = + +Of course, you can ask for help on [the forums](http://wordpress.org/support/) or write a comment on the main article for this plugin on [my site](http://danixland.net/?p=3694), I'll reply ASAP ;) + += I'd like this plugin to be translated in my language, can you do this for me? = + +**danixland author signature** ships with a .POT file that can be used to create a translation of the plugin in your language, so if you're familiar with english you can help by providing a translation and it will be added to future versions of the plugin along with a link to your profile on these pages ;) + +To provide a translation simply edit the file "danixland-author-signature.pot" and fill every line with the traduction in your language, then save it as *yourlanguagecode.po* (E.G. it_IT.po for Italian), then contact me via the forums or my site and I'll tell you how to send this file to me. I'll add your translation ASAP. + +A number of softwares exists to help you with .po files, like [POEdit](https://poedit.net/) or [Lokalize](https://www.kde.org/applications/development/lokalize/ "for kde users") + +####If you have any other questions feel free to ask + +== Screenshots == + +1. The admin area menu showing the `Author Signature` option under the `Settings` menu. +2. The plugin settings page where you can adjust alignment and size of the signature image. +3. The bottom of the profile page, where you can upload your personal signature image. +4. Profile page bottom, displaying a preview of a signature +5. A signature as seen inside an article on the TwentyFifteen theme. + +== Changelog == + += 1.1 = +* Updated the plugin removal routine and fixed a small bug that allowed the signature to show up in every page on paginated posts instead of being displayed only on the last page. + += 1.0 = +* This is the first public release on the WordPress plugin directory. + +== Upgrade Notice == + += 1.1 = +* It is recommended that you upgrade since this update solves a few bugs in the code. + +== ToDo list == + +This list is actually empty, but I'm open to suggestions. + +== Translations == + +**danixland-author-signature** ships in English language with an optional Italian translation and a .POT template. If you want to contribute your own translation contact me and I'll add it. diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 0000000..dae27f9 --- /dev/null +++ b/uninstall.php @@ -0,0 +1,9 @@ +