Auto Terms of Service and Privacy Policy - Version 2.1.4

Version Description

Download this release

Release Info

Developer wpautoterms
Plugin Icon Auto Terms of Service and Privacy Policy
Version 2.1.4
Comparing to
See all releases

Code changes from version 2.1.3 to 2.1.4

auto-terms-of-service-privacy-policy.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://wpautoterms.com
5
  Description: Create Privacy Policy (Simple or GDPR), Terms & Conditions, Disclaimers and more. Compliance Kits to help you be compliant with the law.
6
  Author: WP AutoTerms
7
  Author URI: https://wpautoterms.com
8
- Version: 2.1.3
9
  License: GPLv2 or later
10
  Text Domain: wpautoterms
11
  Domain Path: /languages
@@ -51,10 +51,34 @@ define( 'WPAUTOTERMS_TAG', 'wpautoterms' );
51
  define( 'WPAUTOTERMS_SLUG', 'wpautoterms' );
52
  define( 'WPAUTOTERMS_OPTION_PREFIX', WPAUTOTERMS_SLUG . '_' );
53
  define( 'WPAUTOTERMS_LEGAL_PAGES_DIR', 'legal-pages' . DIRECTORY_SEPARATOR );
54
- define( 'WPAUTOTERMS_VERSION', '1.9.0' );
55
  define( 'WPAUTOTERMS_OPTION_ACTIVATED', 'activated' );
56
  define( 'WPAUTOTERMS_LICENSE_RECHECK_TIME', 24 * 60 * 60 );
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  require_once WPAUTOTERMS_PLUGIN_DIR . 'api.php';
59
  require_once WPAUTOTERMS_PLUGIN_DIR . 'deactivate.php';
60
  require_once WPAUTOTERMS_PLUGIN_DIR . 'uninstall.php';
5
  Description: Create Privacy Policy (Simple or GDPR), Terms & Conditions, Disclaimers and more. Compliance Kits to help you be compliant with the law.
6
  Author: WP AutoTerms
7
  Author URI: https://wpautoterms.com
8
+ Version: 2.1.4
9
  License: GPLv2 or later
10
  Text Domain: wpautoterms
11
  Domain Path: /languages
51
  define( 'WPAUTOTERMS_SLUG', 'wpautoterms' );
52
  define( 'WPAUTOTERMS_OPTION_PREFIX', WPAUTOTERMS_SLUG . '_' );
53
  define( 'WPAUTOTERMS_LEGAL_PAGES_DIR', 'legal-pages' . DIRECTORY_SEPARATOR );
 
54
  define( 'WPAUTOTERMS_OPTION_ACTIVATED', 'activated' );
55
  define( 'WPAUTOTERMS_LICENSE_RECHECK_TIME', 24 * 60 * 60 );
56
 
57
+ function get_version( $file_name ) {
58
+
59
+ $fh = fopen( $file_name, "r" );
60
+ if ( $fh ) {
61
+ $cmp = 'Version:';
62
+ $len = strlen( $cmp );
63
+ while ( true ) {
64
+ $line = fgets( $fh );
65
+ if ( $line === false ) {
66
+ break;
67
+ }
68
+ $line = ltrim( $line );
69
+ if ( strncasecmp( $line, $cmp, $len ) === 0 ) {
70
+ return trim( substr( $line, $len ) );
71
+ }
72
+ }
73
+ fclose( $fh );
74
+ } else {
75
+ die( 'Unexpected error, fopen failed for ' . $file_name );
76
+ }
77
+ die( 'Could not find version in ' . $file_name );
78
+ }
79
+
80
+ define( 'WPAUTOTERMS_VERSION', get_version( __FILE__ ) );
81
+
82
  require_once WPAUTOTERMS_PLUGIN_DIR . 'api.php';
83
  require_once WPAUTOTERMS_PLUGIN_DIR . 'deactivate.php';
84
  require_once WPAUTOTERMS_PLUGIN_DIR . 'uninstall.php';
images/tourkick-logo-square-300.png DELETED
Binary file
includes/admin/action/send-message.php CHANGED
@@ -10,7 +10,7 @@ class Send_Message extends Action_Base {
10
  const SITE_INFO_SHORT = 1;
11
  const SITE_INFO_EXTENDED = 2;
12
 
13
- const DEFAULT_SITE_INFO = 1;
14
 
15
  const MAX_TEXT_LENGTH = 2500;
16
 
@@ -60,7 +60,7 @@ class Send_Message extends Action_Base {
60
  $text = static::_request_var( 'text' );
61
  $site_info = static::_request_var( 'site_info' );
62
  if ( empty( $site_name ) || empty( $site_url ) || empty( $email ) || empty( $text ) ) {
63
- $message = __( 'Please, fill all form fields to submit.', WPAUTOTERMS_SLUG );
64
  } else if ( count( explode( '@', $email ) ) != 2 ) {
65
  $message = __( 'Wrong email address', WPAUTOTERMS_SLUG );
66
  } else if ( count( explode( '.', $site_url ) ) < 2 || count( explode( '..', $site_url ) ) > 1 ) {
10
  const SITE_INFO_SHORT = 1;
11
  const SITE_INFO_EXTENDED = 2;
12
 
13
+ const DEFAULT_SITE_INFO = 2;
14
 
15
  const MAX_TEXT_LENGTH = 2500;
16
 
60
  $text = static::_request_var( 'text' );
61
  $site_info = static::_request_var( 'site_info' );
62
  if ( empty( $site_name ) || empty( $site_url ) || empty( $email ) || empty( $text ) ) {
63
+ $message = __( 'Please fill in the required information in order to send the message.', WPAUTOTERMS_SLUG );
64
  } else if ( count( explode( '@', $email ) ) != 2 ) {
65
  $message = __( 'Wrong email address', WPAUTOTERMS_SLUG );
66
  } else if ( count( explode( '.', $site_url ) ) < 2 || count( explode( '..', $site_url ) ) > 1 ) {
includes/admin/admin.php CHANGED
@@ -13,7 +13,7 @@ use wpautoterms\api\License;
13
  use wpautoterms\api\Query;
14
  use wpautoterms\Countries;
15
  use wpautoterms\cpt\Admin_Columns;
16
- use wpautoterms\admin\page\Legacy_Settings;
17
  use wpautoterms\Wpautoterms;
18
 
19
  define( 'WPAUTOTERMS_API_KEY_HEADER', 'X-WpAutoTerms-ApiKey' );
@@ -37,41 +37,21 @@ abstract class Admin {
37
  static::$_license = $license;
38
  static::$_query = $query;
39
  add_action( 'init', array( __CLASS__, 'action_init' ) );
 
 
40
  }
41
 
42
- public static function upgrade_from_tos_pp() {
43
- $options = get_option( Menu::AUTO_TOS_OPTIONS, false );
44
- update_option( WPAUTOTERMS_OPTION_PREFIX . Menu::LEGACY_OPTIONS, $options !== false );
45
- if ( $options === false ) {
46
- return;
47
- }
48
- $transform = array_keys( Legacy_Settings::all_options() );
49
- foreach ( $transform as $k ) {
50
- if ( isset( $options[ $k ] ) ) {
51
- $v = $options[ $k ];
52
- } else {
53
- $v = '';
54
- }
55
- update_option( WPAUTOTERMS_OPTION_PREFIX . $k, $v );
56
- }
57
- }
58
 
59
  public static function action_init() {
60
- if ( ! get_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED ) ) {
61
- flush_rewrite_rules();
62
- update_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED, true );
63
- $version = get_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION );
64
- if ( $version != WPAUTOTERMS_VERSION ) {
65
- static::upgrade_from_tos_pp();
66
- update_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION, WPAUTOTERMS_VERSION );
67
- }
68
- }
69
  add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ) );
70
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
71
  add_filter( 'post_row_actions', array( __CLASS__, 'row_actions' ), 10, 2 );
 
72
  add_filter( 'get_sample_permalink_html', array( __CLASS__, 'remove_permalink' ), 10, 5 );
73
  add_action( 'edit_form_top', array( __CLASS__, 'edit_form_top' ) );
74
 
 
 
75
  $recheck_action = new Recheck_License( 'manage_options', null, '', null, __( 'Access denied', WPAUTOTERMS_SLUG ) );
76
  $recheck_action->set_license_query( static::$_license );
77
 
@@ -137,6 +117,15 @@ abstract class Admin {
137
  }
138
  }
139
 
 
 
 
 
 
 
 
 
 
140
  public static function row_actions( $actions, $post ) {
141
  if ( ( WPAUTOTERMS_CPT == get_post_type( $post ) ) && ( $post->post_status == 'publish' ) ) {
142
  $link = get_post_permalink( $post->ID );
13
  use wpautoterms\api\Query;
14
  use wpautoterms\Countries;
15
  use wpautoterms\cpt\Admin_Columns;
16
+ use wpautoterms\Upgrade;
17
  use wpautoterms\Wpautoterms;
18
 
19
  define( 'WPAUTOTERMS_API_KEY_HEADER', 'X-WpAutoTerms-ApiKey' );
37
  static::$_license = $license;
38
  static::$_query = $query;
39
  add_action( 'init', array( __CLASS__, 'action_init' ) );
40
+ new Slug_Helper();
41
+ new Upgrade();
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  public static function action_init() {
 
 
 
 
 
 
 
 
 
46
  add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ) );
47
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
48
  add_filter( 'post_row_actions', array( __CLASS__, 'row_actions' ), 10, 2 );
49
+ add_filter( 'pre_update_option', array( __CLASS__, 'fix_update' ), 10, 3 );
50
  add_filter( 'get_sample_permalink_html', array( __CLASS__, 'remove_permalink' ), 10, 5 );
51
  add_action( 'edit_form_top', array( __CLASS__, 'edit_form_top' ) );
52
 
53
+ Notices::init( WPAUTOTERMS_OPTION_PREFIX . 'notices' );
54
+
55
  $recheck_action = new Recheck_License( 'manage_options', null, '', null, __( 'Access denied', WPAUTOTERMS_SLUG ) );
56
  $recheck_action->set_license_query( static::$_license );
57
 
117
  }
118
  }
119
 
120
+ public static function fix_update( $value, $name, $old_value ) {
121
+ if ( $name !== WPAUTOTERMS_OPTION_PREFIX . Options::LEGAL_PAGES_SLUG ) {
122
+ return $value;
123
+ }
124
+
125
+ return static::$_license->status() === License::STATUS_FREE ?
126
+ Options::default_value( Options::LEGAL_PAGES_SLUG ) : $value;
127
+ }
128
+
129
  public static function row_actions( $actions, $post ) {
130
  if ( ( WPAUTOTERMS_CPT == get_post_type( $post ) ) && ( $post->post_status == 'publish' ) ) {
131
  $link = get_post_permalink( $post->ID );
includes/admin/menu.php CHANGED
@@ -60,10 +60,12 @@ abstract class Menu {
60
  $sm = new Send_Message( 'manage_options', null, $contact->id(), null,
61
  __( 'Access denied', WPAUTOTERMS_SLUG ), true );
62
  $contact->action = $sm;
 
 
63
 
64
  static::$_pages = array(
65
  new Compliancekits( static::PAGE_COMPLIANCE_KITS, __( 'Compliance Kits', WPAUTOTERMS_SLUG ), $license ),
66
- new Settings_Page( static::PAGE_SETTINGS, __( 'Settings', WPAUTOTERMS_SLUG ) ),
67
  $ls,
68
  new Legacy_Settings( static::PAGE_LEGACY_SETTINGS, __( 'Legacy Auto TOS & PP', WPAUTOTERMS_SLUG ) ),
69
  $contact,
@@ -79,7 +81,7 @@ abstract class Menu {
79
  }
80
  }
81
  }
82
- update_option( WPAUTOTERMS_OPTION_PREFIX . 'options_activated', true );
83
  }
84
  add_action( 'admin_init', array( __CLASS__, 'register_settings' ) );
85
  add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
60
  $sm = new Send_Message( 'manage_options', null, $contact->id(), null,
61
  __( 'Access denied', WPAUTOTERMS_SLUG ), true );
62
  $contact->action = $sm;
63
+ $sp = new Settings_Page( static::PAGE_SETTINGS, __( 'Settings', WPAUTOTERMS_SLUG ) );
64
+ $sp->set_license( $license );
65
 
66
  static::$_pages = array(
67
  new Compliancekits( static::PAGE_COMPLIANCE_KITS, __( 'Compliance Kits', WPAUTOTERMS_SLUG ), $license ),
68
+ $sp,
69
  $ls,
70
  new Legacy_Settings( static::PAGE_LEGACY_SETTINGS, __( 'Legacy Auto TOS & PP', WPAUTOTERMS_SLUG ) ),
71
  $contact,
81
  }
82
  }
83
  }
84
+ update_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED, true );
85
  }
86
  add_action( 'admin_init', array( __CLASS__, 'register_settings' ) );
87
  add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
includes/admin/notices.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace wpautoterms\admin;
4
+
5
+ class Notices {
6
+ const CLASS_ERROR = 'error';
7
+ const CLASS_UPDATED = 'updated';
8
+
9
+ const TRANSIENT_EXPIRE = 90;
10
+
11
+ protected static $_transient_name;
12
+ protected static $_transient_expire;
13
+
14
+ public static function init( $transient_name, $transient_expire = false ) {
15
+ static::$_transient_name = $transient_name;
16
+ if ( $transient_expire === false ) {
17
+ static::$_transient_expire = static::TRANSIENT_EXPIRE;
18
+ }
19
+ add_action( 'admin_notices', array( __CLASS__, 'show' ) );
20
+ }
21
+
22
+ public static function add( $message, $class = false ) {
23
+ if ( $class === false ) {
24
+ $class = static::CLASS_UPDATED;
25
+ }
26
+ $notices = maybe_unserialize( get_transient( static::$_transient_name ) );
27
+ if ( $notices === false ) {
28
+ $notices = array();
29
+ }
30
+ if ( ! isset( $notices[ $class ] ) ) {
31
+ $notices[ $class ] = array();
32
+ }
33
+ $notices[ $class ][] = $message;
34
+ set_transient( static::$_transient_name, $notices, static::$_transient_expire );
35
+ }
36
+
37
+ public static function show() {
38
+ $notices = maybe_unserialize( get_transient( static::$_transient_name ) );
39
+ if ( is_array( $notices ) ) {
40
+ foreach ( $notices as $class => $messages ) {
41
+ foreach ( $messages as $message ) {
42
+ // TODO: with template
43
+ ?>
44
+ <div class="<?php echo esc_attr( $class ); ?>"><p><?php echo $message; ?></p></div><?php
45
+ }
46
+ }
47
+ }
48
+ delete_transient( static::$_transient_name );
49
+ }
50
+ }
includes/admin/options.php CHANGED
@@ -3,23 +3,44 @@
3
  namespace wpautoterms\admin;
4
 
5
  class Options {
6
- const OPTION_SITE_NAME = 'site_name';
7
- const OPTION_SITE_URL = 'site_url';
8
- const OPTION_COMPANY_NAME = 'company_name';
9
- const OPTION_COUNTRY = 'country';
10
- const OPTION_STATE = 'state';
 
 
11
 
12
  public static function all_options() {
13
  return array(
14
- static::OPTION_SITE_NAME,
15
- static::OPTION_SITE_URL,
16
- static::OPTION_COMPANY_NAME,
17
- static::OPTION_COUNTRY,
18
- static::OPTION_STATE
 
19
  );
20
  }
21
 
22
- public static function get_option( $name, $default = null ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  return get_option( WPAUTOTERMS_OPTION_PREFIX . $name, $default );
24
  }
25
 
3
  namespace wpautoterms\admin;
4
 
5
  class Options {
6
+ const SITE_NAME = 'site_name';
7
+ const SITE_URL = 'site_url';
8
+ const COMPANY_NAME = 'company_name';
9
+ const COUNTRY = 'country';
10
+ const STATE = 'state';
11
+ const LEGAL_PAGES_SLUG = 'legal_pages_slug';
12
+ protected static $_defaults;
13
 
14
  public static function all_options() {
15
  return array(
16
+ static::SITE_NAME,
17
+ static::SITE_URL,
18
+ static::COMPANY_NAME,
19
+ static::COUNTRY,
20
+ static::STATE,
21
+ static::LEGAL_PAGES_SLUG
22
  );
23
  }
24
 
25
+ public static function default_value( $name ) {
26
+ if ( static::$_defaults === null ) {
27
+ $blogname = get_option( 'blogname' );
28
+ static::$_defaults = array(
29
+ Options::SITE_NAME => $blogname,
30
+ Options::SITE_URL => get_option( 'siteurl' ),
31
+ Options::COMPANY_NAME => $blogname,
32
+ Options::COUNTRY => '',
33
+ Options::STATE => '',
34
+ Options::LEGAL_PAGES_SLUG => 'wpautoterms'
35
+ );
36
+ }
37
+
38
+ return static::$_defaults[ $name ];
39
+ }
40
+
41
+ public static function get_option( $name, $no_default = false ) {
42
+ $default = $no_default ? null : static::default_value( $name );
43
+
44
  return get_option( WPAUTOTERMS_OPTION_PREFIX . $name, $default );
45
  }
46
 
includes/admin/page/settings-page.php CHANGED
@@ -2,9 +2,12 @@
2
 
3
  namespace wpautoterms\admin\page;
4
 
 
5
  use wpautoterms\admin\Options;
 
6
  use wpautoterms\Countries;
7
  use wpautoterms\option\Choices_Option;
 
8
  use wpautoterms\option\Text_Option;
9
 
10
  if ( ! defined( 'ABSPATH' ) ) {
@@ -14,25 +17,33 @@ if ( ! defined( 'ABSPATH' ) ) {
14
  class Settings_Page extends Settings_Base {
15
  const SHORTCODE_OPTION_TEMPLATE = 'shortcode-entry-option';
16
  const SHORTCODE_SELECT_TEMPLATE = 'shortcode-select-option';
 
 
 
 
 
 
 
 
17
 
18
  public function define_options() {
19
  parent::define_options();
20
- new Text_Option( Options::OPTION_SITE_NAME,
21
  __( 'Website name', WPAUTOTERMS_SLUG ),
22
  '',
23
  $this->id(), static::SECTION_ID,
24
  static::SHORTCODE_OPTION_TEMPLATE );
25
- new Text_Option( Options::OPTION_SITE_URL,
26
  __( 'Website URL', WPAUTOTERMS_SLUG ),
27
  '',
28
  $this->id(), static::SECTION_ID,
29
  static::SHORTCODE_OPTION_TEMPLATE );
30
- new Text_Option( Options::OPTION_COMPANY_NAME,
31
  __( 'Company name', WPAUTOTERMS_SLUG ),
32
  '',
33
  $this->id(), static::SECTION_ID,
34
  static::SHORTCODE_OPTION_TEMPLATE );
35
- $country = new Choices_Option( Options::OPTION_COUNTRY,
36
  __( 'Country', WPAUTOTERMS_SLUG ),
37
  '',
38
  $this->id(), static::SECTION_ID,
@@ -43,7 +54,7 @@ class Settings_Page extends Settings_Base {
43
  $countries = Countries::get();
44
  $country->set_values( array_combine( $countries, $countries ) );
45
 
46
- $state = new Choices_Option( Options::OPTION_STATE,
47
  __( 'State', WPAUTOTERMS_SLUG ),
48
  '',
49
  $this->id(), static::SECTION_ID,
@@ -54,16 +65,57 @@ class Settings_Page extends Settings_Base {
54
  $states = array_keys( Countries::translations() );
55
  $states = array_diff( $states, $countries );
56
  $state->set_values( array_combine( $states, $states ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
 
59
  public function defaults() {
60
- return array(
61
- Options::OPTION_SITE_NAME => get_option( 'blogname' ),
62
- Options::OPTION_SITE_URL => get_option( 'siteurl' ),
63
- Options::OPTION_COMPANY_NAME => get_option( 'blogname' ),
64
- Options::OPTION_COUNTRY => '',
65
- Options::OPTION_STATE => '',
66
- );
67
  }
68
 
69
  public function enqueue_scripts() {
2
 
3
  namespace wpautoterms\admin\page;
4
 
5
+ use wpautoterms\admin\Notices;
6
  use wpautoterms\admin\Options;
7
+ use wpautoterms\api\License;
8
  use wpautoterms\Countries;
9
  use wpautoterms\option\Choices_Option;
10
+ use wpautoterms\option\CPT_Slug_Option;
11
  use wpautoterms\option\Text_Option;
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
17
  class Settings_Page extends Settings_Base {
18
  const SHORTCODE_OPTION_TEMPLATE = 'shortcode-entry-option';
19
  const SHORTCODE_SELECT_TEMPLATE = 'shortcode-select-option';
20
+ /**
21
+ * @var License
22
+ */
23
+ protected $_license;
24
+
25
+ public function set_license( License $license ) {
26
+ $this->_license = $license;
27
+ }
28
 
29
  public function define_options() {
30
  parent::define_options();
31
+ new Text_Option( Options::SITE_NAME,
32
  __( 'Website name', WPAUTOTERMS_SLUG ),
33
  '',
34
  $this->id(), static::SECTION_ID,
35
  static::SHORTCODE_OPTION_TEMPLATE );
36
+ new Text_Option( Options::SITE_URL,
37
  __( 'Website URL', WPAUTOTERMS_SLUG ),
38
  '',
39
  $this->id(), static::SECTION_ID,
40
  static::SHORTCODE_OPTION_TEMPLATE );
41
+ new Text_Option( Options::COMPANY_NAME,
42
  __( 'Company name', WPAUTOTERMS_SLUG ),
43
  '',
44
  $this->id(), static::SECTION_ID,
45
  static::SHORTCODE_OPTION_TEMPLATE );
46
+ $country = new Choices_Option( Options::COUNTRY,
47
  __( 'Country', WPAUTOTERMS_SLUG ),
48
  '',
49
  $this->id(), static::SECTION_ID,
54
  $countries = Countries::get();
55
  $country->set_values( array_combine( $countries, $countries ) );
56
 
57
+ $state = new Choices_Option( Options::STATE,
58
  __( 'State', WPAUTOTERMS_SLUG ),
59
  '',
60
  $this->id(), static::SECTION_ID,
65
  $states = array_keys( Countries::translations() );
66
  $states = array_diff( $states, $countries );
67
  $state->set_values( array_combine( $states, $states ) );
68
+
69
+ $is_free = $this->_license->status() === License::STATUS_FREE;
70
+ global $wp_rewrite;
71
+ $does_rewrite = $wp_rewrite->using_permalinks();
72
+ $attrs = ( $is_free || ! $does_rewrite ) ? array( 'disabled' => null ) : array();
73
+ $tooltip = $is_free ? '<a href="' . esc_url( WPAUTOTERMS_PURCHASE_URL ) .
74
+ '" target="wpautotermsGetLicense" class="wpautoterms-legal-page-purchase">' .
75
+ __( 'Purchase license to enable this option', WPAUTOTERMS_SLUG ) . '</a><br>' : '';
76
+ if ( ! $does_rewrite ) {
77
+ $tooltip .= __( 'Your Permalinks structure is set to plain. For this option to work, you need to change your Permalinks structure to post name.',
78
+ WPAUTOTERMS_SLUG );
79
+ } else {
80
+ $tooltip .= __( 'Please keep in mind that if you set your Permalinks structure to plain, this option will not work.',
81
+ WPAUTOTERMS_SLUG );
82
+ }
83
+ $slug = new CPT_Slug_Option( Options::LEGAL_PAGES_SLUG,
84
+ __( 'Legal pages slug', WPAUTOTERMS_SLUG ),
85
+ $tooltip,
86
+ $this->id(), static::SECTION_ID, false, $attrs );
87
+ $slug->set_fallback( array( $this, 'slug_fail' ) );
88
+ }
89
+
90
+ protected function _default_slug() {
91
+ $value = Options::get_option( Options::LEGAL_PAGES_SLUG );
92
+ if ( empty( $value ) ) {
93
+ $value = Options::default_value( Options::LEGAL_PAGES_SLUG );
94
+ }
95
+
96
+ return $value;
97
+ }
98
+
99
+ public function slug_fail( $x ) {
100
+ global $wp_rewrite;
101
+ $value = $this->_default_slug();
102
+ if ( $this->_license->status() === License::STATUS_FREE ) {
103
+ $dv = Options::default_value( Options::LEGAL_PAGES_SLUG );
104
+ if ( $value !== $dv ) {
105
+ Notices::add( __( 'Using free license, set pages slug to default.', WPAUTOTERMS_SLUG ), Notices::CLASS_ERROR );
106
+ $value = $dv;
107
+ }
108
+ } elseif ( $wp_rewrite->using_permalinks() ) {
109
+ Notices::add( sprintf( __( 'Invalid slug value, set to %s.', WPAUTOTERMS_SLUG ), $value ), Notices::CLASS_ERROR );
110
+ }
111
+
112
+ return $value;
113
  }
114
 
115
  public function defaults() {
116
+ return array_reduce( Options::all_options(), function ( $acc, $x ) {
117
+ $acc[ $x ] = Options::default_value( $x );
118
+ }, array() );
 
 
 
 
119
  }
120
 
121
  public function enqueue_scripts() {
includes/admin/slug-helper.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace wpautoterms\admin;
4
+
5
+ class Slug_Helper {
6
+ const TRANSIENT_NAME = 'slug_helper';
7
+
8
+ public function __construct() {
9
+ add_action( 'updated_option', array(
10
+ $this,
11
+ 'update_slugs'
12
+ ), 10, 3 );
13
+ add_action( 'admin_init', array( $this, 'init' ) );
14
+ }
15
+
16
+ public function init() {
17
+ if ( ! get_transient( $this->_transient_name() ) ) {
18
+ return;
19
+ }
20
+ delete_transient( $this->_transient_name() );
21
+ flush_rewrite_rules();
22
+ }
23
+
24
+ public function update_slugs( $name, $old_value, $value ) {
25
+ if ( $name === WPAUTOTERMS_OPTION_PREFIX . Options::LEGAL_PAGES_SLUG ) {
26
+ set_transient( $this->_transient_name(), true );
27
+ }
28
+ }
29
+
30
+ protected function _transient_name() {
31
+ return WPAUTOTERMS_OPTION_PREFIX . static::TRANSIENT_NAME;
32
+ }
33
+ }
includes/api/agreement.php CHANGED
@@ -70,8 +70,8 @@ class Agreement {
70
  $args['state'] = '';
71
  }
72
  } else {
73
- $args['country'] = Options::get_option( Options::OPTION_COUNTRY );
74
- $args['state'] = Options::get_option( Options::OPTION_STATE );
75
  }
76
  $headers = array( WPAUTOTERMS_API_KEY_HEADER . ': ' . $this->_license->api_key() );
77
  $resp = $this->_query->post_json( static::_EP_AGREEMENT . $agreement_id . '/', $args, $headers );
@@ -98,8 +98,8 @@ class Agreement {
98
  $headers = array( WPAUTOTERMS_API_KEY_HEADER . ': ' . $this->_license->api_key() );
99
  $data = array(
100
  'name' => $agreement_id,
101
- 'country' => Options::get_option( Options::OPTION_COUNTRY ),
102
- 'state' => Options::get_option( Options::OPTION_STATE ),
103
  'lang' => 'en',
104
  );
105
  $resp = $this->_query->get( Util::format( static::_EP_WIZARD, $data ), $params, $headers );
70
  $args['state'] = '';
71
  }
72
  } else {
73
+ $args['country'] = Options::get_option( Options::COUNTRY );
74
+ $args['state'] = Options::get_option( Options::STATE );
75
  }
76
  $headers = array( WPAUTOTERMS_API_KEY_HEADER . ': ' . $this->_license->api_key() );
77
  $resp = $this->_query->post_json( static::_EP_AGREEMENT . $agreement_id . '/', $args, $headers );
98
  $headers = array( WPAUTOTERMS_API_KEY_HEADER . ': ' . $this->_license->api_key() );
99
  $data = array(
100
  'name' => $agreement_id,
101
+ 'country' => Options::get_option( Options::COUNTRY ),
102
+ 'state' => Options::get_option( Options::STATE ),
103
  'lang' => 'en',
104
  );
105
  $resp = $this->_query->get( Util::format( static::_EP_WIZARD, $data ), $params, $headers );
includes/box/links-box.php CHANGED
@@ -35,7 +35,7 @@ class Links_Box extends Box {
35
 
36
  public function defaults() {
37
  return array(
38
- $this->id() => false,
39
  $this->id() . '_bg_color' => '#ffffff',
40
  $this->id() . '_font' => 'Arial, sans-serif',
41
  $this->id() . '_font_size' => '14px',
35
 
36
  public function defaults() {
37
  return array(
38
+ $this->id() => true,
39
  $this->id() . '_bg_color' => '#ffffff',
40
  $this->id() . '_font' => 'Arial, sans-serif',
41
  $this->id() . '_font_size' => '14px',
includes/countries.php CHANGED
@@ -101,8 +101,8 @@ abstract class Countries {
101
  false, false, true );
102
 
103
  wp_localize_script( WPAUTOTERMS_SLUG . '_countries', 'wpautotermsCountry', array(
104
- 'country' => Options::get_option( Options::OPTION_COUNTRY ),
105
- 'state' => Options::get_option( Options::OPTION_STATE ),
106
  'locale' => $ret[1]
107
  ) );
108
  }
101
  false, false, true );
102
 
103
  wp_localize_script( WPAUTOTERMS_SLUG . '_countries', 'wpautotermsCountry', array(
104
+ 'country' => Options::get_option( Options::COUNTRY ),
105
+ 'state' => Options::get_option( Options::STATE ),
106
  'locale' => $ret[1]
107
  ) );
108
  }
includes/cpt/cpt.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  namespace wpautoterms\cpt;
4
 
 
 
5
  if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
7
  }
@@ -15,6 +17,7 @@ abstract class CPT {
15
  static function init() {
16
  add_action( 'init', array( __CLASS__, 'add_caps' ) );
17
  add_filter( 'map_meta_cap', array( __CLASS__, 'map_meta_cap' ), 10, 4 );
 
18
  }
19
 
20
  static function get_default_caps() {
@@ -71,8 +74,8 @@ abstract class CPT {
71
 
72
  $args = array(
73
  'labels' => $labels,
74
- 'hierarchical' => false,
75
- 'supports' => array( 'title', 'editor', 'revisions' ),
76
  'public' => true,
77
  'show_ui' => true,
78
  //'show_in_nav_menus' => false,
@@ -82,7 +85,7 @@ abstract class CPT {
82
  'has_archive' => true,
83
  'query_var' => true,
84
  'can_export' => true,
85
- 'rewrite' => array( 'slug' => 'wpautoterms' ),
86
  'map_meta_cap' => true,
87
  'capability_type' => array( WPAUTOTERMS_CAP_SINGULAR, WPAUTOTERMS_CAP_PLURAL ),
88
  'menu_icon' => WPAUTOTERMS_PLUGIN_URL . 'images/icon.png',
@@ -139,4 +142,14 @@ abstract class CPT {
139
 
140
  }
141
 
 
 
 
 
 
 
 
 
 
 
142
  }
2
 
3
  namespace wpautoterms\cpt;
4
 
5
+ use wpautoterms\admin\Options;
6
+
7
  if ( ! defined( 'ABSPATH' ) ) {
8
  exit;
9
  }
17
  static function init() {
18
  add_action( 'init', array( __CLASS__, 'add_caps' ) );
19
  add_filter( 'map_meta_cap', array( __CLASS__, 'map_meta_cap' ), 10, 4 );
20
+ add_filter( 'theme_' . WPAUTOTERMS_CPT . '_templates', array( __CLASS__, 'filter_templates' ), 10, 2 );
21
  }
22
 
23
  static function get_default_caps() {
74
 
75
  $args = array(
76
  'labels' => $labels,
77
+ 'hierarchical' => true,
78
+ 'supports' => array( 'title', 'editor', 'revisions', 'page-attributes' ),
79
  'public' => true,
80
  'show_ui' => true,
81
  //'show_in_nav_menus' => false,
85
  'has_archive' => true,
86
  'query_var' => true,
87
  'can_export' => true,
88
+ 'rewrite' => array( 'slug' => Options::get_option( Options::LEGAL_PAGES_SLUG ) ),
89
  'map_meta_cap' => true,
90
  'capability_type' => array( WPAUTOTERMS_CAP_SINGULAR, WPAUTOTERMS_CAP_PLURAL ),
91
  'menu_icon' => WPAUTOTERMS_PLUGIN_URL . 'images/icon.png',
142
 
143
  }
144
 
145
+ /**
146
+ * @param [] $post_templates
147
+ * @param \WP_Theme $theme
148
+ *
149
+ * @return array
150
+ */
151
+ static function filter_templates( $post_templates, $theme ) {
152
+ return array_merge( $post_templates, $theme->get_page_templates() );
153
+ }
154
+
155
  }
includes/option/cpt-slug-option.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace wpautoterms\option;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ class CPT_Slug_Option extends Text_Option {
10
+ protected $_fail_handler;
11
+
12
+ public function set_fallback( $fail_handler = null ) {
13
+ $this->_fail_handler = $fail_handler;
14
+ }
15
+
16
+ public function sanitize( $input ) {
17
+ $value = sanitize_title( parent::sanitize( $input ) );
18
+ if ( empty( $value ) ) {
19
+ $value = call_user_func( $this->_fail_handler, $input );
20
+ }
21
+
22
+ return $value;
23
+ }
24
+ }
includes/shortcodes.php CHANGED
@@ -24,9 +24,9 @@ abstract class Shortcodes {
24
  static::$_root->add_subshortcode( new shortcode\Post_Link( 'page_link' ) );
25
  static::$_root->add_subshortcode( new shortcode\Post_Titles( 'page_titles' ) );
26
  static::$_root->add_subshortcode( new shortcode\Post_Links( 'page_links' ) );
27
- static::$_root->add_subshortcode( new shortcode\Option( $option_fn, Options::OPTION_COMPANY_NAME ) );
28
- static::$_root->add_subshortcode( new shortcode\Option( $option_fn, Options::OPTION_SITE_NAME ) );
29
- static::$_root->add_subshortcode( new shortcode\Option( $option_fn, Options::OPTION_SITE_URL ) );
30
  static::$_root->add_subshortcode( new Country_Option( $option_fn, Country_Option::TYPE_STATE ) );
31
  static::$_root->add_subshortcode( new Country_Option( $option_fn, Country_Option::TYPE_COUNTRY ) );
32
  }
24
  static::$_root->add_subshortcode( new shortcode\Post_Link( 'page_link' ) );
25
  static::$_root->add_subshortcode( new shortcode\Post_Titles( 'page_titles' ) );
26
  static::$_root->add_subshortcode( new shortcode\Post_Links( 'page_links' ) );
27
+ static::$_root->add_subshortcode( new shortcode\Option( $option_fn, Options::COMPANY_NAME ) );
28
+ static::$_root->add_subshortcode( new shortcode\Option( $option_fn, Options::SITE_NAME ) );
29
+ static::$_root->add_subshortcode( new shortcode\Option( $option_fn, Options::SITE_URL ) );
30
  static::$_root->add_subshortcode( new Country_Option( $option_fn, Country_Option::TYPE_STATE ) );
31
  static::$_root->add_subshortcode( new Country_Option( $option_fn, Country_Option::TYPE_COUNTRY ) );
32
  }
includes/upgrade.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace wpautoterms;
4
+
5
+ use wpautoterms\admin\Menu;
6
+ use wpautoterms\admin\Options;
7
+ use wpautoterms\admin\page\Legacy_Settings;
8
+
9
+ class Upgrade {
10
+ public function __construct() {
11
+ add_action( 'plugins_loaded', array( $this, 'run' ) );
12
+ }
13
+
14
+ public function run() {
15
+ if ( ! get_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED ) ) {
16
+ flush_rewrite_rules();
17
+ update_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED, true );
18
+ }
19
+ $version = get_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION );
20
+ if ( $version !== WPAUTOTERMS_VERSION ) {
21
+ $this->_upgrade_from_tos_pp();
22
+ $this->_add_slug_option();
23
+ update_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION, WPAUTOTERMS_VERSION );
24
+ }
25
+ }
26
+
27
+ protected function _upgrade_from_tos_pp() {
28
+ $version = get_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION );
29
+ if ( ! empty( $version ) ) {
30
+ $v = explode( '.', $version );
31
+ if ( intval( $v[0] ) > 1 ) {
32
+ return;
33
+ }
34
+ }
35
+ $options = get_option( Menu::AUTO_TOS_OPTIONS, false );
36
+ update_option( WPAUTOTERMS_OPTION_PREFIX . Menu::LEGACY_OPTIONS, $options !== false );
37
+ if ( $options === false ) {
38
+ return;
39
+ }
40
+ $transform = array_keys( Legacy_Settings::all_options() );
41
+ foreach ( $transform as $k ) {
42
+ if ( isset( $options[ $k ] ) ) {
43
+ $v = $options[ $k ];
44
+ } else {
45
+ $v = '';
46
+ }
47
+ update_option( WPAUTOTERMS_OPTION_PREFIX . $k, $v );
48
+ }
49
+ }
50
+
51
+ protected function _add_slug_option() {
52
+ $slug = Options::get_option( Options::LEGAL_PAGES_SLUG, true );
53
+ if ( empty( $slug ) ) {
54
+ Options::set_option( Options::LEGAL_PAGES_SLUG, Options::default_value( Options::LEGAL_PAGES_SLUG ) );
55
+ }
56
+ }
57
+ }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: gdpr, privacy policy, terms and conditions, terms of service, terms of use
4
  Requires at least: 4.2
5
  Tested up to: 4.9.7
6
  Requires PHP: 5.3
7
- Stable tag: 2.1.3
8
  License: GPL version 3 or any later version
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -113,6 +113,12 @@ Installing the plugin is easy. Just follow these steps:
113
 
114
  == Changelog ==
115
 
 
 
 
 
 
 
116
  = Version 2.1.3 =
117
  * Aug 6, 2018
118
  * Bugfix for "Plugin does not have a valid header"
@@ -222,4 +228,4 @@ Installing the plugin is easy. Just follow these steps:
222
  * Fixed link anchor text to use the name specified in the settings, to fix the issue of displaying hard coded "Terms of Use" and "Privacy Policy" anchor text in the table of contents for the [my_terms_of_service_and_privacy_policy] shortcode.
223
 
224
  = Version: 1.0.2012.09.12 =
225
- * Initial release.
4
  Requires at least: 4.2
5
  Tested up to: 4.9.7
6
  Requires PHP: 5.3
7
+ Stable tag: 2.1.4
8
  License: GPL version 3 or any later version
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
113
 
114
  == Changelog ==
115
 
116
+ = Version 2.1.4 =
117
+ * Aug 23, 2018
118
+ * Various bugfixes
119
+ * Allow to change the legal page slug
120
+ * Allow to change Page Template for created legal pages through Page Attributes widget
121
+
122
  = Version 2.1.3 =
123
  * Aug 6, 2018
124
  * Bugfix for "Plugin does not have a valid header"
228
  * Fixed link anchor text to use the name specified in the settings, to fix the issue of displaying hard coded "Terms of Use" and "Privacy Policy" anchor text in the table of contents for the [my_terms_of_service_and_privacy_policy] shortcode.
229
 
230
  = Version: 1.0.2012.09.12 =
231
+ * Initial release.
templates/legacy/terms-of-service.php CHANGED
@@ -199,7 +199,7 @@
199
  <li><strong>Domain Names.</strong> If you are registering a domain name, using or transferring a previously
200
  registered domain name, you acknowledge and agree that use of the domain name is also subject to the
201
  policies of the Internet Corporation for Assigned Names and Numbers (&quot;ICANN&quot;), including their <a
202
- href=\"http://www.icann.org/en/registrars/registrant-rights-responsibilities-en.htm\">Registration
203
  Rights and Responsibilities</a>.
204
  </li>
205
  <li><strong>Changes. </strong><?php echo $atospp_name; ?> reserves the right, at its sole discretion, to modify
199
  <li><strong>Domain Names.</strong> If you are registering a domain name, using or transferring a previously
200
  registered domain name, you acknowledge and agree that use of the domain name is also subject to the
201
  policies of the Internet Corporation for Assigned Names and Numbers (&quot;ICANN&quot;), including their <a
202
+ href='http://www.icann.org/en/registrars/registrant-rights-responsibilities-en.htm'>Registration
203
  Rights and Responsibilities</a>.
204
  </li>
205
  <li><strong>Changes. </strong><?php echo $atospp_name; ?> reserves the right, at its sole discretion, to modify
templates/pages/contact.php CHANGED
@@ -8,8 +8,8 @@ if ( ! defined( 'ABSPATH' ) ) {
8
  }
9
  $current_user = wp_get_current_user();
10
  $data = $page->action->get_data();
11
- $site_name = Options::get_option( Options::OPTION_SITE_NAME );
12
- $site_url = Options::get_option( Options::OPTION_SITE_URL );
13
  $email = $current_user->user_email;
14
  $site_info = Send_Message::DEFAULT_SITE_INFO;
15
  $text = '';
@@ -116,8 +116,8 @@ if ( ! empty( $data ) ) {
116
  </tbody>
117
  </table>
118
  <div class="wpautoterms-hidden wpautoterms-form-errors" data-name="form"
119
- data-type="notice"><?php _e( 'Please, fill all form fields to submit.', WPAUTOTERMS_SLUG ); ?></div>
120
- <div><?php _e( 'You will be redirected to WPAutoTerms website to complete form submission.', WPAUTOTERMS_SLUG ); ?></div>
121
 
122
  <p class="submit">
123
  <input name="submit_button" data-pending="1" class="button button-primary" value="Send message"
8
  }
9
  $current_user = wp_get_current_user();
10
  $data = $page->action->get_data();
11
+ $site_name = Options::get_option( Options::SITE_NAME );
12
+ $site_url = Options::get_option( Options::SITE_URL );
13
  $email = $current_user->user_email;
14
  $site_info = Send_Message::DEFAULT_SITE_INFO;
15
  $text = '';
116
  </tbody>
117
  </table>
118
  <div class="wpautoterms-hidden wpautoterms-form-errors" data-name="form"
119
+ data-type="notice"><?php _e( 'Please fill in the required information in order to send the message.', WPAUTOTERMS_SLUG ); ?></div>
120
+ <div><?php _e( 'You will be redirected to WPAutoTerms website to complete this form submission.', WPAUTOTERMS_SLUG ); ?></div>
121
 
122
  <p class="submit">
123
  <input name="submit_button" data-pending="1" class="button button-primary" value="Send message"