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

159 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 /* translators: %1$s: Page title, %2$s: Plugin name */
42 $GLOBALS['title'] = sprintf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
43
44 add_filter( 'admin_footer_text', array( $this, 'add_admin_footer_text' ) );
45
46 $this->add_header_message( '<strong>' . __( 'Attention: Further action is required to save the changes to your &#8220;Custom CSS&#8221;!', 'tablepress' ) . '</strong>', 'is-success' );
47
48 TablePress::enqueue_style( 'common', array( 'wp-components' ) );
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 #[\Override]
61 public function render(): void {
62 ?>
63 <div id="tablepress-page" class="wrap">
64 <?php
65 $this->print_nav_tab_menu();
66 ?>
67 <div id="tablepress-body">
68 <hr class="wp-header-end">
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
119 /* translators: %s: Connection information form label */
120 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' ) );
121 ?>
122 </p>
123 <?php
124 }
125
126 /**
127 * Print the content of the "Credentials" text box.
128 *
129 * @since 1.0.0
130 *
131 * @param array<string, mixed> $data Data for this screen.
132 * @param array<string, mixed> $box Information about the text box.
133 */
134 public function textbox_credentials_form( array $data, array $box ): void {
135 echo $data['credentials_form'];
136 }
137
138 /**
139 * Print the content of the "Cancel Saving" text box.
140 *
141 * @since 1.0.0
142 *
143 * @param array<string, mixed> $data Data for this screen.
144 * @param array<string, mixed> $box Information about the text box.
145 */
146 public function textbox_proceed_no_file_saving( array $data, array $box ): void {
147 ?>
148 <h2><?php _e( 'Proceed without saving a file', 'tablepress' ); ?></h2>
149 <p>
150 <?php _e( 'To proceed without trying to save the &#8220;Custom CSS&#8221; to a file, click the button below.', 'tablepress' ); ?>
151 <?php _e( 'Your &#8220;Custom CSS&#8221; will then be loaded inline.', 'tablepress' ); ?>
152 </p><p>
153 <a href="<?php echo TablePress::url( array( 'action' => 'options', 'message' => 'success_save_error_custom_css' ) ); ?>" class="components-button is-secondary"><?php _e( 'Proceed without saving &#8220;Custom CSS&#8221; to a file', 'tablepress' ); ?></a>
154 </p>
155 <?php
156 }
157
158 } // class TablePress_Options_Custom_CSS_View
159