mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-05 10:25:45 +03:00
parent
7b2525aedb
commit
cbabdbb33e
11 changed files with 356 additions and 15 deletions
|
@ -2,12 +2,20 @@
|
|||
|
||||
namespace WordPressDotOrg\Theme\FiveForTheFuture_2024;
|
||||
|
||||
use function WordPressDotOrg\FiveForTheFuture\PledgeMeta\get_pledge_meta;
|
||||
use const WordPressDotOrg\FiveForTheFuture\Pledge\CPT_ID as PLEDGE_POST_TYPE;
|
||||
|
||||
require_once __DIR__ . '/inc/block-config.php';
|
||||
require_once __DIR__ . '/inc/block-bindings.php';
|
||||
|
||||
// Block files.
|
||||
require_once __DIR__ . '/src/pledge-edit-button/index.php';
|
||||
|
||||
/**
|
||||
* Actions and filters.
|
||||
*/
|
||||
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' );
|
||||
add_filter( 'the_content', __NAMESPACE__ . '\inject_pledge_content' );
|
||||
|
||||
/**
|
||||
* Enqueue scripts and styles.
|
||||
|
@ -30,3 +38,22 @@ function enqueue_assets() {
|
|||
$metadata['version']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the post content with the pledge description.
|
||||
*
|
||||
* @param string $content Content of the current post.
|
||||
*
|
||||
* @return string Updated content.
|
||||
*/
|
||||
function inject_pledge_content( $content ) {
|
||||
if ( PLEDGE_POST_TYPE !== get_post_type() ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
remove_filter( 'the_content', __NAMESPACE__ . '\inject_pledge_content' );
|
||||
|
||||
$data = get_pledge_meta( get_the_ID() );
|
||||
$content = apply_filters( 'the_content', $data['org-description'] );
|
||||
return $content;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue