| 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 { |
| 19 |
|
| 20 |
/** |
| 21 |
* Method get_error_message() |
| 22 |
* |
| 23 |
* Check for http error and or "nomainwp" error. |
| 24 |
* |
| 25 |
* @param object $pException Exception object. |
| 26 |
* |
| 27 |
* @return string $error Error message. |
| 28 |
*/ |
| 29 |
public static function get_error_message( $pException ) { |
| 30 |
$error = $pException->getMessage(); |
| 31 |
|
| 32 |
if ( $pException->getMessage() == 'HTTPERROR' ) { |
| 33 |
$error = 'HTTP error' . ( $pException->get_message_extra() != null ? ' - ' . $pException->get_message_extra() : '' ); |
| 34 |
} elseif ( $pException->getMessage() == 'NOMAINWP' ) { |
| 35 |
$error = sprintf( __( 'MainWP Child plugin not detected. First, install and activate the plugin and add your site to your MainWP Dashboard afterward. If you continue experiencing this issue, check the child site for %1$sknown plugin conflicts%2$s, or check the %3$sMainWP Community%4$s for help.', 'mainwp' ), '<a href="https://meta.mainwp.com/t/known-plugin-conflicts/402">', '</a>', '<a href="https://meta.mainwp.com/c/community-support/5">', '</a>' ); |
| 36 |
} |
| 37 |
|
| 38 |
return $error; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Method get_console_error_message() |
| 43 |
* |
| 44 |
* Check for http error and or "nomainwp" and or "WPERROR". |
| 45 |
* |
| 46 |
* @param mixed $pException The exception. |
| 47 |
* |
| 48 |
* @return string @error Error message. |
| 49 |
*/ |
| 50 |
public static function get_console_error_message( $pException ) { |
| 51 |
$error = $pException->getMessage(); |
| 52 |
|
| 53 |
if ( $pException->getMessage() == 'HTTPERROR' ) { |
| 54 |
$error = 'HTTP error' . ( $pException->get_message_extra() != null ? ' - ' . $pException->get_message_extra() : '' ); |
| 55 |
} elseif ( $pException->getMessage() == 'NOMAINWP' ) { |
| 56 |
$error = sprintf( __( 'MainWP Child plugin not detected. First, install and activate the plugin and add your site to your MainWP Dashboard afterward. If you continue experiencing this issue, check the child site for %1$sknown plugin conflicts%2$s, or check the %3$sMainWP Community%4$s for help.', 'mainwp' ), '<a href="https://meta.mainwp.com/t/known-plugin-conflicts/402">', '</a>', '<a href="https://meta.mainwp.com/c/community-support/5">', '</a>' ); |
| 57 |
} elseif ( $pException->getMessage() != 'WPERROR' && ! empty( $pException->get_message_extra() ) ) { |
| 58 |
$error .= ' - ' . $pException->get_message_extra(); |
| 59 |
} |
| 60 |
|
| 61 |
return $error; |
| 62 |
} |
| 63 |
|
| 64 |
} |
| 65 |
|