| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Generates the HTML for a metabox tab. |
| 10 |
*/ |
| 11 |
class WPSEO_Metabox_Collapsible implements WPSEO_Metabox_Tab { |
| 12 |
|
| 13 |
/** |
| 14 |
* The collapsible's unique identifier. |
| 15 |
* |
| 16 |
* @var string |
| 17 |
*/ |
| 18 |
private $name; |
| 19 |
|
| 20 |
/** |
| 21 |
* The content to be displayed inside the collapsible. |
| 22 |
* |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
private $content; |
| 26 |
|
| 27 |
/** |
| 28 |
* The label. |
| 29 |
* |
| 30 |
* @var string |
| 31 |
*/ |
| 32 |
private $link_content; |
| 33 |
|
| 34 |
/** |
| 35 |
* Constructor. |
| 36 |
* |
| 37 |
* @param string $name The name of the tab, used as an identifier in the html. |
| 38 |
* @param string $content The tab content. |
| 39 |
* @param string $link_content The text content of the tab link. |
| 40 |
*/ |
| 41 |
public function __construct( $name, $content, $link_content ) { |
| 42 |
$this->name = $name; |
| 43 |
$this->content = $content; |
| 44 |
$this->link_content = $link_content; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Returns the html for the tab link. |
| 49 |
* |
| 50 |
* @return string |
| 51 |
*/ |
| 52 |
public function link() { |
| 53 |
return $this->link_content; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Returns the html for the tab content. |
| 58 |
* |
| 59 |
* @return string |
| 60 |
*/ |
| 61 |
public function content() { |
| 62 |
$collapsible_paper = new WPSEO_Paper_Presenter( |
| 63 |
$this->link(), |
| 64 |
null, |
| 65 |
[ |
| 66 |
'content' => $this->content, |
| 67 |
'collapsible' => true, |
| 68 |
'class' => 'metabox wpseo-form wpseo-collapsible-container', |
| 69 |
'paper_id' => 'collapsible-' . $this->name, |
| 70 |
], |
| 71 |
); |
| 72 |
|
| 73 |
return $collapsible_paper->get_output(); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Returns the collapsible's unique identifier. |
| 78 |
* |
| 79 |
* @return string |
| 80 |
*/ |
| 81 |
public function get_name() { |
| 82 |
return $this->name; |
| 83 |
} |
| 84 |
} |
| 85 |
|