ShowEditButton.php
901 Bytes
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
<?php
namespace AC\Admin\Section\Partial;
use AC\Form\Element\Toggle;
use AC\Renderable;
use AC\Settings\Option\EditButton;
use AC\View;
class ShowEditButton implements Renderable {
/**
* @var EditButton
*/
private $option;
public function __construct() {
$this->option = new EditButton();
}
private function get_label() {
return sprintf( __( "Show %s button on table screen.", 'codepress-admin-columns' ), sprintf( '"%s"', __( 'Edit columns', 'codepress-admin-columns' ) ) );
}
/**
* @return string
*/
public function render() {
$toggle = new Toggle( $this->option->get_name(), $this->get_label(), $this->option->is_enabled() );
$toggle->set_value( '1' );
$toggle->set_attribute( 'data-ajax-setting', $this->option->get_name() );
$view = new View( [ 'setting' => $toggle->render() ] );
return $view->set_template( 'admin/settings/setting-row' )->render();
}
}