PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.5.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.5.2
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 / includes / functions.php

functions.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 4.5.2, at includes/functions.php

93 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 * MainWP Base Functions.
4 *
5 * Grab MainWP Directory and check for permissions.
6 *
7 * @package MainWP/Dashboard
8 */
9
10 if ( ! defined( 'FILTER_SANITIZE_STRING_COMPATIBLE' ) ) { // to compatible.
11 define( 'FILTER_SANITIZE_STRING_COMPATIBLE', 513 );
12 }
13
14 if ( ! function_exists( 'mainwpdir' ) ) {
15
16 /**
17 * Grab MainWP Directory
18 *
19 * @return string
20 */
21 function mainwpdir() {
22 return WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . dirname( plugin_basename( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'libs' . DIRECTORY_SEPARATOR;
23 }
24 }
25
26
27 if ( ! function_exists( 'mainwp_do_not_have_permissions' ) ) {
28
29 /**
30 * Detect permission level & display message to end user.
31 *
32 * @param string $where User's location.
33 * @param bool $echo Defines weather or not to echo error message.
34 * @return string|bool $msg|false
35 */
36 function mainwp_do_not_have_permissions( $where = '', $echo = true ) {
37 $msg = sprintf( esc_html__( 'You do not have sufficient permissions to access this page (%s).', 'mainwp' ), ucwords( $where ) );
38 if ( $echo ) {
39 echo '<div class="mainwp-permission-error"><p>' . esc_html( $msg ) . '</p>If you need access to this page please contact the dashboard administrator.</div>';
40 } else {
41 return $msg;
42 }
43
44 return false;
45 }
46 }
47
48 if ( ! function_exists( 'mainwp_current_user_can' ) ) {
49
50 /**
51 * Check permission level.
52 *
53 * To compatible with extensions.
54 *
55 * @param string $cap_type Group or type of capabilities.
56 * @param string $cap Capabilities for current user.
57 *
58 * @return bool true|false
59 */
60 function mainwp_current_user_can( $cap_type = '', $cap = '' ) {
61 if ( function_exists( 'MainWP\Dashboard\mainwp_current_user_have_right' ) ) {
62 return MainWP\Dashboard\mainwp_current_user_have_right( $cap_type, $cap );
63 }
64 return true;
65 }
66 }
67
68 if ( ! function_exists( 'mainwp_get_actions_handler_instance' ) ) {
69
70 /**
71 * Function to get mainwp actions handler instance.
72 *
73 * @return bool true|false
74 */
75 function mainwp_get_actions_handler_instance() {
76 return \MainWP\Dashboard\MainWP_Actions_Handler::instance();
77 }
78 }
79
80 if ( ! function_exists( 'mainwp_send_json_output' ) ) {
81 /**
82 * Handle send json output.
83 *
84 * @param array $output Array output.
85 */
86 function mainwp_send_json_output( $output ) {
87 if ( is_array( $output ) ) {
88 $output['execute_time'] = \MainWP\Dashboard\MainWP_Execution_Helper::instance()->get_exec_time();
89 }
90 wp_send_json( $output );
91 }
92 }
93