Support » Plugin: Enhanced Media Library » Add option to media-library

  • Hi I am trying to add a custom option under media-library page

    add_action(‘admin_init’, ‘my_general_section’);
    function my_general_section() {
    // add_settings_section(
    // ‘Descriptionx’, // Section ID
    // ‘My Options Title’, // Section Title
    // ‘my_section_options_callback’, // Callback
    // ‘settings_page_media-library’ // What Page? This makes the section show up on the General Settings Page
    // );

    add_settings_field( // Option 2
    ‘option_2’, // Option ID
    ‘Option 2’, // Label
    ‘my_textbox_callback’, // !important – This is where the args go!
    ‘media-library’, // Page it will be displayed
    ‘Descriptionx’, // Name of our section (General Settings)
    array( // The $args
    ‘option_2’ // Should match Option ID
    )
    );

    register_setting(‘media-library’,’option_2′, ‘wpuxss_eml_lib_options_validate’);
    }

    function my_section_options_callback() { // Section Callback
    echo ‘<p>A little message on editing info</p>’;
    }

    function my_textbox_callback($args) { // Textbox Callback

    echo ‘<input type=”text” id=”‘. $args[0] .'” name=”‘. $args[0] .'” value=”‘ . $option . ‘” />’;
    }
    `

    can please someone tell me what am doing wrong

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Rajneesh Tiwari

    (@rdk594)

    Is someone here or this plugin is no more for support

    Plugin Author webbistro

    (@webbistro)

    Hi @rdk594,

    It is not possible to add custom options to EML’s custom admin pages. You can do this for WordPress default Settings > Media admin page like this:

    /* Admin init */
    add_action( 'admin_init', 'my_settings_init' );
     
    /* Settings Init */
    function my_settings_init(){
     
        /* Register Settings */
        register_setting(
            'media',             // Options group
            'my-option-name',      // Option name/database
            'my_settings_sanitize' // sanitize callback function
        );
     
        /* Create settings section */
        add_settings_section(
            'my-section-id',                   // Section ID
            'My Additional Media Settings',  // Section title
            'my_settings_section_description', // Section callback function
            'media'                          // Settings page slug
        );
     
        /* Create settings field */
        add_settings_field(
            'my-settings-field-id',       // Field ID
            'Image Description',       // Field title 
            'my_settings_field_callback', // Field callback function
            'media',                    // Settings page slug
            'my-section-id'               // Section ID
        );
    }
     
    /* Sanitize Callback Function */
    function my_settings_sanitize( $input ){
        return isset( $input ) ? true : false;
    }
     
    /* Setting Section Description */
    function my_settings_section_description(){
        echo wpautop( "Your custom media section description" );
    }
     
    /* Settings Field Callback */
    function my_settings_field_callback(){
        ?>
        <label>
            <input type="checkbox" value="1" name="my-option-name" <?php checked( get_option( 'my-option-name', true ) ); ?>> Show description under caption on single images in articles
        </label>
        <?php
    }

    Hope this helps!

    Best,
    -Nadia

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.