Skip to content

Instantly share code, notes, and snippets.

@erikccoder
Created May 10, 2013 04:55
Show Gist options
  • Save erikccoder/5552463 to your computer and use it in GitHub Desktop.
Save erikccoder/5552463 to your computer and use it in GitHub Desktop.
wordpress add custom admin page with data submit and receive.
/*
add custom admin page;
http://codex.wordpress.org/Function_Reference/add_menu_page
*/
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page(){
/*
args:
$page_title,
$menu_title,
$capability,
$menu_slug,
$function,
$icon_url,
$position
*/
add_menu_page( 'custom menu title', 'custom menu', 'manage_options', 'custompage', 'my_custom_menu_page', plugins_url( 'myplugin/images/icon.png' ), 6 );
}
function my_custom_menu_page(){
// $content = '[gallery ids="5"]';
$content = get_page( 2 );
/*
add POST Request respon.
http://wordpress.stackexchange.com/questions/10500/how-do-i-best-handle-custom-plugin-page-actions
*/
if ( $_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) {
echo "posted <br>";
$content = $_POST['erik_editor'];
}
echo "Admin Page Test";
echo '<form id="contactForm" method="post">';
$args = array(
'quicktags' => false,
'dfw' => true, 'tabfocus_elements' => 'sample-permalink,post-preview', 'editor_height' => 360
);
wp_editor( $content->post_content, 'erik_editor', $args );
submit_button( 'Save content' );
echo '</form>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment