led_font_statuscairo_toy_font_face_createcairo_matrix_transform_pointcairo_matrix_init_scalecairo_scaled_font_destroycairo_pattern_referencecairo_matrix_init_rotatecairo_matrix_transform_distancecairo_surface_copy_pagecairo_surface_statuscairo_surface_show_pagecairo_scaled_font_extentscairo_scaled_font_glyph_extentscairo_glyph_freecairo_text_cluster_freecairo_text_cluster_allocatecairo_glyph_allocaterandpixman_image_composite32pixman_image_unrefpixman_bltpixman_image_get_datapixman_glyph_cache_freezepixman_glyph_cache_lookuppixman_glyph_cache_insertpixman_glyph_cache_thawpixman_composite_glyphs_no_maskpixman_glyph_cache_createpixman_glyph_get_mask_formatpixman_composite_glyphspixman_fillpixman_image_set_clip_region32pixman_image_create_bitspixman_image_set_destroy_functionpixman_image_get_stridepixman_rasterize_trapezoidpixman_add_trianglespixman_glyph_cache_destroypixman_glyph_cache_removepixman_image_set_transformhypotpixman_image_set_filterpixman_image_set_repeatpixman_image_set_component_alphapixman_image_refcairo_matrix_translatecairo_matrix_scalepixman_image_create_solid_fillpixman_image_create_radial_gradientpixman_image_create_linear_gradientpixman_image_set_ditherpixman_image_get_widthpixman_image_get_heightpixman_image_get_depthpixman_format_supported_destinationcairo_format_stride_for_widthcairo_image_surface_create_for_datacairo_image_surface_get_datacairo_image_surface_get_formatcairo_image_surface_get_widthcairo_image_surface_get_heightcairo_image_surface_get_stridepixman_region32_rectanglescairo_matrix_initcairo_matrix_rotatepixman_transform_point_3dfrexpcairo_status_to_stringlocaleconvstrtod_lnewlocalefreelocalefopen64__snprintf_chkmemmovefflushferrorfclose__errno_locationcairo_path_destroycairo_pattern_create_rgbcairo_pattern_create_linearcairo_pattern_create_radialcairo_pattern_create_meshcairo_pattern_get_typecairo_pattern_statuscairo_pattern_get_reference_countcairo_pattern_get_user_datacairo_pattern_set_user_datacairo_mesh_pattern_begin_patchcairo_mesh_pattern_move_tocairo_mesh_pattern_curve_tocairo_mesh_pattern_line_tocairo_mesh_pattern_end_patchcairo_mesh_pattern_set_control_pointcairo_mesh_pattern_set_corner_color_rgbacairo_mesh_pattern_set_corner_color_rgbcairo_pattern_add_color_stop_rgbacairo_pattern_add_color_stop_rgbcairo_pattern_get_matrixcairo_pattern_set_filtercairo_pattern_get_filtercairo_pattern_get_dithercairo_pattern_set_dithercairo_pattern_set_extendcairo_pattern_get_extendcairo_pattern_get_rgbacairo_pattern_get_surfacecairo_pattern_get_color_stop_rgbacairo_pattern_get_color_stop_countcairo_pattern_get_linear_pointscairo_pattern_get_radial_circlescairo_mesh_pattern_get_patch_countcairo_mesh_pattern_get_pathcairo_mesh_pattern_get_corner_color_rgbacairo_mesh_pattern_get_control_pointacoscairo_pattern_create_raster_sourcecairo_raster_source_pattern_set_callback_datacairo_raster_source_pattern_get_callback_datacairo_raster_source_pattern_set_acquirecairo_raster_source_pattern_get_acquirecairo_raster_source_pattern_set_snapshotcairo_raster_source_pattern_get_snapshotcairo_raster_source_pattern_set_copycairo_raster_source_pattern_get_copycairo_raster_source_pattern_set_finishcairo_raster_source_pattern_get_finishcairo_surface_flushcairo_recording_surface_ink_extentscairo_recording_surface_get_extents__sprintf_chkpixman_region32_initpixman_region32_init_rectpixman_region32_finicairo_region_createpixman_region32_init_rectscairo_region_create_rectanglecairo_region_copypixman_region32_copypixman_region32_n_rectscairo_region_get_extentspixman_region32_extentscairo_region_statuscairo_region_subtractpixman_region32_subtractcairo_region_subtract_rectanglecairo_region_intersectpixman_region32_intersectcairo_region_intersect_rectanglepixman_region32_unioncairo_region_xorcairo_region_xor_rectanglecairo_region_is_emptypixman_region32_not_emptycairo_region_translatepixman_region32_translatepixman_region32_contains_rectanglecairo_region_contains_poinquest_filesystem_credentials' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } // Set current screen for AJAX context (non-silent mode) if ( ! $silent ) { set_current_screen(); } $method = ''; $url = esc_url_raw( admin_url( 'admin.php?page=imagely-settings' ) ); ob_start(); $creds = request_filesystem_credentials( $url, $method, false, false, null ); if ( false === $creds ) { $form = ob_get_clean(); return new \WP_Error( 'filesystem_credentials_required', 'Filesystem credentials required', [ 'form' => $form ] ); } if ( ! WP_Filesystem( $creds ) ) { ob_start(); request_filesystem_credentials( $url, $method, true, false, null ); $form = ob_get_clean(); return new \WP_Error( 'filesystem_not_accessible', 'Filesystem not accessible', [ 'form' => $form ] ); } ob_end_clean(); require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // Check if Installer_Skin class exists if ( ! class_exists( 'Imagely\NGG\Util\Installer_Skin' ) ) { return new \WP_Error( 'installer_skin_missing', 'Installer_Skin class not found' ); } $skin = new \Imagely\NGG\Util\Installer_Skin(); $installer = new \Plugin_Upgrader( $skin ); $result = $installer->install( $download_url ); wp_cache_flush(); if ( is_wp_error( $result ) ) { return $result; } if ( $installer->plugin_info() ) { $plugin_basename = $installer->plugin_info(); $activated = false; // Try to activate the plugin if requested if ( $activate ) { $activation_result = activate_plugin( $plugin_basename, false, false, true ); $activated = ! is_wp_error( $activation_result ); } return [ 'basename' => $plugin_basename, 'activated' => $activated, ]; } return new \WP_Error( 'install_failed', 'Failed to install plugin' ); } /** * Get the current license type/level installed * * @return string */ public static function get_license_type() { if ( defined( 'NGG_PRO_PLUGIN_BASENAME' ) ) { return 'pro'; } elseif ( defined( 'NGG_PLUS_PLUGIN_BASENAME' ) ) { return 'plus'; } elseif ( defined( 'NGG_STARTER_PLUGIN_BASENAME' ) ) { return 'starter'; } return 'lite'; } /** * Check if a specific license level is already installed (active or inactive) * * @param string $product The product level to check (pro, plus, or starter). * @return bool True if installed (active or not), false otherwise. */ public static function is_product_installed( $product ) { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugin_basenames = [ 'pro' => 'nextgen-gallery-pro/nggallery-pro.php', 'plus' => 'nextgen-gallery-plus/nggallery-plus.php', 'starter' => 'nextgen-gallery-starter/nggallery-starter.php', ]; if ( ! isset( $plugin_basenames[ $product ] ) ) { return false; } $all_plugins = get_plugins(); return isset( $all_plugins[ $plugin_basenames[ $product ] ] ); } /** * Get error message for license errors * * @param string|null $error_code The error code. * @return string */ public static function get_error_message( $error_code ) { if ( ! isset( $error_code ) ) { return 'Something went wrong, please try again later.'; } $messages = [ 'empty_site_url' => __( 'The site URL is missing. Please provide a valid URL.', 'nextgen-gallery' ), 'license_not_found' => __( 'The license key was not found. Please verify and try again.', 'nextgen-gallery' ), 'license_status_expired' => __( 'The license key has expired. Please renew your license.', 'nextgen-gallery' ), 'license_expired' => __( 'The license key has expired. Please renew your license.', 'nextgen-gallery' ), 'license_status_disabled' => __( 'The license key has not been activated yet. Please contact support.', 'nextgen-gallery' ), 'license_disabled' => __( 'The license key has not been activated yet. Please contact support.', 'nextgen-gallery' ), 'license_status_revoked' => __( 'The license key has been revoked. Please contact support.', 'nextgen-gallery' ), 'license_revoked' => __( 'The license key has been revoked. Please contact support.', 'nextgen-gallery' ), 'license_limit_installations' => __( 'The license key has reached the maximum number of installations.', 'nextgen-gallery' ), ]; return $messages[ $error_code ] ?? __( 'An unknown error occurred. Please try again.', 'nextgen-gallery' ); } }