PluginProbe
TablePress – Tables in WordPress made easy / 2.4.3
TablePress – Tables in WordPress made easy v2.4.3
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.4.3, at views/view-options_custom_css.php

156 lines 5.2 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 #[\Override]
33 public function setup( /* string */ $action, array $data ) /* : void */ {
34 // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited.
35
36 // Set action manually here, to get correct page title and nav bar entries.
37 $this->action = 'options';
38 $this->data = $data;
39
40 // Set page title.
41 $GLOBALS['title'] = sprintf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
42
43 $this->add_header_message( '<strong>' . __( 'Attention: Further action is required to save the changes to your &#8220;Custom CSS&#8221;!', 'tablepress' ) . '</strong>', 'notice-success' );
44
45 // Admin page helpers, like script/style loading, could be moved to view.
46 $this->admin_page = TablePress::load_class( 'TablePress_Admin_Page', 'class-admin-page-helper.php', 'classes' );
47 $this->admin_page->enqueue_style( 'common' );
48
49 $this->admin_page->add_admin_footer_text();
50
51 $this->add_text_box( 'explanation-text', array( $this, 'textbox_explanation_text' ), 'normal' );
52 $this->add_text_box( 'credentials-form', array( $this, 'textbox_credentials_form' ), 'normal' );
53 $this->add_text_box( 'proceed-no-file-saving', array( $this, 'textbox_proceed_no_file_saving' ), 'submit' );
54 }
55
56 /**
57 * Render the current view (in this view: without form tag).
58 *
59 * @since 1.0.0
60 */
61 #[\Override]
62 public function render(): void {
63 ?>
64 <div id="tablepress-page" class="wrap">
65 <?php
66 $this->print_nav_tab_menu();
67 ?>
68 <div id="tablepress-body">
69 <?php
70 // Print all header messages.
71 foreach ( $this->header_messages as $message ) {
72 echo $message;
73 }
74
75 $this->do_text_boxes( 'header' );
76 ?>
77 <div id="poststuff">
78 <div id="post-body" class="metabox-holder columns-<?php echo ( isset( $GLOBALS['screen_layout_columns'] ) && ( 2 === $GLOBALS['screen_layout_columns'] ) ) ? '2' : '1'; ?>">
79 <div id="postbox-container-2" class="postbox-container">
80 <?php
81 $this->do_text_boxes( 'normal' );
82 $this->do_meta_boxes( 'normal' );
83
84 $this->do_text_boxes( 'additional' );
85 $this->do_meta_boxes( 'additional' );
86
87 // Print all submit buttons.
88 $this->do_text_boxes( 'submit' );
89 ?>
90 </div>
91 <div id="postbox-container-1" class="postbox-container">
92 <?php
93 // Print all boxes in the sidebar.
94 $this->do_text_boxes( 'side' );
95 $this->do_meta_boxes( 'side' );
96 ?>
97 </div>
98 </div>
99 <br class="clear">
100 </div>
101 </div>
102 </div>
103 <?php
104 }
105
106 /**
107 * Print the content of the "Explanation" text box.
108 *
109 * @since 1.0.0
110 *
111 * @param array<string, mixed> $data Data for this screen.
112 * @param array<string, mixed> $box Information about the text box.
113 */
114 public function textbox_explanation_text( array $data, array $box ): void {
115 ?>
116 <p>
117 <?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' ); ?>
118 <?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' ) ); ?>
119 </p>
120 <?php
121 }
122
123 /**
124 * Print the content of the "Credentials" text box.
125 *
126 * @since 1.0.0
127 *
128 * @param array<string, mixed> $data Data for this screen.
129 * @param array<string, mixed> $box Information about the text box.
130 */
131 public function textbox_credentials_form( array $data, array $box ): void {
132 echo $data['credentials_form'];
133 }
134
135 /**
136 * Print the content of the "Cancel Saving" text box.
137 *
138 * @since 1.0.0
139 *
140 * @param array<string, mixed> $data Data for this screen.
141 * @param array<string, mixed> $box Information about the text box.
142 */
143 public function textbox_proceed_no_file_saving( array $data, array $box ): void {
144 ?>
145 <h2><?php _e( 'Proceed without saving a file', 'tablepress' ); ?></h2>
146 <p>
147 <?php _e( 'To proceed without trying to save the &#8220;Custom CSS&#8221; to a file, click the button below.', 'tablepress' ); ?>
148 <?php _e( 'Your &#8220;Custom CSS&#8221; will then be loaded inline.', 'tablepress' ); ?>
149 </p><p>
150 <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>
151 </p>
152 <?php
153 }
154
155 } // class TablePress_Options_Custom_CSS_View
156