WordPress Tutorial: Admin Panel With Image Upload
In previous tutorial we developed a basic plugin that allowed us to use a shortcode. This tutorial will show you how to make basic administration panel in WordPress admin. We will make two fields, first will hold name of the image and the second will hold the image itself. Image adding will be done via WordPress native image upload interface.
[download id=”84″]
STEP 1: VARIABLES DEFINITION
We will use the plugin that we made in previous tutorial and develop from where we left of. First we have to define two variables that will hold name of the image and image itself:
function wp_myCustomPlugin_install () {
$newoptions = get_option(‘mycustomplugin_options’);
$newoptions[‘title’] = ”;
$newoptions[‘image’] = ”;
}
STEP 2: ADDING YOUR PLUGIN INTO WORDPRESS ADMIN
We will first add the plugin into the menu so we can edit it via WordPress administration. Following function will do just that:
function wp_myCustomPlugin_add_pages() {
add_options_page(‘My Custom Plugin’, ‘My Custom Plugin’, 8, __FILE__, ‘wp_myCustomPluginOptions’);
}
STEP 3: DISPLAYING OUR CONTENT
Now that our plugin has been added to WordPress admin we need a function that we are going to call wp_myCustomPluginOptions. This function will display the content of your plugin custom administration:
Function wp_myCustomPluginOptions(){
}
We now have to define two input fields that will hold our values. We will use method POST for updating:
$options = $newoptions = get_option(‘mycustomplugin_options’);
echo ‘
You must be logged in to post a comment.