Site icon Hip-Hop Website Design and Development

automate breadcrumbs to the house web page?

Issues I would like to perform:

  1. Set up a "site variable" the place we are able to set what class a weblog belongs in. These classes are Possibility 1, Possibility 2, Possibility 3, and Possibility 4.
  2. When one of many classes is chosen, it generates the breadcrumb on the weblog’s house web page and likewise the primary half of the secondary breadcrumbs in archive or single pages.
  3. Make it so the weblog house is mechanically the second a part of the breadcrumb hyperlink path.

Listed below are the screenshots that present the customized possibility known as Website Data:

Writes to the wp_options database desk

Right here is the code thus far:

class MySettingsPage
{
personal $choices;

operate __construct()
{
    add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
    add_action( 'admin_init', array( $this, 'page_init' ) );
}

operate add_plugin_page()
{
    // This web page can be underneath "Settings"
    add_options_page(
        'Settings Admin', 
        'Website Data', 
        'manage_options', 
        'my-setting-admin', 
        array( $this, 'create_admin_page' )
    );
}

operate create_admin_page()
{
    // Set class property
    $this->choices = get_option( 'site_information_options' );
    ?>
    <div class="wrap">
        <h1>Website Data</h1>
        <type methodology="post" motion="options.php">
        <?php
            // This prints out all hidden setting fields
            settings_fields( 'site-information_group' );
            do_settings_sections( 'my-setting-admin' );
            submit_button();
        ?>
        </type>
    </div>
     <?php
}

operate page_init()
{        
    register_setting(
        'site-information_group', 
        'site_information_options', 
        array( $this, 'sanitize' ) 
    );

    add_settings_section(
        'setting_section_id', 
        'Customized Settings', 
        array( $this, 'print_section_info' ), 
        'my-setting-admin' 
    );  

    add_settings_field(
        'parent_category', 
        'Mother or father Class', 
        array( $this, 'parent_category_callback' ), 
        'my-setting-admin', 
        'setting_section_id'
    );      

    add_settings_field(
        'subcategory', 
        'Subcategory', 
        array( $this, 'subcategory_callback' ), 
        'my-setting-admin', 
        'setting_section_id'
    ); 
        
    add_settings_field(
        'blog_owner_email', 
        'Weblog Proprietor Electronic mail', 
        array( $this, 'blog_owner_email_callback' ), 
        'my-setting-admin', 
        'setting_section_id'
    ); 
}

operate sanitize( $enter )
{
    $new_input = array();
    if( isset( $enter['parent_category'] ) )
        $new_input['parent_category'] = sanitize_text_field( $enter['parent_category'] );

    if( isset( $enter['subcategory'] ) )
        $new_input['subcategory'] = sanitize_text_field( $enter['subcategory'] );

    if( isset( $enter['blog_owner_email'] ) )
        $new_input['blog_owner_email'] = sanitize_text_field( $enter['blog_owner_email'] );

    return $new_input;
}

operate print_section_info()
{
    print 'Enter your settings under:';
}

operate parent_category_callback()
{
    printf(
        '<choose id="parent_category" title="site_information_options[parent_category]" worth="%s" >
            <possibility>Choose...</possibility>  
            <possibility>Possibility 1</possibility>
            <possibility>Possibility 2</possibility>
            <possibility>Possibility 3</possibility>
            <possibility>Possibility 4</possibility>
        </choose>',
        isset( $this->choices['parent_category'] ) ? esc_attr( $this->choices['parent_category']) : ''
    );
}

operate subcategory_callback()
{
    printf(
        '<choose id="subcategory" title="site_information_options[subcategory]" worth="%s" >
            <possibility>Choose...</possibility>
            <possibility>Possibility 1</possibility>
            <possibility>Possibility 2</possibility>
        </choose>',
        isset( $this->choices['subcategory'] ) ? esc_attr( $this->choices['subcategory']) : ''
    );
}

operate blog_owner_email_callback()
{
    printf(
        '<enter sort="text" id="blog_owner_email" title="site_information_options[blog_owner_email]" worth="%s" />',
         isset( $this->choices['blog_owner_email'] ) ? esc_attr( $this->choices['blog_owner_email']) : ''
    );
}
}
if( is_admin())
    $my_settings_page = new MySettingsPage();