Plugin Directory

Changeset 1344967


Ignore:
Timestamp:
02/07/2016 04:01:56 AM (10 years ago)
Author:
trepmal
Message:

tag 1.4

Location:
add-new-default-avatar
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • add-new-default-avatar/trunk/anda.js

    r640949 r1344967  
    11jQuery(document).ready( function($) {
    2     var $row = $('#add_new_default_avatar').html();
    3     $('#add_new_default_avatar').click( function () {
    4         $row2 = '<p>' + $row + '</p>';
     2    var $row = $( document.getElementById('add_new_default_avatar') ).html();
     3    $( document.getElementById('add_new_default_avatar_add') ).on('click', function (event) {
     4        event.preventDefault();
    55
    6         //get original unique id
    7         var regex = new RegExp( $('#add_new_default_avatar_garbage').val(), "g");
     6        var $row2 = '<p>' + $row + '</p>',
     7            //get original unique id
     8            regex = new RegExp( ANDA.uniqid, "g"),
     9            //replace with time-generated one
     10            newDate = new Date,
     11            key = newDate.getTime();
    812
    9         //replace with time-generated one
    10         var newDate = new Date;
    11         k = newDate.getTime();
     13        $row2 = $row2.replace( regex, key );
     14        $(this).before( $row2 );
    1215
    13         $row2 = $row2.replace( regex, k );
    14         $(this).before( $row2 );
    15         return false;
    1616    });
    1717});
  • add-new-default-avatar/trunk/kl_addnewdefaultavatar.php

    r640953 r1344967  
    55Description: Add new option to the Default Avatar list.
    66Author: Kailey Lampert
    7 Version: 1.3.1
     7Version: 1.4
    88Author URI: http://kaileylampert.com/
    99*/
    1010/*
    11     Copyright (C) 2011-12 Kailey Lampert
     11    Copyright (C) 2011-16 Kailey Lampert
    1212
    1313    This program is free software: you can redistribute it and/or modify
     
    2525*/
    2626
    27 new Add_New_Default_Avatar( );
     27$add_new_default_avatar = new Add_New_Default_Avatar( );
    2828
    2929class Add_New_Default_Avatar {
    3030
    3131    function __construct( ) {
    32         add_filter( 'init' , array( &$this , 'init' ), 9 );
    33         register_deactivation_hook( __FILE__, array( &$this, 'deactivate' ) );
     32        add_filter( 'init' ,                  array( $this , 'init' ), 9 );
     33        register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
    3434
    35         add_filter( 'plugin_action_links_'. plugin_basename( __FILE__ ), array( &$this, 'plugin_action_links' ), 10, 4 );
    36         add_filter( 'admin_init' , array( &$this , 'admin_init' ) );
    37         add_filter( 'avatar_defaults' , array( &$this , 'avatar_defaults' ) );
    38         add_filter( 'get_avatar', array( &$this, 'get_avatar' ), 10, 5 );
    39         add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
     35        add_filter( 'plugin_action_links_'. plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ), 10, 4 );
     36        add_filter( 'admin_init' ,            array( $this, 'admin_init' ) );
     37        add_filter( 'avatar_defaults' ,       array( $this, 'avatar_defaults' ) );
     38        add_filter( 'get_avatar',             array( $this, 'get_avatar' ), 10, 5 );
    4039    }
    4140
     
    6463
    6564        //if the current wasn't created by this plugin, update the backup
    66         if ( ! in_array( $current, $unavailable ) )
     65        if ( ! in_array( $current, $unavailable ) ) {
    6766            update_option( 'pre_anda_avatar_default', $current );
     67        }
    6868
    6969    }
     
    7676    function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
    7777        if ( is_plugin_active( $plugin_file ) )
    78             $actions[] = '<a href="' . admin_url('options-discussion.php#add_new_default_avatar') . '">Setup</a>';
     78            $actions[] = '<a href="' . admin_url('options-discussion.php#add_new_default_avatar') . '">'. __( 'Setup', 'anda' ) .'</a>';
    7979        return $actions;
    8080    }
     81
    8182    function admin_init() {
    82         register_setting( 'discussion', 'add_new_default_avatar', array( &$this, 'validate') );
    83         add_settings_field('add_new_default_avatar', __('Add New Default Avatar' , 'anda' ) , array( &$this, 'field_html') , 'discussion', 'avatars', $args = array() );
     83        register_setting( 'discussion', 'add_new_default_avatar', array( $this, 'validate') );
     84        add_settings_field('add_new_default_avatar', __( 'Add New Default Avatar' , 'anda' ) , array( $this, 'field_html') , 'discussion', 'avatars', $args = array() );
    8485    }
    8586
    8687    function field_html() {
    87         $value = get_option( 'add_new_default_avatar', array( array( 'name' => 'Custom Avatar', 'url' => 'http://colorto.me/png/%size%/row2/purple/yellow/orange/blue.png' ) ) );
     88        $value = get_option( 'add_new_default_avatar', array( array( 'name' => 'Custom Avatar', 'url' => 'http://placehold.it/%size%/%size%' ) ) );
    8889
    8990        foreach( $value as $k => $pair ) {
    90             extract( $pair );
    91             echo "<p><input type='text' name='add_new_default_avatar[$k][name]' value='$name' size='15' />";
    92             echo "<input type='text' name='add_new_default_avatar[$k][url]' value='$url' size='35' /></p>";
     91            extract( $pair ); // $url, $name
     92            echo '<p>';
     93            echo "<input type='text' name='add_new_default_avatar[$k][name]' value='$name' size='15' />";
     94            echo "<input type='text' name='add_new_default_avatar[$k][url]' value='$url' size='35' />";
     95            echo '</p>';
    9396        }
    9497
    9598        $uid = uniqid();
    96         echo "<input type='hidden' id='add_new_default_avatar_garbage' value='$uid' />";
    97         echo "<p id='add_new_default_avatar'><input type='text' name='add_new_default_avatar[$uid][name]' value='' size='15' />";
    98         echo "<input type='text' name='add_new_default_avatar[$uid][url]' value='' size='35' /></p>";
     99        echo '<p id="add_new_default_avatar">';
     100        echo "<input type='text' name='add_new_default_avatar[$uid][name]' value='' size='15' />";
     101        echo "<input type='text' name='add_new_default_avatar[$uid][url]' value='' size='35' />";
     102        echo '</p>';
    99103
    100         echo "<a href='#' id='add_new_default_avatar_add' class='hide-if-no-js'>Add another</a>";
     104        echo '<a href="#" id="add_new_default_avatar_add" class="hide-if-no-js">';
     105        esc_html_e( __( 'Add another', 'anda' ) );
     106        echo '</a>';
    101107
    102         echo '<p>' . __( 'Some themes won\'t resize your image to fit, so it\'s best to use an image that\'s already the right size.', 'anda' );
     108        echo '<p>';
     109        esc_html_e( __( 'Some themes won\'t resize your image to fit, so it\'s best to use an image that\'s already the right size.', 'anda' ) );
    103110
    104111        echo '<br />';
    105         echo sprintf( __( 'However if your image accepts a size argument, you can use %1$s. Example: %2$s', 'anda' ), '<code>%size%</code>', '<code>http://colorto.me/png/%size%/row2/purple/yellow/orange/blue.png</code>' ) . '</p>';
     112        echo sprintf(
     113            __( 'However if your image accepts a size argument, you can use %1$s. Example: %2$s', 'anda' ),
     114            '<code>%size%</code>',
     115            '<code>http://placehold.it/%size%/%size%</code>'
     116        );
     117        echo '</p>';
     118
     119        wp_enqueue_script( 'anda', plugins_url( 'anda.js', __FILE__ ), array('jquery'), '1.4', true );
     120        wp_localize_script( 'anda', 'ANDA', array(
     121            'uniqid' => $uid
     122        ) );
    106123
    107124    }
     
    150167        $local_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
    151168        if ( ! empty( $local_avatars ) && ( isset( $GLOBALS['hook_suffix'] ) && $GLOBALS['hook_suffix'] != 'options-discussion.php' ) ) {
    152             remove_filter( 'get_avatar', array( &$this, 'get_avatar' ), 88, 5 );
     169            remove_filter( 'get_avatar', array( $this, 'get_avatar' ), 88, 5 );
    153170            return $avatar;
    154171        }
     
    175192    }
    176193
    177     function admin_enqueue_scripts( $hook ) {
    178         if ( $hook != 'options-discussion.php' ) return;
    179         wp_enqueue_script( 'jquery' );
    180         wp_enqueue_script( 'anda', plugins_url( 'anda.js', __FILE__ ), array('jquery'), '', true );
    181     }
    182 
    183194}
  • add-new-default-avatar/trunk/readme.txt

    r640955 r1344967  
    11=== Add New Default Avatar ===
    2 Contributors: trepmal 
     2Contributors: trepmal
    33Donate link: http://kaileylampert.com/donate
    44Tags: avatar, gravatar
    55Requires at least: 2.8
    6 Tested up to: 3.5
    7 Stable tag: 1.3.1
     6Tested up to: 4.4
     7Stable tag: 1.4
    88
    9 Add new option to the Default Avatar list. 
     9Add new option to the Default Avatar list.
    1010
    1111== Description ==
     
    3232== Changelog ==
    3333
     34= 1.4 =
     35* Behind the scenes clean up
     36
    3437= 1.3.1 =
    3538* Quick fix a few errors on fresh installs
Note: See TracChangeset for help on using the changeset viewer.