get_available_integrations(); // Check if WooCommerce integration is in the list $has_woocommerce = isset($available_integrations['woocommerce']); // If WooCommerce integration is not in the list, add it manually if (!$has_woocommerce) { // Check if WooCommerce plugin is installed if (!function_exists('is_plugin_active')) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; } $wc_plugin_path = 'woocommerce/woocommerce.php'; // Use WordPress proper function to check if plugin exists if (!function_exists('get_plugins')) { require_once(ABSPATH . 'wp-admin/includes/plugin.php'); } $all_plugins = get_plugins(); $wc_plugin_installed = array_key_exists($wc_plugin_path, $all_plugins); // Make sure we're checking for plugin activation correctly $wc_plugin_active = is_plugin_active($wc_plugin_path) || (function_exists('WC') && class_exists('WooCommerce')); // Add WooCommerce integration to the list $available_integrations['woocommerce'] = array( 'id' => 'woocommerce', 'name' => 'WooCommerce Data Logger', 'description' => sprintf( /* translators: %s: link to WooCommerce plugin */ __('Track %s activities such as order status changes, product updates, and more.', 'activity-log-pro'), 'WooCommerce' ), 'is_active' => $wc_plugin_active, 'plugin_dependency' => $wc_plugin_path ); } // Check if Yoast integration is in the list $has_yoast = isset($available_integrations['yoast']); // If Yoast integration is not in the list, add it manually if (!$has_yoast) { // Check if Yoast SEO plugin is installed if (!function_exists('is_plugin_active')) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; } $yoast_plugin_path = 'wordpress-seo/wp-seo.php'; // Use WordPress proper function to check if plugin exists (reuse get_plugins if already available) if (!isset($all_plugins)) { if (!function_exists('get_plugins')) { require_once(ABSPATH . 'wp-admin/includes/plugin.php'); } $all_plugins = get_plugins(); } $yoast_plugin_installed = array_key_exists($yoast_plugin_path, $all_plugins); // Check if Yoast SEO is active $yoast_plugin_active = is_plugin_active($yoast_plugin_path) || (function_exists('WPSEO') || class_exists('WPSEO_Options')); // Add Yoast integration to the list $available_integrations['yoast'] = array( 'id' => 'yoast', 'name' => 'Yoast Data Logger', 'description' => sprintf( /* translators: %s: link to Yoast SEO plugin */ __('Track %s activities such as SEO settings changes, meta data updates, and more.', 'activity-log-pro'), 'Yoast SEO' ), 'is_active' => $yoast_plugin_active, 'plugin_dependency' => $yoast_plugin_path ); } // Ensure consistent ordering regardless of when integrations were added // Define the desired display order for integrations $integration_display_order = array('woocommerce', 'yoast'); $ordered_integrations = array(); // First, add integrations in the specified order if they exist foreach ($integration_display_order as $integration_id) { if (isset($available_integrations[$integration_id])) { $ordered_integrations[$integration_id] = $available_integrations[$integration_id]; } } // Then add any remaining integrations not in the specified order foreach ($available_integrations as $id => $integration) { if (!isset($ordered_integrations[$id])) { $ordered_integrations[$id] = $integration; } } // Use the ordered integrations for display $available_integrations = $ordered_integrations; if (empty($available_integrations)) { echo '
'; echo '

' . esc_html__('No integrations available at this time.', 'activity-log-pro') . '

'; echo '
'; } else { echo '
'; foreach ($available_integrations as $id => $integration) { $is_active = $integration['is_active']; $status_class = $is_active ? 'alp-integration-active' : 'alp-integration-inactive'; $status_text = $is_active ? esc_html__('Active', 'activity-log-pro') : esc_html__('Inactive', 'activity-log-pro'); $plugin_name = $integration['name']; $plugin_description = $integration['description']; // Check if integration file exists $integration_file_exists = false; $integration_file_path = ACTLOGPRO_PLUGIN_DIR . 'integrations/class-alp-' . $id . '-integration.php'; // First check main plugin directory if (file_exists($integration_file_path)) { $integration_file_exists = true; } else { // For premium integrations, check if premium plugin is active and file exists there $is_premium_integration = ($id === 'woocommerce' || $id === 'yoast'); if ($is_premium_integration && defined('ACTLOGPRO_PREMIUM_PLUGIN_DIR')) { $premium_integration_file_path = ACTLOGPRO_PREMIUM_PLUGIN_DIR . 'integrations/class-alp-' . $id . '-integration.php'; if (file_exists($premium_integration_file_path)) { $integration_file_exists = true; } } } // Get active integrations from options $active_integrations = get_option('actlogpro_active_integrations', array()); $is_integration_active = in_array($id, $active_integrations); // Check if this is a premium integration and handle status accordingly $is_premium_enabled = ACTLOGPRO_Premium_Helper::is_premium_enabled(); $is_premium_integration = ($id === 'woocommerce' || $id === 'yoast'); if ($is_premium_integration) { if (!$is_premium_enabled) { // Premium not enabled - force inactive state $is_integration_active = false; } else { // Premium is enabled - ensure features are registered before checking if (class_exists('ACTLOGPRO_Extension_Interface')) { // Trigger premium feature registration to ensure they're loaded do_action('actlogpro_register_extensions'); do_action('actlogpro_register_premium_features'); // Now check if the premium integration is available and active $feature_id = $id . '_integration'; $is_integration_active = ACTLOGPRO_Extension_Interface::is_premium_feature_available($feature_id); // If not available via extension interface, check settings as fallback if (!$is_integration_active) { $is_integration_active = in_array($id, $active_integrations); } } else { // Fallback: if extension interface not available, check the setting $is_integration_active = in_array($id, $active_integrations); } } } // Determine integration state $integration_state = 'not_installed'; if ($integration_file_exists) { $integration_state = $is_integration_active ? 'active' : 'inactive'; } // Set state-specific classes and text $state_class = 'alp-integration-' . $integration_state; $state_text = ''; switch ($integration_state) { case 'active': $state_text = esc_html__('Active', 'activity-log-pro'); break; case 'inactive': $state_text = esc_html__('Inactive', 'activity-log-pro'); break; case 'not_installed': $state_text = esc_html__('Not Installed', 'activity-log-pro'); break; } // Check if this is a premium integration $is_premium_integration = ($id === 'woocommerce' || $id === 'yoast'); $premium_container_class = $is_premium_integration && ACTLOGPRO_Premium_Helper::show_premium_ui() ? ' alp-premium-integration-container' : ''; echo '
'; echo '
'; if ($is_premium_integration && ACTLOGPRO_Premium_Helper::show_premium_ui()) { echo '
'; echo '

' . esc_html($plugin_name) . '

'; echo 'Premium'; echo '
'; } else { echo '

' . esc_html($plugin_name) . '

'; } echo '' . esc_html($state_text) . ''; echo '
'; // Add status indicators if (class_exists('ACTLOGPRO_Integration_Status_Helper')) { $plugin_dependency = !empty($integration['plugin_dependency']) ? $integration['plugin_dependency'] : ''; $actual_plugin_name = $plugin_name; // Default to integration name if ($id === 'woocommerce') { $actual_plugin_name = 'WooCommerce'; } else if ($id === 'yoast') { $actual_plugin_name = 'Yoast SEO'; } $allowed_html = array( 'div' => array( 'class' => array(), ), 'span' => array( 'class' => array(), ), 'svg' => array( 'viewBox' => array(), 'fill' => array(), 'xmlns' => array(), ), 'path' => array( 'd' => array(), 'stroke' => array(), 'stroke-width' => array(), 'stroke-linecap' => array(), 'stroke-linejoin' => array(), 'fill' => array(), ), ); echo wp_kses(ACTLOGPRO_Integration_Status_Helper::get_integration_status_html($id, $plugin_dependency, esc_html($actual_plugin_name)), $allowed_html); } echo '
'; echo '

' . wp_kses($plugin_description, array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array() ) )) . '

'; if (!$is_active) { echo '
'; // Check if the plugin is installed but not active if (!empty($integration['plugin_dependency'])) { $plugin_path = $integration['plugin_dependency']; // Use WordPress proper function to check if plugin exists (reuse get_plugins if already available) if (!isset($all_plugins)) { if (!function_exists('get_plugins')) { require_once(ABSPATH . 'wp-admin/includes/plugin.php'); } $all_plugins = get_plugins(); } $plugin_installed = array_key_exists($plugin_path, $all_plugins); // Get the actual plugin name for the message $actual_plugin_name = $plugin_name; // Default to integration name if ($id === 'woocommerce') { $actual_plugin_name = 'WooCommerce'; } else if ($id === 'yoast') { $actual_plugin_name = 'Yoast SEO'; } // For WooCommerce, we need a special check if ($id === 'woocommerce') { // Check if WooCommerce is active using multiple methods $wc_plugin_active = is_plugin_active($plugin_path) || (function_exists('WC') && class_exists('WooCommerce')); if ($wc_plugin_active) { // WooCommerce is active, but integration is disabled echo '

' . esc_html__('This integration is currently available but disabled. Use the Activate button below to enable it.', 'activity-log-pro') . '

'; } else if ($plugin_installed) { /* translators: %s: Plugin name */ echo '

' . sprintf(esc_html__('To use this integration, please activate the %s plugin.', 'activity-log-pro'), '' . esc_html($actual_plugin_name) . '') . '

'; } else { /* translators: %s: Plugin name */ echo '

' . sprintf(esc_html__('To use this integration, please install and activate the %s plugin.', 'activity-log-pro'), '' . esc_html($actual_plugin_name) . '') . '

'; } } else if ($id === 'yoast') { // Check if Yoast SEO is active using multiple methods $yoast_plugin_active = is_plugin_active($plugin_path) || (function_exists('WPSEO') || class_exists('WPSEO_Options')); if ($yoast_plugin_active) { // Yoast SEO is active, but integration is disabled echo '

' . esc_html__('This integration is currently available but disabled. Use the Activate button below to enable it.', 'activity-log-pro') . '

'; } else if ($plugin_installed) { /* translators: %s: Plugin name */ echo '

' . sprintf(esc_html__('To use this integration, please activate the %s plugin.', 'activity-log-pro'), '' . esc_html($actual_plugin_name) . '') . '

'; } else { /* translators: %s: Plugin name */ echo '

' . sprintf(esc_html__('To use this integration, please install and activate the %s plugin.', 'activity-log-pro'), '' . esc_html($actual_plugin_name) . '') . '

'; } } else { // For other plugins if ($plugin_installed) { /* translators: %s: Plugin name */ echo '

' . sprintf(esc_html__('To use this integration, please activate the %s plugin.', 'activity-log-pro'), '' . esc_html($actual_plugin_name) . '') . '

'; } else { /* translators: %s: Plugin name */ echo '

' . sprintf(esc_html__('To use this integration, please install and activate the %s plugin.', 'activity-log-pro'), '' . esc_html($actual_plugin_name) . '') . '

'; } } } else { /* translators: %s: Plugin name */ echo '

' . sprintf(esc_html__('To use this integration, please install and activate the %s plugin.', 'activity-log-pro'), '' . esc_html($plugin_name) . '') . '

'; } echo '
'; } else if ($integration_state === 'active') { // For premium integrations with premium UI enabled, don't show anything here // The premium upgrade panel will be shown in the management section instead if (!($is_premium_integration && ACTLOGPRO_Premium_Helper::show_premium_ui())) { // Show message for active integrations (only when not premium UI) echo '
'; echo '

' . esc_html__('You have the premium addon, thanks for your support.', 'activity-log-pro') . '

'; echo '
'; } } // Add integration management section echo '
'; // Status message container echo '
'; // Show different actions based on integration state if (!$integration_file_exists) { // For premium integrations (WooCommerce and Yoast), only show upgrade panel if ($is_premium_integration && ACTLOGPRO_Premium_Helper::show_premium_ui()) { // Show premium upgrade panel echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo ''; echo '
'; echo '
'; echo '

' . esc_html__('Premium Integration', 'activity-log-pro') . '

'; echo '

' . wp_kses($plugin_description, array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array() ) )) . '

'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; } elseif (!$is_premium_integration) { // Only show upload form for non-premium integrations echo '
'; // Add message in an info box first echo '
'; echo '

' . esc_html__('This integration is not currently installed. Please upload the integration file if you have it.', 'activity-log-pro') . '

'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo '
'; } // For premium integrations when premium is enabled but file not found, show nothing (this shouldn't happen) } else { // Check if this is a premium integration and should show premium UI instead of functional buttons if ($is_premium_integration && ACTLOGPRO_Premium_Helper::show_premium_ui()) { // Show premium upgrade panel instead of functional buttons echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo ''; echo '
'; echo '
'; echo '

' . esc_html__('Premium Integration', 'activity-log-pro') . '

'; echo '

' . wp_kses($plugin_description, array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array() ) )) . '

'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; } else { // Show activate/deactivate buttons for installed integrations echo '
'; if ($is_integration_active) { echo ''; } else { echo ''; } echo '
'; } } echo '
'; // Close management section echo '
'; // Close description echo '
'; // Close item } echo '
'; } // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>
actlogpro_render_admin_footer(); ?>