Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert admin ajax endpoints to WP-API endpoints #42

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b001048
convert admin ajax endpoints to WP-API endpoints
pgk Jan 4, 2016
167ad0d
Refactor Zoninator_Rest_Api_Controller to use the pattern established…
pgk Jan 7, 2016
195e8e9
Refactor Zoninator_Rest_Api_Controller to use wp format conventions a…
pgk Jan 10, 2016
c525250
bump version to 0.7, amend changelog, add upgrade notice and rest api
pgk Jan 10, 2016
f8482b9
Do not activate Zoninator if WordPress version is < 4.4
pgk Jan 11, 2016
f6c3b77
Refactor Zoninator_Rest_Api_Controller *_permissions_check methods to
pgk Jan 12, 2016
4b44ea9
Refactor plugin_activation code
pgk Jan 12, 2016
21ec10b
Change several `_get_*` methods to public to keep backwards compat
pgk Jan 12, 2016
0a23f0b
Simplify the switch statement used in Zoninator_Permissions::check
pgk Jan 12, 2016
f680a5f
use rest api endpoint base url instead of hardcoded url in zoninator.…
pgk Jan 12, 2016
5105af9
Use intention-revealing names in Zoninator_Rest_Api_Controller methods
pgk Jan 12, 2016
ad768c7
Ensure backwards compat when triggering `zoninator.ajax`
pgk Jan 12, 2016
a3e75e2
addin underscore.js as a dependency
pgk Jan 13, 2016
30e820b
constantize zoninator text domain
pgk Jan 13, 2016
e3b20d2
add method to get zone post data to Zoninator_Zone_Gateway
pgk Jan 13, 2016
7c386ba
Remove logic from View Renderer zone post view
pgk Jan 13, 2016
3a1a0f1
Render add_post_to_zone result on the client side, return pure data f…
pgk Jan 13, 2016
bcc0f0a
delete Zoninator_View_Renderer
pgk Jan 13, 2016
3028148
Admin Zone Edit: render posts in JavaScript
pgk Jan 14, 2016
d83f9be
Admin zone post view/edit anchors should open in a new tab
pgk Jan 16, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/vendor
9 changes: 9 additions & 0 deletions class-zoninator-constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class Zoninator_Constants
{
const KEY = 'zoninator';
const ZONE_TAXONOMY = 'zoninator_zones';
const NONCE_PREFIX = 'zone-nonce';
const ZONE_AJAX_NONCE_ACTION = 'ajax-action';
}
43 changes: 43 additions & 0 deletions class-zoninator-permissions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php


class Zoninator_Permissions
{
public function check( $action = '', $zone_id = null ) {
// TODO: should check if zone locked
if ( 'insert' == $action ) {
return $this->current_user_can_add_zones();
}

if ( 'update' == $action || 'delete' == $action ) {
return $this->current_user_can_edit_zones( $zone_id );
}

return $this->current_user_can_manage_zones();
}

public function current_user_can_add_zones() {
return current_user_can( $this->_get_add_zones_cap() );
}

public function current_user_can_edit_zones( $zone_id ) {
$has_cap = current_user_can( $this->_get_edit_zones_cap() );
return apply_filters( 'zoninator_current_user_can_edit_zone', $has_cap, $zone_id );
}

public function current_user_can_manage_zones() {
return current_user_can( $this->get_manage_zones_cap() );
}

public function get_manage_zones_cap() {
return apply_filters( 'zoninator_manage_zone_cap', 'edit_others_posts' );
}

private function _get_add_zones_cap() {
return apply_filters( 'zoninator_add_zone_cap', 'edit_others_posts' );
}

private function _get_edit_zones_cap() {
return apply_filters( 'zoninator_edit_zone_cap', 'edit_others_posts' );
}
}
Loading