Changeset 12108
- Timestamp:
- 10/07/2022 06:40:11 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/posts.php
r11679 r12108 14 14 */ 15 15 public static function init() { 16 add_action( 'publish_' . Registrations::get_post_type(), [ __CLASS__, 'make_photo_attachment_available' ] ); 16 $post_type = Registrations::get_post_type(); 17 18 add_action( "publish_{$post_type}", [ __CLASS__, 'make_photo_attachment_available' ] ); 17 19 add_action( 'before_delete_post', [ __CLASS__, 'delete_attachments' ], 10, 2 ); 18 20 add_action( 'delete_attachment', [ __CLASS__, 'delete_photo_post' ], 10, 2 ); … … 27 29 // Fix pages count for front page paginations. 28 30 add_filter( 'the_posts', [ __CLASS__, 'fix_front_page_pagination_count' ], 10, 2 ); 31 32 // Modify REST response to include URL to small photo (used by Profiles). 33 add_filter( "rest_prepare_{$post_type}", [ __CLASS__, 'rest_prepare_add_photo_url' ] ); 34 } 35 36 /** 37 * Amends REST response for photos to include URL to small version of photo. 38 * 39 * @param WP_REST_Response $response 40 * @return WP_REST_Response 41 */ 42 public static function rest_prepare_add_photo_url( $response ) { 43 $data = $response->get_data(); 44 45 $data['photo-thumbnail-url'] = wp_get_attachment_image_src( get_post_thumbnail_id( $data['id'] ), 'medium' )[0]; 46 47 $response->set_data( $data ); 48 49 return $response; 29 50 } 30 51
Note: See TracChangeset
for help on using the changeset viewer.