PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
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_custom_css.php

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

162 lines 5.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/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 declare(strict_types=1);
12
13 // Prohibit direct script loading.
14 defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
15
16 /**
17 * Plugin Options/Save Custom CSS Credentials Form View class
18 *
19 * @package TablePress
20 * @subpackage Views
21 * @author Tobias Bäthge
22 * @since 1.0.0
23 */
24 class TablePress_Options_Custom_CSS_View extends TablePress_View {
25
26 /**
27 * Set up the view with data and do things that are specific for this view.
28 *
29 * @since 1.0.0
30 *
31 * @param string $action Action for this view.
32 * @param array<string, mixed> $data Data for this view.
33 */
34 #[\Override]
35 public function setup( /* string */ $action, array $data ) /* : void */ {
36 // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited.
37
38 // Set action manually here, to get correct page title and nav bar entries.
39 $this->action = 'options';
40 $this->data = $data;
41
42 // Set page title.
43 /* translators: %1$s: Page title, %2$s: Plugin name */
44 $GLOBALS['title'] = sprintf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
45
46 add_filter( 'admin_footer_text', array( $this, 'add_admin_footer_text' ) );
47
48 $this->add_header_message( '<strong>' . __( 'Attention: Further action is required to save the changes to your &#8220;Custom CSS&#8221;!', 'tablepress' ) . '</strong>', 'is-warning notice-warning' );
49
50 TablePress::enqueue_style( 'common', array( 'wp-components' ) );
51
52 $this->add_text_box( 'explanation-text', array( $this, 'textbox_explanation_text' ), 'normal' );
53 $this->add_text_box( 'credentials-form', array( $this, 'textbox_credentials_form' ), 'normal' );
54 $this->add_text_box( 'proceed-no-file-saving', array( $this, 'textbox_proceed_no_file_saving' ), 'submit' );
55 }
56
57 /**
58 * Render the current view (in this view: without form tag).
59 *
60 * @since 1.0.0
61 */
62 #[\Override]
63 public function render(): void {
64 ?>
65 <div id="tablepress-page" class="wrap">
66 <?php
67 $this->print_nav_tab_menu();
68 ?>
69 <div id="tablepress-body">
70 <hr class="wp-header-end">
71 <script>document.querySelectorAll('.notice:has(~#tablepress-page)').forEach(e=>document.querySelector('.wp-header-end').after(e));</script>
72 <?php
73 // Print all header messages.
74 foreach ( $this->header_messages as $message ) {
75 echo $message;
76 }
77
78 $this->do_text_boxes( 'header' );
79 ?>
80 <div id="poststuff">
81 <div id="post-body" class="metabox-holder columns-<?php echo ( isset( $GLOBALS['screen_layout_columns'] ) && ( 2 === $GLOBALS['screen_layout_columns'] ) ) ? '2' : '1'; ?>">
82 <div id="postbox-container-2" class="postbox-container">
83 <?php
84 $this->do_text_boxes( 'normal' );
85 $this->do_meta_boxes( 'normal' );
86
87 $this->do_text_boxes( 'additional' );
88 $this->do_meta_boxes( 'additional' );
89
90 // Print all submit buttons.
91 $this->do_text_boxes( 'submit' );
92 ?>
93 </div>
94 <div id="postbox-container-1" class="postbox-container">
95 <?php
96 // Print all boxes in the sidebar.
97 $this->do_text_boxes( 'side' );
98 $this->do_meta_boxes( 'side' );
99 ?>
100 </div>
101 </div>
102 <br class="clear">
103 </div>
104 </div>
105 </div>
106 <?php
107 }
108
109 /**
110 * Print the content of the "Explanation" text box.
111 *
112 * @since 1.0.0
113 *
114 * @param array<string, mixed> $data Data for this screen.
115 * @param array<string, mixed> $box Information about the text box.
116 */
117 public function textbox_explanation_text( array $data, array $box ): void {
118 ?>
119 <p>
120 <?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' ); ?>
121 <?php
122 /* translators: %s: Connection information form label */
123 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' ) );
124 ?>
125 </p>
126 <?php
127 }
128
129 /**
130 * Print the content of the "Credentials" text box.
131 *
132 * @since 1.0.0
133 *
134 * @param array<string, mixed> $data Data for this screen.
135 * @param array<string, mixed> $box Information about the text box.
136 */
137 public function textbox_credentials_form( array $data, array $box ): void {
138 echo $data['credentials_form'];
139 }
140
141 /**
142 * Print the content of the "Cancel Saving" text box.
143 *
144 * @since 1.0.0
145 *
146 * @param array<string, mixed> $data Data for this screen.
147 * @param array<string, mixed> $box Information about the text box.
148 */
149 public function textbox_proceed_no_file_saving( array $data, array $box ): void {
150 ?>
151 <h2><?php _e( 'Proceed without saving a file', 'tablepress' ); ?></h2>
152 <p>
153 <?php _e( 'To proceed without trying to save the &#8220;Custom CSS&#8221; to a file, click the button below.', 'tablepress' ); ?>
154 <?php _e( 'Your &#8220;Custom CSS&#8221; will then be loaded inline.', 'tablepress' ); ?>
155 </p><p>
156 <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>
157 </p>
158 <?php
159 }
160
161 } // class TablePress_Options_Custom_CSS_View
162