From 3b3b4e597b314f6f44966f388a34a957e915533a Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 2 Oct 2014 14:56:35 -0700 Subject: [PATCH 1/2] Allow the submenu success message to be configurable --- php/context/class-fieldmanager-context-submenu.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/php/context/class-fieldmanager-context-submenu.php b/php/context/class-fieldmanager-context-submenu.php index 47ea9229f6..b637e2c063 100644 --- a/php/context/class-fieldmanager-context-submenu.php +++ b/php/context/class-fieldmanager-context-submenu.php @@ -45,6 +45,12 @@ class Fieldmanager_Context_Submenu extends Fieldmanager_Context { */ public $submit_button_label = Null; + /** + * @var string|Null + * Only used for options pages + */ + public $updated_message = Null; + /** * @var string * For submenu pages, set autoload to true or false @@ -67,6 +73,7 @@ public function __construct( $parent_slug, $page_title, $menu_title = Null, $cap $this->parent_slug = $parent_slug; $this->page_title = $page_title; $this->capability = $capability; + $this->updated_message = esc_html__( 'Options updated', 'fieldmanager' ); $this->uniqid = $this->fm->get_element_id() . '_form'; if ( !$already_registered ) add_action( 'admin_menu', array( $this, 'register_submenu_page' ) ); add_action( 'admin_init', array( $this, 'handle_submenu_save' ) ); @@ -89,7 +96,7 @@ public function render_submenu_page() { ?>
-

+

updated_message ); ?>

page_title ) ?>

From 7ae57e847b9281a50a0cefe6f6521a0fc2401a1c Mon Sep 17 00:00:00 2001 From: Matt Boynes Date: Mon, 4 Jan 2016 10:48:24 -0500 Subject: [PATCH 2/2] Add unit test and clean up for merge --- php/context/class-fieldmanager-context-submenu.php | 10 ++++++---- tests/php/test-fieldmanager-context-submenu.php | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/php/context/class-fieldmanager-context-submenu.php b/php/context/class-fieldmanager-context-submenu.php index cb83d78ac2..f7ebb3ab58 100644 --- a/php/context/class-fieldmanager-context-submenu.php +++ b/php/context/class-fieldmanager-context-submenu.php @@ -46,10 +46,12 @@ class Fieldmanager_Context_Submenu extends Fieldmanager_Context_Storable { public $submit_button_label = Null; /** - * @var string|Null - * Only used for options pages + * The "success" message displayed after options are saved. Defaults to + * "Options updated". + * + * @var string|null */ - public $updated_message = Null; + public $updated_message = null; /** * @var string @@ -73,7 +75,7 @@ public function __construct( $parent_slug, $page_title, $menu_title = Null, $cap $this->parent_slug = $parent_slug; $this->page_title = $page_title; $this->capability = $capability; - $this->updated_message = esc_html__( 'Options updated', 'fieldmanager' ); + $this->updated_message = __( 'Options updated', 'fieldmanager' ); $this->uniqid = $this->fm->get_element_id() . '_form'; if ( ! $already_registered ) { add_action( 'admin_menu', array( $this, 'register_submenu_page' ) ); diff --git a/tests/php/test-fieldmanager-context-submenu.php b/tests/php/test-fieldmanager-context-submenu.php index 0b7c90b403..c5039f8770 100644 --- a/tests/php/test-fieldmanager-context-submenu.php +++ b/tests/php/test-fieldmanager-context-submenu.php @@ -224,4 +224,15 @@ public function presave_alter_number( $values, $context ) { return $values; } + public function test_updated_message() { + $name = 'message_customization'; + $updated_message = rand_str(); + fm_register_submenu_page( $name, 'tools.php', 'Message Customization' ); + $context = $this->get_context( $name ); + $context->updated_message = $updated_message; + $html = $this->get_html( $context, $name ); + $this->build_post( $html, $name ); + $this->assertContains( "

{$updated_message}

", $this->get_html( $context, $name ) ); + } + } \ No newline at end of file