Created
May 10, 2013 04:55
-
-
Save erikccoder/5552463 to your computer and use it in GitHub Desktop.
wordpress add custom admin page with data submit and receive.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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