From 336356f48d6af539493e5f541b4e0833276ef22f Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 20 Apr 2020 03:04:37 -0700 Subject: [PATCH] Add missing ACF Option Page properties (#13) * 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 --- src/Console/stubs/options.full.stub | 55 ++++++++++++++++++++++++++++ src/Options.php | 56 ++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/src/Console/stubs/options.full.stub b/src/Console/stubs/options.full.stub index 5723eab8..c41725f0 100644 --- a/src/Console/stubs/options.full.stub +++ b/src/Console/stubs/options.full.stub @@ -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. * @@ -35,6 +42,34 @@ 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. * @@ -42,6 +77,26 @@ class DummyClass extends Field */ 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. * diff --git a/src/Options.php b/src/Options.php index a20f0691..c295b4b4 100644 --- a/src/Options.php +++ b/src/Options.php @@ -42,6 +42,34 @@ 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. * @@ -49,6 +77,26 @@ abstract class Options extends Composer */ 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. * @@ -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')) {