Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save heldervilela/7d7f64b4f490852ac2078c7690f6dee3 to your computer and use it in GitHub Desktop.
Save heldervilela/7d7f64b4f490852ac2078c7690f6dee3 to your computer and use it in GitHub Desktop.
Displays custom text after the form is submitted with Admin Page Framework, a wordpress plugin/theme framework.
<?php
/*
Plugin Name: Admin Page Framework - Custom Text After Form Submission
Plugin URI: http://en.michaeluno.jp/admin-page-framework
Description: Displays custom text after the form is submitted.
Author: Michael Uno
*/
// Include the library file. Set your file path here.
include( dirname( dirname( __FILE__ ) ) . '/admin-page-framework/library/apf/admin-page-framework.php' );
class APF_CustomTextAfterFormSubmission extends AdminPageFramework {
/**
* Sets up pages.
*/
public function setUp() {
$this->setRootMenuPage( 'Settings' );
$this->addSubMenuItems(
array(
'title' => __( 'Custom Text', 'admin-page-framework-demo' ), // page and menu title
'page_slug' => 'custom_text_after_form_submission', // page slug
)
);
}
/**
* Called when the page loads.
*
* @callback action load_{page slug}
*/
public function load_custom_text_after_form_submission( $oAdminPage ) {
$this->addSettingFields(
array(
'field_id' => 'my_text_field',
'type' => 'text',
'title' => 'Text',
'description' => 'Type something here.',
),
array(
'field_id' => '_my_custom_field',
'type' => '_my_custom_field_for_custom_text',
'if' => isset( $_GET[ 'my_custom_key' ] ),
'content' => '<p style="color:red; font-weight: bold;">This message is shown after the user submits the form.</p>',
),
array(
'field_id' => 'submit_button',
'type' => 'submit',
)
);
add_filter( "setting_update_url_{$oAdminPage->oProp->sClassName}", array( $this, 'replyToModifySettingsUpdateURL' ) );
}
/**
* @callback filter setting_update_url_{class name}
* @return string
*/
public function replyToModifySettingsUpdateURL( $sURL ) {
return add_query_arg(
array(
'my_custom_key' => 'foo',
),
$sURL
);
}
}
new APF_CustomTextAfterFormSubmission;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment