Plugin Directory


Ignore:
Timestamp:
07/30/2026 02:10:55 PM (3 months ago)
Author:
TigrouMeow
Message:

Version 0.9.1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • social-engine/trunk/classes/rest.php

    r3377846 r3628743  
    136136                        register_rest_route( $this->namespace, '/publish_now', array(
    137137                                'methods' => 'POST',
    138                                 'permission_callback' => '__return_true',
     138                                'permission_callback' => array( $this->core, 'can_access_features' ),
    139139                                'callback' => array( $this, 'rest_publish_now' )
    140140                        ) );
    … …  
    815815                }
    816816
     817                $post_id = absint( $post_id );
     818                $post = get_post( $post_id );
     819
     820                if ( !$post ) {
     821                        return new WP_REST_Response([
     822                                'success' => false,
     823                                'message' => 'The post could not be found for the provided post id.',
     824                        ], 404 );
     825                }
     826
     827                if ( $post->post_type !== $this->core->get_social_post_type() ) {
     828                        return new WP_REST_Response([
     829                                'success' => false,
     830                                'message' => 'The post exists but is not a social post (invalid post type).',
     831                        ], 400 );
     832                }
     833
     834                if ( !$this->core->can_access_moderation_features() ) {
     835                        return new WP_REST_Response([
     836                                'success' => false,
     837                                'message' => 'Only an administrator or editor can publish this post.',
     838                        ], 403 );
     839                }
     840
    817841                $thumbnail_ids = json_decode( get_post_meta( $post_id, 'sclegn_thumbnails', true ) ) ?? [];
    818842                $allowd_mimes = array_unique( array_values( $this->core->get_allowed_thumbnail_mimes() ) );
Note: See TracChangeset for help on using the changeset viewer.