Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7288ab1
WIP: Add embeddable to the post and student. Will likely want to spec…
brianhogg Jun 17, 2025
f7a4c05
Changelog.
brianhogg Jun 18, 2025
7d9f3fb
Adding more data to show in webhooks and when _embed query param adde…
brianhogg Jun 18, 2025
b49702e
Removing embed from collections
brianhogg Jun 18, 2025
c1b26e2
Avoid error if core LifterLMS is deactivated.
brianhogg Jun 20, 2025
9cee054
Allow retrieving all progress for a student rather than just a specif…
brianhogg Jun 24, 2025
9469f55
Fixing warning for no pagination args.
brianhogg Jun 24, 2025
562a93b
Fixing individual link.
brianhogg Jun 24, 2025
cb4c5f1
Adding note about maybe changing to getting more items to check progr…
brianhogg Jun 24, 2025
a65132d
WIP: Initial quizzes controller.
brianhogg Jun 24, 2025
49974e2
Quiz attempts controller.
brianhogg Jun 26, 2025
745a7ea
Refactor to use LLMS_Query_Quiz_Attempt.
brianhogg Jun 26, 2025
db78f15
WIP: Adding quiz attempts endpoint.
brianhogg Jun 26, 2025
7524e4e
Quiz attempt completed webhook.
brianhogg Jun 26, 2025
8200ff7
Changelogs.
brianhogg Jun 26, 2025
7c1ef12
WIP: Initial orders endpoint.
brianhogg Jun 26, 2025
4325188
Filter "llms-" out of status. Read-only for order items and collection.
brianhogg Jun 26, 2025
f5a10fc
Fixing comment.
brianhogg Jun 26, 2025
133bd2a
Adding billing email.
brianhogg Jun 26, 2025
deba91a
WIP: Adding additional fields
brianhogg Jun 26, 2025
d336c97
Fixing comments.
brianhogg Jun 27, 2025
aa4c21f
Fixing comments.
brianhogg Jun 27, 2025
d0ec7ed
FIx schema base.
brianhogg Jun 27, 2025
20f861f
More comment fixes.
brianhogg Jun 27, 2025
0819f3b
Removing add-on topic from core. Allow generic webhook rest api build…
brianhogg Jun 27, 2025
d7c814f
Adding assignment webhook topic and hooks within the add-on.
brianhogg Jun 27, 2025
76f3b86
Base certificate endpoint.
brianhogg Jun 27, 2025
16f4142
awarded-certificates endpoint.
brianhogg Jun 27, 2025
46ff338
Awarded-certificates webhook and API mods.
brianhogg Jul 3, 2025
6762e68
Changelog.
brianhogg Jul 3, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: minor
type: added
entry: Allow several endpoints to be "embeddable" along with their links.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: minor
type: added
entry: Ability to list progresses for a student via /students/<id>/progress.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: minor
type: added
entry: New Quiz, Quiz Attempt, Certificate, Awarded Certificate, and Order endpoints.
20 changes: 14 additions & 6 deletions class-lifterlms-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ private function __construct() {

// Load everything else.
add_action( 'plugins_loaded', array( $this, 'init' ), 10 );

}

/**
Expand All @@ -70,6 +69,10 @@ private function __construct() {
*/
public function includes() {

if ( ! class_exists( 'LLMS_Abstract_Database_Store' ) ) {
return;
}

// Abstracts.
include_once LLMS_REST_API_PLUGIN_DIR . 'includes/abstracts/class-llms-rest-database-resource.php';
include_once LLMS_REST_API_PLUGIN_DIR . 'includes/abstracts/class-llms-rest-webhook-data.php';
Expand Down Expand Up @@ -98,7 +101,6 @@ public function includes() {

add_action( 'rest_api_init', array( $this, 'rest_api_includes' ), 5 );
add_action( 'rest_api_init', array( $this, 'rest_api_controllers_init' ), 10 );

}

/**
Expand Down Expand Up @@ -140,6 +142,11 @@ public function rest_api_includes() {
'server/class-llms-rest-api-keys-controller',
'server/class-llms-rest-access-plans-controller',
'server/class-llms-rest-courses-controller',
'server/class-llms-rest-quizzes-controller',
'server/class-llms-rest-quiz-attempts-controller',
'server/class-llms-rest-certificates-controller',
'server/class-llms-rest-awarded-certificates-controller',
'server/class-llms-rest-orders-controller',
'server/class-llms-rest-sections-controller',
'server/class-llms-rest-lessons-controller',
'server/class-llms-rest-memberships-controller',
Expand Down Expand Up @@ -172,6 +179,11 @@ public function rest_api_controllers_init() {
'LLMS_REST_Courses_Controller',
'LLMS_REST_Sections_Controller',
'LLMS_REST_Lessons_Controller',
'LLMS_REST_Quizzes_Controller',
'LLMS_REST_Quiz_Attempts_Controller',
'LLMS_REST_Certificates_Controller',
'LLMS_REST_Awarded_Certificates_Controller',
'LLMS_REST_Orders_Controller',
'LLMS_REST_Memberships_Controller',
'LLMS_REST_Instructors_Controller',
'LLMS_REST_Students_Controller',
Expand All @@ -185,7 +197,6 @@ public function rest_api_controllers_init() {
$controller_instance = new $controller();
$controller_instance->register_routes();
}

}

/**
Expand Down Expand Up @@ -216,7 +227,6 @@ public function init() {

add_action( 'init', array( $this->webhooks(), 'load' ), 6 );
add_action( 'deleted_user', array( $this, 'on_user_deletion' ) );

}

/**
Expand Down Expand Up @@ -278,7 +288,6 @@ public function load_textdomain() {

// Load from the plugin's language file directory.
load_textdomain( 'lifterlms', LLMS_REST_API_PLUGIN_DIR . '/i18n/lifterlms-rest-' . $locale . '.mo' );

}

/**
Expand All @@ -293,5 +302,4 @@ public function load_textdomain() {
public function webhooks() {
return LLMS_REST_Webhooks::instance();
}

}
36 changes: 4 additions & 32 deletions includes/abstracts/class-llms-rest-posts-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public function get_delete_item_args() {
'default' => false,
),
);

}

/**
Expand All @@ -132,7 +131,6 @@ public function get_get_item_params() {
}

return $params;

}

/**
Expand Down Expand Up @@ -163,7 +161,6 @@ public function get_items_permissions_check( $request ) {
}

return true;

}

/**
Expand All @@ -189,7 +186,6 @@ protected function get_pagination_data_from_query( $query, $prepared, $request )
$total_pages = (int) ceil( $total_results / (int) $query->get( 'posts_per_page' ) );

return compact( 'current_page', 'total_results', 'total_pages' );

}

/**
Expand Down Expand Up @@ -411,7 +407,6 @@ public function get_collection_params() {
}

return $query_params;

}

/**
Expand All @@ -437,7 +432,6 @@ protected function prepare_collection_query_args( $request ) {
$query_args = $this->prepare_items_query( $prepared, $request );

return $query_args;

}

/**
Expand Down Expand Up @@ -622,7 +616,6 @@ public function update_item( $request ) {
do_action( "llms_rest_after_insert_{$this->post_type}", $object, $request, $schema, false );

return $this->prepare_item_for_response( $object, $request );

}

/**
Expand Down Expand Up @@ -673,7 +666,6 @@ public function delete_item_permissions_check( $request ) {
}

return true;

}

/**
Expand Down Expand Up @@ -747,7 +739,6 @@ public function delete_item( $request ) {
}

return $response;

}

/**
Expand Down Expand Up @@ -786,7 +777,6 @@ protected function is_trash_supported() {
protected function get_objects_query( $prepared, $request ) {

return new WP_Query( $prepared );

}

/**
Expand All @@ -801,7 +791,6 @@ protected function get_objects_query( $prepared, $request ) {
protected function get_objects_from_query( $query ) {

return $query->posts;

}

/**
Expand Down Expand Up @@ -830,7 +819,6 @@ protected function prepare_collection_items_for_response( $objects, $request ) {
}

return $items;

}

/**
Expand Down Expand Up @@ -880,7 +868,6 @@ protected function prepare_object_for_response( $object, $request ) {
);

return $data;

}

/**
Expand Down Expand Up @@ -925,7 +912,6 @@ protected function prepare_object_data_for_response( $object, $request ) {
wp_reset_postdata();

return $data;

}

/**
Expand Down Expand Up @@ -956,7 +942,6 @@ protected function prepare_items_query( $prepared_args = array(), $request = nul
}

return $query_args;

}

/**
Expand Down Expand Up @@ -985,7 +970,6 @@ protected function prepare_items_query_orderby_mappings( $query_args, $request )
}

return $query_args;

}

/**
Expand Down Expand Up @@ -1093,7 +1077,6 @@ protected function prepare_item_for_database( $request ) {
}

return $prepared_item;

}

/**
Expand Down Expand Up @@ -1150,7 +1133,7 @@ protected function get_item_schema_base() {
'title' => array(
'description' => __( 'Post title.', 'lifterlms' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'context' => array( 'view', 'edit', 'embed' ),
'arg_options' => array(
'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database().
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database().
Expand All @@ -1165,7 +1148,7 @@ protected function get_item_schema_base() {
'rendered' => array(
'description' => __( 'Rendered title.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
),
Expand Down Expand Up @@ -1231,7 +1214,7 @@ protected function get_item_schema_base() {
'description' => __( 'Post URL.', 'lifterlms' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
'slug' => array(
Expand All @@ -1246,7 +1229,7 @@ protected function get_item_schema_base() {
'description' => __( 'LifterLMS custom post type', 'lifterlms' ),
'type' => 'string',
'readonly' => true,
'context' => array( 'view', 'edit' ),
'context' => array( 'view', 'edit', 'embed' ),
),
'status' => array(
'description' => __( 'The publication status of the post.', 'lifterlms' ),
Expand Down Expand Up @@ -1290,7 +1273,6 @@ protected function get_item_schema_base() {
);

return $schema;

}

/**
Expand Down Expand Up @@ -1421,7 +1403,6 @@ protected function prepare_links( $object, $request ) {
}

return $links;

}

/**
Expand Down Expand Up @@ -1454,7 +1435,6 @@ protected function maybe_remove_filters_for_response( $object ) {
}

return $filters_removed;

}

/**
Expand Down Expand Up @@ -1504,7 +1484,6 @@ protected function get_filters_to_be_removed_for_response( $object ) {
* @param LLMS_Post_Model $object LLMS_Post_Model object.
*/
return apply_filters( "llms_rest_{$this->post_type}_filters_removed_for_response", array(), $object );

}

/**
Expand Down Expand Up @@ -1574,7 +1553,6 @@ protected function handle_featured_media( $featured_media, $object_id ) {
} else {
return delete_post_thumbnail( $object_id );
}

}

/**
Expand Down Expand Up @@ -1655,7 +1633,6 @@ protected function check_assign_terms_permission( $request ) {
protected function get_taxonomy_rest_base( $taxonomy ) {

return ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;

}

/**
Expand All @@ -1669,7 +1646,6 @@ protected function check_create_permission() {

$post_type = get_post_type_object( $this->post_type );
return current_user_can( $post_type->cap->publish_posts );

}

/**
Expand All @@ -1684,7 +1660,6 @@ protected function check_update_permission( $object = null ) {

$post_type = get_post_type_object( $this->post_type );
return is_null( $object ) ? current_user_can( $post_type->cap->edit_posts ) : current_user_can( $post_type->cap->edit_post, $object->get( 'id' ) );

}

/**
Expand All @@ -1699,7 +1674,6 @@ protected function check_delete_permission( $object ) {

$post_type = get_post_type_object( $this->post_type );
return current_user_can( $post_type->cap->delete_post, $object->get( 'id' ) );

}

/**
Expand Down Expand Up @@ -1750,7 +1724,6 @@ protected function check_read_permission( $object ) {
}

return false;

}


Expand Down Expand Up @@ -1850,5 +1823,4 @@ public function sanitize_post_statuses( $statuses, $request, $parameter ) {

return $statuses;
}

}
Loading
Loading