PHP code example of loureirorg / settings-as-woocommerce
1. Go to this page and download the library: Download loureirorg/settings-as-woocommerce 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/ */
loureirorg / settings-as-woocommerce example snippets
$label = 'My Submenu';
$slug = 'my_submenu';
$menu = 'users';
$my_submenu = new Submenu( $label, $slug, $menu );
$my_submenu
->add_tab( new MyTab1() )
->add_tab( new MyTab2() );
$my_menu = new Menu( 'My Menu', 'my_menu' );
$my_menu
->add_tab( new MyTab1() )
->add_tab( new MyTab2() );
$my_menu = new Menu( 'My Menu', 'my_menu' );
$my_submenu = new Submenu( 'My Submenu', 'my_submenu', 'my_menu' );
$my_submenu
->add_tab( new MyTab1() )
->add_tab( new MyTab2() );
class MyTab1 extends Tab {
public function __construct() {
$this->id = 'my_tab1';
$this->label = 'My First Tab!';
parent::__construct();
}
public function get_settings() {
$settings = array(
array( 'type' => 'title', 'name' => 'My Field Group' ),
array( 'type' => 'checkbox', 'name' => 'My checkbox 1', 'id' => 'my-checkbox-1' ),
array( 'type' => 'checkbox', 'name' => 'My checkbox 2', 'id' => 'my-checkbox-2' ),
array( 'type' => 'sectionend', 'id' => 'my-field-group-1-end' ),
);
return $settings;
}
public function save() {
$this->update_options( $this->get_settings() );
}
}