Skip to content

Instantly share code, notes, and snippets.

@mahircoding
Last active September 25, 2023 03:27
Show Gist options
  • Save mahircoding/5087f3013b3ecb3919d2cef20d3094fc to your computer and use it in GitHub Desktop.
Save mahircoding/5087f3013b3ecb3919d2cef20d3094fc to your computer and use it in GitHub Desktop.
rest api updater salesloo
<?php
function get_latest_update($request) {
$id = 'ID FILE LICENSE';
$purchase_code = sanitize_text_field($request->get_param('purchase_code'));
$host = sanitize_text_field($request->get_param('host'));
$item = get_post(salesloo_get_item_by_license_id($id));
$package = get_post_meta($item->ID, 'package', true);
return new \WP_REST_Response([
'name' => $item->post_title,
'slug' => $item->post_name,
'version' => get_post_meta($item->ID, 'version', true),
'tested' => '6.3.1',
'requires' => '6.2',
'author' => '<a href="https://domain.com">Plugin Name</a>',
'author_profile' => 'https://domain.com',
'download_url' => get_post_meta($item->ID, 'package', true),
'requires_php' => '7.4',
'last_update' => get_the_modified_date('Y-m-d H:i', $item->ID),
'sections' => array(
'description' => $item->post_content,
'installation' => '',
'frequently_asked_questions' => '',
'screenshots' => '',
'changelog' => get_post_meta($item->ID, 'changelog', true),
),
'banners' => array(
'low' => '',
'high' => '',
)
], 200);
}
add_action('rest_api_init', function () {
register_rest_route( 'update/v2', 'file',array(
'methods' => 'GET',
'callback' => 'get_latest_update'
));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment