Skip to content

Instantly share code, notes, and snippets.

@code-flow
Created April 23, 2014 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-flow/11204937 to your computer and use it in GitHub Desktop.
Save code-flow/11204937 to your computer and use it in GitHub Desktop.
Purple Heart to Pages as Shortcode
<?php
/*
Plugin Name: Purple Heart to Pages as Shortcode
*/
add_action( 'wp', 'add_phrating_to_pages', 10 );
function add_phrating_to_pages() {
global $post, $wpb_purpleheart;
if ( ! is_a( $post, 'WP_Post' ) ) {
return;
}
if ( ! is_a( $wpb_purpleheart, 'WPB_Purple_Heart_Rating' ) ) {
return;
}
if ( get_post_type( $post ) == 'page' ) {
$wpb_purpleheart->_is_rating_active = true;
$wpb_purpleheart->_rating_in = 'shortcode';
}
}
@code-flow
Copy link
Author

This little plugin adds the Purple Heart Rating on the "page" post type of WordPress by a shortcode. The shortcode then should be added using <?php echo do_shortcode( '[purple_heart_rating]' ); ?> in one of your themes template files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment