|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace PHX_WP_DEVKIT\V_1_2\Admin; |
| 4 | + |
| 5 | +use WPOP\V_2_9 as Opts; |
| 6 | + |
| 7 | +/** |
| 8 | + * Class Options_Panel |
| 9 | + */ |
| 10 | +class Options_Panel { |
| 11 | + |
| 12 | + /** |
| 13 | + * @var string |
| 14 | + */ |
| 15 | + public $installed_dir; |
| 16 | + |
| 17 | + /** |
| 18 | + * @var string |
| 19 | + */ |
| 20 | + public $installed_url; |
| 21 | + |
| 22 | + /** |
| 23 | + * @var string |
| 24 | + */ |
| 25 | + protected $site_options; |
| 26 | + |
| 27 | + /** |
| 28 | + * Options_Panel constructor. |
| 29 | + * |
| 30 | + * @param string $installed_dir |
| 31 | + * @param string $installed_url |
| 32 | + */ |
| 33 | + function __construct( $installed_dir, $installed_url ) { |
| 34 | + $this->installed_dir = $installed_dir; |
| 35 | + $this->installed_url = $installed_url; |
| 36 | + |
| 37 | + $this->setup_site_options(); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Register Options Panel |
| 42 | + */ |
| 43 | + function setup_site_options() { |
| 44 | + $page = new Opts\page( |
| 45 | + array( |
| 46 | + 'parent_id' => 'options-general.php', |
| 47 | + 'id' => 'wordpress-development-toolkit-opts', |
| 48 | + 'page_title' => 'WordPress Development Toolkit Settings' . |
| 49 | + ' <small style="font-size:0.66rem;"><code>wordpress-development-toolkit</code></small>', |
| 50 | + 'menu_title' => 'WordPress Development Toolkit', |
| 51 | + 'dashicon' => 'dashicons-admin-settings', |
| 52 | + ) |
| 53 | + ); |
| 54 | + |
| 55 | + $this->site_options = ( $page ); |
| 56 | + |
| 57 | + // setup sections |
| 58 | + $this->site_options->add_part( |
| 59 | + $general_section = new Opts\Section( |
| 60 | + 'general', array( |
| 61 | + 'title' => 'General', |
| 62 | + 'dashicon' => 'dashicons-admin-generic', |
| 63 | + ) |
| 64 | + ) |
| 65 | + ); |
| 66 | + |
| 67 | + /** |
| 68 | + * General Configuration Fields |
| 69 | + */ |
| 70 | + $slug = 'wordpress-development-toolkit_'; |
| 71 | + $general_section->add_part( |
| 72 | + $text_field = new Opts\Text( |
| 73 | + $slug . 'text', array( |
| 74 | + 'label' => 'Text', |
| 75 | + ) |
| 76 | + ) |
| 77 | + ); |
| 78 | + |
| 79 | + $general_section->add_part( |
| 80 | + $textarea = new Opts\Textarea( |
| 81 | + $slug . 'textarea', array( |
| 82 | + 'label' => 'Textarea', |
| 83 | + ) |
| 84 | + ) |
| 85 | + ); |
| 86 | + |
| 87 | + $general_section->add_part( |
| 88 | + $number = new Opts\Number( |
| 89 | + $slug . 'number', array( |
| 90 | + 'label' => 'Number', |
| 91 | + ) |
| 92 | + ) |
| 93 | + ); |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + $general_section->add_part( |
| 98 | + $media = new Opts\Media( |
| 99 | + $slug . 'media', array( |
| 100 | + 'label' => 'Media', |
| 101 | + ) |
| 102 | + ) |
| 103 | + ); |
| 104 | + |
| 105 | + $general_section->add_part( |
| 106 | + $toggle = new Opts\Toggle_Switch( |
| 107 | + $slug . 'toggle', array( |
| 108 | + 'label' => 'Toggle', |
| 109 | + 'value' => 1, |
| 110 | + ) |
| 111 | + ) |
| 112 | + ); |
| 113 | + |
| 114 | + $general_section->add_part( |
| 115 | + $select_field = new Opts\Select( |
| 116 | + $slug . 'select', array( |
| 117 | + 'label' => 'Select', |
| 118 | + 'values' => array( |
| 119 | + 'uno' => 'Uno', |
| 120 | + 'dos' => 'Dos', |
| 121 | + 'tres' => 'Tres', |
| 122 | + ), |
| 123 | + ) |
| 124 | + ) |
| 125 | + ); |
| 126 | + |
| 127 | + // initialize_panel() is a function in the opt panel Container class |
| 128 | + $this->site_options->initialize_panel(); |
| 129 | + } |
| 130 | + |
| 131 | +} |
0 commit comments