-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated :: Namespace params and package name on block.json
- Loading branch information
Showing
2 changed files
with
9 additions
and
14 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
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 |
---|---|---|
|
@@ -71,7 +71,7 @@ public function create_portable_block( $name, $assoc_args ) { | |
'desc' => '', | ||
'keywords' => strtolower( $this->name ), | ||
'icon' => 'table-row-before', | ||
'namespace' => 'WebDevStudios\abs', | ||
'namespace' => 'abs/', | ||
] | ||
); | ||
|
||
|
@@ -133,19 +133,12 @@ private function create_block_dir() { | |
* @since 2.0.0 | ||
* @author Biplav Subedi <[email protected]> | ||
*/ | ||
private function create_block_render_php( $args ) { | ||
$local_file = ABS_ROOT_PATH . 'wpcli/block-starter/block.php'; | ||
$content = ''; | ||
private function create_block_render_php() { | ||
$dir = ABS_ROOT_PATH . 'wpcli/block-starter/block.php'; | ||
|
||
if ( $this->init_filesystem()->exists( $local_file ) ) { | ||
$content = $this->init_filesystem()->get_contents( $local_file ); | ||
$content = str_replace( 'WebDevStudios\abs', esc_html( $args['namespace'] ), $content ); | ||
|
||
if ( ! $this->init_filesystem()->put_contents( ABS_ROOT_PATH . 'src/blocks/' . $this->name . '/block.php', $content ) ) { | ||
WP_CLI::error( 'ERROR :: Could not create a render file.', true ); | ||
} | ||
} else { | ||
WP_CLI::error( 'ERROR :: Could not create a render file.', true ); | ||
// copy block render file. | ||
if ( ! $this->init_filesystem()->copy( $dir, ABS_ROOT_PATH . 'src/blocks/' . $this->name . '/' . $this->name . '.php' ) ) { | ||
WP_CLI::error( 'ERROR :: Could not create render file.', true ); | ||
} | ||
|
||
} | ||
|
@@ -191,12 +184,14 @@ private function create_block_json( $args ) { | |
'{{title}}', | ||
'{{description}}', | ||
'{{icon}}', | ||
'abs/', | ||
], | ||
[ | ||
$this->name, | ||
$args['title'], | ||
$args['desc'], | ||
$args['icon'], | ||
trailingslashit( $args['namespace'] ), | ||
], | ||
$content | ||
); | ||
|