PluginProbe
TablePress – Tables in WordPress made easy / 1.9.2
TablePress – Tables in WordPress made easy v1.9.2
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / views / view-options.php

view-options.php in TablePress – Tables in WordPress made easy 1.9.2, at views/view-options.php

208 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Options View
4 *
5 * @package TablePress
6 * @subpackage Views
7 * @author Tobias Bäthge
8 * @since 1.0.0
9 */
10
11 // Prohibit direct script loading.
12 defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
13
14 /**
15 * Plugin Options View class
16 * @package TablePress
17 * @subpackage Views
18 * @author Tobias Bäthge
19 * @since 1.0.0
20 */
21 class TablePress_Options_View extends TablePress_View {
22
23 /**
24 * Set up the view with data and do things that are specific for this view.
25 *
26 * @since 1.0.0
27 *
28 * @param string $action Action for this view.
29 * @param array $data Data for this view.
30 */
31 public function setup( $action, array $data ) {
32 parent::setup( $action, $data );
33
34 // Enqueue WordPress copy of CodeMirror, with CSS linting, etc.
35 $codemirror_settings = wp_enqueue_code_editor( array( 'type' => 'text/css' ) );
36 if ( ! empty( $codemirror_settings ) ) {
37 // Load CSS adjustments for CodeMirror and the added vertical resizing.
38 $this->admin_page->enqueue_style( 'codemirror', array( 'code-editor' ) );
39 $this->admin_page->enqueue_script( 'codemirror', array( 'jquery-core', 'jquery-ui-resizable' ), array(
40 'codemirror_settings' => $codemirror_settings,
41 ) );
42 }
43
44 $this->admin_page->enqueue_script( 'options', array( 'jquery-core' ), array(
45 'strings' => array(
46 'uninstall_warning_1' => __( 'Do you really want to uninstall TablePress and delete ALL data?', 'tablepress' ),
47 'uninstall_warning_2' => __( 'Are you really sure?', 'tablepress' ),
48 )
49 ) );
50
51 $this->process_action_messages( array(
52 'success_save' => __( 'Options saved successfully.', 'tablepress' ),
53 'success_save_error_custom_css' => __( 'Options saved successfully, but &#8220;Custom CSS&#8221; was not saved to file.', 'tablepress' ),
54 'error_save' => __( 'Error: Options could not be saved.', 'tablepress' ),
55 'success_import_wp_table_reloaded' => __( 'The WP-Table Reloaded &#8220;Custom CSS&#8221; was imported successfully.', 'tablepress' ),
56 ) );
57
58 $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
59 if ( current_user_can( 'tablepress_edit_options' ) ) {
60 $this->add_meta_box( 'frontend-options', __( 'Frontend Options', 'tablepress' ), array( $this, 'postbox_frontend_options' ), 'normal' );
61 }
62 $this->add_meta_box( 'user-options', __( 'User Options', 'tablepress' ), array( $this, 'postbox_user_options' ), 'normal' );
63 $this->data['submit_button_caption'] = __( 'Save Changes', 'tablepress' );
64 $this->add_text_box( 'submit', array( $this, 'textbox_submit_button' ), 'submit' );
65 if ( current_user_can( 'deactivate_plugin', TABLEPRESS_BASENAME ) && current_user_can( 'tablepress_edit_options' ) && current_user_can( 'tablepress_delete_tables' ) && ! is_plugin_active_for_network( TABLEPRESS_BASENAME ) ) {
66 $this->add_text_box( 'uninstall-tablepress', array( $this, 'textbox_uninstall_tablepress' ), 'submit' );
67 }
68 }
69
70 /**
71 * Print the screen head text.
72 *
73 * @since 1.0.0
74 *
75 * @param array $data Data for this screen.
76 * @param array $box Information about the text box.
77 */
78 public function textbox_head( array $data, array $box ) {
79 ?>
80 <p>
81 <?php _e( 'TablePress has several options which affect the plugin&#8217;s behavior in different areas.', 'tablepress' ); ?>
82 </p>
83 <p>
84 <?php
85 if ( current_user_can( 'tablepress_edit_options' ) ) {
86 _e( 'Frontend Options influence the styling of tables in pages, posts, or text widgets, by defining which CSS code shall be loaded.', 'tablepress' );
87 echo '<br />';
88 }
89 _e( 'In the User Options, every TablePress user can choose the position of the plugin in his WordPress admin menu.', 'tablepress' );
90 ?>
91 </p>
92 <?php
93 }
94
95 /**
96 * Print the content of the "Frontend Options" post meta box.
97 *
98 * @since 1.0.0
99 *
100 * @param array $data Data for this screen.
101 * @param array $box Information about the meta box.
102 */
103 public function postbox_frontend_options( array $data, array $box ) {
104 ?>
105 <table class="tablepress-postbox-table fixed">
106 <tbody>
107 <tr>
108 <th class="column-1" scope="row"><label for="option-custom-css"><?php _e( 'Custom CSS', 'tablepress' ); ?></label>:</th>
109 <td class="column-2"><label for="option-use-custom-css"><input type="checkbox" id="option-use-custom-css" name="options[use_custom_css]" value="true"<?php checked( $data['frontend_options']['use_custom_css'] ); ?> /> <?php _e( 'Load these &#8220;Custom CSS&#8221; commands to influence the table styling:', 'tablepress' ); ?></label>
110 </td>
111 </tr>
112 <tr>
113 <td class="column-1"></td>
114 <td class="column-2">
115 <textarea name="options[custom_css]" id="option-custom-css" class="large-text" rows="8"><?php echo esc_textarea( $data['frontend_options']['custom_css'] ); ?></textarea>
116 <p class="description">
117 <?php
118 printf( __( '&#8220;Custom CSS&#8221; (<a href="%s">Cascading Style Sheets</a>) can be used to change the styling or layout of a table.', 'tablepress' ), 'https://www.htmldog.com/guides/css/beginner/' );
119 echo ' ';
120 printf( __( 'You can get styling examples from the <a href="%s">FAQ</a>.', 'tablepress' ), 'https://tablepress.org/faq/' );
121 echo ' ';
122 printf( __( 'Information on available CSS selectors can be found in the <a href="%s">documentation</a>.', 'tablepress' ), 'https://tablepress.org/documentation/' );
123 echo ' ';
124 _e( 'Please note that invalid CSS code will be stripped, if it can not be corrected automatically.', 'tablepress' );
125 ?>
126 </p>
127 </td>
128 </tr>
129 </tbody>
130 </table>
131 <?php
132 }
133
134 /**
135 * Print the content of the "User Options" post meta box.
136 *
137 * @since 1.0.0
138 *
139 * @param array $data Data for this screen.
140 * @param array $box Information about the meta box.
141 */
142 public function postbox_user_options( array $data, array $box ) {
143 ?>
144 <table class="tablepress-postbox-table fixed">
145 <tbody>
146 <?php
147 // Get list of current admin menu entries.
148 $entries = array();
149 foreach ( $GLOBALS['menu'] as $entry ) {
150 if ( false !== strpos( $entry[2], '.php' ) ) {
151 $entries[ $entry[2] ] = $entry[0];
152 }
153 }
154
155 // Remove <span> elements with notification bubbles (e.g. update or comment count).
156 if ( isset( $entries['plugins.php'] ) ) {
157 $entries['plugins.php'] = preg_replace( '/ <span.*span>/', '', $entries['plugins.php'] );
158 }
159 if ( isset( $entries['edit-comments.php'] ) ) {
160 $entries['edit-comments.php'] = preg_replace( '/ <span.*span>/', '', $entries['edit-comments.php'] );
161 }
162
163 // Add separator and generic positions.
164 $entries['-'] = '---';
165 $entries['top'] = __( 'Top-Level (top)', 'tablepress' );
166 $entries['middle'] = __( 'Top-Level (middle)', 'tablepress' );
167 $entries['bottom'] = __( 'Top-Level (bottom)', 'tablepress' );
168
169 $select_box = '<select id="option-admin-menu-parent-page" name="options[admin_menu_parent_page]">' . "\n";
170 foreach ( $entries as $page => $entry ) {
171 $select_box .= '<option' . selected( $page, $data['user_options']['parent_page'], false ) . disabled( $page, '-', false ) . ' value="' . $page . '">' . $entry . "</option>\n";
172 }
173 $select_box .= "</select>\n";
174 ?>
175 <tr>
176 <th class="column-1" scope="row"><label for="option-admin-menu-parent-page"><?php _e( 'Admin menu entry', 'tablepress' ); ?>:</label></th>
177 <td class="column-2"><?php printf( __( 'TablePress shall be shown in this section of my admin menu: %s', 'tablepress' ), $select_box ); ?></td>
178 </tr>
179 </tbody>
180 </table>
181 <?php
182 }
183
184 /**
185 * Print the content of the "Admin Options" post meta box.
186 *
187 * @since 1.0.0
188 *
189 * @param array $data Data for this screen.
190 * @param array $box Information about the text box.
191 */
192 public function textbox_uninstall_tablepress( array $data, array $box ) {
193 ?>
194 <h1 style="margin-top:40px;"><?php _e( 'Uninstall TablePress', 'tablepress' ); ?></h1>
195 <p>
196 <?php
197 echo __( 'Uninstalling <strong>will permanently delete</strong> all TablePress tables and options from the database.', 'tablepress' ) . '<br />'
198 . __( 'It is recommended that you create a backup of the tables (by exporting the tables in the JSON format), in case you later change your mind.', 'tablepress' ) . '<br />'
199 . __( 'You will manually need to remove the plugin&#8217;s files from the plugin folder afterwards.', 'tablepress' ) . '<br />'
200 . __( 'Be very careful with this and only click the button if you know what you are doing!', 'tablepress' );
201 ?>
202 </p>
203 <p><a href="<?php echo TablePress::url( array( 'action' => 'uninstall_tablepress' ), true, 'admin-post.php' ); ?>" id="uninstall-tablepress" class="button"><?php _e( 'Uninstall TablePress', 'tablepress' ); ?></a></p>
204 <?php
205 }
206
207 } // class TablePress_Options_View
208