service IDs it adds and a display name. * * @return array */ public static function known_plugins() { $map = array( 'google-site-kit' => array( 'Site Kit by Google', array( 'google-analytics' ) ), 'google-analytics-for-wordpress' => array( 'MonsterInsights', array( 'google-analytics' ) ), 'google-analytics-dashboard-for-wp' => array( 'ExactMetrics', array( 'google-analytics' ) ), 'ga-google-analytics' => array( 'GA Google Analytics', array( 'google-analytics' ) ), 'woocommerce-google-analytics-integration' => array( 'Google Analytics for WooCommerce', array( 'google-analytics' ) ), 'duracelltomi-google-tag-manager' => array( 'GTM4WP', array( 'google-tag-manager' ) ), 'pixelyoursite' => array( 'PixelYourSite', array( 'meta-pixel' ) ), 'official-facebook-pixel' => array( 'Meta pixel for WordPress', array( 'meta-pixel' ) ), 'facebook-for-woocommerce' => array( 'Facebook for WooCommerce', array( 'meta-pixel' ) ), 'microsoft-clarity' => array( 'Microsoft Clarity', array( 'microsoft-clarity' ) ), 'hotjar' => array( 'Hotjar', array( 'hotjar' ) ), 'pinterest-for-woocommerce' => array( 'Pinterest for WooCommerce', array( 'pinterest-tag' ) ), 'tiktok-for-business' => array( 'TikTok for WooCommerce', array( 'tiktok-pixel' ) ), ); $out = array(); foreach ( $map as $slug => $row ) { $out[ $slug ] = array( 'name' => $row[0], 'services' => $row[1], ); } /** * Filters the plugin => service map. * * @param array $out Plugin folder => name and service IDs. */ return apply_filters( 'ariconsent_known_plugins', $out ); } /** * Service IDs suggested by active plugins, with the plugins that suggest them. * * @param string[]|null $active_plugins Plugin basenames (defaults to the site's active plugins). * @return array Service ID => plugin names. */ public static function detected( $active_plugins = null ) { if ( null === $active_plugins ) { $active_plugins = (array) get_option( 'active_plugins', array() ); if ( is_multisite() ) { $active_plugins = array_merge( $active_plugins, array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) ); } } $known = self::known_plugins(); $out = array(); foreach ( $active_plugins as $basename ) { $slug = strtok( (string) $basename, '/' ); if ( isset( $known[ $slug ] ) ) { foreach ( $known[ $slug ]['services'] as $service_id ) { $out[ $service_id ][] = $known[ $slug ]['name']; } } } return $out; } /** * Cookies other plugins registered through the WP Consent API, mapped to our categories. * * @return array */ public static function registered_cookies() { if ( ! function_exists( 'wp_get_cookie_info' ) ) { return array(); } $map = array( 'functional' => 'necessary', 'preferences' => 'preferences', 'statistics' => 'statistics', 'statistics-anonymous' => 'statistics', 'marketing' => 'marketing', ); $out = array(); foreach ( (array) wp_get_cookie_info() as $name => $info ) { if ( ! is_array( $info ) ) { continue; } $category = isset( $info['category'], $map[ $info['category'] ] ) ? $map[ $info['category'] ] : 'marketing'; $out[] = array( 'name' => (string) $name, 'plugin' => isset( $info['plugin_or_service'] ) ? (string) $info['plugin_or_service'] : '', 'category' => $category, 'expires' => isset( $info['expires'] ) ? (string) $info['expires'] : '', 'purpose' => isset( $info['function'] ) ? (string) $info['function'] : '', ); } return $out; } }