PHP code example of sofyansitorus / wp-yes

1. Go to this page and download the library: Download sofyansitorus/wp-yes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sofyansitorus / wp-yes example snippets


if ( ! function_exists( 'wp_yes_simple' ) ) {
    function wp_yes_simple() {

        $settings = new WP_Yes( 'wp_yes_simple' ); // Initialize the WP_Yes class.

        $settings->add_field(
            array(
                'id' => 'field_1',
                'label' => 'Field 1',
                'tings->init(); // Run the WP_Yes class.
    }
}

add_action( 'init', 'wp_yes_simple' );

if ( ! function_exists( 'wp_yes_simple_bulk' ) ) {
    function wp_yes_simple_bulk() {

        $settings = new WP_Yes( 'wp_yes_simple_bulk' ); // Initialize the WP_Yes class.

        $settings->add_fields(
            array(
                array(
                    'id' => 'field_1',
                    'label' => 'Field 1',
                    '

add_action( 'init', 'wp_yes_simple_bulk' );

if ( ! function_exists( 'wp_yes_simple_with_section' ) ) {
    function wp_yes_simple_with_section() {

        $settings = new WP_Yes( 'wp_yes_simple_with_section' ); // Initialize the WP_Yes class.

        $settings->add_section(
            array(
                'id' => 'section_1',
                'title' => 'Section 1',
            )
        );

        $settings->add_fields(
            array(
                array(
                    'id' => 'field_1',
                    'label' => 'Field 1',
                    '          'id' => 'field_3',
                    'label' => 'Field 3',
                    '

if ( ! function_exists( 'wp_yes_multi_tabs' ) ) {
    function wp_yes_multi_tabs() {
        $settings = new WP_Yes( 'wp_yes_multi_tabs' ); // Initialize the WP_Yes class.

        $settings->add_tab(
            array(
                'id' => 'tab_1',
                'title' => 'Tab 1',
            )
        );

        $settings->add_section(
            array(
                'id' => 'section_1',
                'title' => 'Section 1',
            )
        );

        $settings->add_field(
            array(
                'id'       => 'field_1',
                ' 2',
            )
        );

        $settings->add_fields(
            array(
                array(
                    'id' => 'field_3',
                    'label' => 'Field 3',
                    '

if ( ! function_exists( 'wp_yes_button_and_help_tabs' ) ) {
    function wp_yes_button_and_help_tabs() {

        $settings = new WP_Yes( 'wp_yes_button_and_help_tabs' ); // Initialize the WP_Yes class.

        $settings->add_help_tab(  // <-- Add help tab 1.
            array(
                'id'      => 'my_help_tab',
                'title'   => __( 'My Help Tab' ),
                'content' => '<p>' . __('Descriptive content that will show in My Help Tab-body goes here.') . '</p>',
            )
        );

        $settings->add_help_tab(  // <-- Add help tab 2.
            array(
                'id'      => 'my_help_tab2',
                'title'   => __( 'My Help Tab2' ),
                'content' => '<p>' . __( 'Descriptive content that will show in My Help Tab-body goes here 2. ') . '</p>',
            )
        );

        $settings->add_field(
            array(
                'id' => 'field_1',
                'label' => 'Field 1',
            )
        );

        $settings->add_button( 'Custom Action Button', 'index.php' ); // <-- Add custom action button.

        $settings->init(); // Run the WP_Yes class.
    }
}
add_action( 'init', 'wp_yes_button_and_help_tabs' );

get_option( 'field_1' );

if ( ! function_exists( 'wp_yes_with_prefix' ) ) {
    function wp_yes_with_prefix() {

        $settings = new WP_Yes( 'wp_yes_with_prefix', array(), 'my_setting_prefix' ); // Initialize the WP_Yes class.

        $settings->add_field(
            array(
                'id' => 'field_1',
                'label' => 'Field 1',
            )
        );

        $settings->init(); // Run the WP_Yes class.
    }
}
add_action( 'init', 'wp_yes_with_prefix' );

// To get stored option value for setting field field_1
get_option( 'my_setting_prefix_field_1' );

if ( ! function_exists( 'wp_yes_with_set_prefix' ) ) {
    function wp_yes_with_set_prefix() {

        $settings = new WP_Yes( 'wp_yes_with_set_prefix', array() ); // Initialize the WP_Yes class.

        $settings->set_prefix( 'my_setting_prefix2' );

        $settings->add_field(
            array(
                'id' => 'field_1',
                'label' => 'Field 1',
            )
        );

        $settings->init(); // Run the WP_Yes class.
    }
}
add_action( 'init', 'wp_yes_with_set_prefix' );

// To get stored option value for setting field field_1
get_option( 'my_setting_prefix2_field_1' );