PluginProbe
TablePress – Tables in WordPress made easy / 2.2
TablePress – Tables in WordPress made easy v2.2
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 2.4.4 All 44 releases
tablepress / views / view-options_custom_css.php

view-options_custom_css.php in TablePress – Tables in WordPress made easy 2.2, at views/view-options_custom_css.php

154 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Options/Save Custom CSS Credentials Form 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/Save Custom CSS Credentials Form View class
16 *
17 * @package TablePress
18 * @subpackage Views
19 * @author Tobias Bäthge
20 * @since 1.0.0
21 */
22 class TablePress_Options_Custom_CSS_View extends TablePress_View {
23
24 /**
25 * Set up the view with data and do things that are specific for this view.
26 *
27 * @since 1.0.0
28 *
29 * @param string $action Action for this view.
30 * @param array<string, mixed> $data Data for this view.
31 */
32 public function setup( /* string */ $action, array $data ) /* : void */ {
33 // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited.
34
35 // Set action manually here, to get correct page title and nav bar entries.
36 $this->action = 'options';
37 $this->data = $data;
38
39 // Set page title.
40 $GLOBALS['title'] = sprintf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
41
42 $this->add_header_message( '<strong>' . __( 'Attention: Further action is required to save the changes to your &#8220;Custom CSS&#8221;!', 'tablepress' ) . '</strong>', 'notice-success' );
43
44 // Admin page helpers, like script/style loading, could be moved to view.
45 $this->admin_page = TablePress::load_class( 'TablePress_Admin_Page', 'class-admin-page-helper.php', 'classes' );
46 $this->admin_page->enqueue_style( 'common' );
47
48 $this->admin_page->add_admin_footer_text();
49
50 $this->add_text_box( 'explanation-text', array( $this, 'textbox_explanation_text' ), 'normal' );
51 $this->add_text_box( 'credentials-form', array( $this, 'textbox_credentials_form' ), 'normal' );
52 $this->add_text_box( 'proceed-no-file-saving', array( $this, 'textbox_proceed_no_file_saving' ), 'submit' );
53 }
54
55 /**
56 * Render the current view (in this view: without form tag).
57 *
58 * @since 1.0.0
59 */
60 public function render(): void {
61 ?>
62 <div id="tablepress-page" class="wrap">
63 <?php
64 $this->print_nav_tab_menu();
65 ?>
66 <div id="tablepress-body">
67 <?php
68 // Print all header messages.
69 foreach ( $this->header_messages as $message ) {
70 echo $message;
71 }
72
73 $this->do_text_boxes( 'header' );
74 ?>
75 <div id="poststuff">
76 <div id="post-body" class="metabox-holder columns-<?php echo ( isset( $GLOBALS['screen_layout_columns'] ) && ( 2 === $GLOBALS['screen_layout_columns'] ) ) ? '2' : '1'; ?>">
77 <div id="postbox-container-2" class="postbox-container">
78 <?php
79 $this->do_text_boxes( 'normal' );
80 $this->do_meta_boxes( 'normal' );
81
82 $this->do_text_boxes( 'additional' );
83 $this->do_meta_boxes( 'additional' );
84
85 // Print all submit buttons.
86 $this->do_text_boxes( 'submit' );
87 ?>
88 </div>
89 <div id="postbox-container-1" class="postbox-container">
90 <?php
91 // Print all boxes in the sidebar.
92 $this->do_text_boxes( 'side' );
93 $this->do_meta_boxes( 'side' );
94 ?>
95 </div>
96 </div>
97 <br class="clear" />
98 </div>
99 </div>
100 </div>
101 <?php
102 }
103
104 /**
105 * Print the content of the "Explanation" text box.
106 *
107 * @since 1.0.0
108 *
109 * @param array<string, mixed> $data Data for this screen.
110 * @param array<string, mixed> $box Information about the text box.
111 */
112 public function textbox_explanation_text( array $data, array $box ): void {
113 ?>
114 <p>
115 <?php _e( 'Due to the configuration of your server, TablePress was not able to automatically save your &#8220;Custom CSS&#8221; to a file.', 'tablepress' ); ?>
116 <?php printf( __( 'To try again with the same method that you use for updating plugins or themes, please fill out the &#8220;%s&#8221; form below.', 'tablepress' ), __( 'Connection Information', 'default' ) ); ?>
117 </p>
118 <?php
119 }
120
121 /**
122 * Print the content of the "Credentials" text box.
123 *
124 * @since 1.0.0
125 *
126 * @param array<string, mixed> $data Data for this screen.
127 * @param array<string, mixed> $box Information about the text box.
128 */
129 public function textbox_credentials_form( array $data, array $box ): void {
130 echo $data['credentials_form'];
131 }
132
133 /**
134 * Print the content of the "Cancel Saving" text box.
135 *
136 * @since 1.0.0
137 *
138 * @param array<string, mixed> $data Data for this screen.
139 * @param array<string, mixed> $box Information about the text box.
140 */
141 public function textbox_proceed_no_file_saving( array $data, array $box ): void {
142 ?>
143 <h2><?php _e( 'Proceed without saving a file', 'tablepress' ); ?></h2>
144 <p>
145 <?php _e( 'To proceed without trying to save the &#8220;Custom CSS&#8221; to a file, click the button below.', 'tablepress' ); ?>
146 <?php _e( 'Your &#8220;Custom CSS&#8221; will then be loaded inline.', 'tablepress' ); ?>
147 </p><p>
148 <a href="<?php echo TablePress::url( array( 'action' => 'options', 'message' => 'success_save_error_custom_css' ) ); ?>" class="button button-large"><?php _e( 'Proceed without saving &#8220;Custom CSS&#8221; to a file', 'tablepress' ); ?></a>
149 </p>
150 <?php
151 }
152
153 } // class TablePress_Options_Custom_CSS_View
154