PluginProbe
Analytify – Google Analytics Dashboard For WordPress (GA4 analytics tracking) / trunk
Analytify – Google Analytics Dashboard For WordPress (GA4 analytics tracking) vtrunk
9.1.2 9.1.1 9.1.0 9.0.2 9.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 All 153 releases
wp-analytify / classes / analytify-utils.php

analytify-utils.php in Analytify – Google Analytics Dashboard For WordPress (GA4 analytics tracking) trunk, at classes/analytify-utils.php

97 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -- File naming is acceptable for this plugin structure
2 /**
3 * Analytify Utils Class
4 *
5 * This class provides utility functions for the Analytify plugin,
6 * including core utilities, UI helpers, GA functions, and notices.
7 *
8 * @package WP_Analytify
9 * @since 1.0.0
10 */
11
12 // Include split traits.
13 require_once __DIR__ . '/analytify-utils/analytify-utils-core.php';
14 require_once __DIR__ . '/analytify-utils/analytify-utils-ui.php';
15 require_once __DIR__ . '/analytify-utils/analytify-utils-ga.php';
16 require_once __DIR__ . '/analytify-utils/analytify-utils-notices.php';
17 require_once __DIR__ . '/class-analytify-admin-assets.php';
18
19 /**
20 * Analytify Utils Class
21 *
22 * @package WP_Analytify
23 * @since 1.0.0
24 */
25 class WPANALYTIFY_Utils {
26
27 use Analytify_Utils_Core;
28 use Analytify_Utils_UI;
29 use Analytify_Utils_GA;
30 use Analytify_Utils_Notices;
31
32 /**
33 * Check if tracking script is allowed on current page.
34 *
35 * @return boolean
36 */
37 public static function skip_page_tracking() {
38
39 if ( ! is_singular() ) {
40 return false;
41 }
42
43 global $post;
44
45 if ( ! is_object( $post ) ) {
46 return false;
47 }
48
49 return (bool) get_post_meta( isset( $post->ID ) ? $post->ID : 0, '_analytify_skip_tracking', true );
50 }
51
52 /**
53 * Check if pro version is active.
54 *
55 * @return bool
56 */
57 public static function is_active_pro() {
58
59 return ( is_plugin_active( 'wp-analytify-pro/wp-analytify-pro.php' ) ) ? true : false;
60 }
61
62 /**
63 * Returns all the modules available in pro.
64 *
65 * @return array<string, mixed> Pro modules.
66 * @since 5.1.1
67 */
68 public static function get_pro_modules() {
69 return get_option( 'wp_analytify_modules' ); }
70
71 /**
72 * Check if a module is active via options.
73 *
74 * @param string $slug Slug of the module.
75 * @return boolean
76 */
77 public static function is_module_active( $slug ) {
78
79 $wp_analytify_modules = get_option( 'wp_analytify_modules' );
80
81 return ( $wp_analytify_modules && isset( $wp_analytify_modules[ $slug ] ) && isset( $wp_analytify_modules[ $slug ]['status'] ) && 'active' === $wp_analytify_modules[ $slug ]['status'] ) ? true : false;
82 }
83
84 /**
85 * Get the last element of array.
86 *
87 * @param array<string, mixed> $array The array to get the last element from.
88 * @return mixed
89 * @since 2.1.12
90 */
91 public static function end( $array ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound -- Array parameter name is acceptable for this context
92 return end( $array );
93 }
94 }
95
96 // Admin assets deconfliction moved to a dedicated small file to keep this class lean.
97