Skip to content

Commit

Permalink
Added GDPR tab with new features
Browse files Browse the repository at this point in the history
  • Loading branch information
zreedeecom committed May 25, 2018
1 parent a0584bb commit d62acec
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 31 deletions.
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### General CodeKit files to ignore
*.codekit3

### VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### MacOS
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
69 changes: 63 additions & 6 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ blockquote:before, blockquote:after, q:before, q:after {
content: none;
}
input, button {
-webkit-appearance: none;
/* -webkit-appearance: none; */
border-radius: 0;
}
table {
Expand Down Expand Up @@ -116,16 +116,43 @@ body {
/**
* SUBSCRIBE FORM
**/

.wrap form.subscribe_form {
.wrap div.subscribe_border {
border: 3px solid #e0e0e0;
box-sizing: border-box;
width: 450px;
margin: 0 0 75px;
display: inline-block;
border: 3px solid #e0e0e0;
}
.wrap form.subscribe_form {
/* box-sizing: border-box;
width: 450px; */
margin: 0 0 75px;
/* display: inline-block; */
/* border: 3px solid #e0e0e0; */
overflow: hidden;
text-align: center;
}
.wrap .subscribe_form .privacy_checkbox {
color: #909090;
max-width: 450px;
margin: 15px auto;
position: relative;
}
.wrap form.subscribe_form .privacy_checkbox label.error {
display: block !important;
position: absolute;
font-size: 11px;
left: 39%;
}
.wrap .subscribe_form .privacy_checkbox input {
float: none;
margin: 3px 4.7px;
}
.wrap .subscribe_form .privacy_tail {
font-size: 11px;
color: #909090;
max-width: 450px;
margin: 0 auto;
}
.wrap form.subscribe_form input {
margin: 0;
outline: 0;
Expand Down Expand Up @@ -291,7 +318,9 @@ body {
margin: 100px auto;
transition: 0.2s transform ease-in-out;
}
.contact .form input, .contact .form textarea {
.contact .form input[type=text],
.contact .form input[type=submit],
.contact .form textarea {
padding: 15px 20px;
margin: 0;
outline: 0;
Expand All @@ -303,6 +332,28 @@ body {
box-sizing: border-box;
resize: none;
}
.contact .form label#content-error { margin-bottom: 10px; }
.contact .form .privacy_checkbox {
margin-top: 20px;
clear: both;
color: #909090;
font-size: 15px;
position: relative;
}
.contact .form .privacy_checkbox label#acceptance-error {
position: absolute;
top: 10px;
left: 39%;
}
.contact .form .privacy_checkbox input {
transform: translatey(-2px);
}
.contact .form .privacy_tail {
font-size: 11px;
color: #c7c7c7;
margin-top: 16px;
line-height: 14px;
}
.contact .form textarea {
height: 175px;
padding: 20px;
Expand Down Expand Up @@ -477,3 +528,9 @@ body {
width: 70%;
}
}
@media only screen and (max-width: 465px) {
.contact .form .privacy_checkbox label#acceptance-error {
top: 28px;
left: 32%;
}
}
3 changes: 1 addition & 2 deletions assets/css/style.min.css

Large diffs are not rendered by default.

48 changes: 46 additions & 2 deletions includes/classes/wp-maintenance-mode-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ public function save_plugin_settings() {
$this->delete_cache();
}
break;
case 'gdpr':
//$custom_css = array();

$_POST['options']['gdpr']['status'] = (int)$_POST['options']['gdpr']['status'];
$_POST['options']['gdpr']['policy_page_label'] = sanitize_text_field($_POST['options']['gdpr']['policy_page_label']);
$_POST['options']['gdpr']['policy_page_link'] = sanitize_text_field($_POST['options']['gdpr']['policy_page_link']);
$_POST['options']['gdpr']['contact_form_tail'] = sanitize_text_field($_POST['options']['gdpr']['contact_form_tail']);
$_POST['options']['gdpr']['subscribe_form_tail'] = sanitize_text_field($_POST['options']['gdpr']['subscribe_form_tail']);
}

$this->plugin_settings[$tab] = $_POST['options'][$tab];
Expand Down Expand Up @@ -446,7 +454,7 @@ public function add_safe_style_css($properties) {
}

/**
* Builds the data.js file and writes it into assets/js/
* Builds the data.js file and writes it into uploads
* This file is mandatory for the bot to work correctly.
*
* @param array $messages
Expand Down Expand Up @@ -482,7 +490,6 @@ public function set_datajs_file($messages = array()) {
// Try to write data.js file
try {
$upload_dir = wp_upload_dir();
// if ( file_put_contents( WPMM_PATH . 'assets/js/data.js', $data) === false ){
if ( file_put_contents( trailingslashit($upload_dir['basedir']) . 'data.js', $data) === false ){
throw new Exception(__("WPMM: The file data.js could not be written, the bot will not work correctly.", $this->plugin_slug));
}
Expand Down Expand Up @@ -628,6 +635,43 @@ public function admin_footer_text($text) {
return $text;
}

public function get_is_policy_available() {
if (function_exists('get_privacy_policy_url')) {
return true;
}
return false;
}

public function get_policy_link() {
//Check feature is available
if($this->get_is_policy_available()) {
return get_privacy_policy_url();
}
}

public function get_policy_link_message() {
$url = $this->get_policy_link();
if($this->get_is_policy_available() && $this->plugin_settings['gdpr']['policy_page_link'] === '') {
if($url === '') { // No value and feature available
return __("Your WordPress version supports Privacy settings but you haven't set any privacy policy page yet. Go to Settings ➡ Privacy to set one.", $this->plugin_slug);
}
else { // Value and feature available
return sprintf(__('The plugin detected this Privacy page: %1$s – %2$sUse this url%3$s', $this->plugin_slug), $url, '<button>', '</button>');
}
}
elseif($this->get_is_policy_available() && $this->plugin_settings['gdpr']['policy_page_link'] != '') { // Feature available and value set
if($url != $this->plugin_settings['gdpr']['policy_page_link']) { // Current wp privacy page differs from set value
return sprintf(__("Your Privacy page is pointing to a different URL in WordPress settings. If that's correct ignore this message, otherwise %s", $this->plugin_slug), 'UPDATE VALUE TO NEW URL');
}
}
elseif(!$this->get_is_policy_available()) { // No privacy feature available
return __("No privacy features detected for your WordPress version. Update WordPress to get this field automatically filled in or type in the URL that points to your privacy policy page.", $this->plugin_slug);
}
}




}

}
22 changes: 19 additions & 3 deletions includes/classes/wp-maintenance-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class WP_Maintenance_Mode {

const VERSION = '2.1.2';
const VERSION = '2.2';

protected $plugin_slug = 'wp-maintenance-mode';
protected $plugin_settings;
Expand Down Expand Up @@ -159,9 +159,16 @@ public function default_settings() {
'02_1' => __("Tell me more", $this->plugin_slug),
'02_2' => __("Boring", $this->plugin_slug),
'03' => __("Type your email here…", $this->plugin_slug)
),
),
'custom_css' => array()
)
),
'gdpr' => array(
'status' => 0,
'policy_page_label' => __('Privacy Policy', $this->plugin_slug),
'policy_page_link' => '',
'contact_form_tail' => __('This form collects your name and email so that we can reach you back. Check out our <a href="#">Privacy Policy</a> page to fully understand how we protect and manage your submitted data.', $this->plugin_slug),
'subscribe_form_tail' => __('This form collects your email so that we can add you to our newsletter list. Check out our <a href="#">Privacy Policy</a> page to fully understand how we protect and manage your submitted data.', $this->plugin_slug),
),
);
}

Expand Down Expand Up @@ -422,6 +429,15 @@ public static function single_activate($network_wide = false) {
update_option('wpmm_settings', $v2_options);
}

/**
* Update from =< v2.1.2 to 2.1.5
*/
if(empty($v2_options['gdpr'])) {
$v2_options['gdpr'] = $default_options['gdpr'];
// update options
update_option('wpmm_settings', $v2_options);
}

// set current version
update_option('wpmm_version', WP_Maintenance_Mode::VERSION);
}
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version 2.1.2
# Version 2.2

# WP Maintenance Mode

Expand All @@ -19,6 +19,7 @@ Adds a splash page to your site that lets visitors know your site is down for ma
* SEO options;
* Exclude URLs from maintenance.
* Bot functionality to collect the emails in a friendly and efficient way.
* GDPR Ready

**Credits**

Expand Down
11 changes: 8 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
=== WP Maintenance Mode ===
Contributors: Designmodo
Contributors: Designmodo, impresshq
Plugin Name: WP Maintenance Mode
Plugin URI: https://designmodo.com/
Author: Designmodo
Author URI: https://designmodo.com/
Tags: maintenance mode, admin, administration, unavailable, coming soon, multisite, landing page, under construction, contact form, subscribe, countdown
Requires at least: 3.5
Tested up to: 4.9.4
Stable tag: 2.1.2
Tested up to: 4.9.6
Stable tag: 2.2
Requires PHP: 5.6
License: GPL-2.0+

Adds a splash page to your site that lets visitors know your site is down for maintenance. It's perfect for a coming soon page. The new Bot functionality is here!
Expand Down Expand Up @@ -35,6 +36,7 @@ Also works with WordPress Multisite installs (each blog from the network has it'
* SEO options;
* Exclude URLs from maintenance;
* Bot functionality to collect the emails in a friendly and efficient way.
* GDPR Ready

= Bugs, technical hints or contribute =

Expand Down Expand Up @@ -75,6 +77,9 @@ If you change your login url, please add the new slug (url: http://domain.com/ne

== Changelog ==

= 2.2 (25/05/2018) =
* added GDPR feature

= 2.1.2 (04/03/2018) =
* fixed a bug that was breaking the plugin after updating from 2.0.9 to 2.1.1

Expand Down
26 changes: 22 additions & 4 deletions views/maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,15 @@
<?php if (!empty($this->plugin_settings['modules']['subscribe_text'])) { ?><h3><?php echo stripslashes($this->plugin_settings['modules']['subscribe_text']); ?></h3><?php } ?>
<div class="subscribe_wrapper" style="min-height: 100px;">
<form class="subscribe_form">
<input type="text" placeholder="<?php _e('your e-mail...', $this->plugin_slug); ?>" name="email" class="email_input" data-rule-required="true" data-rule-email="true" data-rule-required="true" data-rule-email="true" />
<input type="submit" value="<?php _e('Subscribe', $this->plugin_slug); ?>" />
<div class="subscribe_border">
<input type="text" placeholder="<?php _e('your e-mail...', $this->plugin_slug); ?>" name="email" class="email_input" data-rule-required="true" data-rule-email="true" data-rule-required="true" data-rule-email="true" />
<input type="submit" value="<?php _e('Subscribe', $this->plugin_slug); ?>" />
</div>
<?php if (!empty($this->plugin_settings['gdpr']['status']) && $this->plugin_settings['gdpr']['status'] == 1) { ?>
<div class="privacy_checkbox"><input type="checkbox" name="acceptance" value="YES" data-rule-required="true" data-msg-required="<?php esc_attr_e('This field is required.', $this->plugin_slug); ?>"><label for="acceptance"><?php _e("I've read and agree with the site's privacy policy", $this->plugin_slug); ?></label></div>
<?php if(!empty($this->plugin_settings['gdpr']['subscribe_form_tail'])) { ?>
<p class="privacy_tail"><?php echo $this->plugin_settings['gdpr']['subscribe_form_tail']; ?></p>
<?php }} ?>
</form>
</div>
<?php } ?>
Expand Down Expand Up @@ -127,6 +134,11 @@

<?php do_action('wpmm_contact_form_after_message'); ?>

<?php if (!empty($this->plugin_settings['gdpr']['status']) && $this->plugin_settings['gdpr']['status'] == 1) { ?>
<div class="privacy_checkbox"><input type="checkbox" name="acceptance" value="YES" data-rule-required="true" data-msg-required="<?php esc_attr_e('This field is required.', $this->plugin_slug); ?>"><label for="acceptance"><?php _e("I've read and agree with the site's privacy policy", $this->plugin_slug); ?></label></div>
<?php if(!empty($this->plugin_settings['gdpr']['contact_form_tail'])) { ?>
<p class="privacy_tail"><?php echo $this->plugin_settings['gdpr']['contact_form_tail']; ?></p>
<?php }} ?>
<p class="submit"><input type="submit" value="<?php _e('Send', $this->plugin_slug); ?>"></p>

<?php do_action('wpmm_contact_form_end'); ?>
Expand All @@ -137,9 +149,15 @@
<a class="contact_us" href="javascript:void(0);" data-open="<?php echo esc_attr($open); ?>" data-close="<?php echo esc_attr($close); ?>"><?php _e('Contact us', $this->plugin_slug); ?></a>
<?php } ?>

<?php if (!empty($this->plugin_settings['general']['admin_link']) && $this->plugin_settings['general']['admin_link'] == 1) { ?>
<?php if ((!empty($this->plugin_settings['general']['admin_link']) && $this->plugin_settings['general']['admin_link'] == 1) ||
(!empty($this->plugin_settings['gdpr']['status']) && $this->plugin_settings['gdpr']['status'] == 1)) { ?>
<div class="author_link">
<a href="<?php echo admin_url(); ?>"><?php _e('Dashboard', $this->plugin_slug); ?></a>
<?php if($this->plugin_settings['general']['admin_link'] == 1) { ?>
<a href="<?php echo admin_url(); ?>"><?php _e('Dashboard', $this->plugin_slug); ?></a>
<?php } ?>
<?php if ($this->plugin_settings['gdpr']['status'] == 1) { ?>
<a href="<?php echo $this->plugin_settings['gdpr']['policy_page_link']; ?>"><?php echo $this->plugin_settings['gdpr']['policy_page_label']; ?></a>
<?php } ?>
</div>
<?php } ?>
</div>
Expand Down
Loading

0 comments on commit d62acec

Please sign in to comment.