| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDeveloper\BetterDocs\Admin\Customizer\Sections; |
| 4 |
|
| 5 |
use WPDeveloper\BetterDocs\Core\Settings; |
| 6 |
use WPDeveloper\BetterDocs\Utils\Enqueue; |
| 7 |
use WPDeveloper\BetterDocs\Admin\Customizer\Sanitizer; |
| 8 |
|
| 9 |
abstract class Section { |
| 10 |
protected $customizer = null; |
| 11 |
protected $defaults = null; |
| 12 |
/** |
| 13 |
* Customizer Panel ID |
| 14 |
* |
| 15 |
* @var string |
| 16 |
*/ |
| 17 |
protected $panel_id = 'betterdocs_customize_options'; |
| 18 |
|
| 19 |
/** |
| 20 |
* Sanitizer |
| 21 |
* |
| 22 |
* @var Sanitizer |
| 23 |
*/ |
| 24 |
protected $sanitizer; |
| 25 |
|
| 26 |
/** |
| 27 |
* Settings |
| 28 |
* @var Settings |
| 29 |
*/ |
| 30 |
protected $settings; |
| 31 |
protected $priority = 100; |
| 32 |
|
| 33 |
abstract public function get_id(); |
| 34 |
abstract public function get_title(); |
| 35 |
|
| 36 |
/** |
| 37 |
* Enqueue Manager |
| 38 |
* |
| 39 |
* @var Enqueue |
| 40 |
*/ |
| 41 |
protected $assets; |
| 42 |
|
| 43 |
public function __construct( Sanitizer $sanitizer, Settings $settings ) { |
| 44 |
$this->sanitizer = $sanitizer; |
| 45 |
$this->settings = $settings; |
| 46 |
$this->assets = betterdocs()->assets; |
| 47 |
} |
| 48 |
|
| 49 |
public function set_customizer( $customizer, $defaults ) { |
| 50 |
$this->customizer = $customizer; |
| 51 |
$this->defaults = $defaults; |
| 52 |
} |
| 53 |
|
| 54 |
public function section() { |
| 55 |
$this->customizer->add_section( $this->get_id(), [ |
| 56 |
'title' => $this->get_title(), |
| 57 |
'priority' => $this->priority, |
| 58 |
'panel' => $this->panel_id |
| 59 |
] ); |
| 60 |
} |
| 61 |
|
| 62 |
public function register( $customizer, $defaults ) { |
| 63 |
$this->set_customizer( $customizer, $defaults ); |
| 64 |
$_methods = get_class_methods( $this ); |
| 65 |
if ( ! empty( $_methods ) ) { |
| 66 |
$this->section(); |
| 67 |
|
| 68 |
foreach ( $_methods as $method ) { |
| 69 |
if ( in_array( $method, ['get_id', 'section', 'get_title', 'register', 'set_customizer', '__construct'] ) ) { |
| 70 |
continue; |
| 71 |
} |
| 72 |
|
| 73 |
$this->{$method}(); |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|