PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.1
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / class / class-mainwp-error-helper.php

class-mainwp-error-helper.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.1, at class/class-mainwp-error-helper.php

72 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * HTTP Error Handler
4 *
5 * Throw this error when MainWP is not detected
6 * due to either an HTTP error or if MainWP Child Plugin is not found.
7 *
8 * @package MainWP/Dashboard
9 */
10
11 namespace MainWP\Dashboard;
12
13 /**
14 * Class MainWP Error Helper
15 *
16 * @return $error
17 */
18 class MainWP_Error_Helper { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
19 /**
20 * Method get_error_message()
21 *
22 * Check for http error and or "nomainwp" error.
23 *
24 * @param object $pException Exception object.
25 *
26 * @return string $error Error message.
27 */
28 public static function get_error_message( $pException ) {
29 $error = $pException->getMessage();
30
31 if ( $pException->getMessage() === 'HTTPERROR' ) {
32 $error = 'HTTP error' . ( ! empty( $pException->get_message_extra() ) ? ' - ' . $pException->get_message_extra() : '' );
33 } elseif ( $pException->getMessage() === 'NOMAINWP' ) {
34 $error = static::get_error_not_detected_connect();
35 }
36
37 return $error;
38 }
39
40 /**
41 * Method get_console_error_message()
42 *
43 * Check for http error and or "nomainwp" and or "WPERROR".
44 *
45 * @param mixed $pException The exception.
46 *
47 * @return string @error Error message.
48 */
49 public static function get_console_error_message( $pException ) {
50 $error = $pException->getMessage();
51
52 if ( $pException->getMessage() === 'HTTPERROR' ) {
53 $error = 'HTTP error' . ( ! empty( $pException->get_message_extra() ) ? ' - ' . $pException->get_message_extra() : '' );
54 } elseif ( $pException->getMessage() === 'NOMAINWP' ) {
55 $error = static::get_error_not_detected_connect();
56 } elseif ( $pException->getMessage() !== 'WPERROR' && ! empty( $pException->get_message_extra() ) ) {
57 $error .= ' - ' . $pException->get_message_extra();
58 }
59
60 return $error;
61 }
62
63 /**
64 * Method get_error_not_detected_connect()
65 *
66 * @return string @error Error message.
67 */
68 public static function get_error_not_detected_connect() {
69 return sprintf( esc_html__( 'MainWP Child plugin not detected or could not be reached! Ensure the MainWP Child plugin is installed and activated on the child site, and there are no security rules blocking requests. If you continue experiencing this issue, check the %1$sMainWP Community%2$s for help.', 'mainwp' ), '<a href="https://managers.mainwp.com/c/community-support/5" target="_blank">', '</a>' );
70 }
71 }
72