Changeset 1344967
- Timestamp:
- 02/07/2016 04:01:56 AM (10 years ago)
- Location:
- add-new-default-avatar
- Files:
-
- 4 added
- 3 edited
-
tags/1.4 (added)
-
tags/1.4/anda.js (added)
-
tags/1.4/kl_addnewdefaultavatar.php (added)
-
tags/1.4/readme.txt (added)
-
trunk/anda.js (modified) (1 diff)
-
trunk/kl_addnewdefaultavatar.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
add-new-default-avatar/trunk/anda.js
r640949 r1344967 1 1 jQuery(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(); 5 5 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(); 8 12 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 ); 12 15 13 $row2 = $row2.replace( regex, k );14 $(this).before( $row2 );15 return false;16 16 }); 17 17 }); -
add-new-default-avatar/trunk/kl_addnewdefaultavatar.php
r640953 r1344967 5 5 Description: Add new option to the Default Avatar list. 6 6 Author: Kailey Lampert 7 Version: 1. 3.17 Version: 1.4 8 8 Author URI: http://kaileylampert.com/ 9 9 */ 10 10 /* 11 Copyright (C) 2011-1 2Kailey Lampert11 Copyright (C) 2011-16 Kailey Lampert 12 12 13 13 This program is free software: you can redistribute it and/or modify … … 25 25 */ 26 26 27 new Add_New_Default_Avatar( );27 $add_new_default_avatar = new Add_New_Default_Avatar( ); 28 28 29 29 class Add_New_Default_Avatar { 30 30 31 31 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' ) ); 34 34 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 ); 40 39 } 41 40 … … 64 63 65 64 //if the current wasn't created by this plugin, update the backup 66 if ( ! in_array( $current, $unavailable ) ) 65 if ( ! in_array( $current, $unavailable ) ) { 67 66 update_option( 'pre_anda_avatar_default', $current ); 67 } 68 68 69 69 } … … 76 76 function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) { 77 77 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>'; 79 79 return $actions; 80 80 } 81 81 82 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() ); 84 85 } 85 86 86 87 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%' ) ) ); 88 89 89 90 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>'; 93 96 } 94 97 95 98 $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>'; 99 103 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>'; 101 107 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' ) ); 103 110 104 111 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 ) ); 106 123 107 124 } … … 150 167 $local_avatars = get_user_meta( $user_id, 'simple_local_avatar', true ); 151 168 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 ); 153 170 return $avatar; 154 171 } … … 175 192 } 176 193 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 183 194 } -
add-new-default-avatar/trunk/readme.txt
r640955 r1344967 1 1 === Add New Default Avatar === 2 Contributors: trepmal 2 Contributors: trepmal 3 3 Donate link: http://kaileylampert.com/donate 4 4 Tags: avatar, gravatar 5 5 Requires at least: 2.8 6 Tested up to: 3.57 Stable tag: 1. 3.16 Tested up to: 4.4 7 Stable tag: 1.4 8 8 9 Add new option to the Default Avatar list. 9 Add new option to the Default Avatar list. 10 10 11 11 == Description == … … 32 32 == Changelog == 33 33 34 = 1.4 = 35 * Behind the scenes clean up 36 34 37 = 1.3.1 = 35 38 * Quick fix a few errors on fresh installs
Note: See TracChangeset
for help on using the changeset viewer.