• Hi, I am doing api setting page for background image. An user can upload or update the existing background image. I would like to know how to add an image uploader into api setting page. I have written my code below.
    ` <?php
    /*
    Plugin Name: background
    */

    function array_example_theme_test() {
    add_theme_page(‘Mulltitple array Test’,’Mulltitple array Test’,’administrator’,’mulltiple_array_test’,’mullarray_display_test’);
    }
    add_action( ‘admin_menu’, ‘array_example_theme_test’ );

    function mullarray_display_test() {
    if ( !empty( $_FILES ) ) {
    require_once(ABSPATH . ‘wp-admin/includes/admin.php’);
    $uploadedfile = $_FILES[‘mullti_arr_display_test’];
    $upload_overrides = array( ‘test_form’ => false );
    $movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
    }

    ?>
    <div class=”wrap”>
    <div id=”icon-themes” class=”icon32″></div>
    <h2>Sandbox Theme Test</h2>
    <?php settings_errors(); ?>
    <form method=”post” action=”options.php” enctype=”multipart/form-data”>
    <?php settings_fields( ‘upload_display_test’ ); ?>
    <?php do_settings_sections( ‘upload_display_test’ ); ?>
    <?php submit_button(); ?>
    </form>
    </div>
    <?php
    }

    function mullti_initialize_theme_test() {
    add_settings_section(‘general_settings_test’,’Background’,’background_test_callback’,’upload_display_test’);

    add_settings_field(‘show_test’,’Background image’,’bgimg_test_callback’,’upload_display_test’,’general_settings_test’);

    register_setting(‘upload_display_test’,’upload_display_test’);

    }
    add_action(‘admin_init’, ‘mullti_initialize_theme_test’);

    function background_test_callback(){
    echo ‘<p>Select an image to display as a background image.</p>’;
    }

    function bgimg_test_callback(){
    $options = get_option(‘upload_display_test’);

    ?>
    <input name=”upload_display_test[img_upload]” type=”file” id=”show_test” size=”50″ />

    <?php

    }

    ?>
    `
    Please help me somebody.

    Thanks in advance.

  • The topic ‘Adding image uploader to api setting page.’ is closed to new replies.