1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
<?php
class Papi_Core_Tab {
/**
* The background of the tab.
*
* Possible values are: `white` or `grey`.
*
* By default if empty the background will be automatic,
* if first property has no sidebar it'll be white and
* if it has a sidebar it'll be grey.
*
* @var string
*/
public $background = '';
/**
* Capabilities list.
*
* @var array
*/
public $capabilities = [];
/**
* Tab icon.
*
* @var string
*/
public $icon = '';
/**
* The core tab identifier.
*
* @var string
*/
public $id = '';
/**
* Box properties.
*
* @var array
*/
public $properties = [];
/**
* The sort order of the core box.
*
* @var int
*/
public $sort_order = 1000;
/**
* Because of old code for tabs this
* property is required to exists on
* core tab class.
*
* @var bool
*/
public $tab = true;
/**
* The title of the box.
*
* @var string
*/
public $title = '';
/**
* The constructor.
*
* @param array $args
* @param array $properties
*/
public function __construct( array $args = [], array $properties = [] ) {
$this->setup_args( $args );
$this->setup_properties( $properties );
}
/**
* Setup arguments.
*
* @param array $args
*/
private function setup_args( array $args ) {
foreach ( $args as $key => $value ) {
if ( isset( $this->$key ) ) {
$this->$key = papi_esc_html( $value );
}
}
if ( empty( $this->id ) ) {
$this->id = strtolower( papi_f( papi_underscorify( papify( $this->title ) ) ) );
}
}
/**
* Setup properties.
*
* @param array $properties
*/
private function setup_properties( array $properties ) {
$this->properties = array_merge( $this->properties, papi_populate_properties( $properties ) );
}
}