'Icon URI',
'SupportForumURI' => 'Support Forum URI',
'DocumentationURI' => 'Documentation URI',
);
$extsPages = array();
$compatible_v4_checks = array(
'advanced-uptime-monitor-extension/advanced-uptime-monitor-extension.php',
'mainwp-article-uploader-extension/mainwp-article-uploader-extension.php',
'mainwp-backwpup-extension/mainwp-backwpup-extension.php',
'boilerplate-extension/boilerplate-extension.php',
'mainwp-branding-extension/mainwp-branding-extension.php',
'mainwp-bulk-settings-manager/mainwp-bulk-settings-manager.php',
'mainwp-clean-and-lock-extension/mainwp-clean-and-lock-extension.php',
'mainwp-client-reports-extension/mainwp-client-reports-extension.php',
'mainwp-clone-extension/mainwp-clone-extension.php',
'mainwp-code-snippets-extension/mainwp-code-snippets-extension.php',
'mainwp-comments-extension/mainwp-comments-extension.php',
'mainwp-favorites-extension/mainwp-favorites-extension.php',
'mainwp-file-uploader-extension/mainwp-file-uploader-extension.php',
'mainwp-google-analytics-extension/mainwp-google-analytics-extension.php',
'mainwp-maintenance-extension/mainwp-maintenance-extension.php',
'mainwp-piwik-extension/mainwp-piwik-extension.php',
'mainwp-post-dripper-extension/mainwp-post-dripper-extension.php',
'mainwp-rocket-extension/mainwp-rocket-extension.php',
'mainwp-sucuri-extension/mainwp-sucuri-extension.php',
'mainwp-team-control/mainwp-team-control.php',
'mainwp-updraftplus-extension/mainwp-updraftplus-extension.php',
'mainwp-url-extractor-extension/mainwp-url-extractor-extension.php',
'mainwp-woocommerce-shortcuts-extension/mainwp-woocommerce-shortcuts-extension.php',
'mainwp-woocommerce-status-extension/mainwp-woocommerce-status-extension.php',
'mainwp-wordfence-extension/mainwp-wordfence-extension.php',
'wordpress-seo-extension/wordpress-seo-extension.php',
'mainwp-page-speed-extension/mainwp-page-speed-extension.php',
'mainwp-ithemes-security-extension/mainwp-ithemes-security-extension.php',
'mainwp-post-plus-extension/mainwp-post-plus-extension.php',
'mainwp-staging-extension/mainwp-staging-extension.php',
'mainwp-custom-post-types/mainwp-custom-post-types.php',
'mainwp-buddy-extension/mainwp-buddy-extension.php',
'mainwp-vulnerability-checker-extension/mainwp-vulnerability-checker-extension.php',
'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php',
'activity-log-mainwp/activity-log-mainwp.php',
);
include_once ABSPATH . '/wp-admin/includes/plugin.php'; // NOSONAR - WP compatible.
$deactivated_imcompatible = array();
foreach ( $init_extensions as $extension ) {
$slug = plugin_basename( $extension['plugin'] );
$plugin_data = get_plugin_data( $extension['plugin'], true, false );
$file_data = get_file_data( $extension['plugin'], $extraHeaders );
if ( ! isset( $plugin_data['Name'] ) || ( '' === $plugin_data['Name'] ) ) {
continue;
}
if ( in_array( $slug, $compatible_v4_checks ) ) {
$check_minver = '3.99999';
if ( 'advanced-uptime-monitor-extension/advanced-uptime-monitor-extension.php' === $slug ) {
$check_minver = '4.6.2';
} elseif ( 'activity-log-mainwp/activity-log-mainwp.php' === $slug ) {
$check_minver = '1.0.5';
}
if ( isset( $plugin_data['Version'] ) && version_compare( $plugin_data['Version'], $check_minver, '<' ) ) {
$deactivated_imcompatible[] = $plugin_data['Name'];
deactivate_plugins( $slug, true );
continue;
}
}
$extension['slug'] = $slug;
if ( ! isset( $extension['name'] ) ) {
$extension['name'] = $plugin_data['Name'];
}
$extension['version'] = $plugin_data['Version'];
$extension['description'] = $plugin_data['Description'];
$extension['author'] = $plugin_data['Author'];
$extension['icon'] = isset( $extension['icon'] ) ? trim( $extension['icon'] ) : '';
$extension['iconURI'] = $file_data['IconURI'];
$extension['SupportForumURI'] = $file_data['SupportForumURI'];
$extension['DocumentationURI'] = $file_data['DocumentationURI'];
$extension['page'] = 'Extensions-' . str_replace( ' ', '-', ucwords( str_replace( '-', ' ', dirname( $slug ) ) ) );
if ( isset( $extension['apiManager'] ) && $extension['apiManager'] ) {
$api_slug = dirname( $slug );
if ( $is_cached ) {
$options = isset( $activations_cached[ $api_slug ] ) ? $activations_cached[ $api_slug ] : array();
} else {
$options = MainWP_Api_Manager::instance()->get_activation_info( $api_slug );
$activations_cached[ $api_slug ] = $options;
}
if ( ! is_array( $options ) ) {
$options = array();
}
$extension['api_key'] = isset( $options['api_key'] ) ? $options['api_key'] : '';
$extension['activated_key'] = isset( $options['activated_key'] ) ? $options['activated_key'] : 'Deactivated';
$extension['deactivate_checkbox'] = isset( $options['deactivate_checkbox'] ) ? $options['deactivate_checkbox'] : 'off';
$extension['product_id'] = isset( $options['product_id'] ) ? $options['product_id'] : '';
$extension['instance_id'] = isset( $options['instance_id'] ) ? $options['instance_id'] : '';
$extension['software_version'] = isset( $options['software_version'] ) ? $options['software_version'] : '';
$extension['mainwp_version'] = isset( $options['mainwp_version'] ) ? $options['mainwp_version'] : '';
if ( isset( $options['product_item_id'] ) ) {
$extension['product_item_id'] = $options['product_item_id'];
}
}
$ext_slug = dirname( $slug );
if ( isset( $all_available_extensions[ $ext_slug ] ) ) {
$extension['type'] = $all_available_extensions[ $ext_slug ]['type']; // to fix.
}
$save_extensions[] = $extension;
if ( \mainwp_current_user_can( 'extension', dirname( $slug ) ) ) {
$callback = isset( $extension['callback'] ) ? $extension['callback'] : '';
$menu_name = MainWP_Extensions_Handler::polish_ext_name( $extension );
if ( MainWP_Extensions_Handler::added_on_menu( $slug ) ) {
$_page = add_submenu_page( 'mainwp_tab', $extension['name'], $menu_name, 'read', $extension['page'], $callback );
} else {
$_page = add_submenu_page( 'mainwp_tab', $extension['name'], '
' . $extension['name'] . '
', 'read', $extension['page'], $callback );
}
if ( isset( $extension['on_load_callback'] ) && ! empty( $extension['on_load_callback'] ) ) {
add_action( 'load-' . $_page, $extension['on_load_callback'] );
}
$_item = array(
'title' => $menu_name,
'slug' => $extension['page'],
'href' => isset( $extension['href'] ) ? $extension['href'] : '',
);
$extsPages[] = $_item;
}
}
if ( ! empty( $deactivated_imcompatible ) ) {
set_transient( 'mainwp_transient_deactivated_incomtible_exts', $deactivated_imcompatible );
}
MainWP_Utility::update_option( 'mainwp_extensions', $save_extensions );
MainWP_Extensions_Handler::get_extensions( true ); // forced reload.
if ( ! $is_cached ) {
update_option( 'mainwp_extensions_all_activation_cached', $activations_cached );
}
static::init_left_menu( $extsPages );
}
/**
* Method init_left_menu()
*
* Initiate top level Extensions Menues.
*
* @param array $extPages List of extension pages.
* @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
* @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
* @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu()
*/
public static function init_left_menu( $extPages ) {
$subPages = array();
if ( ! MainWP_Menu::is_disable_menu_item( 2, 'Extensions' ) ) {
MainWP_Menu::add_left_menu(
array(
'title' => esc_html__( 'Add-ons', 'mainwp' ),
'parent_key' => 'mainwp_tab',
'slug' => 'Extensions',
'href' => 'admin.php?page=Extensions',
'icon' => '';
if ( empty( $installing_exts ) && count( $purchased_data ) === count( $all_free_pro_exts ) ) {
$html .= '
' . esc_html__( 'All purchased add-ons already installed.', 'mainwp' ) . '
';
} else {
if ( isset( $not_purchased_exts ) && ! empty( $not_purchased_exts ) ) {
$html .= '
' . esc_html__( 'You have access to all our Free and third-party Add-ons on WP.org and any that you have registered for, but you DO NOT need to install them. ', 'mainwp' );
$html .= '
';
$html .= esc_html__( 'To avoid information overload, we highly recommend adding Add-ons one at a time and as you need them. Skip any add-on you do not want to install at this time. ', 'mainwp' );
$html .= sprintf( esc_html__( 'After installing all your selected Add-ons, close the modal by clicking the Close button and %1$sactivate Add-ons API license%2$s.', 'mainwp' ), '
', ' ' ) . '
'; // NOSONAR - noopener - open safe.
} else {
$html .= '
' . esc_html__( 'You have access to the MainWP Pro plan, which gives you access to all MainWP-created add-on, but you DO NOT need to install all of them.', 'mainwp' );
$html .= '
';
$html .= esc_html__( 'To avoid information overload, we highly recommend adding Add-ons one at a time and as you need them. Skip any add-on you do not want to install at this time. ', 'mainwp' );
$html .= sprintf( esc_html__( 'After installing all your selected Add-ons, close the modal by clicking the Close button and %1$sactivate Add-ons API license%2$s.', 'mainwp' ), '
', ' ' ) . '
'; // NOSONAR - noopener - open safe.
}
$html .= '
';
$html .= '
';
foreach ( $all_groups as $gr_id => $gr_name ) {
if ( isset( $grouped_exts[ $gr_id ] ) ) {
$html .= '
' . $gr_name . ' ';
}
}
if ( isset( $grouped_exts['others'] ) && ! empty( $grouped_exts['others'] ) ) {
$html .= '
' . esc_html__( 'Other', 'mainwp' ) . ' ';
}
$html .= '
';
$html .= '
';
$html .= '
' . esc_html__( 'Show Extensions', 'mainwp' ) . ' - ' . esc_html__( 'Purpose-built add-ons that expand your Dashboard\'s functionality without relying on third-party tools.', 'mainwp' ) . '
';
$html .= '
' . esc_html__( 'Show Integrations', 'mainwp' ) . ' -' . esc_html__( 'Add-ons that connect to 3rd party tools you already use, bringing their power directly into your Dashboard.', 'mainwp' ) . '
';
$html .= '
';
foreach ( $all_groups as $gr_id => $gr_name ) {
if ( isset( $grouped_exts[ $gr_id ] ) && 'all' !== $gr_id ) {
$html .= '
';
$html .= '
' . $gr_name . ' ';
$html .= '
';
$html .= $grouped_exts[ $gr_id ];
$html .= '
';
$html .= '
';
}
}
if ( isset( $grouped_exts['others'] ) && ! empty( $grouped_exts['others'] ) ) {
$html .= '
';
$html .= '
Other ';
$html .= '
';
$html .= $grouped_exts['others'];
$html .= '
';
$html .= '
';
}
$html .= '
';
$html .= '
Search Add-ons ';
$html .= '
';
$html .= '
';
$html .= $grouped_exts['all'];
$html .= '
';
$html .= '
';
}
$html .= '
';
$html .= '
FREE - ' . esc_html__( 'Free add-on developed by MainWP', 'mainwp' ) . '
';
$html .= '
PRO - ' . esc_html__( 'Premium add-on developed by MainWP', 'mainwp' ) . '
';
$html .= '
.ORG - ' . esc_html__( 'Free add-on developed by 3rd party author, available on WordPress.org', 'mainwp' );
$html .= '
';
$html .= '
' . esc_html__( 'Add-on requires the corresponding plugin on your MainWP Dashboard site too.', 'mainwp' ) . '
';
$html .= '
' . esc_html__( 'Shows the add-on privacy info.', 'mainwp' ) . '
';
$html .= '';
$html .= '';
if ( ! empty( $installing_exts ) ) {
$html .= '
';
}
$html .= '
';
$return = array(
'result' => 'SUCCESS',
'data' => $html,
);
wp_send_json( $return );
}
/**
* Method render_header()
*
* Render page header.
*
* @param string $shownPage The page slug shown at this moment.
*
* @uses \MainWP\Dashboard\MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook()
* @uses \MainWP\Dashboard\MainWP_Extensions_View::render_header()
*/
public static function render_header( $shownPage = '' ) {
MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook();
MainWP_Extensions_View::render_header( $shownPage );
}
/**
* Method render_footer()
*
* Render page footer.
*
* @param string $shownPage The page slug shown at this moment.
*
* @uses \MainWP\Dashboard\MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook()
* @uses \MainWP\Dashboard\MainWP_Extensions_View::render_footer()
*/
public static function render_footer( $shownPage ) {
MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook();
MainWP_Extensions_View::render_footer( $shownPage );
}
/**
* Method render()
*
* Render page content.
*
* @uses \MainWP\Dashboard\MainWP_Extensions_View::render()
* @uses \MainWP\Dashboard\MainWP_UI::render_top_header()
*/
public static function render() {
$params = array(
'title' => esc_html__( 'Add-ons', 'mainwp' ),
);
MainWP_UI::render_top_header( $params );
MainWP_Extensions_View::render();
echo '';
}
/**
* Method mainwp_help_content()
*
* Creates the MainWP Help Documentation List for the help component in the sidebar.
*/
public static function mainwp_help_content() {
if ( isset( $_GET['page'] ) && 'Extensions' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
?>