PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.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 4.1, at class/class-mainwp-error-helper.php

65 lines 2.4 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 {
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