| @@ -8,396 +8,438 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | namespace MainWP\Dashboard; |
| 11 | 11 | |
| 12 | +// Exit if accessed directly. | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 16 | + | |
| 12 | 17 | /** |
| 13 | 18 | * Class MainWP_Widget_Plugins |
| 14 | 19 | */ |
| 15 | -class MainWP_Widget_Plugins { | |
| 16 | - /** | |
| 17 | - * Method get_class_name() | |
| 18 | - * | |
| 19 | - * Get Class Name | |
| 20 | - * | |
| 21 | - * @return string __CLASS__ Class Name. | |
| 22 | - */ | |
| 23 | - public static function get_class_name() { | |
| 24 | - return __CLASS__; | |
| 25 | - } | |
| 20 | +class MainWP_Widget_Plugins { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 21 | + /** | |
| 22 | + * Method get_class_name() | |
| 23 | + * | |
| 24 | + * Get Class Name | |
| 25 | + * | |
| 26 | + * @return string __CLASS__ Class Name. | |
| 27 | + */ | |
| 28 | + public static function get_class_name() { | |
| 29 | + return __CLASS__; | |
| 30 | + } | |
| 26 | 31 | |
| 27 | - /** | |
| 28 | - * Method render() | |
| 29 | - * | |
| 30 | - * Fire off render_widget(). | |
| 31 | - */ | |
| 32 | - public static function render() { | |
| 33 | - self::render_widget(); | |
| 34 | - } | |
| 32 | + /** | |
| 33 | + * Method render() | |
| 34 | + * | |
| 35 | + * Fire off render_widget(). | |
| 36 | + */ | |
| 37 | + public static function render() { | |
| 38 | + static::render_widget(); | |
| 39 | + } | |
| 35 | 40 | |
| 36 | - /** | |
| 37 | - * Method prepair_icons() | |
| 38 | - * | |
| 39 | - * Utilizes WP API to grab plugin icons, last_updated, active_installs | |
| 40 | - */ | |
| 41 | - public function prepare_icons() { | |
| 42 | - include ABSPATH . 'wp-admin/includes/plugin-install.php'; | |
| 41 | + /** | |
| 42 | + * Method prepair_icons() | |
| 43 | + * | |
| 44 | + * Utilizes WP API to grab plugin icons, last_updated, active_installs | |
| 45 | + */ | |
| 46 | + public function prepare_icons() { | |
| 47 | + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // NOSONAR - WP compatible. | |
| 43 | 48 | |
| 44 | - $args = array( | |
| 45 | - 'fields' => array( | |
| 46 | - 'last_updated' => true, | |
| 47 | - 'icons' => true, | |
| 48 | - 'active_installs' => true, | |
| 49 | - ), | |
| 50 | - ); | |
| 49 | + $args = array( | |
| 50 | + 'fields' => array( | |
| 51 | + 'last_updated' => true, | |
| 52 | + 'icons' => true, | |
| 53 | + 'active_installs' => true, | |
| 54 | + ), | |
| 55 | + ); | |
| 51 | 56 | |
| 52 | - $api = plugins_api( 'query_plugins', $args ); | |
| 57 | + $api = plugins_api( 'query_plugins', $args ); | |
| 53 | 58 | |
| 54 | - if ( is_wp_error( $api ) ) { | |
| 55 | - $this->error = $api; | |
| 56 | - return; | |
| 57 | - } | |
| 59 | + if ( is_wp_error( $api ) ) { | |
| 60 | + $this->error = $api; | |
| 61 | + return; | |
| 62 | + } | |
| 58 | 63 | |
| 59 | - $this->items = $api->plugins; | |
| 60 | - } | |
| 64 | + $this->items = $api->plugins; | |
| 65 | + } | |
| 61 | 66 | |
| 62 | 67 | |
| 63 | - /** | |
| 64 | - * Method render_widget() | |
| 65 | - * | |
| 66 | - * Build Plugins Widget | |
| 67 | - * | |
| 68 | - * @uses \MainWP\Dashboard\MainWP_DB::query() | |
| 69 | - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_website_by_id() | |
| 70 | - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 71 | - * @uses \MainWP\Dashboard\MainWP_DB::free_result() | |
| 72 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid() | |
| 73 | - */ | |
| 74 | - public static function render_widget() { | |
| 75 | - $current_wpid = MainWP_System_Utility::get_current_wpid(); | |
| 76 | - if ( empty( $current_wpid ) ) { | |
| 77 | - return; | |
| 78 | - } | |
| 68 | + /** | |
| 69 | + * Method render_widget() | |
| 70 | + * | |
| 71 | + * Build Plugins Widget | |
| 72 | + * | |
| 73 | + * @uses \MainWP\Dashboard\MainWP_DB::query() | |
| 74 | + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_website_by_id() | |
| 75 | + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 76 | + * @uses \MainWP\Dashboard\MainWP_DB::free_result() | |
| 77 | + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid() | |
| 78 | + */ | |
| 79 | + public static function render_widget() { // phpcs:ignore -- NOSONAR - complex. | |
| 80 | + $current_wpid = MainWP_System_Utility::get_current_wpid(); | |
| 81 | + if ( empty( $current_wpid ) ) { | |
| 82 | + return; | |
| 83 | + } | |
| 79 | 84 | |
| 80 | - $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid ); | |
| 81 | - $websites = MainWP_DB::instance()->query( $sql ); | |
| 82 | - $allPlugins = array(); | |
| 83 | - if ( $websites ) { | |
| 84 | - $website = MainWP_DB::fetch_object( $websites ); | |
| 85 | - if ( $website && '' !== $website->plugins ) { | |
| 86 | - $plugins = json_decode( $website->plugins, 1 ); | |
| 87 | - if ( is_array( $plugins ) && 0 !== count( $plugins ) ) { | |
| 88 | - foreach ( $plugins as $plugin ) { | |
| 89 | - if ( isset( $plugin['mainwp'] ) && ( 'T' === $plugin['mainwp'] ) ) { | |
| 90 | - continue; | |
| 91 | - } | |
| 92 | - $allPlugins[] = $plugin; | |
| 93 | - } | |
| 94 | - } | |
| 95 | - } | |
| 96 | - MainWP_DB::free_result( $websites ); | |
| 97 | - } | |
| 85 | + $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid ); | |
| 86 | + $websites = MainWP_DB::instance()->query( $sql ); | |
| 87 | + $allPlugins = array(); | |
| 88 | + if ( $websites ) { | |
| 89 | + $website = MainWP_DB::fetch_object( $websites ); | |
| 90 | + if ( $website && '' !== $website->plugins ) { | |
| 91 | + $plugins = json_decode( $website->plugins, 1 ); | |
| 92 | + if ( is_array( $plugins ) && ! empty( $plugins ) ) { | |
| 93 | + foreach ( $plugins as $plugin ) { | |
| 94 | + if ( isset( $plugin['mainwp'] ) && ( 'T' === $plugin['mainwp'] ) ) { | |
| 95 | + continue; | |
| 96 | + } | |
| 97 | + $allPlugins[] = $plugin; | |
| 98 | + } | |
| 99 | + } | |
| 100 | + } | |
| 101 | + MainWP_DB::free_result( $websites ); | |
| 102 | + } | |
| 98 | 103 | |
| 99 | - self::render_html_widget( $website, $allPlugins ); | |
| 100 | - } | |
| 104 | + static::render_html_widget( $website, $allPlugins ); | |
| 105 | + } | |
| 101 | 106 | |
| 102 | - /** | |
| 103 | - * Method render_html_widget(). | |
| 104 | - * | |
| 105 | - * Render HTML plugins widget for current site | |
| 106 | - * | |
| 107 | - * @param object $website Object containing the child site info. | |
| 108 | - * @param array $allPlugins Array containing all detected plugins data. | |
| 109 | - * | |
| 110 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having() | |
| 111 | - * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti() | |
| 112 | - */ | |
| 113 | - public static function render_html_widget( $website, $allPlugins ) { | |
| 107 | + /** | |
| 108 | + * Method render_html_widget(). | |
| 109 | + * | |
| 110 | + * Render HTML plugins widget for current site | |
| 111 | + * | |
| 112 | + * @param object $website Object containing the child site info. | |
| 113 | + * @param array $allPlugins Array containing all detected plugins data. | |
| 114 | + * | |
| 115 | + * @uses \MainWP\Dashboard\MainWP_Utility::get_sub_array_having() | |
| 116 | + * @uses \MainWP\Dashboard\MainWP_Utility::sortmulti() | |
| 117 | + */ | |
| 118 | + public static function render_html_widget( $website, $allPlugins ) { // phpcs:ignore -- NOSONAR - complex. | |
| 114 | 119 | |
| 115 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 120 | + $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 116 | 121 | |
| 117 | - $actived_plugins = MainWP_Utility::get_sub_array_having( $allPlugins, 'active', 1 ); | |
| 118 | - $actived_plugins = MainWP_Utility::sortmulti( $actived_plugins, 'name', 'asc' ); | |
| 122 | + $actived_plugins = MainWP_Utility::get_sub_array_having( $allPlugins, 'active', 1 ); | |
| 123 | + $actived_plugins = MainWP_Utility::sortmulti( $actived_plugins, 'name', 'asc' ); | |
| 119 | 124 | |
| 120 | - $inactive_plugins = MainWP_Utility::get_sub_array_having( $allPlugins, 'active', 0 ); | |
| 121 | - $inactive_plugins = MainWP_Utility::sortmulti( $inactive_plugins, 'name', 'asc' ); | |
| 125 | + $inactive_plugins = MainWP_Utility::get_sub_array_having( $allPlugins, 'active', 0 ); | |
| 126 | + $inactive_plugins = MainWP_Utility::sortmulti( $inactive_plugins, 'name', 'asc' ); | |
| 122 | 127 | |
| 123 | - ?> | |
| 124 | - <div class="ui grid mainwp-widget-header"> | |
| 125 | - <div class="twelve wide column"> | |
| 126 | - <h3 class="ui header handle-drag"> | |
| 127 | - <?php | |
| 128 | - /** | |
| 129 | - * Filter: mainwp_plugins_widget_title | |
| 130 | - * | |
| 131 | - * Filters the Plugins widget title text. | |
| 132 | - * | |
| 133 | - * @param object $website Object containing the child site info. | |
| 134 | - * | |
| 135 | - * @since 4.1 | |
| 136 | - */ | |
| 137 | - echo esc_html( apply_filters( 'mainwp_plugins_widget_title', esc_html__( 'Plugins', 'mainwp' ), $website ) ); | |
| 138 | - ?> | |
| 139 | - <div class="sub header"><?php esc_html_e( 'Installed plugins on the child site', 'mainwp' ); ?></div> | |
| 140 | - </h3> | |
| 141 | - </div> | |
| 142 | - <div class="four wide column right aligned"> | |
| 143 | - <div class="ui dropdown right pointing mainwp-dropdown-tab"> | |
| 144 | - <div class="text"><?php esc_html_e( 'Active', 'mainwp' ); ?></div> | |
| 145 | - <i class="dropdown icon"></i> | |
| 146 | - <div class="menu"> | |
| 147 | - <a class="item" data-tab="active_plugins" data-value="active_plugins" title="<?php esc_attr_e( 'Active', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Active', 'mainwp' ); ?></a> | |
| 148 | - <a class="item" data-tab="inactive_plugins" data-value="inactive_plugins" title="<?php esc_attr_e( 'Inactive', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Inactive', 'mainwp' ); ?></a> | |
| 149 | - </div> | |
| 150 | - </div> | |
| 151 | - </div> | |
| 152 | - </div> | |
| 153 | - <div class="mainwp-scrolly-overflow"> | |
| 154 | - <?php | |
| 155 | - /** | |
| 156 | - * Action: mainwp_plugins_widget_top | |
| 157 | - * | |
| 158 | - * Fires at the top of the Plugins widget on the Individual site overview page. | |
| 159 | - * | |
| 160 | - * @param object $website Object containing the child site info. | |
| 161 | - * @param array $allPlugins Array containing all detected plugins data. | |
| 162 | - * | |
| 163 | - * @since 4.1 | |
| 164 | - */ | |
| 165 | - do_action( 'mainwp_plugins_widget_top', $website, $allPlugins ); | |
| 166 | - ?> | |
| 167 | - <div id="mainwp-widget-active-plugins" class="ui tab active" data-tab="active_plugins"> | |
| 168 | - <?php | |
| 169 | - /** | |
| 170 | - * Action: mainwp_before_active_plugins_list | |
| 171 | - * | |
| 172 | - * Fires before the active plugins list in the Plugins widget on the Individual site overview page. | |
| 173 | - * | |
| 174 | - * @param object $website Object containing the child site info. | |
| 175 | - * @param array $actived_plugins Array containing all active plugins data. | |
| 176 | - * | |
| 177 | - * @since 4.1 | |
| 178 | - */ | |
| 179 | - do_action( 'mainwp_before_active_plugins_list', $website, $actived_plugins ); | |
| 180 | - ?> | |
| 181 | - <div class="ui divided selection list"> | |
| 182 | - <?php | |
| 183 | - $_count = count( $actived_plugins ); | |
| 184 | - for ( $i = 0; $i < $_count; $i++ ) { | |
| 185 | - $slug = wp_strip_all_tags( $actived_plugins[ $i ]['slug'] ); | |
| 186 | - $plugin_directory = dirname( $slug ); | |
| 187 | - ?> | |
| 188 | - <div class="item <?php echo esc_html( dirname( $slug ) ); ?>"> | |
| 189 | - <input class="pluginSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $actived_plugins[ $i ]['slug'] ) ); ?>"/> | |
| 190 | - <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 191 | - <div class="right floated pluginsAction"> | |
| 192 | - <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { ?> | |
| 193 | - <a href="#" class="mainwp-plugin-deactivate ui mini button green <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="left center" data-tooltip="<?php esc_attr_e( 'Deactivate the ', 'mainwp' ) . esc_html( $actived_plugins[ $i ]['name'] ) . esc_attr_e( ' plugin on the child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></a> | |
| 194 | - <?php } ?> | |
| 195 | - </div> | |
| 196 | - <div class="middle aligned content"> | |
| 197 | - <?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 198 | - <a href="<?php echo esc_url( admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( wp_strip_all_tags( $actived_plugins[ $i ]['slug'] ) ) ) ); ?>" target="_blank" class="open-plugin-details-modal" title="More information about <?php echo wp_strip_all_tags( $actived_plugins[ $i ]['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>"> | |
| 199 | - <?php echo esc_html( $actived_plugins[ $i ]['name'] . ' ' . $actived_plugins[ $i ]['version'] ); ?> | |
| 200 | - </a> | |
| 201 | - </div> | |
| 202 | - <div class="mainwp-row-actions-working"> | |
| 203 | - <i class="notched circle loading icon"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?> | |
| 204 | - </div> | |
| 205 | - </div> | |
| 206 | - <?php } ?> | |
| 207 | - </div> | |
| 208 | - <?php | |
| 209 | - /** | |
| 210 | - * Action: mainwp_after_active_plugins_list | |
| 211 | - * | |
| 212 | - * Fires after the active plugins list in the Plugins widget on the Individual site overview page. | |
| 213 | - * | |
| 214 | - * @param object $website Object containing the child site info. | |
| 215 | - * @param array $actived_plugins Array containing all active plugins data. | |
| 216 | - * | |
| 217 | - * @since 4.1 | |
| 218 | - */ | |
| 219 | - do_action( 'mainwp_after_active_plugins_list', $website, $actived_plugins ); | |
| 220 | - ?> | |
| 221 | - </div> | |
| 222 | - <div id="mainwp-widget-inactive-plugins" class="ui tab" data-tab="inactive_plugins"> | |
| 223 | - <?php | |
| 224 | - /** | |
| 225 | - * Action: mainwp_before_inactive_plugins_list | |
| 226 | - * | |
| 227 | - * Fires before the inactive plugins list in the Plugins widget on the Individual site overview page. | |
| 228 | - * | |
| 229 | - * @param object $website Object containing the child site info. | |
| 230 | - * @param array $inactive_plugins Array containing all active plugins data. | |
| 231 | - * | |
| 232 | - * @since 4.1 | |
| 233 | - */ | |
| 234 | - do_action( 'mainwp_before_inactive_plugins_list', $website, $inactive_plugins ); | |
| 235 | - ?> | |
| 236 | - <div class="ui middle aligned divided selection list"> | |
| 237 | - <?php | |
| 238 | - $_count = count( $inactive_plugins ); | |
| 239 | - for ( $i = 0; $i < $_count; $i++ ) { | |
| 240 | - $slug = $inactive_plugins[ $i ]['slug']; | |
| 241 | - $plugin_directory = dirname( $slug ); | |
| 242 | - ?> | |
| 243 | - <div class="item <?php echo esc_html( sanitize_text_field( dirname( $slug ) ) ); ?>"> | |
| 244 | - <input class="pluginSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $inactive_plugins[ $i ]['slug'] ) ); ?>"/> | |
| 245 | - <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 246 | - <div class="right floated content pluginsAction"> | |
| 247 | - <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { ?> | |
| 248 | - <a href="#" class="mainwp-plugin-activate ui mini green button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="left center" data-tooltip="<?php esc_attr_e( 'Activate the ', 'mainwp' ) . wp_strip_all_tags( $inactive_plugins[ $i ]['name'] ) . esc_attr_e( ' plugin on the child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Activate', 'mainwp' ); ?></a> | |
| 249 | - <?php } ?> | |
| 250 | - <?php if ( mainwp_current_user_have_right( 'dashboard', 'delete_plugins' ) ) { ?> | |
| 251 | - <a href="#" class="mainwp-plugin-delete ui mini basic button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="left center" data-tooltip="<?php esc_attr_e( 'Delete the ', 'mainwp' ) . wp_strip_all_tags( $inactive_plugins[ $i ]['name'] ) . esc_attr_e( ' plugin from the child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Delete', 'mainwp' ); ?></a> | |
| 252 | - <?php } ?> | |
| 253 | - </div> | |
| 254 | - <div class="middle aligned content"> | |
| 255 | - <?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 256 | - <a href="<?php echo esc_url( admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( $inactive_plugins[ $i ]['slug'] ) ) ); ?>" target="_blank" class="open-plugin-details-modal" title="More information about <?php echo wp_strip_all_tags( $inactive_plugins[ $i ]['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>"> | |
| 257 | - <?php echo esc_html( $inactive_plugins[ $i ]['name'] . ' ' . $inactive_plugins[ $i ]['version'] ); ?> | |
| 258 | - </a> | |
| 259 | - </div> | |
| 260 | - <div class="mainwp-row-actions-working"> | |
| 261 | - <i class="ui active inline loader tiny"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?> | |
| 262 | - </div> | |
| 263 | - </div> | |
| 264 | - <?php } ?> | |
| 265 | - </div> | |
| 266 | - <?php | |
| 267 | - /** | |
| 268 | - * Action: mainwp_after_inactive_plugins_list | |
| 269 | - * | |
| 270 | - * Fires after the inactive plugins list in the Plugins widget on the Individual site overview page. | |
| 271 | - * | |
| 272 | - * @param object $website Object containing the child site info. | |
| 273 | - * @param array $inactive_plugins Array containing all active plugins data. | |
| 274 | - * | |
| 275 | - * @since 4.1 | |
| 276 | - */ | |
| 277 | - do_action( 'mainwp_after_inactive_plugins_list', $website, $inactive_plugins ); | |
| 278 | - ?> | |
| 279 | - </div> | |
| 280 | - </div> | |
| 281 | - <?php | |
| 282 | - /** | |
| 283 | - * Action: mainwp_plugins_widget_bottom | |
| 284 | - * | |
| 285 | - * Fires at the bottom of the Plugins widget on the Individual site overview page. | |
| 286 | - * | |
| 287 | - * @param object $website Object containing the child site info. | |
| 288 | - * @param array $allPlugins Array containing all detected plugins data. | |
| 289 | - * | |
| 290 | - * @since 4.1 | |
| 291 | - */ | |
| 292 | - do_action( 'mainwp_plugins_widget_bottom', $website, $allPlugins ); | |
| 293 | - MainWP_Updates::render_plugin_details_modal(); | |
| 294 | - } | |
| 128 | + $wp_info = MainWP_DB::instance()->get_website_option( $website, 'site_info' ); | |
| 129 | + $wp_info = ! empty( $wp_info ) ? json_decode( $wp_info, true ) : array(); | |
| 295 | 130 | |
| 296 | - /** | |
| 297 | - * Method activate_plugin() | |
| 298 | - * | |
| 299 | - * Fire off Action activate & display result | |
| 300 | - */ | |
| 301 | - public static function activate_plugin() { | |
| 302 | - self::action( 'activate' ); | |
| 303 | - die( wp_json_encode( array( 'result' => esc_html__( 'Plugin has been activated!', 'mainwp' ) ) ) ); | |
| 304 | - } | |
| 131 | + if ( ! is_array( $wp_info ) ) { | |
| 132 | + $wp_info = array(); | |
| 133 | + } | |
| 305 | 134 | |
| 306 | - /** | |
| 307 | - * Method deactivate_plugin() | |
| 308 | - * | |
| 309 | - * Fire off action deactivate & display result | |
| 310 | - */ | |
| 311 | - public static function deactivate_plugin() { | |
| 312 | - self::action( 'deactivate' ); | |
| 313 | - die( wp_json_encode( array( 'result' => esc_html__( 'Plugin has been deactivated!', 'mainwp' ) ) ) ); | |
| 314 | - } | |
| 135 | + $use_tzformat = ! empty( $wp_info['format_datetime'] ) && is_array( $wp_info['format_datetime'] ) ? $wp_info['format_datetime'] : array(); | |
| 136 | + $offs = ! empty( $use_tzformat['gmt_offset'] ) ? intval( $use_tzformat['gmt_offset'] ) : 0; | |
| 137 | + $offs_info = esc_html__( ' - Timezone:', 'mainwp' ) . ' UTC' . ( $offs >= 0 ? '+' . $offs : $offs ); | |
| 315 | 138 | |
| 316 | - /** | |
| 317 | - * Method delete_plugin() | |
| 318 | - * | |
| 319 | - * Fire off action delete & display result | |
| 320 | - */ | |
| 321 | - public static function delete_plugin() { | |
| 322 | - self::action( 'delete' ); | |
| 323 | - die( wp_json_encode( array( 'result' => esc_html__( 'Plugin has been permanently deleted!', 'mainwp' ) ) ) ); | |
| 324 | - } | |
| 139 | + ?> | |
| 140 | + <div class="ui grid mainwp-widget-header"> | |
| 141 | + <div class="twelve wide column"> | |
| 142 | + <h2 class="ui header handle-drag"> | |
| 143 | + <?php | |
| 144 | + /** | |
| 145 | + * Filter: mainwp_plugins_widget_title | |
| 146 | + * | |
| 147 | + * Filters the Plugins widget title text. | |
| 148 | + * | |
| 149 | + * @param object $website Object containing the child site info. | |
| 150 | + * | |
| 151 | + * @since 4.1 | |
| 152 | + */ | |
| 153 | + echo esc_html( apply_filters( 'mainwp_plugins_widget_title', esc_html__( 'Plugins', 'mainwp' ), $website ) ); | |
| 154 | + ?> | |
| 155 | + <div class="sub header"><?php esc_html_e( 'Installed plugins on the child site', 'mainwp' ); ?></div> | |
| 156 | + </h2> | |
| 157 | + </div> | |
| 158 | + <div class="four wide column right aligned"> | |
| 159 | + <div class="ui dropdown right pointing mainwp-dropdown-tab"> | |
| 160 | + <i class="vertical ellipsis icon"></i> | |
| 161 | + <div class="menu"> | |
| 162 | + <a class="item" data-tab="active_plugins" data-value="active_plugins" title="<?php esc_attr_e( 'Active', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Active', 'mainwp' ); ?></a> | |
| 163 | + <a class="item" data-tab="inactive_plugins" data-value="inactive_plugins" title="<?php esc_attr_e( 'Inactive', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Inactive', 'mainwp' ); ?></a> | |
| 164 | + </div> | |
| 165 | + </div> | |
| 166 | + </div> | |
| 167 | + </div> | |
| 168 | + <div class="mainwp-scrolly-overflow"> | |
| 169 | + <?php | |
| 170 | + /** | |
| 171 | + * Action: mainwp_plugins_widget_top | |
| 172 | + * | |
| 173 | + * Fires at the top of the Plugins widget on the Individual site overview page. | |
| 174 | + * | |
| 175 | + * @param object $website Object containing the child site info. | |
| 176 | + * @param array $allPlugins Array containing all detected plugins data. | |
| 177 | + * | |
| 178 | + * @since 4.1 | |
| 179 | + */ | |
| 180 | + do_action( 'mainwp_plugins_widget_top', $website, $allPlugins ); | |
| 181 | + $site_info = $website->name . ' (' . $website->url . ') ' . ( ! empty( $offs_info ) ? $offs_info : '' ); | |
| 182 | + ?> | |
| 183 | + <div id="mainwp-widget-active-plugins" class="ui tab active" data-tab="active_plugins" site-info="<?php echo esc_attr( $site_info ); ?>" site-id="<?php echo intval( $website->id ); ?>"> | |
| 184 | + <?php | |
| 185 | + /** | |
| 186 | + * Action: mainwp_before_active_plugins_list | |
| 187 | + * | |
| 188 | + * Fires before the active plugins list in the Plugins widget on the Individual site overview page. | |
| 189 | + * | |
| 190 | + * @param object $website Object containing the child site info. | |
| 191 | + * @param array $actived_plugins Array containing all active plugins data. | |
| 192 | + * | |
| 193 | + * @since 4.1 | |
| 194 | + */ | |
| 195 | + do_action( 'mainwp_before_active_plugins_list', $website, $actived_plugins ); | |
| 196 | + ?> | |
| 197 | + <div class="ui divided selection middle aligned list"> | |
| 198 | + <?php | |
| 199 | + $_count = count( $actived_plugins ); | |
| 200 | + for ( $i = 0; $i < $_count; $i++ ) { | |
| 201 | + $slug = wp_strip_all_tags( $actived_plugins[ $i ]['slug'] ); | |
| 202 | + $plugin_directory = dirname( $slug ); | |
| 203 | + $plugin_name = $actived_plugins[ $i ]['name']; | |
| 204 | + $plugin_title = $plugin_name . ' ' . $actived_plugins[ $i ]['version']; | |
| 205 | + ?> | |
| 206 | + <div class="item <?php echo esc_html( dirname( $slug ) ); ?> row-manage-item" plugin-title="<?php echo esc_attr( $plugin_title ); ?>" plugin-name="<?php echo esc_attr( $plugin_name ); ?>" plugin-slug="<?php echo esc_attr( $slug ); ?>"> | |
| 207 | + <input class="pluginSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $actived_plugins[ $i ]['slug'] ) ); ?>"/> | |
| 208 | + <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 209 | + <div class="right floated pluginsAction"> | |
| 210 | + <div class="ui right pointing dropdown"> | |
| 211 | + <i class="ellipsis vertical icon"></i> | |
| 212 | + <div class="menu"> | |
| 213 | + <?php if ( \mainwp_current_user_can( 'dashboard', 'activate_deactivate_plugins' ) ) { ?> | |
| 214 | + <div class="mainwp-plugin-deactivate item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></div> | |
| 215 | + <?php } ?> | |
| 216 | + <?php if ( \mainwp_current_user_can( 'dashboard', 'delete_plugins' ) ) { ?> | |
| 217 | + <a href="#" class="mainwp-plugin-delete item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Delete', 'mainwp' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></a> | |
| 218 | + <?php } ?> | |
| 219 | + <a href="#" history-view="widget-plugins" class="mainwp-show-history item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'History', 'mainwp' ); ?></a> | |
| 220 | + </div> | |
| 221 | + </div> | |
| 325 | 222 | |
| 326 | - /** | |
| 327 | - * Method action() | |
| 328 | - * | |
| 329 | - * Initiate try catch for chosen Action | |
| 330 | - * | |
| 331 | - * @param mixed $action Plugin Action. | |
| 332 | - * | |
| 333 | - * @throws \Exception Error message. | |
| 334 | - * | |
| 335 | - * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() | |
| 336 | - * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() | |
| 337 | - * @uses \MainWP\Dashboard\MainWP_Exception | |
| 338 | - * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() | |
| 339 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website() | |
| 340 | - */ | |
| 341 | - public static function action( $action ) { | |
| 342 | - $plugin = isset( $_POST['plugin'] ) ? wp_unslash( $_POST['plugin'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 343 | - $plugin = urldecode( $plugin ); | |
| 344 | - $websiteId = isset( $_POST['websiteId'] ) ? intval( $_POST['websiteId'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 223 | + </div> | |
| 224 | + <div class="middle aligned content"> | |
| 225 | + <?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 226 | + <a href="<?php echo esc_url( admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( wp_strip_all_tags( $actived_plugins[ $i ]['slug'] ) ) ) ); ?>" target="_blank" class="open-plugin-details-modal" title="More information about <?php echo wp_strip_all_tags( $actived_plugins[ $i ]['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>"> | |
| 227 | + <?php echo esc_html( $plugin_title ); ?> | |
| 228 | + </a> | |
| 229 | + </div> | |
| 230 | + <div class="mainwp-row-actions-working"> | |
| 231 | + <i class="notched circle loading icon"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?> | |
| 232 | + </div> | |
| 233 | + </div> | |
| 234 | + <?php } ?> | |
| 235 | + </div> | |
| 236 | + <?php | |
| 237 | + /** | |
| 238 | + * Action: mainwp_after_active_plugins_list | |
| 239 | + * | |
| 240 | + * Fires after the active plugins list in the Plugins widget on the Individual site overview page. | |
| 241 | + * | |
| 242 | + * @param object $website Object containing the child site info. | |
| 243 | + * @param array $actived_plugins Array containing all active plugins data. | |
| 244 | + * | |
| 245 | + * @since 4.1 | |
| 246 | + */ | |
| 247 | + do_action( 'mainwp_after_active_plugins_list', $website, $actived_plugins ); | |
| 248 | + ?> | |
| 249 | + </div> | |
| 250 | + <div id="mainwp-widget-inactive-plugins" class="ui tab" data-tab="inactive_plugins"> | |
| 251 | + <?php | |
| 252 | + /** | |
| 253 | + * Action: mainwp_before_inactive_plugins_list | |
| 254 | + * | |
| 255 | + * Fires before the inactive plugins list in the Plugins widget on the Individual site overview page. | |
| 256 | + * | |
| 257 | + * @param object $website Object containing the child site info. | |
| 258 | + * @param array $inactive_plugins Array containing all active plugins data. | |
| 259 | + * | |
| 260 | + * @since 4.1 | |
| 261 | + */ | |
| 262 | + do_action( 'mainwp_before_inactive_plugins_list', $website, $inactive_plugins ); | |
| 263 | + ?> | |
| 264 | + <div class="ui middle aligned divided list"> | |
| 265 | + <?php | |
| 266 | + $_count = count( $inactive_plugins ); | |
| 267 | + for ( $i = 0; $i < $_count; $i++ ) { | |
| 268 | + $slug = $inactive_plugins[ $i ]['slug']; | |
| 269 | + $plugin_directory = dirname( $slug ); | |
| 270 | + $plugin_name = $inactive_plugins[ $i ]['name']; | |
| 271 | + $plugin_title = $plugin_name . ' ' . $inactive_plugins[ $i ]['version']; | |
| 272 | + ?> | |
| 273 | + <div class="item <?php echo esc_html( sanitize_text_field( dirname( $slug ) ) ); ?> row-manage-item" plugin-title="<?php echo esc_attr( $plugin_title ); ?>" plugin-name="<?php echo esc_attr( $plugin_name ); ?>" plugin-slug="<?php echo esc_attr( $slug ); ?>"> | |
| 274 | + <input class="pluginSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $inactive_plugins[ $i ]['slug'] ) ); ?>"/> | |
| 275 | + <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 276 | + <div class="right floated content pluginsAction"> | |
| 277 | + <div class="ui right pointing dropdown"> | |
| 278 | + <i class="ellipsis vertical icon"></i> | |
| 279 | + <div class="menu"> | |
| 280 | + <?php if ( \mainwp_current_user_can( 'dashboard', 'activate_deactivate_plugins' ) ) { ?> | |
| 281 | + <a href="#" class="mainwp-plugin-activate item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Activate', 'mainwp' );// phpcs:ignore WordPress.Security.EscapeOutput ?></a> | |
| 282 | + <?php } ?> | |
| 283 | + <?php if ( \mainwp_current_user_can( 'dashboard', 'delete_plugins' ) ) { ?> | |
| 284 | + <a href="#" class="mainwp-plugin-delete item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Delete', 'mainwp' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></a> | |
| 285 | + <?php } ?> | |
| 286 | + <a href="#" history-view="widget-plugins" class="mainwp-show-history item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'History', 'mainwp' ); ?></a> | |
| 287 | + </div> | |
| 288 | + </div> | |
| 289 | + </div> | |
| 290 | + <div class="middle aligned content"> | |
| 291 | + <?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 292 | + <a href="<?php echo esc_url( admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( $inactive_plugins[ $i ]['slug'] ) ) ); ?>" target="_blank" class="open-plugin-details-modal" title="More information about <?php echo wp_strip_all_tags( $inactive_plugins[ $i ]['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>"> | |
| 293 | + <?php echo esc_html( $plugin_title ); ?> | |
| 294 | + </a> | |
| 295 | + </div> | |
| 296 | + <div class="mainwp-row-actions-working"> | |
| 297 | + <i class="ui active inline loader tiny"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?> | |
| 298 | + </div> | |
| 299 | + </div> | |
| 300 | + <?php } ?> | |
| 301 | + </div> | |
| 302 | + <?php | |
| 303 | + /** | |
| 304 | + * Action: mainwp_after_inactive_plugins_list | |
| 305 | + * | |
| 306 | + * Fires after the inactive plugins list in the Plugins widget on the Individual site overview page. | |
| 307 | + * | |
| 308 | + * @param object $website Object containing the child site info. | |
| 309 | + * @param array $inactive_plugins Array containing all active plugins data. | |
| 310 | + * | |
| 311 | + * @since 4.1 | |
| 312 | + */ | |
| 313 | + do_action( 'mainwp_after_inactive_plugins_list', $website, $inactive_plugins ); | |
| 314 | + ?> | |
| 315 | + </div> | |
| 316 | + </div> | |
| 317 | + <div class="ui two column grid mainwp-widget-footer"> | |
| 318 | + <div class="left aligned middle aligned column"></div> | |
| 319 | + <div class="right aligned middle aligned column"> | |
| 320 | + <a href="admin.php?page=PluginsManage" class="ui mini basic button"><?php esc_html_e( 'Manage Plugins', 'mainwp' ); ?></a> | |
| 321 | + </div> | |
| 322 | + </div> | |
| 323 | + <?php | |
| 324 | + /** | |
| 325 | + * Action: mainwp_plugins_widget_bottom | |
| 326 | + * | |
| 327 | + * Fires at the bottom of the Plugins widget on the Individual site overview page. | |
| 328 | + * | |
| 329 | + * @param object $website Object containing the child site info. | |
| 330 | + * @param array $allPlugins Array containing all detected plugins data. | |
| 331 | + * | |
| 332 | + * @since 4.1 | |
| 333 | + */ | |
| 334 | + do_action( 'mainwp_plugins_widget_bottom', $website, $allPlugins ); | |
| 335 | + MainWP_Updates::render_plugin_details_modal(); | |
| 336 | + } | |
| 345 | 337 | |
| 346 | - if ( empty( $plugin ) || empty( $websiteId ) ) { | |
| 347 | - die( wp_json_encode( array( 'error' => esc_html__( 'Plugin or site ID not found. Please, reload the page and try again.', 'mainwp' ) ) ) ); | |
| 348 | - } | |
| 338 | + /** | |
| 339 | + * Method activate_plugin() | |
| 340 | + * | |
| 341 | + * Fire off Action activate & display result | |
| 342 | + */ | |
| 343 | + public static function activate_plugin() { | |
| 344 | + static::action( 'activate' ); | |
| 345 | + die( wp_json_encode( array( 'result' => esc_html__( 'Plugin has been activated!', 'mainwp' ) ) ) ); | |
| 346 | + } | |
| 349 | 347 | |
| 350 | - $website = MainWP_DB::instance()->get_website_by_id( $websiteId ); | |
| 351 | - if ( ! MainWP_System_Utility::can_edit_website( $website ) ) { | |
| 352 | - die( wp_json_encode( array( 'error' => esc_html__( 'You cannot edit this website.', 'mainwp' ) ) ) ); | |
| 353 | - } | |
| 348 | + /** | |
| 349 | + * Method deactivate_plugin() | |
| 350 | + * | |
| 351 | + * Fire off action deactivate & display result | |
| 352 | + */ | |
| 353 | + public static function deactivate_plugin() { | |
| 354 | + static::action( 'deactivate' ); | |
| 355 | + die( wp_json_encode( array( 'result' => esc_html__( 'Plugin has been deactivated!', 'mainwp' ) ) ) ); | |
| 356 | + } | |
| 354 | 357 | |
| 355 | - if ( MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 356 | - die( | |
| 357 | - wp_json_encode( | |
| 358 | - array( | |
| 359 | - 'error' => esc_html__( 'Suspended site.', 'mainwp' ), | |
| 360 | - 'errorCode' => 'SUSPENDED_SITE', | |
| 361 | - ) | |
| 362 | - ) | |
| 363 | - ); | |
| 364 | - } | |
| 358 | + /** | |
| 359 | + * Method delete_plugin() | |
| 360 | + * | |
| 361 | + * Fire off action delete & display result | |
| 362 | + */ | |
| 363 | + public static function delete_plugin() { | |
| 364 | + static::action( 'delete' ); | |
| 365 | + die( wp_json_encode( array( 'result' => esc_html__( 'Plugin has been permanently deleted!', 'mainwp' ) ) ) ); | |
| 366 | + } | |
| 365 | 367 | |
| 366 | - try { | |
| 368 | + /** | |
| 369 | + * Method action() | |
| 370 | + * | |
| 371 | + * Initiate try catch for chosen Action | |
| 372 | + * | |
| 373 | + * @param mixed $action Plugin Action. | |
| 374 | + * | |
| 375 | + * @throws \MainWP_Exception Error message. | |
| 376 | + * | |
| 377 | + * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() | |
| 378 | + * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() | |
| 379 | + * @uses \MainWP\Dashboard\MainWP_Exception | |
| 380 | + * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() | |
| 381 | + * @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website() | |
| 382 | + */ | |
| 383 | + public static function action( $action ) { | |
| 384 | + $plugin = isset( $_POST['plugin'] ) ? wp_unslash( $_POST['plugin'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 385 | + $plugin = urldecode( $plugin ); | |
| 386 | + $websiteId = isset( $_POST['websiteId'] ) ? intval( $_POST['websiteId'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 367 | 387 | |
| 368 | - /** | |
| 369 | - * Action: mainwp_before_plugin_action | |
| 370 | - * | |
| 371 | - * Fires before plugin activate/deactivate/delete actions. | |
| 372 | - * | |
| 373 | - * @since 4.1 | |
| 374 | - */ | |
| 375 | - do_action( 'mainwp_before_plugin_action', $action, $plugin, $website ); | |
| 388 | + if ( empty( $plugin ) || empty( $websiteId ) ) { | |
| 389 | + die( wp_json_encode( array( 'error' => esc_html__( 'Plugin or site ID not found. Please, reload the page and try again.', 'mainwp' ) ) ) ); | |
| 390 | + } | |
| 376 | 391 | |
| 377 | - $information = MainWP_Connect::fetch_url_authed( | |
| 378 | - $website, | |
| 379 | - 'plugin_action', | |
| 380 | - array( | |
| 381 | - 'action' => $action, | |
| 382 | - 'plugin' => $plugin, | |
| 383 | - ) | |
| 384 | - ); | |
| 392 | + $website = MainWP_DB::instance()->get_website_by_id( $websiteId ); | |
| 393 | + if ( ! MainWP_System_Utility::can_edit_website( $website ) ) { | |
| 394 | + die( wp_json_encode( array( 'error' => esc_html__( 'You cannot edit this website.', 'mainwp' ) ) ) ); | |
| 395 | + } | |
| 385 | 396 | |
| 386 | - /** | |
| 387 | - * Action: mainwp_after_plugin_action | |
| 388 | - * | |
| 389 | - * Fires after plugin activate/deactivate/delete actions. | |
| 390 | - * | |
| 391 | - * @since 4.1 | |
| 392 | - */ | |
| 393 | - do_action( 'mainwp_after_plugin_action', $information, $action, $plugin, $website ); | |
| 397 | + if ( MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 398 | + die( | |
| 399 | + wp_json_encode( | |
| 400 | + array( | |
| 401 | + 'error' => esc_html__( 'Suspended site.', 'mainwp' ), | |
| 402 | + 'errorCode' => 'SUSPENDED_SITE', | |
| 403 | + ) | |
| 404 | + ) | |
| 405 | + ); | |
| 406 | + } | |
| 394 | 407 | |
| 395 | - } catch ( MainWP_Exception $e ) { | |
| 396 | - die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e ) ) ) ); | |
| 397 | - } | |
| 408 | + try { | |
| 398 | 409 | |
| 399 | - if ( ! isset( $information['status'] ) || ( 'SUCCESS' !== $information['status'] ) ) { | |
| 400 | - die( wp_json_encode( array( 'error' => esc_html__( 'Unexpected error occurred. Please try again.', 'mainwp' ) ) ) ); | |
| 401 | - } | |
| 402 | - } | |
| 410 | + /** | |
| 411 | + * Action: mainwp_before_plugin_action | |
| 412 | + * | |
| 413 | + * Fires before plugin activate/deactivate/delete actions. | |
| 414 | + * | |
| 415 | + * @since 4.1 | |
| 416 | + */ | |
| 417 | + do_action( 'mainwp_before_plugin_action', $action, $plugin, $website ); | |
| 418 | + | |
| 419 | + $information = MainWP_Connect::fetch_url_authed( | |
| 420 | + $website, | |
| 421 | + 'plugin_action', | |
| 422 | + array( | |
| 423 | + 'action' => $action, | |
| 424 | + 'plugin' => $plugin, | |
| 425 | + ) | |
| 426 | + ); | |
| 427 | + | |
| 428 | + /** | |
| 429 | + * Action: mainwp_after_plugin_action | |
| 430 | + * | |
| 431 | + * Fires after plugin activate/deactivate/delete actions. | |
| 432 | + * | |
| 433 | + * @since 4.1 | |
| 434 | + */ | |
| 435 | + do_action( 'mainwp_after_plugin_action', $information, $action, $plugin, $website ); | |
| 436 | + | |
| 437 | + } catch ( MainWP_Exception $e ) { | |
| 438 | + die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e, true ) ) ) ); // escaped. | |
| 439 | + } | |
| 440 | + | |
| 441 | + if ( ! isset( $information['status'] ) || ( 'SUCCESS' !== $information['status'] ) ) { | |
| 442 | + die( wp_json_encode( array( 'error' => esc_html__( 'Unexpected error occurred. Please try again.', 'mainwp' ) ) ) ); | |
| 443 | + } | |
| 444 | + } | |
| 403 | 445 | } |