Skip to content

Commit

Permalink
remove setAttribute state change from HOC (#96)
Browse files Browse the repository at this point in the history
* remove setAttribute state change from HOC

* update readme

* Short array syntax is not allowed

* address issue #95 scoping the column to product id
  • Loading branch information
bfocht committed Nov 21, 2019
1 parent 2d7b0ec commit 8f8eef1
Show file tree
Hide file tree
Showing 61 changed files with 452 additions and 442 deletions.
2 changes: 1 addition & 1 deletion .dev/src/blocks/domain-search/inspector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { __ } = wp.i18n;
const { InspectorControls } = wp.editor;
const { InspectorControls } = wp.blockEditor;
const { Fragment } = wp.element;
const {
CheckboxControl,
Expand Down
2 changes: 1 addition & 1 deletion .dev/src/blocks/product/components/inspector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { __ } = wp.i18n;
const { InspectorControls } = wp.editor;
const { InspectorControls } = wp.blockEditor;

const {
CheckboxControl,
Expand Down
4 changes: 1 addition & 3 deletions .dev/src/blocks/product/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ const mediaSelector = withSelect( ( select, { post } ) => {
};
} );

const productSelector = withSelect( ( select, { attributes, setAttributes } ) => {
const productSelector = withSelect( ( select, { attributes } ) => {
const posts = select( 'core' ).getEntityRecords( 'postType', 'reseller_product', { per_page: 100 } );

if ( posts && posts.length ) {
if ( attributes.post_id === undefined ) {
setAttributes( { post_id: posts[ 0 ].id.toString() } );
return {
posts,
post: posts[ 0 ],
Expand All @@ -29,7 +28,6 @@ const productSelector = withSelect( ( select, { attributes, setAttributes } ) =>
} );

if ( post === undefined ) {
setAttributes( { post_id: posts[ 0 ].id.toString() } );
return {
posts,
post: posts[ 0 ],
Expand Down
2 changes: 1 addition & 1 deletion assets/js/editor.blocks.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions includes/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function( $resource ) {

$resource = strtolower(
str_replace(
[ __NAMESPACE__ . '\\', '_' ],
[ '', '-' ],
array( __NAMESPACE__ . '\\', '_' ),
array( '', '-' ),
$resource
)
);
Expand Down
2 changes: 1 addition & 1 deletion includes/butterbean/controls/class-anchor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class Anchor extends \ButterBean_Control {
* @param string $name Setting Name.
* @param array $args ButterBean control attributes.
*/
public function __construct( $manager, $name, $args = [] ) {
public function __construct( $manager, $name, $args = array() ) {

parent::__construct( $manager, $name, $args );

Expand Down
2 changes: 1 addition & 1 deletion includes/butterbean/controls/class-plain-text.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class Plain_Text extends \ButterBean_Control {
* @param string $name Setting Name.
* @param array $args ButterBean control attributes.
*/
public function __construct( $manager, $name, $args = [] ) {
public function __construct( $manager, $name, $args = array() ) {

parent::__construct( $manager, $name, $args );

Expand Down
2 changes: 1 addition & 1 deletion includes/butterbean/settings/class-read-only.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class Read_Only extends \ButterBean_Setting {
* @param string $name Setting Name.
* @param array $args ButterBean control attributes.
*/
public function __construct( $manager, $name, $args = [] ) {
public function __construct( $manager, $name, $args = array() ) {

parent::__construct( $manager, $name, $args );

Expand Down
14 changes: 7 additions & 7 deletions includes/class-admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ final class Admin_Notices {
*/
public function __construct() {

add_action( 'wp_ajax_rstore_dismiss_admin_notice', [ __CLASS__, 'dismiss_admin_notice' ] );
add_action( 'wp_ajax_rstore_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) );

$is_post_type_screen = rstore_is_admin_uri( 'post_type=' . Post_Type::SLUG, false );
if ( ! $is_post_type_screen ) {
return;
}

$errors = rstore_get_option( 'errors', [] );
$errors = rstore_get_option( 'errors', array() );

if ( count( $errors ) > 0 ) {

add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
add_action( 'admin_notices', [ $this, 'error_notices' ] );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'admin_notices', array( $this, 'error_notices' ) );
}

if ( ! empty( $_REQUEST['bulk_restore_posts'] ) ) {
add_action( 'admin_notices', [ $this, 'restore_notice' ] );
add_action( 'admin_notices', array( $this, 'restore_notice' ) );
}

}
Expand All @@ -70,7 +70,7 @@ public function admin_enqueue_scripts() {

$suffix = SCRIPT_DEBUG ? '' : '.min';

wp_enqueue_script( 'rstore-admin-notice', Plugin::assets_url( "js/admin-notice{$suffix}.js" ), [ 'jquery' ], rstore()->version, true );
wp_enqueue_script( 'rstore-admin-notice', Plugin::assets_url( "js/admin-notice{$suffix}.js" ), array( 'jquery' ), rstore()->version, true );

wp_localize_script(
'rstore-admin-notice',
Expand Down Expand Up @@ -110,7 +110,7 @@ public function restore_notice() {
*/
public function error_notices() {

$errors = rstore_get_option( 'errors', [] );
$errors = rstore_get_option( 'errors', array() );

print( '<div id="rstore-update-error" class="notice notice-error is-dismissible">' );
foreach ( $errors as $error ) {
Expand Down
22 changes: 11 additions & 11 deletions includes/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class API {
*
* @var array
*/
private $urls = [];
private $urls = array();

/**
* Class constructor.
Expand Down Expand Up @@ -96,7 +96,7 @@ public function __construct() {
*
* @return string
*/
public function add_query_args( $url, $args = [], $url_key = '' ) {
public function add_query_args( $url, $args = array(), $url_key = '' ) {

if ( rstore_is_setup() ) {

Expand All @@ -121,7 +121,7 @@ public function add_query_args( $url, $args = [], $url_key = '' ) {
*
* @return string
*/
public function url( $url_key, $endpoint = '', $args = [] ) {
public function url( $url_key, $endpoint = '', $args = array() ) {

if ( ! array_key_exists( $url_key, $this->urls ) ) {
return $this->url( 'www', $endpoint );
Expand Down Expand Up @@ -162,15 +162,15 @@ public function url( $url_key, $endpoint = '', $args = [] ) {
*
* @return array|WP_Error
*/
private function request( $method, $endpoint, $args = [] ) {
private function request( $method, $endpoint, $args = array() ) {

$defaults = [
$defaults = array(
'method' => $method,
'sslverify' => true,
'headers' => [
'headers' => array(
'Content-Type: application/json',
],
];
),
);

$args = wp_parse_args( $args, $defaults );

Expand Down Expand Up @@ -225,7 +225,7 @@ private function request( $method, $endpoint, $args = [] ) {
*
* @return array|WP_Error
*/
public function get( $endpoint, $args = [] ) {
public function get( $endpoint, $args = array() ) {

$key = rstore_prefix( 'api_get-' . md5( $endpoint . maybe_serialize( $args ) ) );

Expand Down Expand Up @@ -253,7 +253,7 @@ public function get( $endpoint, $args = [] ) {
*
* @return array|WP_Error
*/
public function post( $endpoint, $args = [] ) {
public function post( $endpoint, $args = array() ) {

return $this->request( 'POST', $endpoint, $args );

Expand All @@ -269,7 +269,7 @@ public function post( $endpoint, $args = [] ) {
*
* @return array|WP_Error
*/
public function delete( $endpoint, $args = [] ) {
public function delete( $endpoint, $args = array() ) {

return $this->request( 'DELETE', $endpoint, $args );

Expand Down
20 changes: 10 additions & 10 deletions includes/class-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ final class Blocks {
*
* @var array
*/
private $args = [
private $args = array(
'before_widget' => '',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
'after_widget' => '</div>',
];
);

/**
* Class constructor.
Expand All @@ -48,9 +48,9 @@ public function __construct() {
return;
}

add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ] );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );

add_filter( 'block_categories', [ $this, 'block_categories' ], 10, 2 );
add_filter( 'block_categories', array( $this, 'block_categories' ), 10, 2 );

add_action(
'init',
Expand All @@ -59,20 +59,20 @@ function() {
register_block_type(
'reseller-store/product',
array(
'render_callback' => [
'render_callback' => array(
$this,
'product',
],
),
)
);

register_block_type(
'reseller-store/domain-search',
array(
'render_callback' => [
'render_callback' => array(
$this,
'domain_search',
],
),
)
);

Expand All @@ -93,12 +93,12 @@ public function enqueue_block_editor_assets() {
wp_enqueue_script(
'reseller-store-blocks-js',
Plugin::assets_url( $block_js_path ),
[ 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components' ],
array( 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components' ),
rstore()->version,
true
);

wp_enqueue_style( 'reseller-store-blocks-css', Plugin::assets_url( "css/blocks-editor{$suffix}.css" ), [], rstore()->version );
wp_enqueue_style( 'reseller-store-blocks-css', Plugin::assets_url( "css/blocks-editor{$suffix}.css" ), array(), rstore()->version );

}

Expand Down
2 changes: 1 addition & 1 deletion includes/class-bulk-restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ( $bulk_actions ) {
}
);

add_filter( 'handle_bulk_actions-edit-' . Post_Type::SLUG, [ $this, 'bulk_action_handler' ], 10, 3 );
add_filter( 'handle_bulk_actions-edit-' . Post_Type::SLUG, array( $this, 'bulk_action_handler' ), 10, 3 );

}

Expand Down
Loading

0 comments on commit 8f8eef1

Please sign in to comment.