1 | <?php |
||
6 | class Tabify_Edit_Screen_Settings_Page { |
||
7 | private $tabs; |
||
8 | |||
9 | /** |
||
10 | * Load helper methods |
||
11 | * |
||
12 | * @since 0.8.2 |
||
13 | */ |
||
14 | public function __construct() { |
||
15 | add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
||
|
|||
16 | } |
||
17 | |||
18 | /** |
||
19 | * Adds a option page to manage all the tabs |
||
20 | * |
||
21 | * @since 0.1.0 |
||
22 | */ |
||
23 | public function admin_menu() { |
||
24 | add_options_page( __( 'Tabify edit screen', 'tabify-edit-screen' ), __( 'Tabify edit screen', 'tabify-edit-screen' ), 'manage_options', 'tabify-edit-screen', array( $this, 'edit_screen' ) ); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * Option page that handles the form request |
||
29 | * |
||
30 | * @since 0.1.0 |
||
31 | */ |
||
32 | public function edit_screen() { |
||
33 | if ( ! current_user_can( 'manage_options' ) ) { |
||
34 | wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); |
||
35 | } |
||
36 | |||
37 | $suffix = SCRIPT_DEBUG ? '' : '.min'; |
||
38 | |||
39 | wp_register_script( 'tabify-edit-screen-admin', plugins_url( '/js/admin' . $suffix . '.js', dirname( __FILE__ ) ), array( 'jquery', 'wp-backbone', 'jquery-ui-sortable', 'jquery-touch-punch' ), '1.0' ); |
||
40 | wp_enqueue_script( 'tabify-edit-screen-admin' ); |
||
41 | |||
42 | $data = array( |
||
43 | 'remove' => __( 'Remove', 'tabify-edit-screen' ), |
||
44 | 'cancel' => __( 'Cancel', 'tabify-edit-screen' ), |
||
45 | 'move_meta_boxes' => __( 'Move meta boxes to', 'tabify-edit-screen' ) |
||
46 | ); |
||
47 | wp_localize_script( 'tabify-edit-screen-admin', 'tabify_l10', $data ); |
||
48 | |||
49 | echo '<div class="wrap">'; |
||
50 | echo '<h1>' . esc_html( get_admin_page_title() ) . '</h1>'; |
||
51 | |||
52 | echo '<form id="tabify-form" method="post">'; |
||
53 | wp_nonce_field( plugin_basename( __FILE__ ), 'tabify_edit_screen_nonce' ); |
||
54 | |||
55 | echo '<input type="hidden" id="tabify_edit_screen_nojs" name="tabify_edit_screen_nojs" value="1" />'; |
||
56 | |||
57 | $tabs = array( |
||
58 | 'posttypes' => array( |
||
59 | 'title' => __('Post types', 'tabify-edit-screen' ), |
||
60 | 'class' => 'Tabify_Edit_Screen_Settings_Posttypes' |
||
61 | ) |
||
62 | ); |
||
63 | $tabs = apply_filters( 'tabify_settings_tabs', $tabs ); |
||
64 | |||
65 | $this->tabs = new Tabify_Edit_Screen_Tabs( $tabs, 'horizontal', 'tab', false ); |
||
66 | |||
67 | if ( count( $tabs ) > 1 ) { |
||
68 | echo $this->tabs->get_tabs_with_container(); |
||
69 | } |
||
70 | |||
71 | if ( isset( $tabs[ $this->tabs->get_current_tab() ] ) ) { |
||
72 | $class_name = $tabs[ $this->tabs->get_current_tab() ]['class']; |
||
73 | $settings_screen = new $class_name(); |
||
74 | |||
75 | $this->update_settings(); |
||
76 | |||
77 | echo '<div id="tabify-settings">'; |
||
78 | echo '<div id="tabify-submenu">'; |
||
79 | echo $settings_screen->get_sections_menu(); |
||
80 | echo '</div>'; |
||
81 | |||
82 | echo '<div id="tabifyboxes">'; |
||
83 | echo $settings_screen->get_sections_box(); |
||
84 | echo '</div>'; |
||
85 | echo '</div>'; |
||
86 | |||
87 | echo '</form>'; |
||
88 | echo '</div>'; |
||
89 | } |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Updates settings on POST |
||
94 | * |
||
95 | * @since 0.2.0 |
||
96 | */ |
||
97 | private function update_settings() { |
||
113 | } |
||
114 | } |
||
115 | |||
116 | } |
||
117 |