--- /dev/null
+.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
--- /dev/null
+<?php
+
+defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
+
+/*
+Plugin Name: danixland author signature
+Description: Enqueue a signature on your posts and pages.
+Plugin URI: http://danixland.net/?p=3694
+Version: 1.1
+Author: Danilo 'danix' Macrì
+Author URI: http://danixland.net
+License: GPL2
+License URI: https://www.gnu.org/licenses/gpl-2.0.html
+Text Domain: dnxasi
+
+*/
+
+/**
+ * Add plugin i18n domain: dnxasi
+ * @since 0.3
+ */
+load_plugin_textdomain('dnxasi', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
+
+/**
+ * Let's load our helper file ( utility functions )
+ * @since 1.1
+ */
+require( dirname( __FILE__ ) . '/inc/dnxasi_helper.php' );
+
+if ( is_admin()) {
+ require_once( dirname(__FILE__) . '/inc/dnxasi-settings.php' );
+}
+
+// enqueue our js for the modal uploader
+function dnxasi_enqueue_scripts($hook) {
+ wp_register_script( 'dnxasi_uploader_modal', plugins_url('/js/dnxasi_uploader_modal.js', __FILE__) );
+ $translation = array(
+ 'frameTitle' => __('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__);
+?>
+
+ <h2><?php _e( 'Profile signature', 'dnxasi' ); ?></h2>
+
+ <p><?php _e('if you don\'t select a signature image nothing will be displayed in the content of your posts or pages.', 'dnxasi'); ?></p>
+
+ <table class="form-table">
+
+ <tr>
+ <th><label for="dnxasi_meta_signature"><?php _e( 'add your signature image', 'dnxasi' ); ?></label></th>
+ <td>
+ <img id="dnxasi_signature_preview" src="<?php echo esc_url( $imagesrc ); ?>" style="width:450px"><br />
+ <!-- Outputs the text field and displays the URL of the image retrieved by the media uploader -->
+ <input type="text" name="dnxasi_meta_signature" id="dnxasi_meta_signature" value="<?php echo esc_url_raw( get_the_author_meta( 'dnxasi_meta_signature', $user->ID ) ); ?>" class="regular-text" readonly="readonly">
+ <!-- Outputs the save button -->
+ <input type='button' class="button-secondary" value="<?php _e( 'Select Signature', 'dnxasi' ); ?>" id="dnxasi_uploadimage">
+ <!-- Outputs the reset button -->
+ <input type='button' class="button-secondary" value="<?php _e( 'Remove Signature', 'dnxasi' ); ?>" id="dnxasi_deleteimage"><br>
+ <span class="description"><?php _e( 'Select and preview your signature image.', 'dnxasi' ); ?></span>
+ </td>
+ </tr>
+
+ </table><!-- end form-table -->
+<?php } // dnxasi_add_signature
+add_action( 'show_user_profile', 'dnxasi_add_signature' );
+add_action( 'edit_user_profile', 'dnxasi_add_signature' );
+
+/**
+* Saves additional user fields to the database
+*/
+function dnxasi_save_signature( $user_id ) {
+
+ // only saves if the current user can edit user profiles
+ if ( ! current_user_can( 'edit_user', $user_id ) )
+ return false;
+
+ update_usermeta( $user_id, 'dnxasi_meta_signature', $_POST['dnxasi_meta_signature'] );
+}
+
+add_action( 'personal_options_update', 'dnxasi_save_signature' );
+add_action( 'edit_user_profile_update', 'dnxasi_save_signature' );
+
+/**
+* Display the signature image only for authors who set it in the admin panel
+* and only in single view.
+*/
+function dnxasi_display_content($content) {
+ global $page;
+ $options = get_option('dnxasi_settings');
+ $signature = get_the_author_meta('dnxasi_meta_signature');
+ $alignment = ( ! empty($options['dnxasi_signature_position']) ) ? $options['dnxasi_signature_position'] : 'right';
+ $signature_size = ( ! empty($options['dnxasi_signature_size']) ) ? $options['dnxasi_signature_size'] : '300';
+ if ( is_single() && is_main_query() && ( '' != $signature ) ) {
+ if ( ! dnxasi_is_post_paginated() || ( $page === dnxasi_post_last_page() ) ) {
+ $new_content = '<figure class="dnxasi_signature"><img class="dnxasi_signature_image align' . $alignment . '" src="' . $signature . '" width="' . $signature_size . '" alt="' . get_the_author_meta('display_name') . '"></figure>';
+ $content .= $new_content;
+ }
+ }
+ return $content;
+}
+add_filter( 'the_content', 'dnxasi_display_content' );
--- /dev/null
+#, 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 <danix@danixland.net>\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 <small>(default)</small>"
+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 "
+"<strong>300px</strong> 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 <a href=\"%1$s\">profile page</a>, "
+"here on this page you can set up the general look of the signature trough "
+"the website."
+msgstr ""
--- /dev/null
+<?php
+add_action( 'admin_menu', 'dnxasi_add_admin_menu' );
+add_action( 'admin_init', 'dnxasi_settings_init' );
+
+function dnxasi_add_admin_menu() {
+ $dnxasi_settings_page = add_options_page( 'danixland author signature', 'Author Signature', 'manage_options', 'dnxasi', 'dnxasi_options_page' );
+ add_action( 'load-' . $dnxasi_settings_page, 'dnxasi_load_admin_scripts' );
+}
+
+function dnxasi_load_admin_scripts() {
+ add_action( 'admin_enqueue_scripts', 'dnxasi_enqueue_styles' );
+}
+
+// enqueue our scripts
+function dnxasi_enqueue_styles() {
+ wp_enqueue_style( 'dnxasi_admin_style', plugins_url('/css/dnxasi_admin_style.css', dirname(__FILE__)), array(), '0.1' );
+}
+
+
+function dnxasi_settings_init() {
+
+ register_setting( 'dnxasi_options', 'dnxasi_settings' );
+
+ add_settings_section(
+ 'dnxasi_pluginPage_section',
+ __( 'Global Signature positioning and sizing', 'dnxasi' ),
+ 'dnxasi_settings_section_callback',
+ 'dnxasi_options'
+ );
+
+ add_settings_field(
+ 'dnxasi_signature_position',
+ __( 'Signature alignment?', 'dnxasi' ),
+ 'dnxasi_signature_position_render',
+ 'dnxasi_options',
+ 'dnxasi_pluginPage_section'
+ );
+
+ add_settings_field(
+ 'dnxasi_signature_size',
+ __( 'signature width?', 'dnxasi' ),
+ 'dnxasi_signature_size_render',
+ 'dnxasi_options',
+ 'dnxasi_pluginPage_section'
+ );
+
+}
+
+
+function dnxasi_signature_position_render( ) {
+
+ $options = get_option( 'dnxasi_settings' );
+ ?>
+ <label class="description dnxasi_label">
+ <input type='radio' name='dnxasi_settings[dnxasi_signature_position]' <?php checked( $options['dnxasi_signature_position'], 'left' ); ?> value='left'>
+ <span>
+ <img src="<?php echo plugins_url('/img/signature-left.png', dirname(__FILE__)); ?>" alt="">
+ <?php _e('left', 'dnxasi'); ?>
+ </span>
+ </label>
+ <label class="description dnxasi_label">
+ <input type='radio' name='dnxasi_settings[dnxasi_signature_position]' <?php checked( $options['dnxasi_signature_position'], 'center' ); ?> value='center'>
+ <span>
+ <img src="<?php echo plugins_url('/img/signature-center.png', dirname(__FILE__)); ?>" alt="">
+ <?php _e('center', 'dnxasi'); ?>
+ </span>
+ </label>
+ <label class="description dnxasi_label">
+ <input type='radio' name='dnxasi_settings[dnxasi_signature_position]' <?php checked( $options['dnxasi_signature_position'], 'right' ); ?> value='right'>
+ <span>
+ <img src="<?php echo plugins_url('/img/signature-right.png', dirname(__FILE__)); ?>" alt="">
+ <?php _e('right <small>(default)</small>', 'dnxasi'); ?>
+ </span>
+ </label>
+ <?php
+
+}
+
+function dnxasi_signature_size_render ( ) {
+ $options = get_option( 'dnxasi_settings' );
+?>
+ <label class="description">
+ <input type="number" name="dnxasi_settings[dnxasi_signature_size]" min="1" max="1600" placeholder="300" value="<?php echo $options['dnxasi_signature_size']; ?>"> <?php _e('pixels', 'dnxasi'); ?><br>
+ </label>
+ <p class="description"><?php _e('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 <strong>300px</strong> will be used.', 'dnxasi'); ?></p>
+<?php
+}
+
+function dnxasi_settings_section_callback( ) {
+
+ echo __( 'Choose how you want to position and scale the signature at the bottom of the article.', 'dnxasi' );
+
+}
+
+
+function dnxasi_options_page( ) {
+
+ ?>
+ <h2><?php _e('danixland Author Signature Settings', 'dnxasi'); ?></h2>
+
+ <p class="description"><?php printf(
+ __('To upload your signature image go to your <a href="%1$s">profile page</a>, here on this page you can set up the general look of the signature trough the website.', 'dnxasi'),
+ admin_url('profile.php')
+ ); ?></p>
+
+ <form action='options.php' method='post'>
+
+ <?php
+ settings_fields( 'dnxasi_options' );
+ do_settings_sections( 'dnxasi_options' );
+ submit_button();
+ ?>
+
+ </form>
+ <?php
+
+}
--- /dev/null
+<?php
+/**
+ * Helper functions for danixland-author-signature
+ */
+
+
+/**
+ * Returns true if current post is paginated aka is split into pages using the <!--nextpage--> 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
--- /dev/null
+/*
+ * 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);
+ });
+
+});
--- /dev/null
+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 <danix@danixland.net>\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 <small>(default)</small>"
+msgstr "destra <small>(default)</small>"
+
+#: 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 "
+"<strong>300px</strong> 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 <strong>300px</strong>."
+
+#: 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 <a href=\"%1$s\">profile page</a>, "
+"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 <a href=\"%1$s\">tuo profilo</a>, in "
+"questa pagina puoi configurare l'aspetto generale delle firme per questo "
+"sito."
+
+#~ msgid "Insert"
+#~ msgstr "Inserisci"
--- /dev/null
+=== 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.
--- /dev/null
+<?php
+//if uninstall not called from WordPress exit
+if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
+ exit();
+
+// delete our metadata for all users
+delete_metadata( 'user', 0, 'dnxasi_meta_signature', '', true );
+// delete options for our plugin from the options table
+delete_option( 'dnxasi_settings' );