diff --git a/admin/class-gdpr-admin.php b/admin/class-gdpr-admin.php index 2679fac8..d25b162d 100755 --- a/admin/class-gdpr-admin.php +++ b/admin/class-gdpr-admin.php @@ -135,19 +135,9 @@ public function add_menu() { $settings_hook = add_submenu_page( $parent_slug, $menu_title, $menu_title, $capability, $menu_slug, $function ); - $menu_slug = 'edit.php?post_type=telemetry'; - - $cpt = 'telemetry'; - $cpt_obj = get_post_type_object( $cpt ); - - if ( $cpt_obj ) { - add_submenu_page( $parent_slug, $cpt_obj->labels->name, $cpt_obj->labels->menu_name, $capability, $menu_slug ); - } - add_action( "load-{$requests_hook}", array( 'GDPR_Help', 'add_requests_help' ) ); add_action( "load-{$tools_hook}", array( 'GDPR_Help', 'add_tools_help' ) ); add_action( "load-{$settings_hook}", array( 'GDPR_Help', 'add_settings_help' ) ); - add_action( 'load-edit.php', array( 'GDPR_Help', 'add_telemetry_help' ) ); } /** @@ -201,7 +191,6 @@ public function register_settings() { 'gdpr_consent_types' => array( $this, 'sanitize_consents' ), 'gdpr_deletion_needs_review' => 'boolval', 'gdpr_disable_css' => 'boolval', - 'gdpr_enable_telemetry_tracker' => 'boolval', 'gdpr_use_recaptcha' => 'boolval', 'gdpr_recaptcha_site_key' => 'sanitize_text_field', 'gdpr_recaptcha_secret_key' => 'sanitize_text_field', @@ -325,6 +314,8 @@ public function tools_page_template() { 'audit-log' => esc_html__( 'Audit Log', 'gdpr' ), ); + $tabs = apply_filters( 'gdpr_tools_tabs', $tabs ); + include plugin_dir_path( __FILE__ ) . 'partials/tools.php'; } @@ -710,25 +701,6 @@ public function clean_data_breach_request() { delete_option( 'gdpr_data_breach_initiated' ); } - /** - * CRON job runs this to clean up the telemetry post type every 12 hours. - * @since 1.0.0 - * @author Fernando Claussen - */ - public function telemetry_cleanup() { - $args = array( - 'post_type' => 'telemetry', - 'posts_per_page' => -1, - 'fields' => 'ids', - ); - - $telemetry_posts = get_posts( $args ); - - foreach ( $telemetry_posts as $post ) { - wp_delete_post( $post, true ); - } - } - /** * Sanitizes the consents during WordPress registration. * @since 1.0.0 @@ -987,4 +959,22 @@ public function add_consents_column_to_user_table( $column_headers ) { return $column_headers; } + public function sort_consents_column_from_user_table( $columns ) { + $columns['consents'] = 'consent'; + return $columns; + } + + public function sort_logic_for_consents_from_user_table( $query ) { + if ( ! is_admin() ) { + return; + } + + $orderby = $query->get( 'orderby' ); + + if ( 'consent' === $orderby ) { + $query->set( 'meta_key', 'gdpr_consents' ); + $query->set( 'orderby', 'meta_value' ); + } + } + } diff --git a/admin/class-gdpr-telemetry.php b/admin/class-gdpr-telemetry.php deleted file mode 100644 index 10101e58..00000000 --- a/admin/class-gdpr-telemetry.php +++ /dev/null @@ -1,522 +0,0 @@ - - */ - -/** - * The telemetry post type registration file. - * - * Defines the custom post type and edit the look and feel of the page. - * - * @package GDPR - * @subpackage admin - * @author Fernando Claussen - */ -class GDPR_Telemetry { - - /** - * Registers the telemetry post type. - * @since 1.0.0 - * @author Fernando Claussen - */ - public function register_post_type() { - $telemetry_enabled = get_option( 'gdpr_enable_telemetry_tracker', false ); - if ( ! $telemetry_enabled ) { - wp_clear_scheduled_hook( 'telemetry_cleanup' ); - return; - } - - if ( ! wp_next_scheduled( 'telemetry_cleanup' ) ) { - wp_schedule_event( - time(), - 'hourly', - 'telemetry_cleanup' - ); - } - - register_post_type( - 'telemetry', - array( - 'label' => esc_html__( 'Telemetry', 'gdpr' ), - 'labels' => array( - 'not_found' => esc_html__( 'No items found. Future connections will be shown at this place.', 'gdpr' ), - 'not_found_in_trash' => esc_html__( 'No items found in trash.', 'gdpr' ), - 'search_items' => esc_html__( 'Search in destination', 'gdpr' ), - ), - 'public' => false, - 'show_ui' => true, - 'show_in_menu' => false, - 'show_in_nav_menus' => false, - 'query_var' => true, // try setting to false - 'hierarchical' => false, - 'capability_type' => 'post', - 'publicly_queryable' => false, - 'exclude_from_search' => true, - ) - ); - } - - /** - * Log the call request. - * @param object $response The call response. - * @param [type] $type Context under which the hook is fired. - * @param [type] $class HTTP transport used. - * @param [type] $args HTTP request arguments. - * @param [type] $url The request URL. - * @since 1.0.0 - */ - public function log_request( $response, $type, $class, $args, $url ) { - $telemetry_enabled = get_option( 'gdpr_enable_telemetry_tracker', false ); - if ( ! $telemetry_enabled ) { - return; - } - /* Only response type */ - if ( 'response' !== $type ) { - return false; - } - - /* Empty url */ - if ( empty( $url ) ) { - return false; - } - - /* Validate host */ - $host = parse_url( $url, PHP_URL_HOST ); - - if ( ! $host ) { - return false; - } - - /* Backtrace data */ - $backtrace = self::_debug_backtrace(); - - /* No reference file found */ - if ( empty( $backtrace['file'] ) ) { - return false; - } - - /* Show your face, file */ - $meta = self::_face_detect( $backtrace['file'] ); - - /* Extract backtrace data */ - $file = str_replace( ABSPATH, '', $backtrace['file'] ); - $line = (int) $backtrace['line']; - - /* Response code */ - $code = ( is_wp_error( $response ) ? -1 : wp_remote_retrieve_response_code( $response ) ); - - $postdata = self::_get_postdata( $args ); - - if ( ! $postdata ) { - return false; - } - - /* Insert CPT */ - $this->insert_post( - array( - 'url' => esc_url_raw( $url ), - 'code' => $code, - 'host' => $host, - 'file' => $file, - 'line' => $line, - 'meta' => $meta, - 'postdata' => $postdata, - ) - ); - } - - /** - * Insert the telemetry post. - * @since 1.0.0 - * @access private - * @param array $meta Meta values. - * @return int The post ID. - */ - private function insert_post( $meta ) { - /* Empty? */ - if ( empty( $meta ) ) { - return; - } - - /* Create post */ - $post_id = wp_insert_post( - array( - 'post_status' => 'publish', - 'post_type' => 'telemetry', - ) - ); - - /* Add meta values */ - foreach ( (array) $meta as $key => $value ) { - add_post_meta( $post_id, '_gdpr_telemetry_' . $key, $value, true ); - } - - return $post_id; - } - - /** - * Add a Delete All button on top of the table. - * @param string $post_type The post type. - * @static - * @since 1.0.0 - */ - public static function actions_above_table( $post_type ) { - if ( 'telemetry' !== $post_type ) { - return; - } - - $url = wp_nonce_url( - add_query_arg( - array( - 'action' => 'delete_all', - 'post_type' => 'telemetry', - 'post_status' => 'publish', - ), - admin_url( 'edit.php' ) - ), - 'bulk-posts' - ); - ?> - - esc_html__( 'Destination', 'gdpr' ), - 'file' => esc_html__( 'File', 'gdpr' ), - 'code' => esc_html__( 'Code', 'gdpr' ), - 'created' => esc_html__( 'Time', 'gdpr' ), - 'postdata' => esc_html__( 'Data', 'gdpr' ), - ); - } - - /** - * Custom columns hook. - * @since 1.0.0 - * @static - * @param string $column The column ID. - * @param int $post_id The post ID. - */ - public static function custom_column( $column, $post_id ) { - /* Column types */ - $types = array( - 'url' => array( __CLASS__, '_html_url' ), - 'file' => array( __CLASS__, '_html_file' ), - 'code' => array( __CLASS__, '_html_code' ), - 'created' => array( __CLASS__, '_html_created' ), - 'postdata' => array( __CLASS__, '_html_postdata' ), - ); - - /* If type exists */ - if ( ! empty( $types[ $column ] ) ) { - /* Callback */ - $callback = $types[ $column ]; - - /* Execute */ - if ( is_callable( $callback ) ) { - call_user_func( $callback, $post_id ); - } - } - } - - /** - * The URL column callback. - * @since 1.0.0 - * @static - * @access private - * @param int $post_id The post ID. - */ - private static function _html_url( $post_id ) { - /* Init data */ - $url = self::_get_post_meta( $post_id, 'url' ); - $host = self::_get_post_meta( $post_id, 'host' ); - - /* Print output */ - echo sprintf( - '
%s
', - str_replace( $host, '' . $host . '', esc_url( $url ) ) - ); // WPCS: XSS ok. - } - - /** - * The file column callback. - * @since 1.0.0 - * @access private - * @static - * @param int $post_id The post ID. - */ - private static function _html_file( $post_id ) { - $file = self::_get_post_meta( $post_id, 'file' ); - $line = self::_get_post_meta( $post_id, 'line' ); - $meta = self::_get_post_meta( $post_id, 'meta' ); - - /* Print output */ - echo sprintf( - '
%s: %s
/%s:%d
', - esc_html( $meta['type'] ), - esc_html( $meta['name'] ), - esc_html( $file ), - esc_html( $line ) - ); - } - - /** - * The response code column callback. - * @since 1.0.0 - * @access private - * @static - * @param int $post_id The post ID. - */ - private static function _html_code( $post_id ) { - echo esc_html( self::_get_post_meta( $post_id, 'code' ) ); - } - - /** - * The created column callback. - * @since 1.0.0 - * @access private - * @static - * @param int $post_id The post ID. - */ - private static function _html_created( $post_id ) { - /* translators: Amount of time */ - echo sprintf( - esc_html__( '%s ago' ), - esc_html( human_time_diff( get_post_time( 'G', true, $post_id ) ) ) - ); - } - - /** - * The post data column callback. - * @since 1.0.0 - * @access private - * @static - * @param int $post_id The post ID. - */ - private static function _html_postdata( $post_id ) { - /* Item post data */ - $postdata = self::_get_post_meta( $post_id, 'postdata' ); - - /* Empty data? */ - if ( empty( $postdata ) ) { - return; - } - - /* Parse POST data */ - if ( ! is_array( $postdata ) ) { - wp_parse_str( $postdata, $postdata ); - } - - /* Empty array? */ - if ( empty( $postdata ) ) { - return; - } - - /* Thickbox content start */ - echo sprintf( - '
',
-			absint( $post_id )
-		);
-
-		/* POST data */
-		print_r( $postdata );
-
-		/* Thickbox content end */
-		echo '
'; - - /* Thickbox button */ - echo sprintf( - '%s', - absint( $post_id ), - esc_html__( 'Show', 'gdpr' ) - ); - } - - /** - * Get the post meta we care about. - * @since 1.0.0 - * @access private - * @static - * @param int $post_id The post ID. - * @param string $key The key that matters to us. - * @return mixed The post meta. - */ - private static function _get_post_meta( $post_id, $key ) { - $value = get_post_meta( $post_id, '_gdpr_telemetry_' . $key, true ); - if ( $value ) { - return $value; - } - - return get_post_meta( $post_id, $key, true ); - } - - /** - * The debug backtrace of the call. This gives us the file and line of origin of the call. - * @since 1.0.0 - * @access private - * @static - * @return array Extra information about the call like File and Line. - */ - private static function _debug_backtrace() { - /* Reverse items */ - $trace = array_reverse( debug_backtrace() ); - - /* Loop items */ - foreach ( $trace as $index => $item ) { - if ( ! empty( $item['function'] ) && strpos( $item['function'], 'wp_remote_' ) !== false ) { - /* Use prev item */ - if ( empty( $item['file'] ) ) { - $item = $trace[ -- $index ]; - } - - /* Get file and line */ - if ( ! empty( $item['file'] ) && ! empty( $item['line'] ) ) { - return $item; - } - } - } - } - - /** - * Is the call coming from a theme or plugin? - * @since 1.0.0 - * @access private - * @static - * @param string $path Path to the file. - * @return array The name of the plugin or theme that made the call. - */ - private static function _face_detect( $path ) { - /* Default */ - $meta = array( - 'type' => 'WordPress', - 'name' => 'Core', - ); - - /* Empty path */ - if ( empty( $path ) ) { - return $meta; - } - - /* Search for plugin */ - if ( self::_localize_plugin( $path ) ) { - $data = self::_localize_plugin( $path ); - return array( - 'type' => 'Plugin', - 'name' => $data['Name'], - ); - - /* Search for theme */ - } elseif ( self::_localize_theme( $path ) ) { - $data = self::_localize_theme( $path ); - return array( - 'type' => 'Theme', - 'name' => $data->get( 'Name' ), - ); - } - - return $meta; - } - - /** - * Figures out if the file that made the call belongs to a plugin. - * @since 1.0.0 - * @access private - * @static - * @param string $path The path to the file that made the call. - * @return string The plugin name. - */ - private static function _localize_plugin( $path ) { - /* Check path */ - if ( false === strpos( $path, WP_PLUGIN_DIR ) ) { - return false; - } - - /* Reduce path */ - $path = ltrim( str_replace( WP_PLUGIN_DIR, '', $path ), DIRECTORY_SEPARATOR ); - - /* Get plugin folder */ - $folder = substr( $path, 0, strpos( $path, DIRECTORY_SEPARATOR ) ) . DIRECTORY_SEPARATOR; - - /* Frontend */ - if ( ! function_exists( 'get_plugins' ) ) { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); - } - - /* All active plugins */ - $plugins = get_plugins(); - - /* Loop plugins */ - foreach ( $plugins as $path => $plugin ) { - if ( 0 === strpos( $path, $folder ) ) { - return $plugin; - } - } - } - - /** - * Figures out if the file that made the call belongs to a theme. - * @since 1.0.0 - * @access private - * @static - * @param string $path The path to the file that made the call. - * @return string The theme name. - */ - private static function _localize_theme( $path ) { - /* Check path */ - if ( false === strpos( $path, get_theme_root() ) ) { - return false; - } - - /* Reduce path */ - $path = ltrim( str_replace( get_theme_root(), '', $path ), DIRECTORY_SEPARATOR ); - - /* Get theme folder */ - $folder = substr( $path, 0, strpos( $path, DIRECTORY_SEPARATOR ) ); - - /* Get theme */ - $theme = wp_get_theme( $folder ); - - /* Check & return theme */ - if ( $theme->exists() ) { - return $theme; - } - - return false; - } - - /** - * The data that was transmitted. - * @since 1.0.0 - * @access private - * @static - * @param array $args The http call arguments. - * @return mixed The request body. - */ - private static function _get_postdata( $args ) { - /* No POST data? */ - if ( empty( $args['method'] ) or 'POST' !== $args['method'] ) { - return null; - } - - /* No body data? */ - if ( empty( $args['body'] ) ) { - return null; - } - - return $args['body']; - } -} diff --git a/admin/partials/settings.php b/admin/partials/settings.php index a49cc234..92766e58 100755 --- a/admin/partials/settings.php +++ b/admin/partials/settings.php @@ -13,7 +13,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -59,20 +59,19 @@ - + - - > + - + @@ -85,7 +84,7 @@ - + @@ -127,7 +126,7 @@ - + @@ -140,7 +139,7 @@ - + @@ -237,7 +236,7 @@ @@ -251,7 +250,7 @@ @@ -271,7 +270,7 @@ @@ -287,7 +286,7 @@ @@ -299,7 +298,7 @@ @@ -324,7 +323,7 @@ @@ -338,7 +337,7 @@ @@ -377,7 +376,7 @@ @@ -396,7 +395,7 @@ @@ -408,7 +407,7 @@ diff --git a/admin/partials/templates/tmpl-consents.php b/admin/partials/templates/tmpl-consents.php index 79c0af2f..5e5b59b6 100644 --- a/admin/partials/templates/tmpl-consents.php +++ b/admin/partials/templates/tmpl-consents.php @@ -9,7 +9,7 @@ @@ -28,7 +28,7 @@ @@ -40,7 +40,7 @@ diff --git a/admin/partials/templates/tmpl-cookies.php b/admin/partials/templates/tmpl-cookies.php index 790d45fa..2d4f02dd 100644 --- a/admin/partials/templates/tmpl-cookies.php +++ b/admin/partials/templates/tmpl-cookies.php @@ -8,7 +8,7 @@ @@ -22,7 +22,7 @@ @@ -42,7 +42,7 @@ @@ -58,7 +58,7 @@ @@ -70,7 +70,7 @@ diff --git a/assets/js/gdpr-admin.js b/assets/js/gdpr-admin.js index 1b2f3521..2fba7c98 100644 --- a/assets/js/gdpr-admin.js +++ b/assets/js/gdpr-admin.js @@ -1 +1 @@ -!function(t){"use strict";t(function(){function a(t){t=(t=t.replace(/^\s+|\s+$/g,"")).toLowerCase();for(var a="àáäâèéëêìíïîòóöôùúüûñç·/_,:;",e=0,n=a.length;e",{href:"data:text/plain;charset=utf-8,"+encodeURIComponent(a.data),download:s+"."+d,text:"click"}).hide().appendTo("body")[0].click()})}),t(document).on("submit",".frm-policy-updated",function(a){a.preventDefault();var e=t(this).find('input[name="action"]').val(),n=t(this).find('input[name="policy_id"]').val(),i=t(this).find('input[name="policy_name"]').val(),s=t(this).find('[id$="nonce"]').val(),d=t(this).parent().find(".spinner"),o=t(this);d.addClass("is-active"),t.post(ajaxurl,{action:e,nonce:s,policy_id:n,policy_name:i},function(t){d.removeClass("is-active"),o.parent().fadeOut()})})})}(jQuery); \ No newline at end of file +!function(t){"use strict";t(function(){function e(t){t=(t=t.replace(/^\s+|\s+$/g,"")).toLowerCase();for(var e="àáäâèéëêìíïîòóöôùúüûñç·/_,:;",a=0,n=e.length;a",{href:"data:text/plain;charset=utf-8,"+encodeURIComponent(e.data),download:s+"."+d,text:"click"}).hide().appendTo("body")[0].click()})}),t(document).on("submit",".frm-policy-updated",function(e){e.preventDefault();var a=t(this).find('input[name="action"]').val(),n=t(this).find('input[name="policy_id"]').val(),i=t(this).find('input[name="policy_name"]').val(),s=t(this).find('[id$="nonce"]').val(),d=t(this).parent().find(".spinner"),o=t(this);d.addClass("is-active"),t.post(ajaxurl,{action:a,nonce:s,policy_id:n,policy_name:i},function(t){d.removeClass("is-active"),o.parent().fadeOut()})})})}(jQuery); \ No newline at end of file diff --git a/assets/js/gdpr-public.js b/assets/js/gdpr-public.js index a45c7f5c..0b108a3d 100644 --- a/assets/js/gdpr-public.js +++ b/assets/js/gdpr-public.js @@ -1 +1 @@ -!function(e){"use strict";var r=location.search,o=location.protocol+"//"+location.host+location.pathname;function n(r,o,n,t){t=void 0!==t,n=void 0!==n?n:[{title:GDPR.i18n.ok,buttonClass:"gdpr-ok",callback:"closeNotification"}];var d=e(window).scrollTop();e(".gdpr-general-confirmation .gdpr-box-title h3").html(r),e(".gdpr-general-confirmation .gdpr-content p").html(o),e(".gdpr-general-confirmation .gdpr-close").show(),t&&e(".gdpr-general-confirmation .gdpr-close").hide();var a="";n.forEach(function(e){a+='"}),e(".gdpr-general-confirmation footer").html(a),e(".gdpr-overlay").fadeIn(400,function(){e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").css({display:"flex"}).hide().fadeIn(),e("body").addClass("gdpr-noscroll").css("top",-d)})}window.has_consent=function(e){if(Cookies.get("gdpr[consent_types]")&&JSON.parse(Cookies.get("gdpr[consent_types]")).indexOf(e)>-1)return!0;return!1},window.is_allowed_cookie=function(e){if(Cookies.get("gdpr[allowed_cookies]")&&JSON.parse(Cookies.get("gdpr[allowed_cookies]")).indexOf(e)>-1)return!0;return!1},e(function(){var t={closeNotification:function(){var r=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(r,10))),e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").fadeOut()},addToDeletionConfirmed:function(){e("form.gdpr-add-to-deletion-requests").addClass("confirmed"),e('form.gdpr-add-to-deletion-requests.confirmed input[type="submit"]').click(),t.closeNotification()},policyDisagreeOk:function(){e(".gdpr.gdpr-general-confirmation .gdpr-wrapper header .gdpr-box-title h3").html(GDPR.i18n.aborting),e(".gdpr.gdpr-general-confirmation .gdpr-wrapper .gdpr-content p").html(GDPR.i18n.logging_out),e(".gdpr.gdpr-general-confirmation .gdpr-wrapper footer button").hide(),window.location.href=GDPR.logouturl},policyDisagreeCancel:function(){e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").fadeOut(),e(".gdpr.gdpr-reconsent .gdpr-wrapper").fadeIn()}};if(-1!==r.indexOf("notify=1")&&(window.history.replaceState({},document.title,o),e("body").addClass("gdpr-notification")),e(document).on("click",".gdpr.gdpr-general-confirmation button",function(r){var o=e(this).data("callback");t[o]()}),e(document).on("submit",".gdpr-privacy-preferences-frm",function(r){r.preventDefault();e(this);var o=e(this).serialize();e.post(GDPR.ajaxurl,o,function(r){if(r.success)if(Cookies.set("gdpr[privacy_bar]",1,{expires:365}),GDPR.refresh)window.location.reload();else{var o=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(o,10))),e(".gdpr.gdpr-privacy-preferences .gdpr-wrapper").fadeOut(),e(".gdpr-privacy-bar").fadeOut()}else n(r.data.title,r.data.content)})}),e(document).on("submit",".gdpr-request-form",function(r){if(r.preventDefault(),e(this).hasClass("confirmed")){var o=e(this).serialize();e.post(GDPR.ajaxurl,o,function(e){n(e.data.title,e.data.content)})}}),e(document).on("change",".gdpr-cookie-category",function(){var r=e(this).data("category"),o=e(this).prop("checked");e('[data-category="'+r+'"]').prop("checked",o)}),Cookies.get("gdpr[privacy_bar]")||0==e(".gdpr-reconsent-bar, .gdpr-reconsent").length&&e(".gdpr.gdpr-privacy-bar").delay(1e3).slideDown(600),e(".gdpr-reconsent-bar").length>0&&e(".gdpr.gdpr-reconsent-bar").delay(1e3).slideDown(600),e(".gdpr-reconsent").length>0&&e(".gdpr-overlay").fadeIn(400,function(){e(".gdpr.gdpr-reconsent .gdpr-wrapper").fadeIn(),e("body").addClass("gdpr-noscroll").delay(1e3)}),e(document).on("click",".gdpr.gdpr-privacy-bar .gdpr-agreement",function(){e(".gdpr-privacy-preferences-frm").submit()}),e(document).on("click",".gdpr.gdpr-reconsent-bar .gdpr-agreement",function(){var r=[];e('.gdpr-policy-list input[type="hidden"]').each(function(){r.push(e(this).val())}),e.post(GDPR.ajaxurl,{action:"agree_with_new_policies",nonce:e(this).data("nonce"),consents:r},function(r){r.success?GDPR.refresh?window.location.reload():(e(".gdpr-reconsent-bar").slideUp(600),Cookies.get("gdpr[privacy_bar]")||e(".gdpr.gdpr-privacy-bar").delay(1e3).slideDown(600)):n(r.data.title,r.data.content)})}),e(document).on("submit",".gdpr-reconsent-frm",function(r){r.preventDefault();var o=[],t=e(this).find("#agree-with-new-policies-nonce").val();e(this).find('[name="gdpr-updated-policy"]').each(function(){o.push(e(this).val())}),e.post(GDPR.ajaxurl,{action:"agree_with_new_policies",nonce:t,consents:o},function(r){if(r.success)if(GDPR.refresh)window.location.reload();else{var o=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(o,10))),e(".gdpr.gdpr-reconsent .gdpr-wrapper").fadeOut(),Cookies.get("gdpr[privacy_bar]")||e(".gdpr.gdpr-privacy-bar").delay(1e3).slideDown(600)}else n(r.data.title,r.data.content)})}),e(document).on("click",".gdpr.gdpr-privacy-bar .gdpr-close, .gdpr.gdpr-reconsent-bar .gdpr-close",function(){var r=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(r,10))),e(".gdpr.gdpr-privacy-bar, .gdpr.gdpr-reconsent-bar").slideUp(600)}),e(document).on("click",".gdpr.gdpr-general-confirmation .gdpr-close",function(){var r=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(r,10))),e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").fadeOut()}),e(document).on("click",".gdpr-preferences",function(r){r.preventDefault();var o=e(window).scrollTop(),n=e(this).data("tab");e(".gdpr-overlay").fadeIn(),e("body").addClass("gdpr-noscroll").css("top",-o),e(".gdpr.gdpr-privacy-preferences .gdpr-wrapper").fadeIn(),n&&e('.gdpr.gdpr-privacy-preferences .gdpr-wrapper .gdpr-tabs [data-target="'+n+'"]').click()}),e(document).on("click",".gdpr.gdpr-privacy-preferences .gdpr-close",function(r){r.preventDefault();var o=e("body").css("top");e(".gdpr-reconsent .gdpr-wrapper").is(":visible")||(e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(o,10)))),e(".gdpr.gdpr-privacy-preferences .gdpr-wrapper").fadeOut()}),e(document).on("click",".gdpr.gdpr-privacy-preferences .gdpr-tabs button, .gdpr.gdpr-reconsent .gdpr-tabs button",function(){var r="."+e(this).data("target");e(".gdpr.gdpr-privacy-preferences .gdpr-tab-content > div, .gdpr.gdpr-reconsent .gdpr-tab-content > div").removeClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tab-content "+r+", .gdpr.gdpr-reconsent .gdpr-tab-content "+r).addClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").hasClass("gdpr-mobile-expanded")&&(e(".gdpr.gdpr-privacy-preferences .gdpr-mobile-menu button, .gdpr.gdpr-reconsent .gdpr-mobile-menu button").removeClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").toggle()),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs button, .gdpr.gdpr-reconsent .gdpr-tabs button").removeClass("gdpr-active"),e(".gdpr-subtabs li button").removeClass("gdpr-active"),e(this).hasClass("gdpr-tab-button")?(e(this).addClass("gdpr-active"),e(this).hasClass("gdpr-cookie-settings")&&e(".gdpr-subtabs").find("li button").first().addClass("gdpr-active")):(e(".gdpr-cookie-settings").addClass("gdpr-active"),e(this).addClass("gdpr-active"))}),e(document).on("click",".gdpr.gdpr-privacy-preferences .gdpr-mobile-menu button, .gdpr.gdpr-reconsent .gdpr-mobile-menu button",function(r){e(this).toggleClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").toggle().addClass("gdpr-mobile-expanded")}),e(window).resize(function(){e(window).width()>640&&e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").hasClass("gdpr-mobile-expanded")&&(e(".gdpr.gdpr-privacy-preferences .gdpr-mobile-menu button, .gdpr.gdpr-reconsent .gdpr-mobile-menu button").removeClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").removeClass("gdpr-mobile-expanded").removeAttr("style"))}),e("form.gdpr-add-to-deletion-requests").on("submit",function(r){if(!e(this).hasClass("confirmed")){r.preventDefault();var o=[{title:GDPR.i18n.ok,buttonClass:"gdpr-ok",callback:"addToDeletionConfirmed"},{title:GDPR.i18n.cancel,buttonClass:"gdpr-cancel",callback:"closeNotification"}];n(GDPR.i18n.close_account,GDPR.i18n.close_account_warning,o)}}),e("body").hasClass("gdpr-notification")){var d=e(window).scrollTop();e(".gdpr-overlay").fadeIn(400,function(){e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").css({display:"flex"}).hide().fadeIn(),e("body").addClass("gdpr-noscroll").css("top",-d)})}e(document).on("click",".gdpr-disagree a",function(r){e(".gdpr.gdpr-reconsent .gdpr-wrapper").fadeOut();var o=[{title:GDPR.i18n.ok,buttonClass:"gdpr-ok",callback:"policyDisagreeOk"},{title:GDPR.i18n.cancel,buttonClass:"gdpr-cancel",callback:"policyDisagreeCancel"}];n(GDPR.i18n.are_you_sure,GDPR.i18n.policy_disagree,o,!0)})})}(jQuery),function(e){var r=!1;if("function"==typeof define&&define.amd&&(define(e),r=!0),"object"==typeof exports&&(module.exports=e(),r=!0),!r){var o=window.Cookies,n=window.Cookies=e();n.noConflict=function(){return window.Cookies=o,n}}}(function(){function e(){for(var e=0,r={};e1){if("number"==typeof(d=e({path:"/"},n.defaults,d)).expires){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*d.expires),d.expires=p}d.expires=d.expires?d.expires.toUTCString():"";try{a=JSON.stringify(t),/^[\{\[]/.test(a)&&(t=a)}catch(e){}t=o.write?o.write(t,r):encodeURIComponent(String(t)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),r=(r=(r=encodeURIComponent(String(r))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);var i="";for(var c in d)d[c]&&(i+="; "+c,!0!==d[c]&&(i+="="+d[c]));return document.cookie=r+"="+t+i}r||(a={});for(var s=document.cookie?document.cookie.split("; "):[],g=/(%[0-9A-Z]{2})+/g,l=0;l'+e.title+""}),e(".gdpr-general-confirmation footer").html(a),e(".gdpr-overlay").fadeIn(400,function(){e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").css({display:"flex"}).hide().fadeIn(),e("body").addClass("gdpr-noscroll").css("top",-d)})}window.has_consent=function(e){e=e.substring(0,e.indexOf('{'));if(Cookies.get("gdpr[consent_types]")&&JSON.parse(Cookies.get("gdpr[consent_types]")).indexOf(e)>-1)return!0;return!1},window.is_allowed_cookie=function(e){if(Cookies.get("gdpr[allowed_cookies]")&&JSON.parse(Cookies.get("gdpr[allowed_cookies]")).indexOf(e)>-1)return!0;return!1},e(function(){var t={closeNotification:function(){var r=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(r,10))),e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").fadeOut()},addToDeletionConfirmed:function(){e("form.gdpr-add-to-deletion-requests").addClass("confirmed"),e('form.gdpr-add-to-deletion-requests.confirmed input[type="submit"]').click(),t.closeNotification()},policyDisagreeOk:function(){e(".gdpr.gdpr-general-confirmation .gdpr-wrapper header .gdpr-box-title h3").html(GDPR.i18n.aborting),e(".gdpr.gdpr-general-confirmation .gdpr-wrapper .gdpr-content p").html(GDPR.i18n.logging_out),e(".gdpr.gdpr-general-confirmation .gdpr-wrapper footer button").hide(),window.location.href=GDPR.logouturl},policyDisagreeCancel:function(){e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").fadeOut(),e(".gdpr.gdpr-reconsent .gdpr-wrapper").fadeIn()}};if(-1!==r.indexOf("notify=1")&&(window.history.replaceState({},document.title,o),e("body").addClass("gdpr-notification")),e(document).on("click",".gdpr.gdpr-general-confirmation button",function(r){var o=e(this).data("callback");t[o]()}),e(document).on("submit",".gdpr-privacy-preferences-frm",function(r){r.preventDefault();e(this);var o=e(this).serialize();e.post(GDPR.ajaxurl,o,function(r){if(r.success)if(Cookies.set("gdpr[privacy_bar]",1,{expires:365}),GDPR.refresh)window.location.reload();else{var o=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(o,10))),e(".gdpr.gdpr-privacy-preferences .gdpr-wrapper").fadeOut(),e(".gdpr-privacy-bar").fadeOut()}else n(r.data.title,r.data.content)})}),e(document).on("submit",".gdpr-request-form",function(r){if(r.preventDefault(),e(this).hasClass("confirmed")){var o=e(this).serialize();e.post(GDPR.ajaxurl,o,function(e){n(e.data.title,e.data.content)})}}),e(document).on("change",".gdpr-cookie-category",function(){var r=e(this).data("category"),o=e(this).prop("checked");e('[data-category="'+r+'"]').prop("checked",o)}),Cookies.get("gdpr[privacy_bar]")||0==e(".gdpr-reconsent-bar, .gdpr-reconsent").length&&e(".gdpr.gdpr-privacy-bar").delay(1e3).slideDown(600),e(".gdpr-reconsent-bar").length>0&&e(".gdpr.gdpr-reconsent-bar").delay(1e3).slideDown(600),e(".gdpr-reconsent").length>0&&e(".gdpr-overlay").fadeIn(400,function(){e(".gdpr.gdpr-reconsent .gdpr-wrapper").fadeIn(),e("body").addClass("gdpr-noscroll").delay(1e3)}),e(document).on("click",".gdpr.gdpr-privacy-bar .gdpr-agreement",function(){e(".gdpr-privacy-preferences-frm").submit()}),e(document).on("click",".gdpr.gdpr-reconsent-bar .gdpr-agreement",function(){var r=[];e('.gdpr-policy-list input[type="hidden"]').each(function(){r.push(e(this).val())}),e.post(GDPR.ajaxurl,{action:"agree_with_new_policies",nonce:e(this).data("nonce"),consents:r},function(r){r.success?GDPR.refresh?window.location.reload():(e(".gdpr-reconsent-bar").slideUp(600),Cookies.get("gdpr[privacy_bar]")||e(".gdpr.gdpr-privacy-bar").delay(1e3).slideDown(600)):n(r.data.title,r.data.content)})}),e(document).on("submit",".gdpr-reconsent-frm",function(r){r.preventDefault();var o=[],t=e(this).find("#agree-with-new-policies-nonce").val();e(this).find('[name="gdpr-updated-policy"]').each(function(){o.push(e(this).val())}),e.post(GDPR.ajaxurl,{action:"agree_with_new_policies",nonce:t,consents:o},function(r){if(r.success)if(GDPR.refresh)window.location.reload();else{var o=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(o,10))),e(".gdpr.gdpr-reconsent .gdpr-wrapper").fadeOut(),Cookies.get("gdpr[privacy_bar]")||e(".gdpr.gdpr-privacy-bar").delay(1e3).slideDown(600)}else n(r.data.title,r.data.content)})}),e(document).on("click",".gdpr.gdpr-privacy-bar .gdpr-close, .gdpr.gdpr-reconsent-bar .gdpr-close",function(){var r=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(r,10))),e(".gdpr.gdpr-privacy-bar, .gdpr.gdpr-reconsent-bar").slideUp(600)}),e(document).on("click",".gdpr.gdpr-general-confirmation .gdpr-close",function(){var r=e("body").css("top");e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(r,10))),e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").fadeOut()}),e(document).on("click",".gdpr-preferences",function(r){r.preventDefault();var o=e(window).scrollTop(),n=e(this).data("tab");e(".gdpr-overlay").fadeIn(),e("body").addClass("gdpr-noscroll").css("top",-o),e(".gdpr.gdpr-privacy-preferences .gdpr-wrapper").fadeIn(),n&&e('.gdpr.gdpr-privacy-preferences .gdpr-wrapper .gdpr-tabs [data-target="'+n+'"]').click()}),e(document).on("click",".gdpr.gdpr-privacy-preferences .gdpr-close",function(r){r.preventDefault();var o=e("body").css("top");e(".gdpr-reconsent .gdpr-wrapper").is(":visible")||(e(".gdpr-overlay").fadeOut(),e("body").removeClass("gdpr-noscroll"),e(window).scrollTop(Math.abs(parseInt(o,10)))),e(".gdpr.gdpr-privacy-preferences .gdpr-wrapper").fadeOut()}),e(document).on("click",".gdpr.gdpr-privacy-preferences .gdpr-tabs button, .gdpr.gdpr-reconsent .gdpr-tabs button",function(){var r="."+e(this).data("target");e(".gdpr.gdpr-privacy-preferences .gdpr-tab-content > div, .gdpr.gdpr-reconsent .gdpr-tab-content > div").removeClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tab-content "+r+", .gdpr.gdpr-reconsent .gdpr-tab-content "+r).addClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").hasClass("gdpr-mobile-expanded")&&(e(".gdpr.gdpr-privacy-preferences .gdpr-mobile-menu button, .gdpr.gdpr-reconsent .gdpr-mobile-menu button").removeClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").toggle()),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs button, .gdpr.gdpr-reconsent .gdpr-tabs button").removeClass("gdpr-active"),e(".gdpr-subtabs li button").removeClass("gdpr-active"),e(this).hasClass("gdpr-tab-button")?(e(this).addClass("gdpr-active"),e(this).hasClass("gdpr-cookie-settings")&&e(".gdpr-subtabs").find("li button").first().addClass("gdpr-active")):(e(".gdpr-cookie-settings").addClass("gdpr-active"),e(this).addClass("gdpr-active"))}),e(document).on("click",".gdpr.gdpr-privacy-preferences .gdpr-mobile-menu button, .gdpr.gdpr-reconsent .gdpr-mobile-menu button",function(r){e(this).toggleClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").toggle().addClass("gdpr-mobile-expanded")}),e(window).resize(function(){e(window).width()>640&&e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").hasClass("gdpr-mobile-expanded")&&(e(".gdpr.gdpr-privacy-preferences .gdpr-mobile-menu button, .gdpr.gdpr-reconsent .gdpr-mobile-menu button").removeClass("gdpr-active"),e(".gdpr.gdpr-privacy-preferences .gdpr-tabs, .gdpr.gdpr-reconsent .gdpr-tabs").removeClass("gdpr-mobile-expanded").removeAttr("style"))}),e("form.gdpr-add-to-deletion-requests").on("submit",function(r){if(!e(this).hasClass("confirmed")){r.preventDefault();var o=[{title:GDPR.i18n.ok,buttonClass:"gdpr-ok",callback:"addToDeletionConfirmed"},{title:GDPR.i18n.cancel,buttonClass:"gdpr-cancel",callback:"closeNotification"}];n(GDPR.i18n.close_account,GDPR.i18n.close_account_warning,o)}}),e("body").hasClass("gdpr-notification")){var d=e(window).scrollTop();e(".gdpr-overlay").fadeIn(400,function(){e(".gdpr.gdpr-general-confirmation .gdpr-wrapper").css({display:"flex"}).hide().fadeIn(),e("body").addClass("gdpr-noscroll").css("top",-d)})}e(document).on("click",".gdpr-disagree a",function(r){e(".gdpr.gdpr-reconsent .gdpr-wrapper").fadeOut();var o=[{title:GDPR.i18n.ok,buttonClass:"gdpr-ok",callback:"policyDisagreeOk"},{title:GDPR.i18n.cancel,buttonClass:"gdpr-cancel",callback:"policyDisagreeCancel"}];n(GDPR.i18n.are_you_sure,GDPR.i18n.policy_disagree,o,!0)})})}(jQuery),function(e){var r=!1;if("function"==typeof define&&define.amd&&(define(e),r=!0),"object"==typeof exports&&(module.exports=e(),r=!0),!r){var o=window.Cookies,n=window.Cookies=e();n.noConflict=function(){return window.Cookies=o,n}}}(function(){function e(){for(var e=0,r={};e1){if("number"==typeof(d=e({path:"/"},n.defaults,d)).expires){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*d.expires),d.expires=p}d.expires=d.expires?d.expires.toUTCString():"";try{a=JSON.stringify(t),/^[\{\[]/.test(a)&&(t=a)}catch(e){}t=o.write?o.write(t,r):encodeURIComponent(String(t)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),r=(r=(r=encodeURIComponent(String(r))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);var i="";for(var c in d)d[c]&&(i+="; "+c,!0!==d[c]&&(i+="="+d[c]));return document.cookie=r+"="+t+i}r||(a={});for(var s=document.cookie?document.cookie.split("; "):[],g=/(%[0-9A-Z]{2})+/g,l=0;l */ public static function deactivate() { - wp_clear_scheduled_hook( 'telemetry_cleanup' ); } } diff --git a/includes/class-gdpr-email.php b/includes/class-gdpr-email.php index a855f117..3ecbd57c 100644 --- a/includes/class-gdpr-email.php +++ b/includes/class-gdpr-email.php @@ -10,6 +10,8 @@ * @author Fernando Claussen */ +require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-gdpr-templates.php'; + /** * Handles emailing users. * @@ -19,63 +21,6 @@ * @author Fernando Claussen */ class GDPR_Email { - /** - * Locate template. - * - * Locate the called template. - * Search Order: - * 1. /themes/theme/gdpr/templates/email/$template_name - * 2. /plugins/gdpr/templates/$template_name. - * - * @since 1.0.0 - * @author Fernando Claussen - * @access private - * @static - * @param string $template_name Template to load. - * @return string Path to the template file. - */ - private static function locate_template( $template_name ) { - // Set variable to search in gdpr folder of theme. - $theme_path = 'gdpr/email/'; - - // Set default plugin templates path. - $plugin_path = plugin_dir_path( dirname( __FILE__ ) ) . 'templates/email/'; // Path to the template folder - - // Search template file in theme folder. - $template = locate_template( - array( - $theme_path . $template_name, - ) - ); - - // Get plugins template file. - if ( ! $template ) { - $template = $plugin_path . $template_name; - } - return $template; - } - - /** - * Get template. - * - * Search for the template and include the file. - * - * @since 1.0.0 - * @author Fernando Claussen - * @access private - * @static - * @param string $template_name Template to load. - * @param array $args Arguments passed to the template file. - */ - private static function get_template( $template_name, $args = array() ) { - $template_file = self::locate_template( $template_name ); - - if ( ! file_exists( $template_file ) ) { - return; - } - include $template_file; - } - /** * Get the email content from the correct file. * @since 1.0.0 @@ -87,7 +32,7 @@ private static function get_template( $template_name, $args = array() ) { */ public static function get_email_content( $template_name, $args = array() ) { ob_start(); - self::get_template( $template_name, $args ); + GDPR_Templates::get_template( $template_name, $args ); return ob_get_clean(); } @@ -224,7 +169,7 @@ public static function send( $emails, $type, $args = array(), $attachments = arr $headers[] = 'Bcc: ' . sanitize_email( $email ); } - $content = self::get_email_content( $type . '.php', $args ); + $content = self::get_email_content( 'email/' . $type . '.php', $args ); return wp_mail( $no_reply, diff --git a/includes/class-gdpr-help.php b/includes/class-gdpr-help.php index f24a9153..ca84d933 100644 --- a/includes/class-gdpr-help.php +++ b/includes/class-gdpr-help.php @@ -186,29 +186,4 @@ public static function add_settings_help() { ) ); } - - /** - * Add the telemetry page help tabs. - * @since 1.0.0 - * @author Fernando Claussen - * @static - */ - public static function add_telemetry_help() { - if ( 'edit-telemetry' !== get_current_screen()->id ) { - return; - } - - $telemetry_help = '

' . esc_html__( 'Overview', 'gdpr' ) . '

' . - '

' . esc_html__( 'This is all data that are being sent outside of your site. WordPress send some data to it\'s servers to be able to do automatic updates. You can reduce the amount of data being sent using filters.', 'gdpr' ) . '

' . - '

' . esc_html__( 'Some plugins also capture data and send it to their servers. Such practice is not allowed for plugins hosted on wordpress.org plugin repository. In case this is a Premium plugin, you should have been given the option to choose which type of data you want to send.', 'gdpr' ) . '

' . - '

' . esc_html__( 'Use this tool to identify plugins or themes sending potential personal data outside of your server and take action if necessary.', 'gdpr' ) . '

' . - '

' . esc_html__( 'All information on this page is automatically deleted every 12 hours so this doesn\'t grow too large and slow your site.' ) . '

'; - get_current_screen()->add_help_tab( - array( - 'id' => 'overview', - 'title' => esc_html__( 'Overview', 'gdpr' ), - 'content' => $telemetry_help, - ) - ); - } } diff --git a/includes/class-gdpr-templates.php b/includes/class-gdpr-templates.php new file mode 100644 index 00000000..8b15f93c --- /dev/null +++ b/includes/class-gdpr-templates.php @@ -0,0 +1,62 @@ + + * @access private + * @static + * @param string $template_name Template to load. + * @return string Path to the template file. + */ + private static function locate_template( $template_name ) { + // Set variable to search in gdpr folder of theme. + $theme_path = 'gdpr/'; + + // Set default plugin templates path. + $plugin_path = plugin_dir_path( dirname( __FILE__ ) ) . 'templates/'; // Path to the template folder + + // Search template file in theme folder. + $template = locate_template( + array( + $theme_path . $template_name, + ) + ); + + // Get plugins template file. + if ( ! $template ) { + $template = $plugin_path . $template_name; + } + return $template; + } + + /** + * Get template. + * + * Search for the template and include the file. + * + * @since 1.0.0 + * @author Fernando Claussen + * @access private + * @static + * @param string $template_name Template to load. + * @param array $args Arguments passed to the template file. + */ + public static function get_template( $template_name, $args = array() ) { + $template_file = self::locate_template( $template_name ); + + if ( ! file_exists( $template_file ) ) { + return; + } + include $template_file; + } + +} diff --git a/includes/class-gdpr.php b/includes/class-gdpr.php index 449e815b..620406b2 100755 --- a/includes/class-gdpr.php +++ b/includes/class-gdpr.php @@ -96,11 +96,6 @@ private function load_dependencies() { */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-gdpr-audit-log.php'; - /** - * The class responsible for defining the telemetry post type. - */ - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-gdpr-telemetry.php'; - /** * The class responsible for defining the requests section of the plugin. */ @@ -175,7 +170,6 @@ private function define_admin_hooks() { $plugin_admin = new GDPR_Admin( $this->get_plugin_name(), $this->get_version() ); $requests_admin = new GDPR_Requests_Admin( $this->get_plugin_name(), $this->get_version() ); - $telemetry = new GDPR_Telemetry( $this->get_plugin_name(), $this->get_version() ); $requests = new GDPR_Requests( $this->get_plugin_name(), $this->get_version() ); $plugin_emails = new GDPR_Email(); $woo_add_to_registration = get_option( 'gdpr_add_consent_checkboxes_registration', false ); @@ -193,6 +187,8 @@ private function define_admin_hooks() { } add_filter( 'manage_users_custom_column', array( $plugin_admin, 'add_consents_to_consents_column' ), 10, 3 ); add_filter( 'manage_users_columns', array( $plugin_admin, 'add_consents_column_to_user_table' ) ); + add_filter( 'manage_users_sortable_columns', array( $plugin_admin, 'sort_consents_column_from_user_table' ) ); + add_action( 'pre_get_users', array( $plugin_admin, 'sort_logic_for_consents_from_user_table' ) ); add_action( 'show_user_profile', array( $plugin_admin, 'edit_user_profile' ) ); add_action( 'personal_options_update', array( $plugin_admin, 'user_profile_update' ) ); add_action( 'admin_notices', array( $plugin_admin, 'policy_updated_notice' ) ); @@ -213,7 +209,6 @@ private function define_admin_hooks() { add_action( 'wp_ajax_gdpr_audit_log', array( $plugin_admin, 'audit_log' ) ); add_action( 'admin_post_gdpr_data_breach', array( $plugin_admin, 'send_data_breach_confirmation_email' ) ); add_action( 'clean_gdpr_data_breach_request', array( $plugin_admin, 'clean_data_breach_request' ), 10, 2 ); // CRON JOB - add_action( 'telemetry_cleanup', array( $plugin_admin, 'telemetry_cleanup' ) ); // CRON JOB add_action( 'admin_post_gdpr_delete_user', array( $requests_admin, 'delete_user' ) ); add_action( 'admin_post_gdpr_cancel_request', array( $requests_admin, 'cancel_request' ) ); @@ -222,13 +217,6 @@ private function define_admin_hooks() { add_action( 'wp_ajax_gdpr_anonymize_comments', array( $requests_admin, 'anonymize_comments' ) ); add_action( 'wp_ajax_gdpr_reassign_content', array( $requests_admin, 'reassign_content' ) ); - add_action( 'init', array( $telemetry, 'register_post_type' ) ); - add_filter( 'http_api_debug', array( $telemetry, 'log_request' ), 10, 5 ); - add_filter( 'manage_telemetry_posts_columns', array( $telemetry, 'manage_columns' ) ); - add_filter( 'manage_telemetry_posts_custom_column', array( $telemetry, 'custom_column' ), 10, 2 ); - add_filter( 'restrict_manage_posts', array( $telemetry, 'actions_above_table' ) ); - add_filter( 'views_edit-telemetry', '__return_null' ); - // CRON JOBS add_action( 'clean_gdpr_requests', array( $requests, 'clean_requests' ) ); add_action( 'clean_gdpr_user_request_key', array( $requests, 'clean_user_request_key' ), 10, 2 ); @@ -285,11 +273,21 @@ private function define_public_hooks() { /** * Checks in an array if a value is found using LIKE instead of =. + * + * Variable string placeholders can begin with '{' (eg. 'wordfence_{hash}') + * * @since 1.4.3 * @author Fernando Claussen * @return Bool */ public static function similar_in_array( $needle, $haystack ) { + if ( strpos ( $needle, '{' ) !== false ) { + $needle = substr( $needle, 0, strpos ( $needle, '{' ) ); + if ( strlen( $needle ) == 0 ) { + return false; + } + } + foreach ( $haystack as $value ) { if ( stripos( strtolower( $value ), strtolower( $needle ) ) !== false ) { return true; @@ -343,7 +341,7 @@ public static function get_consent_checkboxes( $consent_key = false ) { ); if ( $consent_key ) { - $consent_types = array_filter_compat( + $consent_types = array_filter( $consent_types, function( $key ) use ( $consent_key ) { return $key === $consent_key; }, ARRAY_FILTER_USE_KEY diff --git a/includes/compatibility-functions.php b/includes/compatibility-functions.php index 3e3f9ddd..a18431cf 100644 --- a/includes/compatibility-functions.php +++ b/includes/compatibility-functions.php @@ -5,22 +5,8 @@ * @package GDPR */ -/** - * compatibility function array_filter before php 5.6 - * $flag is new in php 5.6 - */ -function array_filter_compat( array $array, $callback, $flag = 0 ) { - if ( $flag == 0 ) { - return array_filter( $array, $callback ); - } - elseif ( $flag == ARRAY_FILTER_USE_KEY ) { - $matchedKeys = array_filter( array_keys( $array ), $callback ); - return array_intersect_key( $array, array_flip( $matchedKeys ) ); - } - else { /* ARRAY_FILTER_USE_BOTH */ - $matchedKeys = array_filter(array_keys( $array ), $callback ); - $matchedValues = array_filter( $array, $callback ); - return array_intersect_key( $array, array_flip( $matchedKeys ) + $matchedValues ); - } +if( ! function_exists( 'boolval' ) ) { + function boolval( $var ){ + return (bool) $var; + } } - diff --git a/public/class-gdpr-public.php b/public/class-gdpr-public.php index c17a56e9..723ae978 100755 --- a/public/class-gdpr-public.php +++ b/public/class-gdpr-public.php @@ -11,6 +11,8 @@ * @author Fernando Claussen */ +require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-gdpr-templates.php'; + /** * The public-facing functionality of the plugin. * @@ -115,7 +117,8 @@ public function enqueue_scripts() { $secret_key = get_option( 'gdpr_recaptcha_secret_key', '' ); if ( $site_key && $secret_key ) { - wp_enqueue_script( $this->plugin_name . '-recaptcha', 'https://www.google.com/recaptcha/api.js' ); + $lang = get_locale(); + wp_enqueue_script( $this->plugin_name . '-recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . $lang ); } } wp_enqueue_script( $this->plugin_name, plugin_dir_url( dirname( __FILE__ ) ) . 'assets/js/gdpr-public.js', array( 'jquery' ), $this->version, false ); @@ -158,7 +161,12 @@ public function privacy_bar() { return; } - include plugin_dir_path( __FILE__ ) . 'partials/privacy-bar.php'; + GDPR_Templates::get_template( 'privacy-bar.php', array( + 'content' => $content, + 'registered_cookies' => $registered_cookies, + 'show_cookie_cat_checkboxes' => $show_cookie_cat_checkboxes, + 'button_text' => $button_text, + ) ); } /** @@ -178,7 +186,14 @@ public function privacy_preferences_modal() { return; } - include plugin_dir_path( __FILE__ ) . 'partials/privacy-preferences-modal.php'; + GDPR_Templates::get_template( 'privacy-preferences-modal.php', array( + 'cookie_privacy_excerpt' => $cookie_privacy_excerpt, + 'consent_types' => $consent_types, + 'approved_cookies' => $approved_cookies, + 'user_consents' => $user_consents, + 'tabs' => $tabs, + 'allowed_html' => $this->allowed_html, + ) ); } /** @@ -297,7 +312,7 @@ public function is_consent_needed() { return; } - $updated_consents = array_filter_compat( + $updated_consents = array_filter( $required_consents, function( $consent, $consent_id ) use ( $user_consents ) { return ! in_array( $consent_id, $user_consents, true ); }, ARRAY_FILTER_USE_BOTH @@ -310,9 +325,13 @@ public function is_consent_needed() { $reconsent_template = get_option( 'gdpr_reconsent_template', 'modal' ); if ( 'bar' === $reconsent_template ) { - include plugin_dir_path( __FILE__ ) . 'partials/reconsent-bar.php'; + GDPR_Templates::get_template( 'reconsent-bar.php', array( + 'updated_consents' => $updated_consents, + ) ); } else { - include plugin_dir_path( __FILE__ ) . 'partials/reconsent-modal.php'; + GDPR_Templates::get_template( 'reconsent-modal.php', array( + 'updated_consents' => $updated_consents, + ) ); } } diff --git a/public/class-gdpr-requests-public.php b/public/class-gdpr-requests-public.php index 90f1c1d8..c38d64f9 100644 --- a/public/class-gdpr-requests-public.php +++ b/public/class-gdpr-requests-public.php @@ -11,6 +11,8 @@ * @author Fernando Claussen */ +require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-gdpr-templates.php'; + /** * The public facing requests functionality of the plugin. * @@ -64,7 +66,7 @@ public static function request_form( $type, $submit_button_text = '' ) { } ob_start(); - include plugin_dir_path( dirname( __FILE__ ) ) . 'public/partials/' . $type . '-form.php'; + GDPR_Templates::get_template( 'forms/' . $type . '-form.php', array( 'submit_button_text' => $submit_button_text ) ); return ob_get_clean(); } diff --git a/src/css/admin/_tooltips.scss b/src/css/admin/_tooltips.scss index 53794991..c736ad43 100644 --- a/src/css/admin/_tooltips.scss +++ b/src/css/admin/_tooltips.scss @@ -1,5 +1,5 @@ /* Add this attribute to the element that needs a tooltip */ -[data-tooltip] { +[data-gdprtooltip] { position: relative; z-index: 9999; cursor: pointer; @@ -22,7 +22,7 @@ background-color: #000; background-color: hsla(0, 0%, 20%, 0.9); color: #fff; - content: attr(data-tooltip); + content: attr(data-gdprtooltip); text-align: center; font-size: 14px; line-height: 1.2; diff --git a/src/css/admin/gdpr-admin.scss b/src/css/admin/gdpr-admin.scss index 7180a199..a5effb48 100644 --- a/src/css/admin/gdpr-admin.scss +++ b/src/css/admin/gdpr-admin.scss @@ -147,23 +147,6 @@ display: none; } -.post-type-telemetry{ - .page-title-action{ - display: none; - } - .row-actions{ - display: none; - } - .search-box { - display: none; - } - .actions{ - #filter-by-date, #post-query-submit, &.bulkactions { - display: none; - } - } -} - .gdpr .not-full { display: inline-block; } @@ -219,9 +202,6 @@ } } } - .type-telemetry * { - word-wrap: break-word !important; - } } @include breakpoint(small-only) { diff --git a/src/js/admin/gdpr-admin.js b/src/js/admin/gdpr-admin.js index 3491f10f..48bd5844 100644 --- a/src/js/admin/gdpr-admin.js +++ b/src/js/admin/gdpr-admin.js @@ -11,8 +11,8 @@ str = str.toLowerCase(); // remove accents, swap ñ for n, etc - var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;"; - var to = "aaaaeeeeiiiioooouuuunc------"; + var from = "àáäâèéëêìíïîòóöôùúüûñňçčľĺšťžýď·/_,:;"; + var to = "aaaaeeeeiiiioooouuuunnccllstzyd------"; for (var i=0, l=from.length ; i -1 ) { diff --git a/public/partials/complaint-form.php b/templates/forms/complaint-form.php similarity index 87% rename from public/partials/complaint-form.php rename to templates/forms/complaint-form.php index c5020f04..4cfd9eff 100644 --- a/public/partials/complaint-form.php +++ b/templates/forms/complaint-form.php @@ -8,6 +8,6 @@ - + diff --git a/public/partials/delete-form.php b/templates/forms/delete-form.php similarity index 88% rename from public/partials/delete-form.php rename to templates/forms/delete-form.php index 3d723c58..a45bb511 100644 --- a/public/partials/delete-form.php +++ b/templates/forms/delete-form.php @@ -19,6 +19,6 @@ - + diff --git a/public/partials/export-data-form.php b/templates/forms/export-data-form.php similarity index 84% rename from public/partials/export-data-form.php rename to templates/forms/export-data-form.php index 7e27772d..a36cc3ef 100644 --- a/public/partials/export-data-form.php +++ b/templates/forms/export-data-form.php @@ -6,6 +6,6 @@ - + diff --git a/templates/forms/index.php b/templates/forms/index.php new file mode 100644 index 00000000..8142269b --- /dev/null +++ b/templates/forms/index.php @@ -0,0 +1 @@ + - + diff --git a/templates/index.php b/templates/index.php new file mode 100644 index 00000000..8142269b --- /dev/null +++ b/templates/index.php @@ -0,0 +1 @@ +
-

+

- +
diff --git a/public/partials/privacy-preferences-modal.php b/templates/privacy-preferences-modal.php similarity index 82% rename from public/partials/privacy-preferences-modal.php rename to templates/privacy-preferences-modal.php index 62f35dd0..ccca008d 100755 --- a/public/partials/privacy-preferences-modal.php +++ b/templates/privacy-preferences-modal.php @@ -30,12 +30,12 @@
  • - - -
  • + + +
    • $tab ) { + foreach ( $args['tabs'] as $key => $tab ) { if ( ( isset( $tab['cookies_used'] ) && empty( $tab['cookies_used'] ) ) && ( isset( $tab['hosts'] ) && empty( $tab['hosts'] ) ) ) { continue; } @@ -47,8 +47,8 @@
      - - $type ) : ?> + + $type ) : ?>
      -

      - - $type ) : ?> +

      + + $type ) : ?>
      - allowed_html ); ?> +
      @@ -92,7 +92,7 @@
- $tab ) : ?> + $tab ) : ?>

@@ -107,12 +107,12 @@ $site_cookies = array(); $enabled = ( 'off' === $tab['status'] ) ? false : true; $cookies_used = explode( ',', $tab['cookies_used'] ); - $approved_cookies = isset( $_COOKIE['gdpr']['allowed_cookies'] ) ? json_decode( sanitize_text_field( wp_unslash( $_COOKIE['gdpr']['allowed_cookies'] ) ) ) : array(); // WPCS: input var ok. + $args['approved_cookies'] = isset( $_COOKIE['gdpr']['allowed_cookies'] ) ? json_decode( sanitize_text_field( wp_unslash( $_COOKIE['gdpr']['allowed_cookies'] ) ) ) : array(); // WPCS: input var ok. foreach ( $cookies_used as $cookie ) { $site_cookies[] = trim( $cookie ); $all_cookies[] = trim( $cookie ); - if ( ! empty( $approved_cookies ) && isset( $_COOKIE['gdpr']['privacy_bar'] ) ) { - if ( in_array( trim( $cookie ), $approved_cookies, true ) ) { + if ( ! empty( $args['approved_cookies'] ) && isset( $_COOKIE['gdpr']['privacy_bar'] ) ) { + if ( in_array( trim( $cookie ), $args['approved_cookies'], true ) ) { $enabled = true; } else { $enabled = false; @@ -123,7 +123,7 @@ - +
    - $consent ) : ?> + $consent ) : ?>
  • diff --git a/public/partials/reconsent-modal.php b/templates/reconsent-modal.php similarity index 74% rename from public/partials/reconsent-modal.php rename to templates/reconsent-modal.php index 67a12afe..6a1a9339 100755 --- a/public/partials/reconsent-modal.php +++ b/templates/reconsent-modal.php @@ -26,37 +26,25 @@
      - - -
    • + + +
      • $consent ) : + foreach ( $args['updated_consents'] as $consent_id => $consent ) : echo '
      • ' . esc_html( $consent['name'] ) . '
      • '; $policy_counter++; - endforeach + endforeach; ?>
    -
      - - $type ) : ?> - -
    • - - -
    - $consent ) : ?> + $consent ) : ?>

    @@ -81,7 +69,7 @@