Created
June 20, 2022 19:43
-
-
Save Alimir/c05e35c968d27c62627b826cd0b4a279 to your computer and use it in GitHub Desktop.
Add wp ulike block in the card builder (wpgridbuilder plugin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function register_wp_ulike_block( $blocks ) { | |
$blocks['custom_field_image_block'] = [ | |
'name' => 'WP ULike Button', | |
'render_callback' => 'render_wp_ulike_block', | |
]; | |
return $blocks; | |
} | |
add_filter( 'wp_grid_builder/blocks', 'register_wp_ulike_block' ); | |
function render_wp_ulike_block() { | |
// Object can be a post, term or user. | |
$object = wpgb_get_object(); | |
// If this is not a post (you may change this condition for user or term). | |
if ( ! isset( $object->post_type ) ) { | |
return; | |
} | |
echo wp_ulike( 'put', array( | |
'id' => $object->ID | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment