Skip to content

Commit

Permalink
Merge pull request #5 from sarahcssiqueira/develop
Browse files Browse the repository at this point in the history
refactor: code cleanup, reorganized and linted using wpcs
  • Loading branch information
sarahcssiqueira committed Dec 4, 2023
2 parents 3689398 + 2168da4 commit c419a89
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 97 deletions.
66 changes: 60 additions & 6 deletions inc/class-block-x.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,60 @@
<?php
/**
* Block X
*
* @package xywzblocks
*/
<?php
/**
* Block X
*
* @package xywzblocks
*/

namespace XYWZBlocks\Inc;

/**
* Block X
*/
class Block_X {


/**
* Constructor for handle WordPress Hooks
*/
public function __construct() {
add_action( 'init', [ $this, 'block_x_register' ] );
add_action( 'enqueue_block_editor_assets', [ $this, 'block_x_enqueues' ] );
add_filter( 'block_categories_all', [ $this, 'register_new_category' ], 10, 2 );
}

/**
* Register Block
*/
public function block_x_register() {
register_block_type( __DIR__ );
}

/**
* Enqueues
*/
public function block_x_enqueues() {
wp_enqueue_script(
'block-x',
plugin_dir_url( __FILE__ ) . './blocks/block-x/build/index.js',
[ 'wp-blocks', 'wp-i18n', 'wp-editor' ]
);

wp_enqueue_style(
'block-x',
plugin_dir_url( __FILE__ ) . '.style/style.css',
[],
);
}

/**
* Register custom category
*/
public function register_new_category( $categories ) {
$categories[] = [
'slug' => 'xywz-blocks',
'title' => 'XYW...Z Blocks',
];

return $categories;
}
}
47 changes: 47 additions & 0 deletions inc/class-block-y.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Block Y
*
* @package xywzblocks
*/

namespace XYWZBlocks\Inc;

/**
* Block Y
*/
class Block_Y {


/**
* Constructor for handle WordPress Hooks
*/
public function __construct() {
add_action( 'init', [ $this, 'block_y_register' ] );
add_action( 'enqueue_block_editor_assets', [ $this, 'block_y_enqueues' ] );
}

/**
* Register Block
*/
public function block_y_register() {
register_block_type( __DIR__ );
}

/**
* Enqueues
*/
public function block_y_enqueues() {
wp_enqueue_script(
'block-y',
plugin_dir_url( __FILE__ ) . './blocks/block-y/build/index.js',
[ 'wp-blocks', 'wp-i18n', 'wp-editor' ]
);

wp_enqueue_style(
'block-y',
plugin_dir_url( __FILE__ ) . '.style/style.css',
[],
);
}
}
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php // Silence is golden.
<?php // Silence is golden.
101 changes: 11 additions & 90 deletions xywz-blocks.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* Plugin Name: XYW...Z Blocks
* Plugin URI: https://sarahjobs.com/wordpress/plugins/xywz-blocks
Expand All @@ -16,98 +15,20 @@
* Update URI: https://sarahjobs.com/wordpress/plugins/xywz-blocks/update
*
* @package xywzblocks
*
*/

defined('ABSPATH') || exit;
defined( 'ABSPATH' ) || exit;

/**
* Block X
*/
require dirname( __FILE__ ) . '/inc/class-block-x.php';
use XYWZBlocks\Inc\Block_X;
new Block_X();

class Block_X
{

public function __construct()
{
add_action('init', array($this, 'block_x_register'));
add_action('enqueue_block_editor_assets', array($this, 'block_x_enqueues'));
add_filter('block_categories_all', array($this, 'register_new_category'), 10, 2);
}

/**
* Register Block
*/
public function block_x_register()
{
register_block_type(__DIR__);
}

/**
* Enqueues
*/
public function block_x_enqueues()
{
wp_enqueue_script(
'block-x',
plugin_dir_url(__FILE__) . './blocks/block-x/build/index.js',
array('wp-blocks', 'wp-i18n', 'wp-editor')
);

wp_enqueue_style(
'block-x',
plugin_dir_url(__FILE__) . '.style/style.css',
array(),
);
}

/**
* Register custom category
*/
public function register_new_category($categories)
{
$categories[] = array(
'slug' => 'xywz-blocks',
'title' => 'XYW...Z Blocks',
);

return $categories;
}
}


/**
* Block Y
*/
require dirname( __FILE__ ) . '/inc/class-block-y.php';
use XYWZBlocks\Inc\Block_Y;
new Block_Y();

class Block_Y
{

public function __construct()
{
add_action('init', array($this, 'block_y_register'));
add_action('enqueue_block_editor_assets', array($this, 'block_y_enqueues'));
}

/**
* Register Block
*/
public function block_y_register()
{
register_block_type(__DIR__);
}

/**
* Enqueues
*/
public function block_y_enqueues()
{
wp_enqueue_script(
'block-y',
plugin_dir_url(__FILE__) . './blocks/block-y/build/index.js',
array('wp-blocks', 'wp-i18n', 'wp-editor')
);

wp_enqueue_style(
'block-y',
plugin_dir_url(__FILE__) . '.style/style.css',
array(),
);
}
}

0 comments on commit c419a89

Please sign in to comment.