Skip to main content
added 70 characters in body; added 39 characters in body
Source Link
Jlil
  • 222
  • 3
  • 10

I need to add a new options to my settings, the new filed shown in settings page but not saved.

My add_settings_field callback:

  public function field_option_callback()
    {
        ?>
        <p>
            <input type='checkbox' name='my_options[imgs][]' <?php checked( in_array( 'thumbnail', $imgs ), 1 ); ?> value='thumbnail'>
            <label><?php _e('Thumbnail','do'); ?></label>
        </p>
        <?php
        $html = "";
       echo apply_filters( 'after_options_callback', $html );
    }

How I can add more fields and settings to my plugin using hooks?

EDIT: It works if I remove sanitize_callback from register_setting and use add_filter in same plugin file

I need to add a new options to my settings, the new filed shown in settings page but not saved.

My add_settings_field callback:

  public function field_option_callback()
    {
        ?>
        <p>
            <input type='checkbox' name='my_options[imgs][]' <?php checked( in_array( 'thumbnail', $imgs ), 1 ); ?> value='thumbnail'>
            <label><?php _e('Thumbnail','do'); ?></label>
        </p>
        <?php
        $html = "";
       echo apply_filters( 'after_options_callback', $html );
    }

How I can add more fields and settings to my plugin using hooks?

I need to add a new options to my settings, the new filed shown in settings page but not saved.

My add_settings_field callback:

  public function field_option_callback()
    {
        ?>
        <p>
            <input type='checkbox' name='my_options[imgs][]' <?php checked( in_array( 'thumbnail', $imgs ), 1 ); ?> value='thumbnail'>
            <label><?php _e('Thumbnail','do'); ?></label>
        </p>
        <?php
        $html = "";
       echo apply_filters( 'after_options_callback', $html );
    }

How I can add more fields and settings to my plugin using hooks?

EDIT: It works if I remove sanitize_callback from register_setting and use add_filter in same plugin file

Source Link
Jlil
  • 222
  • 3
  • 10

Extend my plugin settings with hooks

I need to add a new options to my settings, the new filed shown in settings page but not saved.

My add_settings_field callback:

  public function field_option_callback()
    {
        ?>
        <p>
            <input type='checkbox' name='my_options[imgs][]' <?php checked( in_array( 'thumbnail', $imgs ), 1 ); ?> value='thumbnail'>
            <label><?php _e('Thumbnail','do'); ?></label>
        </p>
        <?php
        $html = "";
       echo apply_filters( 'after_options_callback', $html );
    }

How I can add more fields and settings to my plugin using hooks?