-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b55ba8e
commit a522880
Showing
22 changed files
with
2,099 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Autoloading | ||
* | ||
* @package WPFW | ||
*/ | ||
|
||
defined('ABSPATH') || die("Can't access directly"); | ||
|
||
// require utility classes. | ||
require_once __DIR__ . '/utilities/class-asset.php'; | ||
require_once __DIR__ . '/utilities/class-debug.php'; | ||
require_once __DIR__ . '/utilities/class-file-util.php'; | ||
require_once __DIR__ . '/utilities/class-vars.php'; | ||
|
||
// require helper classes. | ||
require_once __DIR__ . '/helpers/class-admin-ajax-helper.php'; | ||
require_once __DIR__ . '/helpers/class-css-helper.php'; | ||
require_once __DIR__ . '/helpers/class-file-helper.php'; | ||
require_once __DIR__ . '/helpers/class-image-size-helper.php'; | ||
require_once __DIR__ . '/helpers/class-js-helper.php'; | ||
require_once __DIR__ . '/helpers/class-metabox-helper.php'; | ||
require_once __DIR__ . '/helpers/class-post-type-helper.php'; | ||
require_once __DIR__ . '/helpers/class-taxonomy-helper.php'; | ||
|
||
// require utility classes. | ||
require_once __DIR__ . '/utilities/class-admin-ajax.php'; | ||
require_once __DIR__ . '/utilities/class-css.php'; | ||
require_once __DIR__ . '/utilities/class-image-size.php'; | ||
require_once __DIR__ . '/utilities/class-js.php'; | ||
require_once __DIR__ . '/utilities/class-metabox.php'; | ||
require_once __DIR__ . '/utilities/class-post-type.php'; | ||
require_once __DIR__ . '/utilities/class-taxonomy.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Admin ajax interfaces | ||
* | ||
* @package WPFW | ||
*/ | ||
|
||
namespace Wpfw\Helpers; | ||
|
||
/** | ||
* Class to provide admin ajax methods | ||
*/ | ||
class Admin_Ajax_Helper { | ||
|
||
/** | ||
* Item's id | ||
* | ||
* @var integer | ||
*/ | ||
private $id = -1; | ||
|
||
/** | ||
* Item's container | ||
* | ||
* @var array | ||
*/ | ||
private $item = []; | ||
|
||
/** | ||
* Register action | ||
* | ||
* @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; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Set the request as public | ||
* | ||
* @return object | ||
*/ | ||
public function set_public() { | ||
$this->item[ $this->id ]['is_private'] = false; | ||
return $this; | ||
} | ||
|
||
/** | ||
* 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' ] ); | ||
|
||
if ( ! $this->item[ $this->id ]['is_private'] ) { | ||
add_action( 'wp_ajax_nopriv_' . $this->item[ $this->id ]['action'], [ $handler, 'ajax' ] ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
/** | ||
* CSS enqueue interfaces | ||
* | ||
* @package WPFW | ||
*/ | ||
|
||
namespace Wpfw\Helpers; | ||
|
||
/** | ||
* Class to provide stylesheet enqueue methods | ||
*/ | ||
class CSS_Helper { | ||
|
||
/** | ||
* Item's id | ||
* | ||
* @var integer | ||
*/ | ||
private $id = -1; | ||
|
||
/** | ||
* Item's container | ||
* | ||
* @var array | ||
*/ | ||
private $item = []; | ||
|
||
/** | ||
* 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; | ||
return $this; | ||
} | ||
|
||
/** | ||
* 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; | ||
return $this; | ||
} | ||
|
||
/** | ||
* 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; | ||
return $this; | ||
} | ||
|
||
/** | ||
* 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; | ||
return $this; | ||
} | ||
|
||
/** | ||
* 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. | ||
$ver = $ver && 'auto' === $ver ? Asset::get_modified_time( $url ) : $ver; | ||
|
||
wp_register_style( $handle, $url, $deps, $ver ); | ||
} | ||
|
||
/** | ||
* Enqueue the stylesheet | ||
* | ||
* @param string $handle Name of the stylesheet. Should be unique. | ||
* @return void | ||
*/ | ||
public function enqueue( $handle = false ) { | ||
if ( $handle ) { | ||
wp_enqueue_style( $handle ); | ||
} else { | ||
$this->save(); | ||
wp_enqueue_style( $this->item[ $this->id ]['handle'] ); | ||
} | ||
} | ||
|
||
/** | ||
* Unregister a stylesheet. | ||
* | ||
* @param string $handle Name of the stylesheet to be un-registered. | ||
* @return void | ||
*/ | ||
public function deregister( $handle ) { | ||
wp_deregister_style( $handle ); | ||
} | ||
|
||
/** | ||
* Dequeue a stylesheet. | ||
* | ||
* @param string $handle Name of the stylesheet to be de-queued. | ||
* @return void | ||
*/ | ||
public function dequeue( $handle ) { | ||
wp_dequeue_style( $handle ); | ||
} | ||
} |
Oops, something went wrong.