get( $placement_id ); if ( ! $placement ) { return ''; } if ( $placement->get_type() !== 'manual' ) { Notification_Center::get()->register( [ 'type' => 'info', 'slug' => 'adpresso-manual-placement', 'message' => 'Wrong usage of manual placement', 'context' => 'adpresso-notifications', 'location' => 'admin_bar', // dashboard | admin_bar | wp_notice | reactive ] ); return ''; } $output = match ( $placement_data['output_mode'] ) { 'ssr' => $placement->render_with_wrapper( $placement_data['content'] ), 'js' => $placement->get_placeholder_html(), default => '', }; if ( ! $return ) { /* * phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is pre-checked by the placement renderer. * The output deliberately contains unfiltered HTML/JS for an advertisement. * Security is ensured by the preceding check `author_can( $post, ‘unfiltered_html’ )`. * This ensures that the code is only output raw if the author of the ad has the appropriate permission. When saving, entries from users without this permission are already rigorously cleaned up with `wp_kses_post()`. */ echo $output; } return $output; } } /** * Get an existing Placement by its post ID. * * @param int $post_id * * @return Placement|null */ function adpresso_get_placement( int $post_id ): ?Placement { if ( get_post_type( $post_id ) !== Constants::POST_TYPE_PLACEMENT ) { return null; } return adpresso_get_placement_repository()->get( $post_id ); } /** * Fetches the PlacementRepository instance from the Plugin globals. * * @return PlacementRepository */ function adpresso_get_placement_repository(): PlacementRepository { return Plugin::get()->globals[ PlacementRepository::class ]; }