Skip to content

Commit

Permalink
Klaro link color and users export
Browse files Browse the repository at this point in the history
  • Loading branch information
IntoJHyyry committed Jun 24, 2021
1 parent 5fa422e commit ca9128f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 5 deletions.
3 changes: 1 addition & 2 deletions dev/stylesheets/screen.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/stylesheets/screen.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
require get_template_directory() . '/inc/menu-walker.php';
require get_template_directory() . '/inc/new-site-init.php';

require get_template_directory() . '/inc/users-export.php';


/* Enable developer checklist in admin */
if (is_admin()) {
Expand Down
71 changes: 70 additions & 1 deletion inc/admin-tweaks.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,89 @@
'redirect' => false,
'position' => 4
));

} else {
acf_add_options_page(array(
'page_title' => __('Evästeasetukset', 'ID_admin'),
'menu_title' => __('Evästeasetukset', 'ID_admin'),
'menu_slug' => 'global-cookie-settings',
//'capability' => 'delete_sites',
'capability' => 'delete_pages',
'capability' => 'delete_site',
'redirect' => false,
'position' => 4
));
}

}



function ID_users_export_plugin() {
add_options_page(
__('Vie käyttäjät', 'ID_admin'),
__('Vie käyttäjät', 'ID_admin'),
'delete_sites',
'user-export',
'user_export_plugin',
7
);
}
add_action( 'admin_menu', 'ID_users_export_plugin');


function user_export_plugin() {
?>
<div class="wrap">
<h1>Vie käyttäjät</h1>

<form method="post" action="<?php echo wp_nonce_url('options-general.php?page=user-export&id-export-users', 'id-user-export', 'id-user-export'); ?>">
<?php
settings_fields( 'ID_export_users' );
submit_button('Vie käyttäjät');
?>
</form>
</div>
<?php
}


add_action( 'admin_init', 'ID_export_users' );
function ID_export_users() {
if(isset($_GET['id-export-users']) && isset($_GET['id-user-export']) && wp_verify_nonce($_GET['id-user-export'], 'id-user-export')) {

if(current_user_can('delete_sites')) {
$args = array( 'blog_id' => 0 );
$users = get_users( $args );

if(!empty($users)) {
$fp = fopen('file.csv', 'w');

foreach($users as $user) {
fputcsv($fp, array($user->user_email));
}

fclose($fp);


header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename('file.csv'));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize('file.csv'));
readfile('file.csv');
exit;
}

echo 'users exported';
} else {
echo 'error';
}
}
}



/**
* Add analytics to default settings
* TODO GTM alternative
Expand Down
8 changes: 8 additions & 0 deletions inc/users-export.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
//check_admin_referer( 'export_users' );


function export_users() {

}
?>
2 changes: 1 addition & 1 deletion sass/partials/_klaro.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
}

a {
@include primary-color-text(true);
color: $clr-black !important;
transition: 0.2s;

&:hover {
Expand Down

0 comments on commit ca9128f

Please sign in to comment.