← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Logger.php
+18
-4
4.2.9
→
trunk
View file →
| @@ -101,19 +101,33 @@ | ||
| 101 | 101 | * |
| 102 | 102 | * @return bool Is logger active? |
| 103 | 103 | */ |
| 104 | 104 | private function is_logger_active() { |
| 105 | + return self::is_logging_active( $this->product ); | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * Check if the logging consent is granted for a product. | |
| 110 | + * | |
| 111 | + * Shared with the other telemetry modules (e.g. the crash reporter) so the | |
| 112 | + * consent semantics live in a single place. | |
| 113 | + * | |
| 114 | + * @param \ThemeisleSDK\Product $product Product to check. | |
| 115 | + * | |
| 116 | + * @return bool Is logging active for the product? | |
| 117 | + */ | |
| 118 | + public static function is_logging_active( $product ) { | |
| 105 | 119 | if ( apply_filters( 'themeisle_sdk_disable_telemetry', false ) ) { |
| 106 | 120 | return false; |
| 107 | 121 | } |
| 108 | 122 | $default = 'no'; |
| 109 | 123 | |
| 110 | - if ( ! $this->product->is_wordpress_available() ) { | |
| 124 | + if ( ! $product->is_wordpress_available() ) { | |
| 111 | 125 | $default = 'yes'; |
| 112 | 126 | } else { |
| 113 | 127 | $all_products = Loader::get_products(); |
| 114 | - foreach ( $all_products as $product ) { | |
| 115 | - if ( $product->requires_license() ) { | |
| 128 | + foreach ( $all_products as $registered_product ) { | |
| 129 | + if ( $registered_product->requires_license() ) { | |
| 116 | 130 | $default = 'yes'; |
| 117 | 131 | break; |
| 118 | 132 | } |
| 119 | 133 | } |
| @@ -119,9 +133,9 @@ | ||
| 119 | 133 | } |
| 120 | 134 | } |
| 121 | 135 | |
| 122 | 136 | |
| 123 | - return ( get_option( $this->product->get_key() . '_logger_flag', $default ) === 'yes' ); | |
| 137 | + return ( get_option( $product->get_key() . '_logger_flag', $default ) === 'yes' ); | |
| 124 | 138 | } |
| 125 | 139 | /** |
| 126 | 140 | * Add notification to queue. |
| 127 | 141 | * |