I have an existing plugin(payment gateway for woocommerce) that goes about generating settings as follows:

In the constructor, It does the following:


// Calls all the fields
    $this->title                = $this->get_option( 'title' );

In the init_form_fields function:

$this->form_fields = array(
                'enabled' => array(
                    'title'       => __( 'Enable/Disable:', 'plugin-name' ),
                    'type'        => 'checkbox',
                    'label'       => __( 'Enable Payment', 'plugin-name' ),
                    'description' => __( 'Enable this if you want to collect payment via example gateway.', 'plugin-name' ),
                    'default'     => 'yes',
                    'desc_tip'    => true,
                'img' => array(
                    'title'       => __( 'Upload Image:', 'plugin-name' ),
                    'type'        => 'file',
                    'description' => __( 'Please upload your image', 'plugin-name' ),
                    'default'     => '',
                    'desc_tip'    => true,

I am able to create fields such as text, textarea etc, however, It does not save any file for the field 'img' anywhere.

All the examples I have seen online use custom html via - settings_fields("section"); do_settings_sections("demo");

Is there a way I can change my existing code to just have the image field, or will I have to change my approach?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.