| 1 |
<?php |
| 2 |
/** |
| 3 |
* some basics for message |
| 4 |
*/ |
| 5 |
if ( ! function_exists( 'add_action' ) ) { |
| 6 |
die( "Hi there! I'm just a part of plugin, not much I can do when called directly." ); |
| 7 |
} |
| 8 |
|
| 9 |
// Need only on admin area |
| 10 |
if ( ! is_admin() ) { |
| 11 |
return; |
| 12 |
} |
| 13 |
|
| 14 |
// If is AJAX Call. |
| 15 |
if ( defined('DOING_AJAX') && DOING_AJAX ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
class _mw_adminimize_message_class { |
| 20 |
|
| 21 |
/** |
| 22 |
* constructor |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
|
| 26 |
$this->errors = new WP_Error(); |
| 27 |
$this->initialize_errors(); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* get_error - Returns an error message based on the passed code |
| 32 |
* Parameters - $code (the error code as a string) |
| 33 |
* |
| 34 |
* @param string $code |
| 35 |
* |
| 36 |
* @return string $errorMessage |
| 37 |
*/ |
| 38 |
public function get_error( $code = '' ) { |
| 39 |
|
| 40 |
$errorMessage = $this->errors->get_error_message( $code ); |
| 41 |
|
| 42 |
if ( NULL === $errorMessage ) { |
| 43 |
return esc_attr__( 'Unknown error.', 'adminimize' ); |
| 44 |
} |
| 45 |
|
| 46 |
return $errorMessage; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Initializes all the error messages |
| 51 |
*/ |
| 52 |
public function initialize_errors() { |
| 53 |
|
| 54 |
$this->errors->add( '_mw_adminimize_update', esc_attr__( 'The updates were saved.', 'adminimize' ) ); |
| 55 |
$this->errors->add( |
| 56 |
'_mw_adminimize_access_denied', |
| 57 |
esc_attr__( 'You have not enough rights to edit entries in the database.', 'adminimize' ) |
| 58 |
); |
| 59 |
$this->errors->add( |
| 60 |
'_mw_adminimize_import', esc_attr__( 'All entries in the database were imported.', 'adminimize' ) |
| 61 |
); |
| 62 |
$this->errors->add( |
| 63 |
'_mw_adminimize_uninstall', esc_attr__( 'All entries in the database were deleted.', 'adminimize' ) |
| 64 |
); |
| 65 |
$this->errors->add( |
| 66 |
'_mw_adminimize_uninstall_yes', esc_attr__( 'Set the checkbox on deinstall-button.', 'adminimize' ) |
| 67 |
); |
| 68 |
$this->errors->add( |
| 69 |
'_mw_adminimize_get_option', esc_attr__( 'Can\'t load menu and submenu.', 'adminimize' ) |
| 70 |
); |
| 71 |
$this->errors->add( '_mw_adminimize_set_theme', esc_attr__( 'Backend-Theme was activated!', 'adminimize' ) ); |
| 72 |
$this->errors->add( |
| 73 |
'_mw_adminimize_load_theme', esc_attr__( 'Load user data to themes was successful.', 'adminimize' ) |
| 74 |
); |
| 75 |
} |
| 76 |
|
| 77 |
} // end class |