Skip to content

wp add cpt --name="Instagram posts" - whitespace in name results in wrong content generation #14

Description

@KubaDrx

When using a whitespace within the CPT name, script generates wrong file name and content.

File name generated: Instagram-posts.php (will not autopload in Composer 2.0)

File contents:

<?php

namespace Juniper\Cpt;

class Instagram - posts {
	public string $cpt_slug;
	public string $cpt_name;

	public function __construct() {
		$this->cpt_slug = substr( 'instagram-posts', 0, 20 );
		$this->cpt_name = substr( 'Instagram posts', 0, 20 );

		add_action( 'init', array( $this, 'register_custom_cpt' ) );
	}

class name is wrong.

Also, this is creating another bug within the inc/include.php file:

$juniper_instagram - posts = new \Juniper\Cpt\Instagram() - posts();

Expected behaviour: script should detect whitespaces within the --name param and convert it correctly. Here it should give InstagramPosts.php filename and InstagramPosts class name

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions