Skip to content

Commit

Permalink
username prefix option, minor bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Tresso committed Nov 29, 2013
1 parent 6cbe4bb commit 567c77c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
30 changes: 15 additions & 15 deletions inc/admin.class.php
Expand Up @@ -12,22 +12,20 @@ class SWER_uploadplus_admin extends SWER_uploadplus_core {
* options header text
*/
static function upp_options_intro() {
$test_string = 'αι βασίλης και σύζηγος.jpeg';
$test_string = 'Ελληνικά language files.jpeg';
$demo_string = parent::upp_mangle_filename( $test_string );
?>
<div style="border:1px solid #eee; padding:.2em .5em; width:20%;" class="alignright">
<p><a href="http://wordpress.org/plugins/uploadplus/">UploadPlus</a> <?php _e( 'is mantained and developed by', 'uploadplus' ); ?><a href="http://swergroup.com" target="_blank">SWERgroup</a>, <?php _e( 'with the help of the open source community.', 'uploadplus' ); ?></p>

<ul>
<li><a href="http://wordpress.org/support/plugin/uploadplus/"><?php _e( 'Support forum on wordpress.org', 'uploadplus' ); ?></a>
<li><a href="http://github.com/swergroup/uploadplus/"><?php _e( 'Code repository on Github', 'uploadplus' ); ?></a>
<li><a href="https://travis-ci.org/swergroup/uploadplus"><?php _e( 'Build status on Travis CI', 'uploadplus' ); ?></a>
</ul>
<div style="border:1px solid #ddd; background:#eee; padding:2%; margin:1em 0; display:inline-block;">
<p><a href="http://wordpress.org/plugins/uploadplus/">UploadPlus</a> <?php _e( 'is released by ', 'uploadplus' ); ?><a href="http://swergroup.com" target="_blank">SWERgroup</a>. <?php _e( 'If you find this plugin useful feel free to ', 'uploadplus' ); ?> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=K9J3Y78FPD7KW"><?php _e( 'say thank you!', 'uploadplus' ); ?></a></p>

<p>
<a href="http://wordpress.org/support/plugin/uploadplus/"><?php _e( 'Support forum on wordpress.org', 'uploadplus' ); ?></a> &bull; <a href="http://github.com/swergroup/uploadplus/"><?php _e( 'Code repository on Github', 'uploadplus' ); ?></a>
&bull; <a href="https://travis-ci.org/swergroup/uploadplus"><?php _e( 'Build status on Travis CI', 'uploadplus' ); ?></a>
</p>

<p><?php _e( 'Found this plugin useful? Would like to thanks developers and support team? Need a new feature? Feel free to', 'uploadplus' ); ?> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=K9J3Y78FPD7KW"><?php _e( 'sponsor a coding session!', 'uploadplus' ); ?></a></p>
</div>

<p><?php _e( 'UploadPlus will clean and customize your uploads\' file and post name with your own style.', 'uploadplus' ); ?> <!-- You can preview how a file name will be cleaned using this tool: --><br>
<p><?php _e( 'UploadPlus clean and customize filenames with your favourite style:', 'uploadplus' ); ?> <!-- You can preview how a file name will be cleaned using this tool: --><br>
<ul>
<li><strong><?php _e( 'Separator', 'uploadplus' ); ?></strong> &mdash; <?php _e( 'change whitespaces into dashes or underscores.', 'uploadplus' ); ?></li>
<li><strong><?php _e( 'Case', 'uploadplus' ); ?></strong> &mdash; <?php _e( 'lowercase, UPPERCASE or CamelCase.', 'uploadplus' ); ?></li>
Expand Down Expand Up @@ -100,17 +98,18 @@ static function upp_options_box_customprefix(){
* setting box: standard prefix
*/
static function upp_options_box_prefix(){
global $sep;
global $sep, $current_user;
#$clean = get_option( 'uploadplus_separator' );
$prefix = get_option( 'uploadplus_prefix' );

get_currentuserinfo();

$datebased = array(
'1' => 'd (' . date( 'd' ) . $sep . ')',
'2' => 'md (' . date( 'md' ) . $sep . ')',
'3' => 'ymd (' . date( 'ymd' ) . $sep . ')"',
'4' => 'Ymd (' . date( 'Ymd' ) . $sep . ')',
'5' => 'YmdHi (' . date( 'YmdHi' ) . $sep . ')',
'6' => 'YmdHis (' . date( 'YmdHis' ) . $sep . ')',
# '5' => 'YmdHi (' . date( 'YmdHi' ) . $sep . ')',
# '6' => 'YmdHis (' . date( 'YmdHis' ) . $sep . ')',
'7' => 'unix timestamp (' . date( 'U' ) . $sep . ')',
);
$otherstyles = array(
Expand All @@ -119,6 +118,7 @@ static function upp_options_box_prefix(){
'10' => '['.__( 'Blog name', 'uploadplus' ).'] '.str_replace( array( '.', ' ', '-', '_' ) ,$sep, get_bloginfo( 'name' ) ).$sep,
'A' => '['.__( 'Short blog name', 'uploadplus' ).'] '.str_replace( array( '.', '_', '-', ' ' ), '', get_bloginfo( 'name' ) ).$sep,
'B' => __( 'WordPress unique filename', 'uploadplus' ),
'C' => 'username (' . $current_user->user_login . $sep . ')',
);

$nullval = ( $prefix == '' ) ? 'selected="selected"' : '';
Expand Down
36 changes: 27 additions & 9 deletions inc/core.class.php
Expand Up @@ -177,8 +177,22 @@ static function _clean_global( $file_name ){
* @param string $custom if not null, force a custom prefix
* @return string
*/
function _add_prefix( $file_name, $options = '', $custom = '' ){
global $sep;
static function _add_prefix( $file_name, $options = '', $custom = '' ){
global $current_user;
$option_sep = get_option( 'uploadplus_separator', true );
switch ( $option_sep ):
case 'dash' :
default:
$sep = '-';
break;
case 'space' :
$sep = ' ';
break;
case 'underscore':
$sep = '_';
break;
endswitch;

$options = ( $options == '' ) ? get_option( 'uploadplus_prefix' ) : $options;
$custom = ( $custom == '' ) ? get_option( 'uploadplus_customprefix' ) : $custom;

Expand All @@ -195,12 +209,12 @@ function _add_prefix( $file_name, $options = '', $custom = '' ){
case '4':
$file_name = date( 'Ymd' ) . $sep . $file_name;
break;
case '5':
$file_name = date( 'YmdHi' ).$sep . $file_name;
break;
case '6':
$file_name = date( 'YmdHis' ).$sep . $file_name;
break;
# case '5':
# $file_name = date( 'YmdHi' ).$sep . $file_name;
# break;
# case '6':
# $file_name = date( 'YmdHis' ).$sep . $file_name;
# break;
case '7':
$file_name = date( 'U' ) . $sep . $file_name;
break;
Expand All @@ -222,13 +236,17 @@ function _add_prefix( $file_name, $options = '', $custom = '' ){
$filename = wp_unique_filename( $dir, $file_name, null );
$file_name = $filename;
break;
case 'C':
get_currentuserinfo();
$file_name = $current_user->user_login . $sep . $file_name;
break;
default:
$file_name = $file_name;
break;
endswitch;

if ( $custom !== '' ):
$return_file_name = $custom.$file_name;
$return_file_name = $custom . $file_name;
else :
$return_file_name = $file_name;
endif;
Expand Down
4 changes: 2 additions & 2 deletions inc/wp-cli.class.php
@@ -1,6 +1,6 @@
<?php
/**
* Implements example command.
* UploadPlus command-line utilities
*
* @package wp-cli
*/
Expand Down Expand Up @@ -30,4 +30,4 @@ function full( $args ) {

}

WP_CLI::add_command( 'upplus', 'UploadPlus_Cmds' );
WP_CLI::add_command( 'uploadplus', 'UploadPlus_Cmds' );
6 changes: 5 additions & 1 deletion readme.txt
Expand Up @@ -50,11 +50,15 @@ GPL2&copy; 2008+ Paolo Tresso/[SWERgroup](http://swergroup.com/sviluppo/siti-int

== Changelog ==

= 3.3.0 =
= 3.3.1 =

* NEW username prefix option
* NEW random filename option
* NEW Wider WP compatibility tests (3.3.x, 3.4.x, 3.5.x, 3.6)
* NEW Wider PHP compatibility tests (5.2, 5.3, 5.4, 5.5)

= 3.3.0 =

* DEV Codesniffer + PHPlint pre-commit routines
* DEV PHPdoc descriptions
* DEV Fix PHP warnings and strict
Expand Down
4 changes: 2 additions & 2 deletions uploadplus.php
Expand Up @@ -4,7 +4,7 @@
Plugin URI: http://wordpress.org/extend/plugins/uploadplus/
Description: Clean file names and enhance security while uploading.
Author: SWERgroup
Version: 3.3.0-b3
Version: 3.3.1
Author URI: http://swergroup.com/
Copyright (C) 2007+ Paolo Tresso / SWERgroup (http://swergroup.com/)
Expand All @@ -28,7 +28,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

define( 'UPLOADPLUS_VERSION', '3.3.0-b3' );
define( 'UPLOADPLUS_VERSION', '3.3.1' );
define( 'UPLOADPLUS_PATH', plugin_dir_path( __FILE__ ) );

require_once UPLOADPLUS_PATH . '/lib/URLify.php';
Expand Down

0 comments on commit 567c77c

Please sign in to comment.