Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 20 additions & 30 deletions admin/class-gdpr-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}

/**
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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';
}

Expand Down Expand Up @@ -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 <fernandoclaussen@gmail.com>
*/
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
Expand Down Expand Up @@ -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' );
}
}

}
Loading