Version Description
Download this release
Release Info
Developer | wpautoterms |
Plugin | Auto Terms of Service and Privacy Policy |
Version | 2.1.9 |
Comparing to | |
See all releases |
Code changes from version 2.1.8 to 2.1.9
- README.txt +7 -1
- api.php +1 -1
- auto-terms-of-service-privacy-policy.php +3 -1
- css/wpautoterms.css +6 -0
- includes/admin/admin.php +9 -8
- includes/admin/form/legal-page.php +2 -1
- includes/admin/menu.php +3 -2
- includes/admin/page/base.php +4 -2
- includes/box/box.php +2 -1
- includes/box/cookies-notice-box.php +2 -1
- includes/box/links-box.php +4 -1
- includes/box/update-notice-box.php +2 -1
- includes/cpt/admin-columns.php +4 -4
- includes/cpt/cpt.php +64 -63
- includes/frontend.php +116 -0
- includes/frontend/links.php +16 -4
- includes/frontend/notice/base-notice.php +2 -2
- includes/frontend/notice/update-notice.php +3 -1
- includes/legacy-shortcodes.php +2 -1
- includes/upgrade.php +33 -15
- includes/wpautoterms.php +1 -67
- templates/auto-draft.php +1 -1
- templates/links.php +3 -8
- templates/options/box-page.php +1 -1
- templates/options/box.php +1 -1
- templates/pages/contact.php +1 -1
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.
|
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.8 =
|
117 |
* Sep 9, 2018
|
118 |
* Bugfix for loading plugin scripts regardless of third party scripts
|
4 |
Requires at least: 4.2
|
5 |
Tested up to: 4.9.7
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 2.1.9
|
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.9 =
|
117 |
+
* Sep 23, 2018
|
118 |
+
* Add z-index values to prevent theme issues
|
119 |
+
* Add a new option for Links to Legal Pages Compliance Kit: open in a new tab
|
120 |
+
* Various bugfixes under the hood
|
121 |
+
|
122 |
= Version 2.1.8 =
|
123 |
* Sep 9, 2018
|
124 |
* Bugfix for loading plugin scripts regardless of third party scripts
|
api.php
CHANGED
@@ -12,5 +12,5 @@ define( 'WPAUTOTERMS_PURCHASE_URL', 'https://app.wpautoterms.com/product/v1/buy'
|
|
12 |
| DO NOT MODIFY
|
13 |
|
|
14 |
*/
|
15 |
-
//define( 'WPAUTOTERMS_API_URL', 'http://127.0.0.1:5000/' );
|
16 |
//define( 'WPAUTOTERMS_PURCHASE_URL', 'http://127.0.0.1:5000/product/v1/buy' );
|
12 |
| DO NOT MODIFY
|
13 |
|
|
14 |
*/
|
15 |
+
// define( 'WPAUTOTERMS_API_URL', 'http://127.0.0.1:5000/' );
|
16 |
//define( 'WPAUTOTERMS_PURCHASE_URL', 'http://127.0.0.1:5000/product/v1/buy' );
|
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.
|
9 |
License: GPLv2 or later
|
10 |
Text Domain: wpautoterms
|
11 |
Domain Path: /languages
|
@@ -123,4 +123,6 @@ $license = new License( $query );
|
|
123 |
Wpautoterms::init( $license, $query );
|
124 |
if ( is_admin() ) {
|
125 |
Admin::init( $license, $query );
|
|
|
|
|
126 |
}
|
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.9
|
9 |
License: GPLv2 or later
|
10 |
Text Domain: wpautoterms
|
11 |
Domain Path: /languages
|
123 |
Wpautoterms::init( $license, $query );
|
124 |
if ( is_admin() ) {
|
125 |
Admin::init( $license, $query );
|
126 |
+
} else {
|
127 |
+
Frontend::init( $license );
|
128 |
}
|
css/wpautoterms.css
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
.wpautoterms-footer {
|
2 |
display:block;
|
3 |
width:100%;
|
|
|
|
|
4 |
}
|
5 |
|
6 |
.wpautoterms-footer a:hover {
|
@@ -21,8 +23,12 @@
|
|
21 |
|
22 |
#wpautoterms-top-static-container {
|
23 |
width:100%;
|
|
|
|
|
24 |
}
|
25 |
|
26 |
#wpautoterms-bottom-static-container {
|
27 |
width:100%;
|
|
|
|
|
28 |
}
|
1 |
.wpautoterms-footer {
|
2 |
display:block;
|
3 |
width:100%;
|
4 |
+
position:relative;
|
5 |
+
z-index:10000002;
|
6 |
}
|
7 |
|
8 |
.wpautoterms-footer a:hover {
|
23 |
|
24 |
#wpautoterms-top-static-container {
|
25 |
width:100%;
|
26 |
+
position:relative;
|
27 |
+
z-index:10000002;
|
28 |
}
|
29 |
|
30 |
#wpautoterms-bottom-static-container {
|
31 |
width:100%;
|
32 |
+
position:relative;
|
33 |
+
z-index:10000002;
|
34 |
}
|
includes/admin/admin.php
CHANGED
@@ -13,6 +13,7 @@ use wpautoterms\api\License;
|
|
13 |
use wpautoterms\api\Query;
|
14 |
use wpautoterms\Countries;
|
15 |
use wpautoterms\cpt\Admin_Columns;
|
|
|
16 |
use wpautoterms\Upgrade;
|
17 |
use wpautoterms\Wpautoterms;
|
18 |
|
@@ -50,11 +51,11 @@ abstract class Admin {
|
|
50 |
|
51 |
Notices::init( WPAUTOTERMS_OPTION_PREFIX . 'notices' );
|
52 |
|
53 |
-
$recheck_action = new Recheck_License(
|
54 |
$recheck_action->set_license_query( static::$_license );
|
55 |
|
56 |
// TODO: extract warnings class
|
57 |
-
static::$_warning_action = new Set_Option(
|
58 |
static::$_warning_action->set_option_name( 'settings_warning_disable' );
|
59 |
|
60 |
Admin_Columns::init();
|
@@ -65,7 +66,7 @@ abstract class Admin {
|
|
65 |
public static function add_meta_boxes() {
|
66 |
global $post;
|
67 |
|
68 |
-
if ( empty( $post ) || ( $post->post_type !=
|
69 |
return;
|
70 |
}
|
71 |
|
@@ -73,7 +74,7 @@ abstract class Admin {
|
|
73 |
}
|
74 |
|
75 |
public static function remove_permalink( $permalink, $post_id, $new_title, $new_slug, $post ) {
|
76 |
-
if ( $post->post_type !=
|
77 |
return $permalink;
|
78 |
}
|
79 |
|
@@ -81,7 +82,7 @@ abstract class Admin {
|
|
81 |
}
|
82 |
|
83 |
public static function edit_form_top( $post ) {
|
84 |
-
if ( $post->post_type !=
|
85 |
return;
|
86 |
}
|
87 |
|
@@ -97,7 +98,7 @@ abstract class Admin {
|
|
97 |
}
|
98 |
if ( $page === false ) {
|
99 |
global $wpdb;
|
100 |
-
$cpt =
|
101 |
$cases = array();
|
102 |
foreach ( Wpautoterms::get_legal_pages() as $page ) {
|
103 |
$id = $page->id();
|
@@ -125,7 +126,7 @@ abstract class Admin {
|
|
125 |
}
|
126 |
|
127 |
public static function row_actions( $actions, $post ) {
|
128 |
-
if ( (
|
129 |
$link = get_post_permalink( $post->ID );
|
130 |
$short_link = preg_replace( '/https?:\/\//i', '', trim( $link, '/' ) );
|
131 |
$info = '<a href="' . $link . '">' . $short_link . '</a>';
|
@@ -137,7 +138,7 @@ abstract class Admin {
|
|
137 |
|
138 |
public static function enqueue_scripts( $page ) {
|
139 |
global $post;
|
140 |
-
if ( ! empty( $post ) && ( $post->post_type ==
|
141 |
// NOTE: load media scripts in case 3-rd party plugin fails to enqueue them properly.
|
142 |
$scripts = wp_scripts();
|
143 |
if ( ! empty( $scripts->queue ) ) {
|
13 |
use wpautoterms\api\Query;
|
14 |
use wpautoterms\Countries;
|
15 |
use wpautoterms\cpt\Admin_Columns;
|
16 |
+
use wpautoterms\cpt\CPT;
|
17 |
use wpautoterms\Upgrade;
|
18 |
use wpautoterms\Wpautoterms;
|
19 |
|
51 |
|
52 |
Notices::init( WPAUTOTERMS_OPTION_PREFIX . 'notices' );
|
53 |
|
54 |
+
$recheck_action = new Recheck_License( CPT::edit_cap(), null, '', null, __( 'Access denied', WPAUTOTERMS_SLUG ) );
|
55 |
$recheck_action->set_license_query( static::$_license );
|
56 |
|
57 |
// TODO: extract warnings class
|
58 |
+
static::$_warning_action = new Set_Option( CPT::edit_cap(), null, 'settings_warning_disable' );
|
59 |
static::$_warning_action->set_option_name( 'settings_warning_disable' );
|
60 |
|
61 |
Admin_Columns::init();
|
66 |
public static function add_meta_boxes() {
|
67 |
global $post;
|
68 |
|
69 |
+
if ( empty( $post ) || ( $post->post_type != CPT::type() ) ) {
|
70 |
return;
|
71 |
}
|
72 |
|
74 |
}
|
75 |
|
76 |
public static function remove_permalink( $permalink, $post_id, $new_title, $new_slug, $post ) {
|
77 |
+
if ( $post->post_type != CPT::type() ) {
|
78 |
return $permalink;
|
79 |
}
|
80 |
|
82 |
}
|
83 |
|
84 |
public static function edit_form_top( $post ) {
|
85 |
+
if ( $post->post_type != CPT::type() ) {
|
86 |
return;
|
87 |
}
|
88 |
|
98 |
}
|
99 |
if ( $page === false ) {
|
100 |
global $wpdb;
|
101 |
+
$cpt = CPT::type();
|
102 |
$cases = array();
|
103 |
foreach ( Wpautoterms::get_legal_pages() as $page ) {
|
104 |
$id = $page->id();
|
126 |
}
|
127 |
|
128 |
public static function row_actions( $actions, $post ) {
|
129 |
+
if ( ( CPT::type() == get_post_type( $post ) ) && ( $post->post_status == 'publish' ) ) {
|
130 |
$link = get_post_permalink( $post->ID );
|
131 |
$short_link = preg_replace( '/https?:\/\//i', '', trim( $link, '/' ) );
|
132 |
$info = '<a href="' . $link . '">' . $short_link . '</a>';
|
138 |
|
139 |
public static function enqueue_scripts( $page ) {
|
140 |
global $post;
|
141 |
+
if ( ! empty( $post ) && ( $post->post_type == CPT::type() ) ) {
|
142 |
// NOTE: load media scripts in case 3-rd party plugin fails to enqueue them properly.
|
143 |
$scripts = wp_scripts();
|
144 |
if ( ! empty( $scripts->queue ) ) {
|
includes/admin/form/legal-page.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
namespace wpautoterms\admin\form;
|
4 |
|
5 |
use wpautoterms\Countries;
|
|
|
6 |
|
7 |
class Legal_Page {
|
8 |
protected $_id;
|
@@ -87,7 +88,7 @@ class Legal_Page {
|
|
87 |
|
88 |
public function save_post( $post_id ) {
|
89 |
$post = get_post( $post_id );
|
90 |
-
if ( (
|
91 |
return;
|
92 |
}
|
93 |
$legal_page = sanitize_text_field( $_POST['legal_page'] );
|
3 |
namespace wpautoterms\admin\form;
|
4 |
|
5 |
use wpautoterms\Countries;
|
6 |
+
use wpautoterms\cpt\CPT;
|
7 |
|
8 |
class Legal_Page {
|
9 |
protected $_id;
|
88 |
|
89 |
public function save_post( $post_id ) {
|
90 |
$post = get_post( $post_id );
|
91 |
+
if ( ( CPT::type() != $post->post_type ) || ! isset( $_POST['legal_page'] ) ) {
|
92 |
return;
|
93 |
}
|
94 |
$legal_page = sanitize_text_field( $_POST['legal_page'] );
|
includes/admin/menu.php
CHANGED
@@ -11,6 +11,7 @@ use wpautoterms\admin\page\License_Settings;
|
|
11 |
use wpautoterms\admin\page\Settings_Page;
|
12 |
use wpautoterms\admin\page;
|
13 |
use wpautoterms\api;
|
|
|
14 |
|
15 |
if ( ! defined( 'ABSPATH' ) ) {
|
16 |
exit;
|
@@ -57,7 +58,7 @@ abstract class Menu {
|
|
57 |
__( 'License', WPAUTOTERMS_SLUG ) );
|
58 |
$ls->set_license( $license );
|
59 |
$contact = new page\Contact( static::PAGE_CONTACT, __( 'Contact', WPAUTOTERMS_SLUG ) );
|
60 |
-
$sm = new Send_Message(
|
61 |
__( 'Access denied', WPAUTOTERMS_SLUG ), true );
|
62 |
$contact->action = $sm;
|
63 |
$sp = new Settings_Page( static::PAGE_SETTINGS, __( 'Settings', WPAUTOTERMS_SLUG ) );
|
@@ -90,7 +91,7 @@ abstract class Menu {
|
|
90 |
}
|
91 |
|
92 |
public static function enqueue_scripts( $page ) {
|
93 |
-
$prefix =
|
94 |
if ( 0 != strncmp( $page, $prefix, strlen( $prefix ) ) ) {
|
95 |
return;
|
96 |
}
|
11 |
use wpautoterms\admin\page\Settings_Page;
|
12 |
use wpautoterms\admin\page;
|
13 |
use wpautoterms\api;
|
14 |
+
use wpautoterms\cpt\CPT;
|
15 |
|
16 |
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
exit;
|
58 |
__( 'License', WPAUTOTERMS_SLUG ) );
|
59 |
$ls->set_license( $license );
|
60 |
$contact = new page\Contact( static::PAGE_CONTACT, __( 'Contact', WPAUTOTERMS_SLUG ) );
|
61 |
+
$sm = new Send_Message( CPT::edit_cap(), null, $contact->id(), null,
|
62 |
__( 'Access denied', WPAUTOTERMS_SLUG ), true );
|
63 |
$contact->action = $sm;
|
64 |
$sp = new Settings_Page( static::PAGE_SETTINGS, __( 'Settings', WPAUTOTERMS_SLUG ) );
|
91 |
}
|
92 |
|
93 |
public static function enqueue_scripts( $page ) {
|
94 |
+
$prefix = CPT::type() . '_page_';
|
95 |
if ( 0 != strncmp( $page, $prefix, strlen( $prefix ) ) ) {
|
96 |
return;
|
97 |
}
|
includes/admin/page/base.php
CHANGED
@@ -2,6 +2,8 @@
|
|
2 |
|
3 |
namespace wpautoterms\admin\page;
|
4 |
|
|
|
|
|
5 |
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
exit;
|
7 |
}
|
@@ -30,10 +32,10 @@ class Base {
|
|
30 |
}
|
31 |
|
32 |
public function register_menu() {
|
33 |
-
add_submenu_page( 'edit.php?post_type=' .
|
34 |
$this->title(),
|
35 |
$this->menu_title(),
|
36 |
-
|
37 |
$this->id(),
|
38 |
array( $this, 'render' )
|
39 |
);
|
2 |
|
3 |
namespace wpautoterms\admin\page;
|
4 |
|
5 |
+
use wpautoterms\cpt\CPT;
|
6 |
+
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
exit;
|
9 |
}
|
32 |
}
|
33 |
|
34 |
public function register_menu() {
|
35 |
+
add_submenu_page( 'edit.php?post_type=' . CPT::type(),
|
36 |
$this->title(),
|
37 |
$this->menu_title(),
|
38 |
+
CPT::edit_cap(),
|
39 |
$this->id(),
|
40 |
array( $this, 'render' )
|
41 |
);
|
includes/box/box.php
CHANGED
@@ -4,6 +4,7 @@ namespace wpautoterms\box;
|
|
4 |
|
5 |
use wpautoterms\admin\action\Toggle_Action;
|
6 |
use wpautoterms\admin\page;
|
|
|
7 |
use wpautoterms\option\Text_Option;
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -18,7 +19,7 @@ abstract class Box {
|
|
18 |
|
19 |
public function __construct( $id, $title, $infotip ) {
|
20 |
$this->_id = $id;
|
21 |
-
$this->_action = new Toggle_Action(
|
22 |
$this->_action->set_option_name( $this->_enabled_option() );
|
23 |
$this->_title = $title;
|
24 |
$this->_infotip = $infotip;
|
4 |
|
5 |
use wpautoterms\admin\action\Toggle_Action;
|
6 |
use wpautoterms\admin\page;
|
7 |
+
use wpautoterms\cpt\CPT;
|
8 |
use wpautoterms\option\Text_Option;
|
9 |
|
10 |
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
|
20 |
public function __construct( $id, $title, $infotip ) {
|
21 |
$this->_id = $id;
|
22 |
+
$this->_action = new Toggle_Action( CPT::edit_cap(), null, $this->enable_action_id() );
|
23 |
$this->_action->set_option_name( $this->_enabled_option() );
|
24 |
$this->_title = $title;
|
25 |
$this->_infotip = $infotip;
|
includes/box/cookies-notice-box.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
namespace wpautoterms\box;
|
4 |
|
5 |
use wpautoterms\admin\Menu;
|
|
|
6 |
use wpautoterms\option;
|
7 |
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -47,7 +48,7 @@ class Cookies_Notice_Box extends Licensed_Box {
|
|
47 |
public function define_options( $page_id, $section_id ) {
|
48 |
parent::define_options( $page_id, $section_id );
|
49 |
|
50 |
-
if ( current_user_can(
|
51 |
// new option\Checkbox_Option( $this->id() . '_test_mode', __( 'Test mode', WPAUTOTERMS_SLUG ),
|
52 |
// __( 'Show sample box to admin', WPAUTOTERMS_SLUG ), $page_id, $section_id );
|
53 |
}
|
3 |
namespace wpautoterms\box;
|
4 |
|
5 |
use wpautoterms\admin\Menu;
|
6 |
+
use wpautoterms\cpt\CPT;
|
7 |
use wpautoterms\option;
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
48 |
public function define_options( $page_id, $section_id ) {
|
49 |
parent::define_options( $page_id, $section_id );
|
50 |
|
51 |
+
if ( current_user_can( CPT::edit_cap() ) ) {
|
52 |
// new option\Checkbox_Option( $this->id() . '_test_mode', __( 'Test mode', WPAUTOTERMS_SLUG ),
|
53 |
// __( 'Show sample box to admin', WPAUTOTERMS_SLUG ), $page_id, $section_id );
|
54 |
}
|
includes/box/links-box.php
CHANGED
@@ -30,7 +30,9 @@ class Links_Box extends Box {
|
|
30 |
new option\Color_Option( $this->id() . '_links_color', __( 'Links color', WPAUTOTERMS_SLUG ), '', $page_id, $section_id );
|
31 |
new option\Text_Option( $this->id() . '_separator', __( 'Links separator', WPAUTOTERMS_SLUG ), '',
|
32 |
$page_id, $section_id );
|
33 |
-
$this->
|
|
|
|
|
34 |
}
|
35 |
|
36 |
public function defaults() {
|
@@ -43,6 +45,7 @@ class Links_Box extends Box {
|
|
43 |
$this->id() . '_text_align' => 'center',
|
44 |
$this->id() . '_links_color' => '#000000',
|
45 |
$this->id() . '_separator' => '-',
|
|
|
46 |
);
|
47 |
}
|
48 |
}
|
30 |
new option\Color_Option( $this->id() . '_links_color', __( 'Links color', WPAUTOTERMS_SLUG ), '', $page_id, $section_id );
|
31 |
new option\Text_Option( $this->id() . '_separator', __( 'Links separator', WPAUTOTERMS_SLUG ), '',
|
32 |
$page_id, $section_id );
|
33 |
+
new option\Checkbox_Option( $this->id() . '_target_blank', __( 'Links to open in a new page', WPAUTOTERMS_SLUG ),
|
34 |
+
'', $page_id, $section_id );
|
35 |
+
$this->_custom_css_options( $page_id, $section_id );
|
36 |
}
|
37 |
|
38 |
public function defaults() {
|
45 |
$this->id() . '_text_align' => 'center',
|
46 |
$this->id() . '_links_color' => '#000000',
|
47 |
$this->id() . '_separator' => '-',
|
48 |
+
$this->id() . '_target_blank' => false,
|
49 |
);
|
50 |
}
|
51 |
}
|
includes/box/update-notice-box.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
namespace wpautoterms\box;
|
4 |
|
5 |
use wpautoterms\admin\Menu;
|
|
|
6 |
use wpautoterms\option;
|
7 |
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -53,7 +54,7 @@ class Update_Notice_Box extends Box {
|
|
53 |
function define_options( $page_id, $section_id ) {
|
54 |
new option\Checkbox_Option( $this->id(), __( 'Enabled', WPAUTOTERMS_SLUG ), '', $page_id, $section_id );
|
55 |
|
56 |
-
if ( current_user_can(
|
57 |
// new option\Checkbox_Option( $this->id() . '_test_mode', __( 'Test mode', WPAUTOTERMS_SLUG ),
|
58 |
// __( 'Show sample box to admin', WPAUTOTERMS_SLUG ), $page_id, $section_id );
|
59 |
}
|
3 |
namespace wpautoterms\box;
|
4 |
|
5 |
use wpautoterms\admin\Menu;
|
6 |
+
use wpautoterms\cpt\CPT;
|
7 |
use wpautoterms\option;
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
54 |
function define_options( $page_id, $section_id ) {
|
55 |
new option\Checkbox_Option( $this->id(), __( 'Enabled', WPAUTOTERMS_SLUG ), '', $page_id, $section_id );
|
56 |
|
57 |
+
if ( current_user_can( CPT::edit_cap() ) ) {
|
58 |
// new option\Checkbox_Option( $this->id() . '_test_mode', __( 'Test mode', WPAUTOTERMS_SLUG ),
|
59 |
// __( 'Show sample box to admin', WPAUTOTERMS_SLUG ), $page_id, $section_id );
|
60 |
}
|
includes/cpt/admin-columns.php
CHANGED
@@ -14,13 +14,13 @@ abstract class Admin_Columns {
|
|
14 |
const COL_DATE = 'date';
|
15 |
|
16 |
static function init() {
|
17 |
-
add_filter( 'manage_edit-' .
|
18 |
-
add_filter( 'manage_edit-' .
|
19 |
__CLASS__,
|
20 |
'sortable_columns'
|
21 |
) );
|
22 |
add_filter( 'display_post_states', array( __CLASS__, 'display_post_states' ), 10, 2 );
|
23 |
-
add_action( 'manage_' .
|
24 |
array( __CLASS__, 'manage_columns' ),
|
25 |
10,
|
26 |
2 );
|
@@ -58,7 +58,7 @@ abstract class Admin_Columns {
|
|
58 |
}
|
59 |
|
60 |
static function display_post_states( $post_states, $post ) {
|
61 |
-
if ( $post->post_type ==
|
62 |
return array();
|
63 |
}
|
64 |
|
14 |
const COL_DATE = 'date';
|
15 |
|
16 |
static function init() {
|
17 |
+
add_filter( 'manage_edit-' . CPT::type() . '_columns', array( __CLASS__, 'edit_columns' ) );
|
18 |
+
add_filter( 'manage_edit-' . CPT::type() . '_sortable_columns', array(
|
19 |
__CLASS__,
|
20 |
'sortable_columns'
|
21 |
) );
|
22 |
add_filter( 'display_post_states', array( __CLASS__, 'display_post_states' ), 10, 2 );
|
23 |
+
add_action( 'manage_' . CPT::type() . '_posts_custom_column',
|
24 |
array( __CLASS__, 'manage_columns' ),
|
25 |
10,
|
26 |
2 );
|
58 |
}
|
59 |
|
60 |
static function display_post_states( $post_states, $post ) {
|
61 |
+
if ( $post->post_type == CPT::type() ) {
|
62 |
return array();
|
63 |
}
|
64 |
|
includes/cpt/cpt.php
CHANGED
@@ -8,55 +8,50 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
8 |
exit;
|
9 |
}
|
10 |
|
11 |
-
define( 'WPAUTOTERMS_CPT', WPAUTOTERMS_SLUG . '_page' );
|
12 |
-
define( 'WPAUTOTERMS_CAP_SINGULAR', WPAUTOTERMS_SLUG . '_page' );
|
13 |
-
define( 'WPAUTOTERMS_CAP_PLURAL', WPAUTOTERMS_SLUG . '_pages' );
|
14 |
|
15 |
abstract class CPT {
|
|
|
|
|
16 |
|
17 |
-
static function init() {
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
-
static function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
return array(
|
29 |
-
'
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
'delete_published_' . WPAUTOTERMS_CAP_PLURAL => true,
|
40 |
-
'publish_' . WPAUTOTERMS_CAP_PLURAL => true,
|
41 |
-
),
|
42 |
-
'subscriber' => array(
|
43 |
-
'edit_' . WPAUTOTERMS_CAP_PLURAL => false,
|
44 |
-
'edit_others_' . WPAUTOTERMS_CAP_PLURAL => false,
|
45 |
-
'edit_private_' . WPAUTOTERMS_CAP_PLURAL => false,
|
46 |
-
'edit_published_' . WPAUTOTERMS_CAP_PLURAL => false,
|
47 |
-
'read_' . WPAUTOTERMS_CAP_PLURAL => true,
|
48 |
-
'read_private_' . WPAUTOTERMS_CAP_PLURAL => false,
|
49 |
-
'delete_' . WPAUTOTERMS_CAP_PLURAL => false,
|
50 |
-
'delete_others_' . WPAUTOTERMS_CAP_PLURAL => false,
|
51 |
-
'delete_private_' . WPAUTOTERMS_CAP_PLURAL => false,
|
52 |
-
'delete_published_' . WPAUTOTERMS_CAP_PLURAL => false,
|
53 |
-
'publish_' . WPAUTOTERMS_CAP_PLURAL => false,
|
54 |
-
),
|
55 |
);
|
56 |
}
|
57 |
|
58 |
-
static function register() {
|
59 |
-
|
60 |
$labels = array(
|
61 |
'name' => __( 'Legal Pages', WPAUTOTERMS_SLUG ),
|
62 |
'all_items' => __( 'All Legal Pages', WPAUTOTERMS_SLUG ),
|
@@ -76,6 +71,9 @@ abstract class CPT {
|
|
76 |
'menu_name' => __( 'WP AutoTerms', WPAUTOTERMS_SLUG ),
|
77 |
);
|
78 |
|
|
|
|
|
|
|
79 |
$args = array(
|
80 |
'labels' => $labels,
|
81 |
'hierarchical' => true,
|
@@ -91,45 +89,48 @@ abstract class CPT {
|
|
91 |
'can_export' => true,
|
92 |
'rewrite' => array( 'slug' => Options::get_option( Options::LEGAL_PAGES_SLUG ) ),
|
93 |
'map_meta_cap' => true,
|
94 |
-
'capability_type' => array(
|
95 |
'menu_icon' => WPAUTOTERMS_PLUGIN_URL . 'images/icon.png',
|
96 |
'show_admin_column' => true,
|
97 |
);
|
98 |
|
99 |
-
register_post_type(
|
100 |
}
|
101 |
|
102 |
-
static function
|
103 |
-
$
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
$caps = $default_caps['subscriber'];
|
115 |
-
}
|
116 |
-
$mo = $role->has_cap( 'manage_options' );
|
117 |
-
foreach ( $caps as $cap => $grant ) {
|
118 |
-
if ( ! isset( $wp_roles->roles[ $role_name ]['capabilities'][ $cap ] ) ) {
|
119 |
-
$wp_roles->add_cap( $role_name, $cap, $grant || $mo );
|
120 |
-
}
|
121 |
}
|
122 |
}
|
123 |
}
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
/**
|
126 |
* @param [] $post_templates
|
127 |
* @param \WP_Theme $theme
|
128 |
*
|
129 |
* @return array
|
130 |
*/
|
131 |
-
static function filter_templates( $post_templates, $theme ) {
|
132 |
return array_merge( $post_templates, $theme->get_page_templates() );
|
133 |
}
|
134 |
-
|
135 |
}
|
8 |
exit;
|
9 |
}
|
10 |
|
|
|
|
|
|
|
11 |
|
12 |
abstract class CPT {
|
13 |
+
const ROLE = 'manage_wpautoterms_pages';
|
14 |
+
const ADD_TO_ROLE = 'administrator';
|
15 |
|
16 |
+
public static function init() {
|
17 |
+
add_filter( 'theme_' . static::type() . '_templates', array( __CLASS__, 'filter_templates' ), 10, 2 );
|
18 |
+
add_action( 'user_register', array( __CLASS__, 'add_role' ), 10, 1 );
|
19 |
+
}
|
20 |
+
|
21 |
+
public static function edit_cap() {
|
22 |
+
return 'edit_' . static::cap_plural();
|
23 |
+
}
|
24 |
+
|
25 |
+
public static function type() {
|
26 |
+
return WPAUTOTERMS_SLUG . '_page';
|
27 |
}
|
28 |
|
29 |
+
public static function cap_singular() {
|
30 |
+
return WPAUTOTERMS_SLUG . '_page';
|
31 |
+
}
|
32 |
+
|
33 |
+
public static function cap_plural() {
|
34 |
+
return WPAUTOTERMS_SLUG . '_pages';
|
35 |
+
}
|
36 |
+
|
37 |
+
public static function caps() {
|
38 |
+
$p = static::cap_plural();
|
39 |
+
|
40 |
return array(
|
41 |
+
'edit_' . $p => true,
|
42 |
+
'edit_others_' . $p => true,
|
43 |
+
'edit_private_' . $p => true,
|
44 |
+
'edit_published_' . $p => true,
|
45 |
+
'read_private_' . $p => true,
|
46 |
+
'delete_' . $p => true,
|
47 |
+
'delete_others_' . $p => true,
|
48 |
+
'delete_private_' . $p => true,
|
49 |
+
'delete_published_' . $p => true,
|
50 |
+
'publish_' . $p => true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
);
|
52 |
}
|
53 |
|
54 |
+
public static function register() {
|
|
|
55 |
$labels = array(
|
56 |
'name' => __( 'Legal Pages', WPAUTOTERMS_SLUG ),
|
57 |
'all_items' => __( 'All Legal Pages', WPAUTOTERMS_SLUG ),
|
71 |
'menu_name' => __( 'WP AutoTerms', WPAUTOTERMS_SLUG ),
|
72 |
);
|
73 |
|
74 |
+
$cs = static::cap_singular();
|
75 |
+
$cp = static::cap_plural();
|
76 |
+
|
77 |
$args = array(
|
78 |
'labels' => $labels,
|
79 |
'hierarchical' => true,
|
89 |
'can_export' => true,
|
90 |
'rewrite' => array( 'slug' => Options::get_option( Options::LEGAL_PAGES_SLUG ) ),
|
91 |
'map_meta_cap' => true,
|
92 |
+
'capability_type' => array( static::cap_singular(), static::cap_plural() ),
|
93 |
'menu_icon' => WPAUTOTERMS_PLUGIN_URL . 'images/icon.png',
|
94 |
'show_admin_column' => true,
|
95 |
);
|
96 |
|
97 |
+
register_post_type( static::type(), $args );
|
98 |
}
|
99 |
|
100 |
+
public static function register_role() {
|
101 |
+
$role = add_role( static::ROLE, __( 'WPAutoTerms Legal pages editor' ), static::caps() );
|
102 |
+
if ( $role === null ) {
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
$users = get_users( array( 'role' => static::ADD_TO_ROLE ) );
|
106 |
+
if ( ! empty( $users ) ) {
|
107 |
+
/**
|
108 |
+
* @var $user \WP_User
|
109 |
+
*/
|
110 |
+
foreach ( $users as $user ) {
|
111 |
+
$user->add_role( static::ROLE );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
}
|
114 |
}
|
115 |
|
116 |
+
public static function unregister_role() {
|
117 |
+
remove_role( static::ROLE );
|
118 |
+
}
|
119 |
+
|
120 |
+
public static function add_role( $user_id ) {
|
121 |
+
$user = get_user_by( 'id', $user_id );
|
122 |
+
if ( in_array( static::ADD_TO_ROLE, $user->roles ) ) {
|
123 |
+
$user->add_role( static::ROLE );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
/**
|
128 |
* @param [] $post_templates
|
129 |
* @param \WP_Theme $theme
|
130 |
*
|
131 |
* @return array
|
132 |
*/
|
133 |
+
public static function filter_templates( $post_templates, $theme ) {
|
134 |
return array_merge( $post_templates, $theme->get_page_templates() );
|
135 |
}
|
|
|
136 |
}
|
includes/frontend.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace wpautoterms;
|
4 |
+
|
5 |
+
|
6 |
+
use wpautoterms\frontend\Endorsements;
|
7 |
+
use wpautoterms\frontend\Links;
|
8 |
+
use wpautoterms\frontend\notice\Cookies_Notice;
|
9 |
+
use wpautoterms\frontend\notice\Update_Notice;
|
10 |
+
|
11 |
+
abstract class Frontend {
|
12 |
+
protected static $_body_top = '';
|
13 |
+
/**
|
14 |
+
* @var Links
|
15 |
+
*/
|
16 |
+
protected static $_links;
|
17 |
+
|
18 |
+
public static function init( $license ) {
|
19 |
+
global $pagenow;
|
20 |
+
if ( in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ) ) ) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
// NOTE: modify buffer on teardown.
|
24 |
+
ob_start( array( __CLASS__, '_out_head' ) );
|
25 |
+
add_action( WPAUTOTERMS_SLUG . '_registered_cpt', array( __CLASS__, 'action_registered_cpt' ), 20 );
|
26 |
+
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
|
27 |
+
add_action( 'wp_footer', array( __CLASS__, 'footer' ), 100002 );
|
28 |
+
$a = Update_Notice::create();
|
29 |
+
$a->init();
|
30 |
+
$a = Cookies_Notice::create( $license );
|
31 |
+
$a->init();
|
32 |
+
new Endorsements( $license );
|
33 |
+
static::$_links = new Links();
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
public static function action_registered_cpt() {
|
38 |
+
static::$_body_top = static::top_container( true );
|
39 |
+
}
|
40 |
+
|
41 |
+
public static function enqueue_scripts() {
|
42 |
+
wp_register_style( WPAUTOTERMS_SLUG . '_css', WPAUTOTERMS_PLUGIN_URL . 'css/wpautoterms.css', false );
|
43 |
+
wp_enqueue_style( WPAUTOTERMS_SLUG . '_css' );
|
44 |
+
}
|
45 |
+
|
46 |
+
public static function _out_head( $buf ) {
|
47 |
+
$ct = 'content-type';
|
48 |
+
$ct_len = strlen( $ct );
|
49 |
+
$handle = true;
|
50 |
+
foreach ( headers_list() as $h ) {
|
51 |
+
$h = ltrim( $h );
|
52 |
+
if ( strncasecmp( $h, $ct, $ct_len ) === 0 ) {
|
53 |
+
// do not handle non-html content
|
54 |
+
if ( 1 !== preg_match( '/^content-type:\s*(text\/html|application\/xhtml\+xml)([^[:alnum:]]+.*|)$/i', $h ) ) {
|
55 |
+
$handle = false;
|
56 |
+
}
|
57 |
+
break;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
if ( ! $handle ) {
|
61 |
+
return $buf;
|
62 |
+
}
|
63 |
+
$m = array();
|
64 |
+
preg_match( '/(.*<\s*body[^>]*>)(.*)/is', $buf, $m );
|
65 |
+
$ret = '';
|
66 |
+
if ( count( $m ) < 3 ) {
|
67 |
+
// NOTE: HTML is not well formed, we can only detect a closing body
|
68 |
+
$ret .= $buf;
|
69 |
+
$ret .= static::$_body_top;
|
70 |
+
error_log( 'WPAutoTerms: Body opening tag not found' );
|
71 |
+
} else {
|
72 |
+
$ret .= $m[1];
|
73 |
+
$ret .= static::$_body_top;
|
74 |
+
$ret .= $m[2];
|
75 |
+
}
|
76 |
+
|
77 |
+
return $ret;
|
78 |
+
}
|
79 |
+
|
80 |
+
public static function footer() {
|
81 |
+
static::$_links->links_box();
|
82 |
+
static::bottom_container();
|
83 |
+
}
|
84 |
+
|
85 |
+
protected static function container( $where, $type, $return = false ) {
|
86 |
+
ob_start();
|
87 |
+
do_action( WPAUTOTERMS_SLUG . '_container', $where, $type );
|
88 |
+
$c = ob_get_contents();
|
89 |
+
ob_end_clean();
|
90 |
+
if ( ! empty( $c ) ) {
|
91 |
+
$c = '<div id="wpautoterms-' . $where . '-' . $type . '-container">' . $c . '</div>';
|
92 |
+
}
|
93 |
+
if ( $return ) {
|
94 |
+
return $c;
|
95 |
+
}
|
96 |
+
echo $c;
|
97 |
+
|
98 |
+
return '';
|
99 |
+
}
|
100 |
+
|
101 |
+
protected static function top_container( $return = false ) {
|
102 |
+
$c = static::container( 'top', 'static', $return );
|
103 |
+
$c .= static::container( 'top', 'fixed', $return );
|
104 |
+
if ( $return ) {
|
105 |
+
return $c;
|
106 |
+
}
|
107 |
+
echo $c;
|
108 |
+
|
109 |
+
return '';
|
110 |
+
}
|
111 |
+
|
112 |
+
protected static function bottom_container() {
|
113 |
+
static::container( 'bottom', 'fixed' );
|
114 |
+
static::container( 'bottom', 'static' );
|
115 |
+
}
|
116 |
+
}
|
includes/frontend/links.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
namespace wpautoterms\frontend;
|
4 |
|
|
|
5 |
use wpautoterms\gen_css\Attr;
|
6 |
use wpautoterms\gen_css\Document;
|
7 |
use wpautoterms\gen_css\Record;
|
@@ -13,16 +14,27 @@ class Links {
|
|
13 |
add_action( 'wp_print_styles', array( $this, 'print_styles' ) );
|
14 |
}
|
15 |
|
|
|
|
|
|
|
|
|
16 |
public function links_box() {
|
17 |
if ( ! get_option( WPAUTOTERMS_OPTION_PREFIX . static::MODULE_ID ) ) {
|
18 |
return;
|
19 |
}
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
|
23 |
public function print_styles() {
|
24 |
-
$option_prefix =
|
25 |
-
|
26 |
if ( ! get_option( $option_prefix ) ) {
|
27 |
return;
|
28 |
}
|
@@ -46,7 +58,7 @@ class Links {
|
|
46 |
$text = $d->text();
|
47 |
$custom = get_option( $option_prefix . '_custom_css' );
|
48 |
if ( ! empty( $custom ) ) {
|
49 |
-
$text .= "\n" . strip_tags($custom);
|
50 |
}
|
51 |
echo Document::style( $text ) . "\n";
|
52 |
}
|
2 |
|
3 |
namespace wpautoterms\frontend;
|
4 |
|
5 |
+
use wpautoterms\cpt\CPT;
|
6 |
use wpautoterms\gen_css\Attr;
|
7 |
use wpautoterms\gen_css\Document;
|
8 |
use wpautoterms\gen_css\Record;
|
14 |
add_action( 'wp_print_styles', array( $this, 'print_styles' ) );
|
15 |
}
|
16 |
|
17 |
+
protected static function _option_prefix() {
|
18 |
+
return WPAUTOTERMS_OPTION_PREFIX . static::MODULE_ID;
|
19 |
+
}
|
20 |
+
|
21 |
public function links_box() {
|
22 |
if ( ! get_option( WPAUTOTERMS_OPTION_PREFIX . static::MODULE_ID ) ) {
|
23 |
return;
|
24 |
}
|
25 |
+
$args = array(
|
26 |
+
'post_type' => CPT::type(),
|
27 |
+
'post_status' => 'publish',
|
28 |
+
'orderby' => 'post_modified',
|
29 |
+
);
|
30 |
+
|
31 |
+
$posts = get_posts( $args );
|
32 |
+
$new_page = $custom = get_option( static::_option_prefix() . '_target_blank' );
|
33 |
+
\wpautoterms\print_template( static::MODULE_ID, compact( 'posts', 'new_page' ) );
|
34 |
}
|
35 |
|
36 |
public function print_styles() {
|
37 |
+
$option_prefix = static::_option_prefix();
|
|
|
38 |
if ( ! get_option( $option_prefix ) ) {
|
39 |
return;
|
40 |
}
|
58 |
$text = $d->text();
|
59 |
$custom = get_option( $option_prefix . '_custom_css' );
|
60 |
if ( ! empty( $custom ) ) {
|
61 |
+
$text .= "\n" . strip_tags( $custom );
|
62 |
}
|
63 |
echo Document::style( $text ) . "\n";
|
64 |
}
|
includes/frontend/notice/base-notice.php
CHANGED
@@ -32,7 +32,7 @@ abstract class Base_Notice {
|
|
32 |
if ( ! $this->_is_enabled() ) {
|
33 |
return;
|
34 |
}
|
35 |
-
add_action( '
|
36 |
add_action( 'wp_print_styles', array( $this, 'print_styles' ) );
|
37 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
38 |
add_action( WPAUTOTERMS_SLUG . '_container', array( $this, 'container' ), 10, 2 );
|
@@ -65,7 +65,7 @@ abstract class Base_Notice {
|
|
65 |
|
66 |
abstract protected function get_data();
|
67 |
|
68 |
-
public function
|
69 |
$disable_logged = get_option( WPAUTOTERMS_OPTION_PREFIX . $this->_id . '_disable_logged' );
|
70 |
if ( ( ( $disable_logged == 'yes' ) && \is_user_logged_in() ) || ! $this->get_data() ) {
|
71 |
$this->_skip = true;
|
32 |
if ( ! $this->_is_enabled() ) {
|
33 |
return;
|
34 |
}
|
35 |
+
add_action( WPAUTOTERMS_SLUG . '_registered_cpt', array( $this, 'action_registered_cpt' ) );
|
36 |
add_action( 'wp_print_styles', array( $this, 'print_styles' ) );
|
37 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
38 |
add_action( WPAUTOTERMS_SLUG . '_container', array( $this, 'container' ), 10, 2 );
|
65 |
|
66 |
abstract protected function get_data();
|
67 |
|
68 |
+
public function action_registered_cpt() {
|
69 |
$disable_logged = get_option( WPAUTOTERMS_OPTION_PREFIX . $this->_id . '_disable_logged' );
|
70 |
if ( ( ( $disable_logged == 'yes' ) && \is_user_logged_in() ) || ! $this->get_data() ) {
|
71 |
$this->_skip = true;
|
includes/frontend/notice/update-notice.php
CHANGED
@@ -2,6 +2,8 @@
|
|
2 |
|
3 |
namespace wpautoterms\frontend\notice;
|
4 |
|
|
|
|
|
5 |
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
exit;
|
7 |
}
|
@@ -21,7 +23,7 @@ class Update_Notice extends Base_Notice {
|
|
21 |
|
22 |
protected function get_posts() {
|
23 |
$args = array(
|
24 |
-
'post_type' =>
|
25 |
'post_status' => 'publish',
|
26 |
'orderby' => 'post_modified',
|
27 |
'date_query' => array(
|
2 |
|
3 |
namespace wpautoterms\frontend\notice;
|
4 |
|
5 |
+
use wpautoterms\cpt\CPT;
|
6 |
+
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
exit;
|
9 |
}
|
23 |
|
24 |
protected function get_posts() {
|
25 |
$args = array(
|
26 |
+
'post_type' => CPT::type(),
|
27 |
'post_status' => 'publish',
|
28 |
'orderby' => 'post_modified',
|
29 |
'date_query' => array(
|
includes/legacy-shortcodes.php
CHANGED
@@ -4,6 +4,7 @@ namespace wpautoterms;
|
|
4 |
|
5 |
use wpautoterms\admin\Menu;
|
6 |
use wpautoterms\admin\page\Legacy_Settings;
|
|
|
7 |
|
8 |
abstract class Legacy_Shortcodes {
|
9 |
public static function my_terms_of_service_and_privacy_policy() {
|
@@ -46,7 +47,7 @@ abstract class Legacy_Shortcodes {
|
|
46 |
$args = array( 'text' => $text );
|
47 |
if ( current_user_can( 'edit_plugins' ) ) {
|
48 |
$args['settings_url'] =
|
49 |
-
admin_url( 'edit.php?post_type=' .
|
50 |
|
51 |
return \wpautoterms\print_template( 'legacy/coming-soon-admin', $args, true );
|
52 |
}
|
4 |
|
5 |
use wpautoterms\admin\Menu;
|
6 |
use wpautoterms\admin\page\Legacy_Settings;
|
7 |
+
use wpautoterms\cpt\CPT;
|
8 |
|
9 |
abstract class Legacy_Shortcodes {
|
10 |
public static function my_terms_of_service_and_privacy_policy() {
|
47 |
$args = array( 'text' => $text );
|
48 |
if ( current_user_can( 'edit_plugins' ) ) {
|
49 |
$args['settings_url'] =
|
50 |
+
admin_url( 'edit.php?post_type=' . CPT::type() . '&page=' . WPAUTOTERMS_SLUG . '_' . Menu::PAGE_LEGACY_SETTINGS );
|
51 |
|
52 |
return \wpautoterms\print_template( 'legacy/coming-soon-admin', $args, true );
|
53 |
}
|
includes/upgrade.php
CHANGED
@@ -9,12 +9,43 @@ use wpautoterms\admin\page\Settings_Base;
|
|
9 |
use wpautoterms\cpt\CPT;
|
10 |
|
11 |
class Upgrade {
|
|
|
|
|
|
|
12 |
public function __construct() {
|
13 |
-
add_action( 'init', array( $this, 'run' ) );
|
14 |
}
|
15 |
|
16 |
public function run() {
|
17 |
if ( ! get_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
/**
|
19 |
* @var $page \wpautoterms\admin\page\Base
|
20 |
*/
|
@@ -28,26 +59,13 @@ class Upgrade {
|
|
28 |
}
|
29 |
}
|
30 |
}
|
31 |
-
flush_rewrite_rules();
|
32 |
-
CPT::add_caps();
|
33 |
-
update_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED, true );
|
34 |
}
|
35 |
-
|
36 |
-
if ( $version !== WPAUTOTERMS_VERSION ) {
|
37 |
$this->_upgrade_from_tos_pp();
|
38 |
-
$this->_add_slug_option();
|
39 |
-
update_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION, WPAUTOTERMS_VERSION );
|
40 |
}
|
41 |
}
|
42 |
|
43 |
protected function _upgrade_from_tos_pp() {
|
44 |
-
$version = get_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION );
|
45 |
-
if ( ! empty( $version ) ) {
|
46 |
-
$v = explode( '.', $version );
|
47 |
-
if ( intval( $v[0] ) > 1 ) {
|
48 |
-
return;
|
49 |
-
}
|
50 |
-
}
|
51 |
$options = get_option( Menu::AUTO_TOS_OPTIONS, false );
|
52 |
update_option( WPAUTOTERMS_OPTION_PREFIX . Menu::LEGACY_OPTIONS, $options !== false );
|
53 |
if ( $options === false ) {
|
9 |
use wpautoterms\cpt\CPT;
|
10 |
|
11 |
class Upgrade {
|
12 |
+
protected $_activate = false;
|
13 |
+
protected $_update_legacy = false;
|
14 |
+
|
15 |
public function __construct() {
|
16 |
+
add_action( 'init', array( $this, 'run' ), 0 );
|
17 |
}
|
18 |
|
19 |
public function run() {
|
20 |
if ( ! get_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED ) ) {
|
21 |
+
flush_rewrite_rules();
|
22 |
+
update_option( WPAUTOTERMS_OPTION_PREFIX . WPAUTOTERMS_OPTION_ACTIVATED, true );
|
23 |
+
CPT::register_role();
|
24 |
+
$activated = true;
|
25 |
+
$this->_activate = true;
|
26 |
+
} else {
|
27 |
+
$activated = false;
|
28 |
+
}
|
29 |
+
$version = get_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION, false );
|
30 |
+
if ( $version !== WPAUTOTERMS_VERSION ) {
|
31 |
+
if ( $version === false ) {
|
32 |
+
$this->_update_legacy = true;
|
33 |
+
}
|
34 |
+
$this->_add_slug_option();
|
35 |
+
if ( ! $activated ) {
|
36 |
+
CPT::register_role();
|
37 |
+
}
|
38 |
+
update_option( WPAUTOTERMS_OPTION_PREFIX . Menu::VERSION, WPAUTOTERMS_VERSION );
|
39 |
+
}
|
40 |
+
if ( did_action( 'admin_init' ) ) {
|
41 |
+
$this->run_translated();
|
42 |
+
} else {
|
43 |
+
add_action( 'admin_init', array( $this, 'run_translated' ) );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
public function run_translated() {
|
48 |
+
if ( $this->_activate ) {
|
49 |
/**
|
50 |
* @var $page \wpautoterms\admin\page\Base
|
51 |
*/
|
59 |
}
|
60 |
}
|
61 |
}
|
|
|
|
|
|
|
62 |
}
|
63 |
+
if ( $this->_update_legacy ) {
|
|
|
64 |
$this->_upgrade_from_tos_pp();
|
|
|
|
|
65 |
}
|
66 |
}
|
67 |
|
68 |
protected function _upgrade_from_tos_pp() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
$options = get_option( Menu::AUTO_TOS_OPTIONS, false );
|
70 |
update_option( WPAUTOTERMS_OPTION_PREFIX . Menu::LEGACY_OPTIONS, $options !== false );
|
71 |
if ( $options === false ) {
|
includes/wpautoterms.php
CHANGED
@@ -4,19 +4,10 @@ namespace wpautoterms;
|
|
4 |
|
5 |
use wpautoterms\admin\form\Legal_Page;
|
6 |
use wpautoterms\cpt\CPT;
|
7 |
-
use wpautoterms\frontend\Endorsements;
|
8 |
-
use wpautoterms\frontend\Links;
|
9 |
-
use wpautoterms\frontend\notice\Cookies_Notice;
|
10 |
-
use wpautoterms\frontend\notice\Update_Notice;
|
11 |
use wpautoterms\legal_pages;
|
12 |
|
13 |
abstract class Wpautoterms {
|
14 |
-
|
15 |
protected static $_legal_pages;
|
16 |
-
/**
|
17 |
-
* @var Links
|
18 |
-
*/
|
19 |
-
protected static $_links;
|
20 |
|
21 |
public static function init( $license, $query ) {
|
22 |
static::$_legal_pages = array();
|
@@ -37,16 +28,6 @@ abstract class Wpautoterms {
|
|
37 |
CPT::init();
|
38 |
Shortcodes::init();
|
39 |
Legacy_Shortcodes::init();
|
40 |
-
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
|
41 |
-
|
42 |
-
add_action( 'wp_head', array( __CLASS__, 'head' ), 100002 );
|
43 |
-
add_action( 'wp_footer', array( __CLASS__, 'footer' ), 100002 );
|
44 |
-
$a = Update_Notice::create();
|
45 |
-
$a->init();
|
46 |
-
$a = Cookies_Notice::create( $license );
|
47 |
-
$a->init();
|
48 |
-
new Endorsements( $license );
|
49 |
-
static::$_links = new Links();
|
50 |
}
|
51 |
|
52 |
/**
|
@@ -77,53 +58,6 @@ abstract class Wpautoterms {
|
|
77 |
|
78 |
public static function action_init() {
|
79 |
CPT::register();
|
80 |
-
|
81 |
-
|
82 |
-
public static function enqueue_scripts() {
|
83 |
-
wp_register_style( WPAUTOTERMS_SLUG . '_css', WPAUTOTERMS_PLUGIN_URL . 'css/wpautoterms.css', false );
|
84 |
-
wp_enqueue_style( WPAUTOTERMS_SLUG . '_css' );
|
85 |
-
}
|
86 |
-
|
87 |
-
public static function head() {
|
88 |
-
ob_start();
|
89 |
-
}
|
90 |
-
|
91 |
-
public static function footer() {
|
92 |
-
$c = ob_get_contents();
|
93 |
-
preg_match( '/(.*<\s*body[^>]*>)(.*)/is', $c, $m );
|
94 |
-
ob_end_clean();
|
95 |
-
if ( count( $m ) < 3 ) {
|
96 |
-
// NOTE: HTML is not well formed, we can only detect a closing body
|
97 |
-
echo $c;
|
98 |
-
static::top_container();
|
99 |
-
static::bottom_container();
|
100 |
-
|
101 |
-
return;
|
102 |
-
}
|
103 |
-
echo $m[1];
|
104 |
-
static::top_container();
|
105 |
-
echo $m[2];
|
106 |
-
static::$_links->links_box();
|
107 |
-
static::bottom_container();
|
108 |
-
}
|
109 |
-
|
110 |
-
protected static function container( $where, $type ) {
|
111 |
-
ob_start();
|
112 |
-
do_action( WPAUTOTERMS_SLUG . '_container', $where, $type );
|
113 |
-
$c = ob_get_contents();
|
114 |
-
ob_end_clean();
|
115 |
-
if ( ! empty( $c ) ) {
|
116 |
-
echo '<div id="wpautoterms-' . $where . '-' . $type . '-container">' . $c . '</div>';
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
protected static function top_container() {
|
121 |
-
static::container( 'top', 'static' );
|
122 |
-
static::container( 'top', 'fixed' );
|
123 |
-
}
|
124 |
-
|
125 |
-
protected static function bottom_container() {
|
126 |
-
static::container( 'bottom', 'fixed' );
|
127 |
-
static::container( 'bottom', 'static' );
|
128 |
}
|
129 |
}
|
4 |
|
5 |
use wpautoterms\admin\form\Legal_Page;
|
6 |
use wpautoterms\cpt\CPT;
|
|
|
|
|
|
|
|
|
7 |
use wpautoterms\legal_pages;
|
8 |
|
9 |
abstract class Wpautoterms {
|
|
|
10 |
protected static $_legal_pages;
|
|
|
|
|
|
|
|
|
11 |
|
12 |
public static function init( $license, $query ) {
|
13 |
static::$_legal_pages = array();
|
28 |
CPT::init();
|
29 |
Shortcodes::init();
|
30 |
Legacy_Shortcodes::init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
/**
|
58 |
|
59 |
public static function action_init() {
|
60 |
CPT::register();
|
61 |
+
do_action( WPAUTOTERMS_SLUG . '_registered_cpt' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
63 |
}
|
templates/auto-draft.php
CHANGED
@@ -39,7 +39,7 @@ if ( ! empty( $agreement_data ) ) {
|
|
39 |
<p>
|
40 |
<?php _e( 'Please make sure the website information is correct at the', WPAUTOTERMS_SLUG ); ?>
|
41 |
<strong><a href="<?php
|
42 |
-
echo esc_url( admin_url( 'edit.php?post_type=' .
|
43 |
?>"><?php _e( 'Settings page', WPAUTOTERMS_SLUG ); ?></a></strong>
|
44 |
<?php _e( 'before you create a legal page.', WPAUTOTERMS_SLUG ); ?>
|
45 |
</p>
|
39 |
<p>
|
40 |
<?php _e( 'Please make sure the website information is correct at the', WPAUTOTERMS_SLUG ); ?>
|
41 |
<strong><a href="<?php
|
42 |
+
echo esc_url( admin_url( 'edit.php?post_type=' . \wpautoterms\cpt\CPT::type() . '&page=' . WPAUTOTERMS_SLUG . '_' . Menu::PAGE_SETTINGS ) );
|
43 |
?>"><?php _e( 'Settings page', WPAUTOTERMS_SLUG ); ?></a></strong>
|
44 |
<?php _e( 'before you create a legal page.', WPAUTOTERMS_SLUG ); ?>
|
45 |
</p>
|
templates/links.php
CHANGED
@@ -2,13 +2,6 @@
|
|
2 |
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
exit;
|
4 |
}
|
5 |
-
$args = array(
|
6 |
-
'post_type' => WPAUTOTERMS_CPT,
|
7 |
-
'post_status' => 'publish',
|
8 |
-
'orderby' => 'post_modified',
|
9 |
-
);
|
10 |
-
|
11 |
-
$posts = get_posts( $args );
|
12 |
if ( empty( $posts ) ) {
|
13 |
return;
|
14 |
}
|
@@ -16,8 +9,10 @@ if ( empty( $posts ) ) {
|
|
16 |
<div class="wpautoterms-footer"><p>
|
17 |
<?php
|
18 |
$links = array();
|
|
|
19 |
foreach ( $posts as $post ) {
|
20 |
-
$links[] = '<a href="' . esc_url( get_post_permalink( $post->ID ) ) . '"
|
|
|
21 |
}
|
22 |
echo join( '<span class="separator"> ' . get_option( WPAUTOTERMS_OPTION_PREFIX . 'links_separator' ) . ' </span>', $links );
|
23 |
?></p>
|
2 |
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
exit;
|
4 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
if ( empty( $posts ) ) {
|
6 |
return;
|
7 |
}
|
9 |
<div class="wpautoterms-footer"><p>
|
10 |
<?php
|
11 |
$links = array();
|
12 |
+
$target = $new_page ? ' target="_blank"' : '';
|
13 |
foreach ( $posts as $post ) {
|
14 |
+
$links[] = '<a href="' . esc_url( get_post_permalink( $post->ID ) ) . '"' . $target . '>' .
|
15 |
+
esc_html( $post->post_title ) . '</a>';
|
16 |
}
|
17 |
echo join( '<span class="separator"> ' . get_option( WPAUTOTERMS_OPTION_PREFIX . 'links_separator' ) . ' </span>', $links );
|
18 |
?></p>
|
templates/options/box-page.php
CHANGED
@@ -17,7 +17,7 @@ if (!defined( 'ABSPATH' )) {
|
|
17 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e('Save Changes'); ?>" />
|
18 |
</div>
|
19 |
<div class="wpautoterms-box-page-back">
|
20 |
-
<a href="edit.php?post_type=<?php echo
|
21 |
<?php _e('Back to Compliance Kits', WPAUTOTERMS_SLUG); ?>
|
22 |
</a>
|
23 |
</div>
|
17 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e('Save Changes'); ?>" />
|
18 |
</div>
|
19 |
<div class="wpautoterms-box-page-back">
|
20 |
+
<a href="edit.php?post_type=<?php echo \wpautoterms\cpt\CPT::type(); ?>&page=wpautoterms_compliancekits">
|
21 |
<?php _e('Back to Compliance Kits', WPAUTOTERMS_SLUG); ?>
|
22 |
</a>
|
23 |
</div>
|
templates/options/box.php
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
</div>
|
29 |
<div class="wpautoterms-box-configure-button">
|
30 |
<a class="button button-primary"
|
31 |
-
href="edit.php?post_type=<?php echo
|
32 |
<?php _e( 'Configure', WPAUTOTERMS_SLUG ); ?>
|
33 |
</a>
|
34 |
</div>
|
28 |
</div>
|
29 |
<div class="wpautoterms-box-configure-button">
|
30 |
<a class="button button-primary"
|
31 |
+
href="edit.php?post_type=<?php echo \wpautoterms\cpt\CPT::type(); ?>&page=wpautoterms_compliancekits&box=<?php echo $box->id(); ?>">
|
32 |
<?php _e( 'Configure', WPAUTOTERMS_SLUG ); ?>
|
33 |
</a>
|
34 |
</div>
|
templates/pages/contact.php
CHANGED
@@ -49,7 +49,7 @@ if ( ! empty( $data ) ) {
|
|
49 |
<input type="hidden" name="site_info" value=""/>
|
50 |
<input type="hidden" name="locale" value="<?php echo esc_attr( get_locale() ); ?>"/>
|
51 |
<input type="hidden" name="ret_url" value="<?php
|
52 |
-
echo esc_url( admin_url( 'edit.php?post_type=' .
|
53 |
<table class="form-table">
|
54 |
<tbody>
|
55 |
<tr>
|
49 |
<input type="hidden" name="site_info" value=""/>
|
50 |
<input type="hidden" name="locale" value="<?php echo esc_attr( get_locale() ); ?>"/>
|
51 |
<input type="hidden" name="ret_url" value="<?php
|
52 |
+
echo esc_url( admin_url( 'edit.php?post_type=' . \wpautoterms\cpt\CPT::type() . '&page=' . $page->id() ) ); ?>">
|
53 |
<table class="form-table">
|
54 |
<tbody>
|
55 |
<tr>
|