Skip to content

Instantly share code, notes, and snippets.

View danielpowney's full-sized avatar

Daniel Powney danielpowney

View GitHub Profile
@danielpowney
danielpowney / recalculate_rating_item_results.php
Last active December 18, 2016 02:14
Recalculate rating item results for a post and rating form.
<?php
/**
* Recalculate rating item results for a post and rating form
*
* @param unknown $post_id
* @param unknown $rating_form_id
*/
function mrp_recalculate_rating_item_results( $post_id, $rating_form_id ) {
$rating_form = MRP_Multi_Rating_API::get_rating_form( $rating_form_id );
@danielpowney
danielpowney / increase-star-thumb-icon-sizes.css
Created June 29, 2015 23:05
Increase size of star and thumb icons
.mrp-star-rating, .mrp-thumbs {
font-size: 150%;
}
@danielpowney
danielpowney / required_optional_fields.php
Last active August 29, 2015 14:24
Makes the name, e-mail and comment fields mandatory in the rating form.
<?php
/**
* Makes optional fields required
*
* @param unknown $validation_results
* @param unknown $fields
* @return $validation_results
*/
function mrp_optional_fields_validation( $validation_results, $fields ) {
<?php
/**
* Sets post_tag taxonomy terms that are allowed to do auto placement
*
* @param boolean $can_apply_filter
* @param string $filter_name
* @param string $value
* @param int $post_id
* @return $can_apply_filter
*/
<?php
/**
* Sets post_tag taxonomy terms that are allowed to do wp comment integration
*
* @param boolean $can_apply_filter
* @param string $filter_name
* @param string $value
* @param int $post_id
* @return $can_apply_filter
*/
<?php
function mrp_posts_fields( $posts_fields ) {
if ( is_main_query() ) {
$sticky_posts = get_option( 'sticky_posts' );
if ( is_array( $sticky_posts ) && ! empty( $sticky_posts ) ) {
$sticky_posts = implode( ', ', $sticky_posts );
<?php
/**
* Sets default rating form for a post based on category
*
* @param int $rating_form_id
* @param int $post_id
* @param array $params
* @return $rating_form_id
*/
function mrp_default_rating_form_by_category( $rating_form_id, $post_id, $params ) {
<?php
$query = new WP_Query( array( 'mrp_sort_highest_rated' => true ) );
/**
* Adds WP query sort by highest rating then count entries
*
* @param unknown $order_by
* @param unknown $query
* @return string
*/
@danielpowney
danielpowney / mrp_rating_result_recipe_microdata.php
Created August 13, 2015 10:04
Adds "http://schema.org/Recipe" microdata with aggregateRating. Replaces the default "http://schema.org/Article"
<?php
/**
* Adds "http://schema.org/Recipe" microdata with aggregateRating. Replaces the default
* "http://schema.org/Article"
*
* @param unknown $microdata
* @param unknown $rating_form_id
* @param unknown $post_id
* @param unknown $rating_result
* @return string
<?php
function my_include_minus( $include_minus ) {
return false;
}
add_filter( 'mrp_rating_form_include_minus', 'my_include_minus', 10, 1 );