-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make it possible for two word registerables
- Loading branch information
1 parent
635d582
commit 0aba270
Showing
8 changed files
with
64 additions
and
6 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
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
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
class PostType extends Registrable | ||
{ | ||
use Resourceful; | ||
|
||
private $title = null; | ||
private $form = []; | ||
|
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,31 @@ | ||
<?php | ||
|
||
namespace TypeRocket\Register; | ||
|
||
use TypeRocket\Utility\Inflect; | ||
use TypeRocket\Utility\Sanitize; | ||
|
||
trait Resourceful | ||
{ | ||
/** | ||
* Set the Registrable ID for WordPress to use. Don't use reserved names. | ||
* | ||
* @param string $id set the ID | ||
* @param boolean $resource update the resource binding | ||
* | ||
* @return $this | ||
*/ | ||
public function setId($id, $resource = false) | ||
{ | ||
$this->id = Sanitize::underscore($id); | ||
$this->dieIfReserved(); | ||
|
||
if($resource) { | ||
$singular = Sanitize::underscore( $this->id ); | ||
$plural = Sanitize::underscore( Inflect::pluralize($this->id) ); | ||
$this->resource = [$singular, $plural]; | ||
} | ||
|
||
return $this; | ||
} | ||
} |
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