Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
contactjavas committed Oct 9, 2019
1 parent a522880 commit 7fc1c31
Show file tree
Hide file tree
Showing 19 changed files with 251 additions and 254 deletions.
30 changes: 15 additions & 15 deletions helpers/class-admin-ajax-helper.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
/**
* Admin ajax interfaces
* Admin ajax helper.
*
* @package WPFW
*/

namespace Wpfw\Helpers;

/**
* Class to provide admin ajax methods
* Class to provide admin ajax methods.
*/
class Admin_Ajax_Helper {

Expand All @@ -20,47 +20,47 @@ class Admin_Ajax_Helper {
private $id = -1;

/**
* Item's container
* Item's container.
*
* @var array
*/
private $item = [];
private $items = [];

/**
* Register action
* Register action.
*
* @param string $action Action to be registered to wp_ajax_ .
* @param string $action Action to be registered to wp_ajax_.
* @return object
*/
public function register( $action ) {
$this->id++;
$this->item[ $this->id ] = [];
$this->item[ $this->id ]['action'] = $action;
$this->item[ $this->id ]['is_private'] = true;
$this->items[ $this->id ] = [];
$this->items[ $this->id ]['action'] = $action;
$this->items[ $this->id ]['is_private'] = true;
return $this;
}

/**
* Set the request as public
* Set the request as public.
*
* @return object
*/
public function set_public() {
$this->item[ $this->id ]['is_private'] = false;
$this->items[ $this->id ]['is_private'] = false;
return $this;
}

/**
* Set handler class for the request
* Set handler class for the request.
*
* @param object $handler Class to handle the request.
* @return void
*/
public function set_handler( $handler ) {
add_action( 'wp_ajax_' . $this->item[ $this->id ]['action'], [ $handler, 'ajax' ] );
add_action( 'wp_ajax_' . $this->items[ $this->id ]['action'], [ $handler, 'ajax' ] );

if ( ! $this->item[ $this->id ]['is_private'] ) {
add_action( 'wp_ajax_nopriv_' . $this->item[ $this->id ]['action'], [ $handler, 'ajax' ] );
if ( ! $this->items[ $this->id ]['is_private'] ) {
add_action( 'wp_ajax_nopriv_' . $this->items[ $this->id ]['action'], [ $handler, 'ajax' ] );
}
}
}
42 changes: 21 additions & 21 deletions helpers/class-css-helper.php
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
<?php
/**
* CSS enqueue interfaces
* CSS enqueue helper.
*
* @package WPFW
*/

namespace Wpfw\Helpers;

/**
* Class to provide stylesheet enqueue methods
* Class to provide stylesheet enqueue methods.
*/
class CSS_Helper {

/**
* Item's id
* Item's id.
*
* @var integer
*/
private $id = -1;

/**
* Item's container
* Item's container.
*
* @var array
*/
private $item = [];
private $items = [];

/**
* Register the stylesheet handle name
* Register the stylesheet handle name.
*
* @param string $handle Name of the stylesheet. Should be unique.
* @return object
*/
public function register( $handle ) {
$this->id++;
$this->item[ $this->id ] = [];
$this->item[ $this->id ]['handle'] = $handle;
$this->items[ $this->id ] = [];
$this->items[ $this->id ]['handle'] = $handle;
return $this;
}

/**
* Set the stylesheet url
* Set the stylesheet url.
*
* @param string $url Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.
* @return object
*/
public function set_url( $url ) {
$this->item[ $this->id ]['url'] = $url;
$this->items[ $this->id ]['url'] = $url;
return $this;
}

/**
* Set the stylesheet dependencies
* Set the stylesheet dependencies.
*
* @param array $deps An array of registered stylesheet handles which this stylesheet depends on.
* @return object
*/
public function set_dependencies( $deps ) {
$this->item[ $this->id ]['deps'] = $deps;
$this->items[ $this->id ]['deps'] = $deps;
return $this;
}

/**
* Set the stylesheet version
* Set the stylesheet version.
*
* @param string $ver String specifying stylesheet version number.
* @return object
*/
public function set_version( $ver ) {
$this->item[ $this->id ]['ver'] = $ver;
$this->items[ $this->id ]['ver'] = $ver;
return $this;
}

/**
* Register the stylesheet to WP
* Register the stylesheet to WP.
*
* @return void
*/
public function save() {
$handle = $this->item[ $this->id ]['handle'];
$url = $this->item[ $this->id ]['url'];
$deps = isset( $this->item[ $this->id ]['deps'] ) ? $this->item[ $this->id ]['deps'] : [];
$ver = isset( $this->item[ $this->id ]['ver'] ) ? $this->item[ $this->id ]['ver'] : null; // remove default WordPress version for security.
$handle = $this->items[ $this->id ]['handle'];
$url = $this->items[ $this->id ]['url'];
$deps = isset( $this->items[ $this->id ]['deps'] ) ? $this->items[ $this->id ]['deps'] : [];
$ver = isset( $this->items[ $this->id ]['ver'] ) ? $this->items[ $this->id ]['ver'] : null; // remove default WordPress version for security.
$ver = $ver && 'auto' === $ver ? Asset::get_modified_time( $url ) : $ver;

wp_register_style( $handle, $url, $deps, $ver );
}

/**
* Enqueue the stylesheet
* Enqueue the stylesheet.
*
* @param string $handle Name of the stylesheet. Should be unique.
* @return void
Expand All @@ -98,7 +98,7 @@ public function enqueue( $handle = false ) {
wp_enqueue_style( $handle );
} else {
$this->save();
wp_enqueue_style( $this->item[ $this->id ]['handle'] );
wp_enqueue_style( $this->items[ $this->id ]['handle'] );
}
}

Expand Down
20 changes: 10 additions & 10 deletions helpers/class-file-helper.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php
/**
* File helper interfaces
* File operation helper.
*
* @package WPFW
*/

namespace Wpfw\Helpers;

/**
* Class to provide file helper methods
* Class to provide file helper methods.
*
* @todo Many operations are phpcs-ignored, need to find proper solution
* @todo Many operations are phpcs-ignored, need to find proper solution.
*/
class File_Helper {

/**
* Maximum scan depth
* Maximum scan depth.
*
* @var integer
*/
protected $max_scan_depth = 5;

/**
* Copy a file, or recursively copy a folder and its contents
* Copy a file, or recursively copy a folder and its contents.
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.1
Expand All @@ -32,7 +32,7 @@ class File_Helper {
* @param string $dest Destination path.
* @param int $permissions New folder creation permissions.
*
* @return bool Returns true on success, false on failure
* @return bool Returns true on success, false on failure.
*/
public function copy( $source, $dest, $permissions = 0755 ) {
// check for symlinks.
Expand Down Expand Up @@ -89,7 +89,7 @@ public function remove_dir( $dir ) {
}

/**
* Empty a directory
* Empty a directory.
*
* @param string $dir The directory path.
* @return void
Expand Down Expand Up @@ -147,7 +147,7 @@ protected function scan_dir( $type, $dir, $depth ) {
}

/**
* Load components
* Load components.
*
* @param string $dir The directory path.
* @param integer $max_depth Maximum depth to scan.
Expand All @@ -163,7 +163,7 @@ public function load_components( $dir, $max_depth = 1 ) {
}

/**
* Include all files
* Include all files.
*
* @param string $dir The directory path.
* @param integer $max_depth Maximum depth to scan.
Expand All @@ -179,7 +179,7 @@ public function include_all( $dir, $max_depth = 1 ) {
}

/**
* Require all files
* Require all files.
*
* @param string $dir The directory path.
* @param integer $max_depth Maximum depth to scan.
Expand Down
38 changes: 19 additions & 19 deletions helpers/class-image-size-helper.php
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
<?php
/**
* Image size utility
* Image size helper.
*
* @package WPFW
*/

namespace Wpfw\Helpers;

/**
* Class to add image size
* Class to add image size.
*/
class Image_Size_Helper {

/**
* Item's id
* Item's id.
*
* @var integer
*/
private $id = -1;

/**
* Item's container
* Item's container.
*
* @var array
*/
private $item = [];
private $items = [];

/**
* Register image size
* Register image size.
*
* @param string $size_name Image size identifier.
* @return object
*/
public function register( $size_name ) {
$this->id++;
$this->item[ $this->id ] = [];
$this->item[ $this->id ]['name'] = $size_name;
$this->items[ $this->id ] = [];
$this->items[ $this->id ]['name'] = $size_name;
return $this;
}

/**
* Set the width
* Set the width.
*
* @param int $width Image width in pixels.
* @return object
*/
public function set_width( $width ) {
$this->item[ $this->id ]['width'] = $width;
$this->items[ $this->id ]['width'] = $width;
return $this;
}

/**
* Set the height
* Set the height.
*
* @param int $height Image height in pixels.
* @return object
*/
public function set_height( $height ) {
$this->item[ $this->id ]['height'] = $height;
$this->items[ $this->id ]['height'] = $height;
return $this;
}

/**
* Set the crop mode
* Set the crop mode.
*
* @param boolean $crop Whether to crop images to specified width and height or resize.
* @return object
*/
public function set_crop( $crop = true ) {
$this->item[ $this->id ]['crop'] = $crop;
$this->items[ $this->id ]['crop'] = $crop;
return $this;
}

/**
* Add the registered size
* Add the registered size.
*
* @return void
*/
public function add() {
$name = $this->item[ $this->id ]['name'];
$width = isset( $this->item[ $this->id ]['width'] ) ? $this->item[ $this->id ]['width'] : 9999;
$height = isset( $this->item[ $this->id ]['height'] ) ? $this->item[ $this->id ]['height'] : 9999;
$crop = isset( $this->item[ $this->id ]['crop'] ) ? $this->item[ $this->id ]['crop'] : false;
$name = $this->items[ $this->id ]['name'];
$width = isset( $this->items[ $this->id ]['width'] ) ? $this->items[ $this->id ]['width'] : 9999;
$height = isset( $this->items[ $this->id ]['height'] ) ? $this->items[ $this->id ]['height'] : 9999;
$crop = isset( $this->items[ $this->id ]['crop'] ) ? $this->items[ $this->id ]['crop'] : false;

add_image_size( $name, $width, $height, $crop );
}
Expand Down
Loading

0 comments on commit 7fc1c31

Please sign in to comment.