Skip to content

Commit

Permalink
Merge pull request #33 from petenelson/rc-1.6.0
Browse files Browse the repository at this point in the history
Rc 1.6.0
  • Loading branch information
petenelson authored Feb 24, 2017
2 parents cd46402 + b982514 commit 09365c3
Show file tree
Hide file tree
Showing 25 changed files with 1,843 additions and 335 deletions.
12 changes: 9 additions & 3 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ engines:
checks:
Controversial/CamelCaseClassName:
enabled: false
CleanCode/ElseExpression:
enabled: false
Controversial/CamelCaseParameterName:
enabled: false
Controversial/CamelCaseVariableName:
enabled: false
Controversial/CamelCaseMethodName:
enabled: false
Controversial/CamelCaseVariableName:
Controversial/CamelCasePropertyName:
enabled: false
CleanCode/ElseExpression:
enabled: false
CleanCode/StaticAccess:
enabled: false
Naming/ShortVariable:
enabled: false
ratings:
paths:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
/.phpintel
/npm-debug.log
/node_modules
Expand Down
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ matrix:
env: WP_VERSION=4.4
- php: 5.6
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=4.4
- php: 7.0
env: WP_VERSION=latest

install:
- composer self-update && composer --version
Expand Down
5 changes: 2 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module.exports = function( grunt ) {

require('phplint').gruntPlugin(grunt);

grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),

Expand Down Expand Up @@ -114,7 +112,8 @@ module.exports = function( grunt ) {
'grunt-wp-i18n',
'grunt-potomo',
'grunt-wp-readme-to-markdown',
'grunt-insert'
'grunt-insert',
'grunt-phplint'
];

for ( var i = 0; i < tasks.length; i++ ) {
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
**Donate link:** https://petenelson.com/
**Requires at least:** 4.4
**Tested up to:** 4.7
**Stable tag:** 1.5.0
**Stable tag:** 1.6.0
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

[![Code Climate](https://codeclimate.com/github/petenelson/dashboard-directory-size/badges/gpa.svg)](https://codeclimate.com/github/petenelson/dashboard-directory-size)
[![Test Coverage](https://codeclimate.com/github/petenelson/dashboard-directory-size/badges/coverage.svg)](https://codeclimate.com/github/petenelson/dashboard-directory-size/coverage)
[![Travis CS](https://api.travis-ci.org/petenelson/dashboard-directory-size.svg)](https://travis-ci.org/petenelson/dashboard-directory-size)


Dashboard widget to display directory sizes
Expand All @@ -31,6 +29,10 @@ Find us on [GitHub](https:/petenelson/dashboard-directory-size)

## Changelog ##

### v1.6.0 February 24, 2017 ###
* Added a setting for number of decimal places when displaying sizes.
* Added ability to show a sum of all items.

### v1.5.0 June 17, 2016 ###
* Viewing/refreshing directory sizes from the dahsboard widget is now done via an async REST API request

Expand All @@ -55,13 +57,13 @@ Find us on [GitHub](https:/petenelson/dashboard-directory-size)

## Upgrade Notice ##

### v1.6.0 February 24, 2017 ###
* Added a setting for number of decimal places when displaying sizes.
* Added ability to show a sum of all items.

### v1.5.0 June 17, 2016 ###
* Viewing/refreshing directory sizes from the dahsboard widget is now done via an async REST API request

### v1.4.0 April 27, 2016 ###
* Added WP-CLI support: wp dashboard-directory-size
* Added German translations (thanks Gahapati)


## Frequently Asked Questions ##

Expand Down
43 changes: 39 additions & 4 deletions admin/js/dashboard-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@

populateSizes: function( refresh ) {
var self = this;
self.table.find( '.cell-size-needed' ).each( function() {

var cellSum = this.table.find( '.cell-sum' );
cellSum.find( '.spinner' ).addClass( 'is-active' ).removeClass( 'hidden' );
cellSum.find( '.size' ).text( '' );

self.table.find( '.cell-size-data' ).each( function() {
var el = $( this );
el.find( '.spinner' ).addClass( 'is-active' ).removeClass( 'hidden' );
el.find( '.size' ).html( '' );
el.find( '.size' ).text( '' );
el.removeClass( 'cell-has-size' ).addClass( 'cell-size-needed' );
self.getSize( el, refresh );
} );

Expand Down Expand Up @@ -76,9 +82,38 @@

populateSize: function( el, response ) {
if ( response ) {
el.find( '.spinner' ).removeClass( 'is-active' ).addClass( 'hidden' )
el.find( '.size' ).html( response.size_friendly );
el.find( '.spinner' ).removeClass( 'is-active' ).addClass( 'hidden' );
el.find( '.size' ).text( response.size_friendly ).data( 'size', response.size );
el.addClass( 'cell-has-size' ).removeClass( 'cell-size-needed' );
Dashboard_Directory_Size.updateTotalSize();
}
},

updateTotalSize: function() {

if ( this.table.find( '.cell-size-needed' ).length > 0 ) {
return;
}

var totalSize = 0;
this.table.find( '.cell-has-size' ).each( function() {
totalSize += parseInt( $(this).find( '.size' ).data( 'size' ) );
} );

var self = this;

$.ajax( {
url: Dashboard_Directory_Size_Settings.endpoints.size_format,
method: 'GET',
data: { "size":totalSize },
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', Dashboard_Directory_Size_Settings.nonce );
}
} ).done( function( response ) {
var cellSum = self.table.find( '.cell-sum' );
cellSum.find( '.spinner' ).removeClass( 'is-active' ).addClass( 'hidden' );
cellSum.find( '.size' ).text( response.size_friendly );
} );
}

};
Expand Down
2 changes: 1 addition & 1 deletion admin/partials/admin-help.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="dashboard-directory-size-help">

<h3 class="title"><?php _e( 'Contact', 'dashboard-directory-size' ); ?></h3>
<h3 class="title"><?php esc_html_e( 'Contact', 'dashboard-directory-size' ); ?></h3>
<p>
<?php esc_html_e( 'E-Mail', 'dashboard-directory-size' ) ?>: <a href="mailto:[email protected]">[email protected]</a><br/>
<?php esc_html_e( 'Twitter', 'dashboard-directory-size' ) ?>: <a href="https://twitter.com/GunGeekATX" target="_blank">@GunGeekATX</a><br/>
Expand Down
2 changes: 0 additions & 2 deletions badges.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

[![Code Climate](https://codeclimate.com/github/petenelson/dashboard-directory-size/badges/gpa.svg)](https://codeclimate.com/github/petenelson/dashboard-directory-size)
[![Test Coverage](https://codeclimate.com/github/petenelson/dashboard-directory-size/badges/coverage.svg)](https://codeclimate.com/github/petenelson/dashboard-directory-size/coverage)
[![Travis CS](https://api.travis-ci.org/petenelson/dashboard-directory-size.svg)](https://travis-ci.org/petenelson/dashboard-directory-size)
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"require-dev": {
"squizlabs/php_codesniffer": "^2.5",
"wp-coding-standards/wpcs": "2014-12-11",
"wp-coding-standards/wpcs": "dev-master",
"phpunit/phpunit": "^4.8",
"codeclimate/php-test-reporter": "^0.3.0",
"behat/behat": "~2.5"
"behat/behat": "~2.5",
"10up/wp_mock": "dev-master"
}
}
64 changes: 14 additions & 50 deletions dashboard-directory-size.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,28 @@
Plugin Name: Dashboard Directory Size
Description: Dashboard widget to display directory sizes
Author: Pete Nelson <a href="https://twitter.com/GunGeekATX">(@GunGeekATX)</a>
Version: 1.5.0
Version: 1.6.0
Text Domain: dashboard-directory-size
Domain Path: /languages
*/

if ( ! defined( 'ABSPATH' ) ) die( 'restricted access' );

class Dashboard_Directory_Size_Plugin {

function define_constants() {
if ( ! defined( 'DASHBOARD_DIRECOTRY_SIZE_ROOT' ) ) {
define( 'DASHBOARD_DIRECOTRY_SIZE_ROOT', trailingslashit( dirname( __FILE__ ) ) );
}
}

function get_required_files() {
$include_files = array( 'common', 'i18n', 'settings', 'dashboard-widget', 'rest-api' );
$files = array();
foreach ( $include_files as $include_file ) {
$files[] = DASHBOARD_DIRECOTRY_SIZE_ROOT . 'includes/class-dashboard-directory-size-' . $include_file . '.php';
}
return $files;
}

function get_class_names() {
return array(
'Dashboard_Directory_Size_Common',
'Dashboard_Directory_Size_i18n',
'Dashboard_Directory_Size_Settings',
'Dashboard_Directory_Size_Dashboard_Widget',
'Dashboard_Directory_Size_REST_API',
);
}

function require_files( $files ) {
foreach( $files as $file ) {
require_once $file;
}
}

}

$plugin = new Dashboard_Directory_Size_Plugin();
$plugin->define_constants();
$plugin->require_files( $plugin->get_required_files() );

// load plugin classes
foreach( $plugin->get_class_names() as $class_name ) {
$classes = array();
if ( class_exists( $class_name ) ) {
$classes[] = new $class_name;
}

foreach ( $classes as $class ) {
add_action( 'plugins_loaded', array( $class, 'plugins_loaded' ) );
}
if ( ! defined( 'DASHBOARD_DIRECOTRY_SIZE_ROOT' ) ) {
define( 'DASHBOARD_DIRECOTRY_SIZE_ROOT', trailingslashit( dirname( __FILE__ ) ) );
}

require_once DASHBOARD_DIRECOTRY_SIZE_ROOT . 'includes/class-dashboard-directory-size-common.php';
require_once DASHBOARD_DIRECOTRY_SIZE_ROOT . 'includes/class-dashboard-directory-size-i18n.php';
require_once DASHBOARD_DIRECOTRY_SIZE_ROOT . 'includes/class-dashboard-directory-size-settings.php';
require_once DASHBOARD_DIRECOTRY_SIZE_ROOT . 'includes/class-dashboard-directory-size-dashboard-widget.php';
require_once DASHBOARD_DIRECOTRY_SIZE_ROOT . 'includes/class-dashboard-directory-size-rest-api.php';

add_action( 'plugins_loaded', 'Dashboard_Directory_Size_i18n::plugins_loaded' );
add_action( 'plugins_loaded', 'Dashboard_Directory_Size_Common::plugins_loaded' );
add_action( 'plugins_loaded', 'Dashboard_Directory_Size_Dashboard_Widget::plugins_loaded' );
add_action( 'plugins_loaded', 'Dashboard_Directory_Size_Settings::plugins_loaded' );
add_action( 'plugins_loaded', 'Dashboard_Directory_Size_REST_API::plugins_loaded' );

// handler for activation
if ( class_exists( 'Dashboard_Directory_Size_Settings' ) ) {
Expand Down
Loading

0 comments on commit 09365c3

Please sign in to comment.