plugins - Shrink down register_settings on Settings API

Instead of having so many function calls, is there a way that I can have one function call and all the fields under one

Instead of having so many function calls, is there a way that I can have one function call and all the fields under one section and then just call one section on the form?

/**
 * Register each section
 */
function register_insta_heading()
{
    register_setting('instagram-settings','insta_heading','');
    add_settings_section('','','','insta_heading_field');
    add_settings_field('','Heading','heading_display', 'insta_heading_field','');
}

function register_insta_username()
{
    register_setting('instagram-settings','insta_username');
    add_settings_section('','','','insta_username_field');
    add_settings_field('','Username','username_display','insta_username_field','');
}

function register_insta_id()
{
    register_setting('instagram-settings','insta_id');
    add_settings_section('','','','insta_id_field');
    add_settings_field('','Instagram ID','id_display','insta_id_field','');}

function register_insta_posts()
{
    register_setting('instagram-settings','insta_posts');
    add_settings_section('','','','posts_number_field');
    add_settings_field('','# of Posts','posts_number_display','posts_number_field','');
}

function register_insta_accesstoken()
{
    register_setting('instagram-settings','insta_accesstoken');
    add_settings_section('','','','access_token_field');
    add_settings_field('','Access Token','access_token_display','access_token_field','');
}

The form submit:


<?php
        settings_fields( 'instagram-settings' );
        do_settings_sections("insta_heading_field");
        do_settings_sections("insta_username_field");
        do_settings_sections("insta_id_field");
        do_settings_sections("posts_number_field");
        do_settings_sections("access_token_field");
        submit_button();
        ?>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745163045a4614485.html

相关推荐

  • plugins - Shrink down register_settings on Settings API

    Instead of having so many function calls, is there a way that I can have one function call and all the fields under one

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信