Nested Pages - Version 1.3.5

Version Description

  • Minor bug fixes
  • Editorial Access Manager Plugin Integration
Download this release

Release Info

Developer kylephillips
Plugin Icon 128x128 Nested Pages
Version 1.3.5
Comparing to
See all releases

Code changes from version 1.3.4 to 1.3.5

app/Activation/Updates/Updates.php CHANGED
@@ -46,7 +46,8 @@ class Updates {
46
  private function addMenu()
47
  {
48
  if ( !get_option('nestedpages_menu') ){
49
- $menu_id = wp_create_nav_menu('Nested Pages');
 
50
  update_option('nestedpages_menu', $menu_id);
51
  }
52
  }
@@ -75,17 +76,21 @@ class Updates {
75
 
76
  /**
77
  * Make Page Post Type Enabled by Default
78
- * @since 1.2.1
 
79
  */
80
  private function enablePagePostType()
81
- {
82
- if ( version_compare( $this->current_version, '1.3.0', '<' ) ){
83
- $enabled = get_option('nestedpages_posttypes');
84
- $default = array('page' => array(
 
 
 
 
85
  'replace_menu' => true
86
- ));
87
- if ( !$enabled ) update_option('nestedpages_posttypes', $default);
88
- }
89
  }
90
 
91
 
46
  private function addMenu()
47
  {
48
  if ( !get_option('nestedpages_menu') ){
49
+ $menu_id = $this->nav_menu_repo->getMenuIDFromTitle('Nested Pages');
50
+ if ( !$menu_id ) $menu_id = wp_create_nav_menu('Nested Pages');
51
  update_option('nestedpages_menu', $menu_id);
52
  }
53
  }
76
 
77
  /**
78
  * Make Page Post Type Enabled by Default
79
+ * Option can be blank, using get_option returns false if blank
80
+ * @since 1.3.5
81
  */
82
  private function enablePagePostType()
83
+ {
84
+ global $wpdb;
85
+ $options_table = $wpdb->prefix . 'options';
86
+ $sql = "SELECT * FROM wp_options WHERE option_name = 'nestedpages_posttypes'";
87
+ $results = $wpdb->get_results($sql);
88
+ if ( $results ) return;
89
+ update_option('nestedpages_posttypes', array(
90
+ 'page' => array(
91
  'replace_menu' => true
92
+ )
93
+ ));
 
94
  }
95
 
96
 
app/Entities/Listing/Listing.php CHANGED
@@ -8,6 +8,7 @@ use NestedPages\Entities\User\UserRepository;
8
  use NestedPages\Entities\PostType\PostTypeRepository;
9
  use NestedPages\Entities\Listing\ListingRepository;
10
  use NestedPages\Config\SettingsRepository;
 
11
 
12
  /**
13
  * Primary Post Listing
@@ -79,10 +80,16 @@ class Listing {
79
  */
80
  private $settings;
81
 
 
 
 
 
 
82
 
83
  public function __construct($post_type)
84
  {
85
  $this->setPostType($post_type);
 
86
  $this->post_repo = new PostRepository;
87
  $this->user = new UserRepository;
88
  $this->confirmation = new ConfirmationFactory;
8
  use NestedPages\Entities\PostType\PostTypeRepository;
9
  use NestedPages\Entities\Listing\ListingRepository;
10
  use NestedPages\Config\SettingsRepository;
11
+ use NestedPages\Entities\PluginIntegration\IntegrationFactory;
12
 
13
  /**
14
  * Primary Post Listing
80
  */
81
  private $settings;
82
 
83
+ /**
84
+ * Plugin Integrations
85
+ */
86
+ private $integrations;
87
+
88
 
89
  public function __construct($post_type)
90
  {
91
  $this->setPostType($post_type);
92
+ $this->integrations = new IntegrationFactory;
93
  $this->post_repo = new PostRepository;
94
  $this->user = new UserRepository;
95
  $this->confirmation = new ConfirmationFactory;
app/Entities/NavMenu/NavMenuRepository.php CHANGED
@@ -83,6 +83,18 @@ class NavMenuRepository {
83
  }
84
 
85
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  /**
87
  * Create Empty Menu if one doesn't exist
88
  * @since 1.3.4
83
  }
84
 
85
 
86
+ /**
87
+ * Get the Menu ID from the title
88
+ * @since 1.3.5
89
+ * @return int
90
+ */
91
+ public function getMenuIDFromTitle($title)
92
+ {
93
+ $term = get_term_by('name', $title, 'nav_menu');
94
+ return ( $term ) ? $term->term_id : false;
95
+ }
96
+
97
+
98
  /**
99
  * Create Empty Menu if one doesn't exist
100
  * @since 1.3.4
app/Entities/PluginIntegration/EditorialAccessManager.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php namespace NestedPages\Entities\PluginIntegration;
2
+
3
+ /**
4
+ * Editorial Access Manager Integration
5
+ * @link https://wordpress.org/plugins/editorial-access-manager/
6
+ */
7
+
8
+ class EditorialAccessManager {
9
+
10
+ /**
11
+ * Installed
12
+ * @var boolean
13
+ */
14
+ public $installed;
15
+
16
+ /**
17
+ * Current User ID
18
+ */
19
+ private $user;
20
+
21
+
22
+ public function __construct()
23
+ {
24
+ if ( class_exists('Editorial_Access_Manager') ){
25
+ $this->installed = true;
26
+ $this->user = wp_get_current_user();
27
+ }
28
+ }
29
+
30
+
31
+ /**
32
+ * Does the current user have access to the specified post id?
33
+ * @return boolean
34
+ */
35
+ public function hasAccess($post_id)
36
+ {
37
+ if ( $this->abortCheck() ) return true;
38
+
39
+ $access_meta = get_post_meta($post_id, 'eam_enable_custom_access', true);
40
+
41
+ if ( $access_meta == 'users' ){
42
+ $allowed_users = (array) get_post_meta($post_id, 'eam_allowed_users', true);
43
+ if ( isset($allowed_users[0]) && $allowed_users[0] == "" ) return true;
44
+ if ( !in_array($this->user->ID, $allowed_users) ) return false;
45
+ }
46
+
47
+ if ( $access_meta == 'roles' ){
48
+ $allowed_roles = (array) get_post_meta($post_id, 'eam_allowed_roles', true);
49
+ if ( count( array_diff( $this->user->roles, $allowed_roles ) ) >= 1 ) return false;
50
+ }
51
+
52
+ return true;
53
+ }
54
+
55
+
56
+ /**
57
+ * Abort Role Check?
58
+ * @return boolean
59
+ */
60
+ private function abortCheck()
61
+ {
62
+ if ( !$this->installed ) return true;
63
+ if ( in_array('administrator', $this->user->roles) ) return true;
64
+ return false;
65
+ }
66
+
67
+ }
app/Entities/PluginIntegration/IntegrationFactory.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php namespace NestedPages\Entities\PluginIntegration;
2
+
3
+ use NestedPages\Entities\PluginIntegration\EditorialAccessManager;
4
+
5
+ class IntegrationFactory {
6
+
7
+ /**
8
+ * Integration Classes
9
+ */
10
+ public $plugins;
11
+
12
+ public function __construct()
13
+ {
14
+ $this->build();
15
+ return $this->plugins;
16
+ }
17
+
18
+ public function build()
19
+ {
20
+ $this->plugins = new \StdClass();
21
+ $this->plugins->editorial_access_manager = new EditorialAccessManager;
22
+ }
23
+
24
+ }
app/NestedPages.php CHANGED
@@ -12,7 +12,7 @@ class NestedPages {
12
  $np_env = 'live';
13
 
14
  global $np_version;
15
- $np_version = '1.3.4';
16
 
17
  if ( is_admin() ) $app = new NestedPages\Bootstrap;
18
  }
12
  $np_env = 'live';
13
 
14
  global $np_version;
15
+ $np_version = '1.3.5';
16
 
17
  if ( is_admin() ) $app = new NestedPages\Bootstrap;
18
  }
app/Views/partials/row.php CHANGED
@@ -45,9 +45,12 @@
45
  if ( $user = wp_check_post_lock($this->post->id) ){
46
  $u = get_userdata($user);
47
  echo '<span class="locked"><i class="np-icon-lock"></i><em> ' . $u->display_name . ' ' . __('currently editing', 'nestedpages') . '</em></span>';
 
 
48
  } else {
49
  echo '<span class="edit-indicator"><i class="np-icon-pencil"></i>' . __('Edit') . '</span>';
50
  }
 
51
  ?>
52
  </a>
53
 
@@ -86,7 +89,7 @@
86
 
87
  <?php endif; ?>
88
 
89
- <?php if ( !$user = wp_check_post_lock($this->post->id) ) : ?>
90
  <a href="#"
91
  class="np-btn np-quick-edit"
92
  data-id="<?php echo $this->post->id; ?>"
@@ -120,7 +123,7 @@
120
 
121
  <a href="<?php echo get_the_permalink(); ?>" class="np-btn" target="_blank"><?php _e('View'); ?></a>
122
 
123
- <?php if ( current_user_can('delete_pages') ) : ?>
124
  <a href="<?php echo get_delete_post_link(get_the_id()); ?>" class="np-btn np-btn-trash">
125
  <i class="np-icon-remove"></i>
126
  </a>
45
  if ( $user = wp_check_post_lock($this->post->id) ){
46
  $u = get_userdata($user);
47
  echo '<span class="locked"><i class="np-icon-lock"></i><em> ' . $u->display_name . ' ' . __('currently editing', 'nestedpages') . '</em></span>';
48
+ } elseif ( !$this->integrations->plugins->editorial_access_manager->hasAccess($this->post->id) ){
49
+ echo '<span class="locked"><i class="np-icon-lock"></i></span>';
50
  } else {
51
  echo '<span class="edit-indicator"><i class="np-icon-pencil"></i>' . __('Edit') . '</span>';
52
  }
53
+
54
  ?>
55
  </a>
56
 
89
 
90
  <?php endif; ?>
91
 
92
+ <?php if ( !$user = wp_check_post_lock($this->post->id) || !$this->integrations->plugins->editorial_access_manager->hasAccess($this->post->id) ) : ?>
93
  <a href="#"
94
  class="np-btn np-quick-edit"
95
  data-id="<?php echo $this->post->id; ?>"
123
 
124
  <a href="<?php echo get_the_permalink(); ?>" class="np-btn" target="_blank"><?php _e('View'); ?></a>
125
 
126
+ <?php if ( current_user_can('delete_pages') && $this->integrations->plugins->editorial_access_manager->hasAccess($this->post->id) ) : ?>
127
  <a href="<?php echo get_delete_post_link(get_the_id()); ?>" class="np-btn np-btn-trash">
128
  <i class="np-icon-remove"></i>
129
  </a>
nestedpages.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Nested Pages
4
  Plugin URI: http://nestedpages.com
5
  Description: Provides an intuitive drag and drop interface for managing pages in the Wordpress admin, while maintaining quick edit functionality.
6
- Version: 1.3.4
7
  Author: Kyle Phillips
8
  Author URI: https://github.com/kylephillips
9
  Text Domain: nestedpages
3
  Plugin Name: Nested Pages
4
  Plugin URI: http://nestedpages.com
5
  Description: Provides an intuitive drag and drop interface for managing pages in the Wordpress admin, while maintaining quick edit functionality.
6
+ Version: 1.3.5
7
  Author: Kyle Phillips
8
  Author URI: https://github.com/kylephillips
9
  Text Domain: nestedpages
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://nestedpages.com/
4
  Tags: pages, admin, nested, tree view, page tree, sort, quick edit, structure
5
  Requires at least: 3.8
6
  Tested up to: 4.1
7
- Stable tag: 1.3.3
8
 
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -79,8 +79,16 @@ If you have WordPress SEO by Yoast installed, your page score indicators are sho
79
 
80
  5. Quickly add posts without leaving the page tree
81
 
 
 
 
 
82
  == Changelog ==
83
 
 
 
 
 
84
  = 1.3.4 =
85
  * Minor bug fixes
86
  * Minor UI enhancements
4
  Tags: pages, admin, nested, tree view, page tree, sort, quick edit, structure
5
  Requires at least: 3.8
6
  Tested up to: 4.1
7
+ Stable tag: 1.3.4
8
 
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
79
 
80
  5. Quickly add posts without leaving the page tree
81
 
82
+ 6. Set capabilities
83
+
84
+ 7. The Nested Pages interface can be enabled on a per-post-type basis, with customizable options for each type.
85
+
86
  == Changelog ==
87
 
88
+ = 1.3.5 =
89
+ * Minor bug fixes
90
+ * Editorial Access Manager Plugin Integration
91
+
92
  = 1.3.4 =
93
  * Minor bug fixes
94
  * Minor UI enhancements