PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 1.6.4
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v1.6.4
3.4.6 3.4.5 3.4.4 3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 All 199 releases
← All changes | admin/section/class-convertkit-settings-tools.php +315 -263 2.3.0 → 1.6.4 View file →
@@ -1,7 +1,8 @@
1 1 <?php
2 +
2 3 /**
3 - * ConvertKit Settings Tools class.
4 + * ConvertKit Tools Settings class
4 5 *
5 6 * @package ConvertKit
6 7 * @author ConvertKit
7 8 */
@@ -6,371 +7,422 @@
6 7 * @author ConvertKit
7 8 */
8 9
9 10 /**
10 - * Registers Tools for debugging and system information that can be accessed at Settings > ConvertKit > Tools.
11 - *
12 - * @package ConvertKit
13 - * @author ConvertKit
11 + * Class ConvertKit_Settings_Tools
14 12 */
15 13 class ConvertKit_Settings_Tools extends ConvertKit_Settings_Base {
16 14
17 15 /**
16 + * We are hiding the submit button.
17 + *
18 + * @var bool
19 + */
20 + protected $show_submit = false;
21 +
22 + /**
18 23 * Constructor
19 24 */
20 25 public function __construct() {
21 -
22 - // Initialize WP_Filesystem.
23 - require_once ABSPATH . 'wp-admin/includes/file.php';
24 - WP_Filesystem();
25 -
26 - $this->settings_key = '_wp_convertkit_tools'; // Required for ConvertKit_Settings_Base, but we don't save settings on the Tools screen.
26 + $this->settings_key = '_wp_convertkit_integration_tools_settings';
27 27 $this->name = 'tools';
28 28 $this->title = __( 'Tools', 'convertkit' );
29 29 $this->tab_text = __( 'Tools', 'convertkit' );
30 30
31 - // Output notices.
32 - add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_notices' ) );
31 + parent::__construct();
32 + }
33 33
34 - parent::__construct();
34 + /**
35 + * Register and add settings
36 + */
37 + public function register_fields() {
38 + add_settings_field(
39 + 'log',
40 + 'Log',
41 + array( $this, 'view_log' ),
42 + $this->settings_key,
43 + $this->name
44 + );
45 + }
35 46
36 - $this->maybe_perform_actions();
47 + /**
48 + * Prints help info for this section
49 + */
50 + public function print_section_info() {
51 + ?>
52 + <p><?php esc_html_e( 'Tools to help you manage ConvertKit on your site.', 'convertkit' ); ?></p>
53 + <?php
37 54 }
38 55
39 56 /**
40 - * Possibly perform some actions, such as clearing the log, downloading the log,
41 - * downloading system information or any third party actions now.
42 - *
43 - * @since 1.9.7.4
57 + * Renders the section
44 58 */
45 - private function maybe_perform_actions() {
59 + public function render() {
60 + settings_fields( $this->settings_key );
61 + $this->view_log();
62 + $this->view_server_info();
63 + }
46 64
47 - // Bail if nonce is invalid.
48 - if ( ! $this->verify_nonce() ) {
49 - return;
50 - }
65 + /*
66 + * View the Log
67 + */
68 + public function view_log() {
69 + $log_file = trailingslashit( CONVERTKIT_PLUGIN_PATH ) . 'log.txt';
70 + $log = file_get_contents( $log_file );
51 71
52 - $this->maybe_clear_log();
53 - $this->maybe_download_log();
54 - $this->maybe_download_system_info();
55 - $this->maybe_export_configuration();
56 - $this->maybe_import_configuration();
72 + ?>
73 + <div class="metabox-holder">
74 + <div class="postbox ck-debug-log">
75 + <h3><span><?php esc_html_e( 'Debug Log', 'convertkit' ); ?></span></h3>
76 + <div class="inside">
77 + <p><?php _e( 'Use this tool to help debug ConvertKit plugin functionality.', 'convertkit' ); ?></p>
78 + <textarea readonly="readonly" class="large-text monospace" rows="15"
79 + name="convertkit-debug-log-contents"><?php echo esc_textarea( $log ); ?></textarea>
80 + <p class="submit">
81 + <?php
82 + submit_button(
83 + __( 'Copy Log','convertkit' ),
84 + 'primary',
85 + 'convertkit-copy-debug-log',
86 + false,
87 + array(
88 + 'onclick' => "this.form['convertkit-debug-log-contents'].focus();this.form['convertkit-debug-log-contents'].select();document.execCommand('copy');return false;"
89 + )
90 + );
91 + submit_button(
92 + __( 'Clear Log', 'convertkit' ),
93 + 'secondary ck-inline-button',
94 + 'convertkit-clear-debug-log',
95 + false
96 + );
97 + ?>
98 + </p>
99 + <p><?php _e( 'Log file', 'convertkit' ); ?>: <code><?php echo $log_file; ?></code></p>
100 + </div><!-- .inside -->
101 + </div><!-- .postbox -->
102 + </div><!-- .metabox-holder -->
103 + <?php
104 + }
57 105
106 + public function view_server_info() {
107 + ?>
108 + <div class="metabox-holder">
109 + <div class="postbox ck-debug-log">
110 + <h3><span><?php esc_html_e( 'System Info', 'convertkit' ); ?></span></h3>
111 + <div class="inside">
112 + <p><?php _e( 'Use this tool to send system info to support when necessary.', 'convertkit' ); ?></p>
113 + <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" class="large-text monospace" rows="15" name="convertkit-sysinfo"><?php echo $this->get_system_info(); ?></textarea>
114 + <p class="submit">
115 + <input type="hidden" name="convertkit-action" value="download_sysinfo" />
116 + <?php
117 + submit_button(
118 + __( 'Copy System Info', 'convertkit' ),
119 + 'primary',
120 + 'convertkit-copy-system-info',
121 + false,
122 + array(
123 + 'onclick' => "this.form['convertkit-sysinfo'].focus();this.form['convertkit-sysinfo'].select();document.execCommand('copy');return false;"
124 + )
125 + );
126 + ?>
127 + </p>
128 + </div><!-- .inside -->
129 + </div><!-- .postbox -->
130 + </div><!-- .metabox-holder -->
131 + <?php
58 132 }
59 133
60 134 /**
61 - * Clears the Log.
135 + * Sanitizes the settings.
136 + * We are also using this to clear the Log file.
62 137 *
63 - * @since 1.9.6
138 + * @param array $settings The settings fields submitted.
139 + * @return array Sanitized settings.
64 140 */
65 - private function maybe_clear_log() {
141 + public function sanitize_settings( $settings ) {
66 142
67 - // Bail if the submit button for clearing the debug log was not clicked.
68 - // Nonce verification already performed in maybe_perform_actions() which calls this function.
69 - if ( ! array_key_exists( 'convertkit-clear-debug-log', $_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification
143 + $log_file = trailingslashit( CONVERTKIT_PLUGIN_PATH ) . 'log.txt';
144 +
145 + if ( ! current_user_can( 'manage_options' ) ) {
70 146 return;
71 147 }
72 148
73 - // Clear Log.
74 - $log = new ConvertKit_Log( CONVERTKIT_PLUGIN_PATH );
75 - $log->clear();
149 + if ( isset( $_REQUEST['convertkit-clear-debug-log'] ) ) {
76 150
77 - // Redirect to Tools screen.
78 - $this->redirect();
151 + $handle = fopen( $log_file, 'w' );
152 + fclose( $handle );
79 153
154 + wp_safe_redirect( admin_url( 'options-general.php?page=_wp_convertkit_settings&tab=tools' ) );
155 + exit;
156 +
157 + }
80 158 }
81 159
82 160 /**
83 - * Prompts a browser download for the log file, if the user clicked
84 - * the Download Log button.
161 + * Get system info
162 + *
163 + * Adapted from Easy Digital Downloads
85 164 *
86 - * @since 1.9.6
165 + * @since 2.0
166 + * @global object $wpdb Used to query the database using the WordPress Database API
167 + * @return string $return A string containing the info to output
87 168 */
88 - private function maybe_download_log() {
169 + function get_system_info() {
170 + global $wpdb;
89 171
90 - global $wp_filesystem;
172 + if ( ! class_exists( 'Browser' ) ) {
173 + require_once CONVERTKIT_PLUGIN_PATH . 'lib/browser.php';
174 + }
91 175
92 - // Bail if the submit button for downloading the debug log was not clicked.
93 - // Nonce verification already performed in maybe_perform_actions() which calls this function.
94 - if ( ! array_key_exists( 'convertkit-download-debug-log', $_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification
95 - return;
176 + $browser = new Browser();
177 +
178 + // Get theme info
179 + $theme_data = wp_get_theme();
180 + $theme = $theme_data->Name . ' ' . $theme_data->Version;
181 + $parent_theme = $theme_data->Template;
182 + if ( ! empty( $parent_theme ) ) {
183 + $parent_theme_data = wp_get_theme( $parent_theme );
184 + $parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version;
96 185 }
97 186
98 - // Get Log and download.
99 - $log = new ConvertKit_Log( CONVERTKIT_PLUGIN_PATH );
187 + // Try to identify the hosting provider
188 + $host = $this->get_host();
100 189
101 - // Download.
102 - header( 'Content-type: application/octet-stream' );
103 - header( 'Content-Disposition: attachment; filename=convertkit-log.txt' );
104 - header( 'Pragma: no-cache' );
105 - header( 'Expires: 0' );
106 - echo esc_html( $wp_filesystem->get_contents( $log->get_filename() ) );
107 - exit();
190 + $return = '### Begin System Info ###' . "\n\n";
108 191
109 - }
192 + // Start with the basics...
193 + $return .= '-- Site Info' . "\n\n";
194 + $return .= 'Site URL: ' . site_url() . "\n";
195 + $return .= 'Home URL: ' . home_url() . "\n";
196 + $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
110 197
111 - /**
112 - * Prompts a browser download for the system information, if the user clicked
113 - * the Download System Info button.
114 - *
115 - * @since 1.9.6
116 - */
117 - private function maybe_download_system_info() {
198 + $return = apply_filters( 'convertkit_sysinfo_after_site_info', $return );
118 199
119 - global $wp_filesystem;
200 + // Can we determine the site's host?
201 + if( $host ) {
202 + $return .= "\n" . '-- Hosting Provider' . "\n\n";
203 + $return .= 'Host: ' . $host . "\n";
120 204
121 - // Bail if the submit button for downloading the system info was not clicked.
122 - // Nonce verification already performed in maybe_perform_actions() which calls this function.
123 - if ( ! array_key_exists( 'convertkit-download-system-info', $_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification
124 - return;
205 + $return = apply_filters( 'convertkit_sysinfo_after_host_info', $return );
125 206 }
126 207
127 - // Get System Info.
128 - $system_info = $this->get_system_info();
208 + // The local users' browser information, handled by the Browser class
209 + $return .= "\n" . '-- User Browser' . "\n\n";
210 + $return .= $browser;
129 211
130 - // Write contents to temporary file.
131 - $tmpfile = tmpfile();
132 - $filename = stream_get_meta_data( $tmpfile )['uri'];
133 - $wp_filesystem->put_contents(
134 - $filename,
135 - esc_attr( $system_info )
136 - );
212 + $return = apply_filters( 'convertkit_sysinfo_after_user_browser', $return );
137 213
138 - // Download.
139 - header( 'Content-type: application/octet-stream' );
140 - header( 'Content-Disposition: attachment; filename=convertkit-system-info.txt' );
141 - header( 'Pragma: no-cache' );
142 - header( 'Expires: 0' );
143 - echo esc_html( $wp_filesystem->get_contents( $filename ) );
144 - $wp_filesystem->delete( $filename );
145 - exit();
214 + $locale = get_locale();
146 215
147 - }
216 + // WordPress configuration
217 + $return .= "\n" . '-- WordPress Configuration' . "\n\n";
218 + $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
219 + $return .= 'Language: ' . ( !empty( $locale ) ? $locale : 'en_US' ) . "\n";
220 + $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
221 + $return .= 'Active Theme: ' . $theme . "\n";
222 + if ( $parent_theme !== $theme ) {
223 + $return .= 'Parent Theme: ' . $parent_theme . "\n";
224 + }
225 + $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
148 226
149 - /**
150 - * Prompts a browser download for the configuration file, if the user clicked
151 - * the Export button.
152 - *
153 - * @since 1.9.7.4
154 - */
155 - private function maybe_export_configuration() {
227 + // Only show page specs if frontpage is set to 'page'
228 + if( get_option( 'show_on_front' ) == 'page' ) {
229 + $front_page_id = get_option( 'page_on_front' );
230 + $blog_page_id = get_option( 'page_for_posts' );
156 231
157 - // Bail if the submit button for exporting the configuration was not clicked.
158 - // Nonce verification already performed in maybe_perform_actions() which calls this function.
159 - if ( ! array_key_exists( 'convertkit-export', $_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification
160 - return;
232 + $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
233 + $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
161 234 }
162 235
163 - // Initialize classes that hold settings.
164 - $settings = new ConvertKit_Settings();
165 - $restrict_content_settings = new ConvertKit_Settings_Restrict_Content();
236 + $return .= 'ABSPATH: ' . ABSPATH . "\n";
166 237
167 - // Define configuration data to include in the export file.
168 - $json = wp_json_encode(
169 - array(
170 - 'settings' => $settings->get(),
171 - 'restrict_content' => $restrict_content_settings->get(),
172 - )
238 + // Make sure wp_remote_post() is working
239 + $request['cmd'] = '_notify-validate';
240 +
241 + $params = array(
242 + 'sslverify' => false,
243 + 'timeout' => 60,
244 + 'user-agent' => 'ConvertKit/' . CONVERTKIT_PLUGIN_VERSION,
245 + 'body' => $request
173 246 );
174 247
175 - // Download.
176 - header( 'Content-type: application/x-msdownload' );
177 - header( 'Content-Disposition: attachment; filename=convertkit-export.json' );
178 - header( 'Pragma: no-cache' );
179 - header( 'Expires: 0' );
180 - echo $json; // phpcs:ignore WordPress.Security.EscapeOutput
181 - exit();
248 + $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
182 249
183 - }
250 + if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
251 + $WP_REMOTE_POST = 'wp_remote_post() works';
252 + } else {
253 + $WP_REMOTE_POST = 'wp_remote_post() does not work';
254 + }
184 255
185 - /**
186 - * Imports the configuration file, if it's included in the form request
187 - * and has the expected structure.
188 - *
189 - * @since 1.9.7.4
190 - */
191 - private function maybe_import_configuration() {
256 + $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
257 + $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
258 + $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
259 + $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
260 + $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
192 261
193 - // Allow us to easily interact with the filesystem.
194 - require_once ABSPATH . 'wp-admin/includes/file.php';
195 - WP_Filesystem();
196 - global $wp_filesystem;
262 + $return = apply_filters( 'convertkit_sysinfo_after_wordpress_config', $return );
197 263
198 - // Bail if the submit button for importing the configuration was not clicked.
199 - // Nonce verification already performed in maybe_perform_actions() which calls this function.
200 - if ( ! array_key_exists( 'convertkit-import', $_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification
201 - return;
202 - }
264 + // ConvertKit configuration
265 + $return .= "\n" . '-- ConvertKit Configuration' . "\n\n";
266 + $return .= 'Version: ' . CONVERTKIT_PLUGIN_VERSION . "\n";
267 + // @TODO add info on form settings, incl. integrations, etc.
203 268
204 - // Bail if no configuration file was supplied.
205 - if ( ! is_array( $_FILES ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
206 - $this->redirect();
207 - }
208 - if ( $_FILES['import']['error'] !== 0 ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
209 - $this->redirect( 'import_configuration_upload_error' );
210 - }
269 + $return = apply_filters( 'convertkit_sysinfo_after_convertkit_config', $return );
211 270
212 - // Read file.
213 - $json = $wp_filesystem->get_contents( $_FILES['import']['tmp_name'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
271 + // Get plugins that have an update
272 + $updates = get_plugin_updates();
214 273
215 - // Decode.
216 - $import = json_decode( $json, true );
274 + // Must-use plugins
275 + // NOTE: MU plugins can't show updates!
276 + $muplugins = get_mu_plugins();
277 + if( count( $muplugins ) > 0 ) {
278 + $return .= "\n" . '-- Must-Use Plugins' . "\n\n";
217 279
218 - // Bail if the data isn't JSON.
219 - if ( is_null( $import ) ) {
220 - $this->redirect( 'import_configuration_invalid_file_type' );
280 + foreach( $muplugins as $plugin => $plugin_data ) {
281 + $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
282 + }
283 +
284 + $return = apply_filters( 'convertkit_sysinfo_after_wordpress_mu_plugins', $return );
221 285 }
222 286
223 - // Bail if no settings exist.
224 - if ( ! array_key_exists( 'settings', $import ) ) {
225 - $this->redirect( 'import_configuration_empty' );
226 - }
287 + // WordPress active plugins
288 + $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
227 289
228 - // Import: Settings.
229 - if ( array_key_exists( 'settings', $import ) ) {
230 - $settings = new ConvertKit_Settings();
231 - update_option( $settings::SETTINGS_NAME, $import['settings'] );
232 - }
290 + $plugins = get_plugins();
291 + $active_plugins = get_option( 'active_plugins', array() );
233 292
234 - // Import: Restrict Content Settings.
235 - if ( array_key_exists( 'restrict_content', $import ) ) {
236 - $restrict_content_settings = new ConvertKit_Settings_Restrict_Content();
237 - update_option( $restrict_content_settings::SETTINGS_NAME, $import['restrict_content'] );
293 + foreach( $plugins as $plugin_path => $plugin ) {
294 + if( !in_array( $plugin_path, $active_plugins ) )
295 + continue;
296 +
297 + $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
298 + $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
238 299 }
239 300
240 - // Redirect to Tools screen.
241 - $this->redirect( false, 'import_configuration_success' );
301 + $return = apply_filters( 'convertkit_sysinfo_after_wordpress_plugins', $return );
242 302
243 - }
303 + // WordPress inactive plugins
304 + $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
244 305
245 - /**
246 - * Verifies if the _convertkit_settings_tools_nonce nonce was included in the request,
247 - * and if so whether the nonce action is valid.
248 - *
249 - * @since 1.9.6
250 - *
251 - * @return bool
252 - */
253 - private function verify_nonce() {
306 + foreach( $plugins as $plugin_path => $plugin ) {
307 + if( in_array( $plugin_path, $active_plugins ) )
308 + continue;
254 309
255 - // Bail if nonce verification fails.
256 - if ( ! isset( $_REQUEST['_convertkit_settings_tools_nonce'] ) ) {
257 - return false;
310 + $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
311 + $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
258 312 }
259 313
260 - return wp_verify_nonce( sanitize_key( $_REQUEST['_convertkit_settings_tools_nonce'] ), 'convertkit-settings-tools' );
314 + $return = apply_filters( 'convertkit_sysinfo_after_wordpress_plugins_inactive', $return );
261 315
262 - }
316 + if( is_multisite() ) {
317 + // WordPress Multisite active plugins
318 + $return .= "\n" . '-- Network Active Plugins' . "\n\n";
263 319
264 - /**
265 - * Register fields for this section
266 - */
267 - public function register_fields() {
320 + $plugins = wp_get_active_network_plugins();
321 + $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
268 322
269 - // No fields are registered for the Debug Log.
270 - // This function is deliberately blank.
271 - }
323 + foreach( $plugins as $plugin_path ) {
324 + $plugin_base = plugin_basename( $plugin_path );
272 325
273 - /**
274 - * Outputs success and/or error notices if required.
275 - *
276 - * @since 2.0.0
277 - */
278 - public function maybe_output_notices() {
326 + if( !array_key_exists( $plugin_base, $active_plugins ) )
327 + continue;
279 328
280 - // Define messages that might be displayed as a notification.
281 - $messages = array(
282 - 'import_configuration_upload_error' => __( 'An error occured uploading the configuration file.', 'convertkit' ),
283 - 'import_configuration_invalid_file_type' => __( 'The uploaded configuration file isn\'t valid.', 'convertkit' ),
284 - 'import_configuration_empty' => __( 'The uploaded configuration file contains no settings.', 'convertkit' ),
285 - 'import_configuration_success' => __( 'Configuration imported successfully.', 'convertkit' ),
286 - );
329 + $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
330 + $plugin = get_plugin_data( $plugin_path );
331 + $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
332 + }
287 333
288 - // Output error notification if defined.
289 - if ( isset( $_REQUEST['error'] ) && array_key_exists( sanitize_text_field( $_REQUEST['error'] ), $messages ) ) { // phpcs:ignore WordPress.Security.NonceVerification
290 - $this->output_error( $messages[ sanitize_text_field( $_REQUEST['error'] ) ] ); // phpcs:ignore WordPress.Security.NonceVerification
334 + $return = apply_filters( 'convertkit_sysinfo_after_wordpress_ms_plugins', $return );
291 335 }
292 336
293 - // Output success notification if defined.
294 - if ( isset( $_REQUEST['success'] ) && array_key_exists( sanitize_text_field( $_REQUEST['success'] ), $messages ) ) { // phpcs:ignore WordPress.Security.NonceVerification
295 - $this->output_success( $messages[ sanitize_text_field( $_REQUEST['success'] ) ] ); // phpcs:ignore WordPress.Security.NonceVerification
296 - }
337 + // Server configuration (really just versioning)
338 + $return .= "\n" . '-- Webserver Configuration' . "\n\n";
339 + $return .= 'PHP Version: ' . PHP_VERSION . "\n";
340 + $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
341 + $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
297 342
298 - }
343 + $return = apply_filters( 'convertkit_sysinfo_after_webserver_config', $return );
299 344
300 - /**
301 - * Outputs the Debug Log and System Info view.
302 - *
303 - * @since 1.9.6
304 - */
305 - public function render() {
345 + // PHP configs... now we're getting to the important stuff
346 + $return .= "\n" . '-- PHP Configuration' . "\n\n";
347 + $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
348 + $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
349 + $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
350 + $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
351 + $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
352 + $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
353 + $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
354 + $return .= 'PHP Arg Separator: ' . ini_get( 'arg_separator.output') . "\n";
306 355
307 - /**
308 - * Performs actions prior to rendering the settings form.
309 - *
310 - * @since 2.0.0
311 - */
312 - do_action( 'convertkit_settings_base_render_before' );
356 + $return = apply_filters( 'convertkit_sysinfo_after_php_config', $return );
313 357
314 - // Get Log and System Info.
315 - $log = new ConvertKit_Log( CONVERTKIT_PLUGIN_PATH );
316 - $system_info = $this->get_system_info();
358 + // PHP extensions and such
359 + $return .= "\n" . '-- PHP Extensions' . "\n\n";
360 + $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
361 + $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
362 + $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
363 + $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
317 364
318 - // Output view.
319 - require_once CONVERTKIT_PLUGIN_PATH . '/views/backend/settings/tools.php';
365 + $return = apply_filters( 'convertkit_sysinfo_after_php_ext', $return );
320 366
321 - /**
322 - * Performs actions after rendering of the settings form.
323 - *
324 - * @since 2.0.0
325 - */
326 - do_action( 'convertkit_settings_base_render_after' );
367 + // Session stuff
368 + $return .= "\n" . '-- Session Configuration' . "\n\n";
327 369
328 - }
370 + // The rest of this is only relevant is session is enabled
371 + if( isset( $_SESSION ) ) {
372 + $return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n";
373 + $return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
374 + $return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
375 + $return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
376 + $return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
377 + }
329 378
330 - /**
331 - * Prints help info for this section
332 - */
333 - public function print_section_info() {
379 + $return = apply_filters( 'convertkit_sysinfo_after_session_config', $return );
334 380
335 - ?>
336 - <p><?php esc_html_e( 'Tools to help you manage ConvertKit on your site.', 'convertkit' ); ?></p>
337 - <?php
381 + $return .= "\n" . '### End System Info ###';
338 382
383 + return $return;
339 384 }
340 385
341 386 /**
342 - * Returns the URL for the ConvertKit documentation for this setting section.
387 + * Get user host
388 + *
389 + * Adapted from Easy Digital Downloads
343 390 *
344 - * @since 2.0.8
391 + * Returns the webhost this site is using if possible
345 392 *
346 - * @return string Documentation URL.
393 + * @since 1.6.4
394 + * @return mixed string $host if detected, false otherwise
347 395 */
348 - public function documentation_url() {
396 + function get_host() {
397 + $host = false;
349 398
350 - return 'https://help.convertkit.com/en/articles/2502591-the-convertkit-wordpress-plugin';
351 -
352 - }
353 -
354 - /**
355 - * Returns a string comprising of the WordPress system information, with Plugin information
356 - * prepended.
357 - *
358 - * @since 1.9.8.3
359 - */
360 - private function get_system_info() {
361 -
362 - // If we're using WordPress < 5.2, there's no WP_Debug_Data class to fetch system information from.
363 - if ( version_compare( get_bloginfo( 'version' ), '5.2', '<' ) ) {
364 - return __( 'WordPress 5.2 or higher is required for system information report.', 'convertkit' );
399 + if( defined( 'WPE_APIKEY' ) ) {
400 + $host = 'WP Engine';
401 + } elseif( defined( 'PAGELYBIN' ) ) {
402 + $host = 'Pagely';
403 + } elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
404 + $host = 'ICDSoft';
405 + } elseif( DB_HOST == 'mysqlv5' ) {
406 + $host = 'NetworkSolutions';
407 + } elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
408 + $host = 'iPage';
409 + } elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
410 + $host = 'IPower';
411 + } elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
412 + $host = 'MediaTemple Grid';
413 + } elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
414 + $host = 'pair Networks';
415 + } elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
416 + $host = 'Rackspace Cloud';
417 + } elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
418 + $host = 'SysFix.eu Power Hosting';
419 + } elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
420 + $host = 'Flywheel';
421 + } else {
422 + // Adding a general fallback for data gathering
423 + $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
365 424 }
366 425
367 - // Use WordPress' debug_data() function to get system info, matching how Tools > Site Health > Info works.
368 - if ( ! class_exists( 'WP_Debug_Data' ) ) {
369 - require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
370 - }
371 -
372 - return str_replace( '`', '', WP_Debug_Data::format( WP_Debug_Data::debug_data(), 'debug' ) );
373 -
426 + return $host;
374 427 }
375 -
376 428 }