Admin
1 month ago
Builder
1 month ago
Integrations
1 month ago
SmashTwitter
1 month ago
UsageTracking
1 month ago
V2
1 month ago
blocks
1 month ago
CTF_Display_Elements.php
1 month ago
CTF_Feed.php
1 month ago
CTF_Feed_Locator.php
1 month ago
CTF_GDPR_Integrations.php
1 month ago
CTF_Parse.php
1 month ago
CTF_Settings.php
1 month ago
CtfAdmin.php
1 month ago
CtfCache.php
1 month ago
CtfFeed.php
1 month ago
CtfOauthConnect.php
1 month ago
SB_Twitter_Cron_Updater.php
1 month ago
admin-hooks.php
1 month ago
ctf-functions.php
1 month ago
notices.php
1 month ago
widget.php
1 month ago
CTF_GDPR_Integrations.php
144 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class CTF_GDPR_Integrations |
| 4 | * |
| 5 | * Adds GDPR related workarounds for third-party plugins: |
| 6 | * https://wordpress.org/plugins/cookie-law-info/ |
| 7 | * |
| 8 | * @since 1.7/1.12 |
| 9 | */ |
| 10 | namespace TwitterFeed; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | die( '-1' ); |
| 14 | } |
| 15 | |
| 16 | class CTF_GDPR_Integrations { |
| 17 | |
| 18 | /** |
| 19 | * Undoing of Cookie Notice's Twitter Feed related code |
| 20 | * needs to be done late. |
| 21 | * |
| 22 | * @since 1.7/1.12 |
| 23 | */ |
| 24 | public static function init() { |
| 25 | add_filter( 'wt_cli_third_party_scripts', array( 'TwitterFeed\CTF_GDPR_Integrations', 'undo_script_blocking' ), 11 ); |
| 26 | add_filter( 'cmplz_known_script_tags', array( 'TwitterFeed\CTF_GDPR_Integrations', 'undo_script_blocking' ), 11 ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Prevents changes made to how JavaScript file is added to |
| 31 | * pages. |
| 32 | * |
| 33 | * @param array $return |
| 34 | * |
| 35 | * @return array |
| 36 | * |
| 37 | * @since 1.7/1.12 |
| 38 | */ |
| 39 | public static function undo_script_blocking( $return ) { |
| 40 | $settings = ctf_get_database_settings(); |
| 41 | if ( ! self::doing_gdpr( $settings ) ) { |
| 42 | return $return; |
| 43 | } unset( $return['twitter-feed'] ); |
| 44 | |
| 45 | remove_filter( 'wt_cli_third_party_scripts', 'wt_cli_twitter_feed_script' ); |
| 46 | remove_filter( 'cmplz_known_script_tags', 'cmplz_twitter_feed_script' ); |
| 47 | |
| 48 | return $return; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Whether or not consent plugins that Twitter Feed |
| 53 | * is compatible with are active. |
| 54 | * |
| 55 | * @return bool|string |
| 56 | * |
| 57 | * @since 1.7/1.12 |
| 58 | */ |
| 59 | public static function gdpr_plugins_active() { |
| 60 | if ( function_exists( 'WPConsent' ) ) { |
| 61 | return 'WPConsent by the WPConsent team'; |
| 62 | } |
| 63 | if ( defined( 'RCB_ROOT_SLUG' ) ) { |
| 64 | return 'Real Cookie Banner by devowl.io'; |
| 65 | } |
| 66 | if ( function_exists( 'gdpr_cookie_is_accepted' ) ) { |
| 67 | return 'GDPR Cookie Compliance by Moove Agency'; |
| 68 | } |
| 69 | if ( class_exists( 'Cookie_Notice' ) ) { |
| 70 | return 'Cookie Notice by dFactory'; |
| 71 | } |
| 72 | if ( function_exists( 'run_cookie_law_info' ) ) { |
| 73 | return 'GDPR Cookie Consent by WebToffee'; |
| 74 | } |
| 75 | if ( class_exists( 'Cookiebot_WP' ) ) { |
| 76 | return 'Cookiebot by Cybot A/S'; |
| 77 | } |
| 78 | if ( class_exists( 'COMPLIANZ' ) ) { |
| 79 | return 'Complianz by Really Simple Plugins'; |
| 80 | } |
| 81 | if (function_exists('BorlabsCookieHelper') || ( defined('BORLABS_COOKIE_VERSION') && version_compare(BORLABS_COOKIE_VERSION, '3.0', '>=') )) { |
| 82 | return 'Borlabs Cookie by Borlabs'; |
| 83 | } |
| 84 | if ( is_admin() && ! empty( $_GET['page'] ) && $_GET['page'] === 'ctf-feed-builder' ) { |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * GDPR features can be added automatically, forced enabled, |
| 93 | * or forced disabled. |
| 94 | * |
| 95 | * @param $settings |
| 96 | * |
| 97 | * @return bool |
| 98 | * |
| 99 | * @since 1.7/1.12 |
| 100 | */ |
| 101 | public static function doing_gdpr( $settings ) { |
| 102 | $gdpr = isset( $settings['gdpr'] ) ? $settings['gdpr'] : 'auto'; |
| 103 | if ( $gdpr === 'no' ) { |
| 104 | return false; |
| 105 | } |
| 106 | if ( $gdpr === 'yes' ) { |
| 107 | return true; |
| 108 | } |
| 109 | return ( self::gdpr_plugins_active() !== false ); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * No tests needed in free version |
| 114 | * |
| 115 | * @param bool $retest |
| 116 | * |
| 117 | * @return bool |
| 118 | * |
| 119 | * @since 1.7/1.12 |
| 120 | */ |
| 121 | public static function gdpr_tests_successful( $retest = false ) { |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * No tests needed in free version |
| 127 | * |
| 128 | * @return array |
| 129 | * |
| 130 | * @since 1.7/1.12 |
| 131 | */ |
| 132 | public static function gdpr_tests_error_message() { |
| 133 | return array(); |
| 134 | } |
| 135 | |
| 136 | public static function statuses() { |
| 137 | $statuses_option = get_option( 'ctf_statuses', array() ); |
| 138 | |
| 139 | $return = isset( $statuses_option['gdpr'] ) ? $statuses_option['gdpr'] : array(); |
| 140 | return $return; |
| 141 | } |
| 142 | |
| 143 | } |
| 144 |