Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_Telemetry::setup_data()

Prepares telemetry data to be sent


Description Description


Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Return Return

(array)


Top ↑

Source Source

File: classes/Telemetry.php

	public static function setup_data() {
		global $wpdb;

		// Retrieve current theme info.
		$theme_data = wp_get_theme();
		$theme      = $theme_data->Name . ' ' . $theme_data->Version;

		// Retrieve current plugin information.
		if ( ! function_exists( 'get_plugins' ) ) {
			include ABSPATH . '/wp-admin/includes/plugin.php';
		}

		$plugins        = array_keys( get_plugins() );
		$active_plugins = get_option( 'active_plugins', array() );

		foreach ( $plugins as $key => $plugin ) {
			if ( in_array( $plugin, $active_plugins ) ) {
				// Remove active plugins from list so we can show active and inactive separately.
				unset( $plugins[ $key ] );
			}
		}

		$popups = 0;
		foreach ( wp_count_posts( 'popup' ) as $status ) {
			$popups += $status;
		}

		$popup_themes = 0;
		foreach ( wp_count_posts( 'popup_theme' ) as $status ) {
			$popup_themes += $status;
		}

		// Aggregates important settings across all popups.
		$all_popups = pum_get_all_popups();
		$triggers   = array();
		$cookies    = array();
		$conditions = array();
		$location   = array();
		$sizes      = array();
		$sounds     = array();

		// Cycle through each popup.
		foreach ( $all_popups as $popup ) {
			$settings = PUM_Admin_Popups::parse_values( $popup->get_settings() );

			// Cycle through each trigger to count the number of unique triggers.
			foreach ( $settings['triggers'] as $trigger ) {
				if ( isset( $triggers[ $trigger['type'] ] ) ) {
					$triggers[ $trigger['type'] ] += 1;
				} else {
					$triggers[ $trigger['type'] ] = 1;
				}
			}

			// Cycle through each cookie to count the number of unique cookie.
			foreach ( $settings['cookies'] as $cookie ) {
				if ( isset( $cookies[ $cookie['event'] ] ) ) {
					$cookies[ $cookie['event'] ] += 1;
				} else {
					$cookies[ $cookie['event'] ] = 1;
				}
			}

			// Cycle through each condition to count the number of unique condition.
			foreach ( $settings['conditions'] as $condition ) {
				foreach ( $condition as $target ) {
					if ( isset( $conditions[ $target['target'] ] ) ) {
						$conditions[ $target['target'] ] += 1;
					} else {
						$conditions[ $target['target'] ] = 1;
					}
				}
			}

			// Add locations setting.
			if ( isset( $location[ $settings['location'] ] ) ) {
				$location[ $settings['location'] ] += 1;
			} else {
				$location[ $settings['location'] ] = 1;
			}

			// Add size setting.
			if ( isset( $sizes[ $settings['size'] ] ) ) {
				$sizes[ $settings['size'] ] += 1;
			} else {
				$sizes[ $settings['size'] ] = 1;
			}

			// Add opening sound setting.
			if ( isset( $sounds[ $settings['open_sound'] ] ) ) {
				$sounds[ $settings['open_sound'] ] += 1;
			} else {
				$sounds[ $settings['open_sound'] ] = 1;
			}
		}

		return array(
			// UID.
			'uid'                    => self::get_uuid(),

			// Language Info.
			'language'               => get_bloginfo( 'language' ),
			'charset'                => get_bloginfo( 'charset' ),

			// Server Info.
			'php_version'            => phpversion(),
			'mysql_version'          => $wpdb->db_version(),
			'is_localhost'           => self::is_localhost(),

			// WP Install Info.
			'url'                    => get_site_url(),
			'version'                => Popup_Maker::$VER,
			'wp_version'             => get_bloginfo( 'version' ),
			'theme'                  => $theme,
			'active_plugins'         => $active_plugins,
			'inactive_plugins'       => array_values( $plugins ),

			// Popup Metrics.
			'popups'                 => $popups,
			'popup_themes'           => $popup_themes,
			'open_count'             => get_option( 'pum_total_open_count', 0 ),

			// Popup Maker Settings.
			'block_editor_enabled'   => pum_get_option( 'gutenberg_support_enabled' ),
			'bypass_ad_blockers'     => pum_get_option( 'bypass_adblockers' ),
			'disable_taxonimies'     => pum_get_option( 'disable_popup_category_tag' ),
			'disable_asset_cache'    => pum_get_option( 'disable_asset_caching' ),
			'disable_open_tracking'  => pum_get_option( 'disable_popup_open_tracking' ),
			'default_email_provider' => pum_get_option( 'newsletter_default_provider', 'none' ),

			// Aggregate Popup Settings.
			'triggers'               => $triggers,
			'cookies'                => $cookies,
			'conditions'             => $conditions,
			'locations'              => $location,
			'sizes'                  => $sizes,
			'sounds'                 => $sounds,
		);
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.11.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.