Skip to content

Instantly share code, notes, and snippets.

View danielpowney's full-sized avatar

Daniel Powney danielpowney

View GitHub Profile
<?php
function strip_shortcode_from_excerpt( $content ) {
$content = strip_shortcodes( $content );
return $content;
}
add_filter('the_excerpt', 'strip_shortcode_from_excerpt');
<?php
/**
* Changes order of comment form fields for anonymous users. Rating form items first, followed
* by comment, author, email and url. Note the comment_form_fields filter is only available since
* WordPress 4.4
*
* @param array $fields
* @return array $fields
*/
function my_comment_form_fields( $fields ) {
<?php
if ( function_exists( 'mrp_rating_result' ) ) {
mrp_rating_result();
// you can also pass in parameters such as the the post id if needed e.g. mrp_rating_result( array( 'post_id' => $post_id ) );
}
<?php
// get post id - assumes in WP loop
global $post;
$post_id = $post->ID;
// get default rating form for post, this checks the filter settings, post meta and general settings
$rating_form_id = MRP_Utils::get_rating_form( $post_id );
// get current logged in user
$user_id = 0; // anonymous
<?php
$rating_form_id = 1;
if ( class_exists( 'MRP_Multi_Rating_API' ) ) {
$rating_form = MRP_Multi_Rating_API::get_rating_form( $rating_form_id );
// do something
}
<?php
/**
* Automatically approve ratings > 3 out 5 stars.
*/
function my_auto_approve_good_ratings( $auto_approve_ratings, $rating_entry ) {
$rating_result = mrp_calculate_rating_entry_result( $rating_entry );
if ( $rating_result['adjusted_star_result'] > 3 ) {
return true;
<?php
/**
* Adds necessary CSS classes for full star, half star and empty star ratings. Note it does
* not need to actually be a star.
*
* @param unknown $icon_classes
* @param unknown $icon_font_library
* @return string
*/
function my_add_icomoon_classes( $icon_classes, $icon_font_library ) {
<?php
/**
* Add IcoMoon generated fonts to the available font icon libraries in Multi Rating Pro
*
* @param unknown $icon_font_library_options
* @return unknown
*/
function my_add_icomoon_font_library_option( $icon_font_library_options ) {
$icon_font_library_options['icomoon-faces'] = __( 'IcoMoon Faces', 'multi-rating-pro' );
return $icon_font_library_options;
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?agusew');
src: url('fonts/icomoon.eot?agusew#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?agusew') format('truetype'),
url('fonts/icomoon.woff?agusew') format('woff'),
url('fonts/icomoon.svg?agusew#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
.amazon-rating-form {
text-align: right;
display: inline-block;
width: auto;
}
.amazon-rating-form p, .amazon-rating-form h4, .amazon-rating-form img {
text-align: left;
}