Skip to content

Commit

Permalink
Add missing ACF Option Page properties (#13)
Browse files Browse the repository at this point in the history
* feat(options): Add missing option page properties
* feat(options): Add missing option properties to `options.full.stub`
* fix(options): Add missing `$slug` property to `options.full.stub`
* chore(options): Clean up the class properties

Co-authored-by: Brandon <[email protected]>
  • Loading branch information
alwaysblank and Log1x authored Apr 20, 2020
1 parent 6f0c756 commit 336356f
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 1 deletion.
55 changes: 55 additions & 0 deletions src/Console/stubs/options.full.stub
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class DummyClass extends Field
*/
public $name = 'DummyClass';

/**
* The option page menu slug.
*
* @var string
*/
public $slug = 'DummySlug';

/**
* The option page document title.
*
Expand All @@ -35,13 +42,61 @@ class DummyClass extends Field
*/
public $position = PHP_INT_MAX;

/**
* The slug of another admin page to be used as a parent.
*
* @var string
*/
public $parent = null;

/**
* The option page menu icon.
*
* @var string
*/
public $icon = null;

/**
* Redirect to the first child page if one exists.
*
* @var boolean
*/
public $redirect = true;

/**
* The post ID to save and load values from.
*
* @var string|int
*/
public $post = 'options';

/**
* The option page autoload setting.
*
* @var bool
*/
public $autoload = true;

/**
* Localized text displayed on the submit button.
*
* @return string
*/
public function updateButton()
{
return __('Update', 'acf');
}

/**
* Localized text displayed after form submission.
*
* @return string
*/
public function updatedMessage()
{
return __('Options Updated', 'acf');
}

/**
* The option page field group.
*
Expand Down
56 changes: 55 additions & 1 deletion src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,61 @@ abstract class Options extends Composer
*/
public $position = PHP_INT_MAX;

/**
* The slug of another admin page to be used as a parent.
*
* @var string
*/
public $parent = null;

/**
* The option page menu icon.
*
* @var string
*/
public $icon = null;

/**
* Redirect to the first child page if one exists.
*
* @var boolean
*/
public $redirect = true;

/**
* The post ID to save and load values from.
*
* @var string|int
*/
public $post = 'options';

/**
* The option page autoload setting.
*
* @var bool
*/
public $autoload = true;

/**
* Localized text displayed on the submit button.
*
* @return string
*/
public function updateButton()
{
return __('Update', 'acf');
}

/**
* Localized text displayed after form submission.
*
* @return string
*/
public function updatedMessage()
{
return __('Options Updated', 'acf');
}

/**
* Compose and register the defined field groups with ACF.
*
Expand Down Expand Up @@ -76,7 +124,13 @@ public function compose($callback = null)
'page_title' => $this->title,
'capability' => $this->capability,
'position' => $this->position,
'autoload' => $this->autoload
'parent_slug' => $this->parent,
'icon_url' => $this->icon,
'redirect' => $this->redirect,
'post_id' => $this->post,
'autoload' => $this->autoload,
'update_button' => $this->updateButton(),
'updated_message' => $this->updatedMessage()
]);

if (! Arr::has($this->fields, 'location.0.0')) {
Expand Down

0 comments on commit 336356f

Please sign in to comment.