• Resolved chochi

    (@chochi)


    Is it possible to utilize a REST API to transmit an expiration date? If so, could you please guide me on how to accomplish this?

Viewing 1 replies (of 1 total)
  • Plugin Author andergmartins

    (@andergmartins)

    Hi @chochi not yet, but I added it as a feature request here: https://github.com/publishpress/PublishPress-Future/discussions/439 Feel free to visit and upvote it.

    For now, you can probably create a custom plugin or add a code to the functions.php file exposing the data with something like:

    <?php
    
    register_rest_field('post', 'expiration', [
        'get_callback' => function ($data) {
            $container = \PublishPressFuture\Core\DI\Container::getInstance();
            $modelFactory = $container->get(\PublishPressFuture\Core\DI\ServicesAbstract::EXPIRABLE_POST_MODEL_FACTORY);
    
            $model = $modelFactory($data['id']);
            
            return $model->getExpirationDate();
        },
    ]);
    

    Of course this is just a simple example, and in a few weeks we might release a new version of the plugin that will change how the expiration data is stored, but we could help you to adapt that when the time comes if needed.

Viewing 1 replies (of 1 total)
  • The topic ‘Expiration date via REST API’ is closed to new replies.