Skip to content

Instantly share code, notes, and snippets.

View danielpowney's full-sized avatar

Daniel Powney danielpowney

View GitHub Profile
<?php
global $wpdb;
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . MRP_Multi_Rating::RATING_ITEM_ENTRY_TBL_NAME );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . MRP_Multi_Rating::RATING_ITEM_ENTRY_VALUE_TBL_NAME );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . MRP_Multi_Rating::RATING_ITEM_TBL_NAME );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . MRP_Multi_Rating::RATING_FORM_TBL_NAME );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . MRP_Multi_Rating::RATING_RESULT_TBL_NAME );
// custom fields
$custom_fields = MRP_Multi_Rating_API::get_custom_fields( null );
@danielpowney
danielpowney / recalc_after_rating_entry_status_changes.php
Last active April 25, 2017 10:40
When a comment status or rating entry status is changed, all "calculated" ratings which share the same rating form id or post id are deleted from the database. The ratings are recalculated when needed if using the shortcodes/auto placment. The WP query does not check if any ratings need to be recalculated. If necessary to recalclate the ratings …
<?php
// When a comment status or rating entry status is changed, all "calculated" ratings which share the same rating form
// id or post id are deleted from the database. The ratings are recalculated when needed if using the
// shortcodes/auto placment.
//
// The WP query does not check if any ratings need to be recalculated. If necessary to recalclate the ratings straight
// away, you can use the mrp_comment_status_changed and mrp_after_save_rating_entry_success hooks as follows.
/**
* If a comment status has changed, recalculate all post ratings associated with the rating form id
@danielpowney
danielpowney / rest-field.json
Created March 24, 2017 21:38
multi-rating-pro REST API field added to post object
{
"multi-rating-pro":{
"mrp_rating_result_1":[
{
"star_result":3,
"adjusted_star_result":3,
"score_result":3,
"adjusted_score_result":3,
"percentage_result":60,
"adjusted_percentage_result":60,
@danielpowney
danielpowney / custom-fields.json
Created March 24, 2017 21:26
custom-fields REST API route endpoint e.g. https://<website>/wp-json/mrp/v1/custom-fields
{
"1":{
"custom_field_id":1,
"label":"Sample custom field",
"max_length":255,
"type":"input",
"placeholder":""
}
}
@danielpowney
danielpowney / rating-item-results.json
Last active March 24, 2017 21:24
rating-item-results REST API route endpoint e.g. https://<website>/wp-json/mrp/v1/rating-item-results?post_id=1128&entry_status=
[
{
"adjusted_star_result":3.5,
"star_result":3.5,
"adjusted_score_result":3.5,
"score_result":3.5,
"adjusted_percentage_result":70,
"percentage_result":70,
"total_max_option_value":"5",
"count_entries":"2",
@danielpowney
danielpowney / rating-results.json
Created March 24, 2017 21:20
rating-results REST API route endpoint e.g. https://<website>/wp-json/mrp/v1/rating-results
{
"rating_results":[
{
"adjusted_star_result":3.9,
"star_result":3.9,
"adjusted_score_result":11.5,
"score_result":11.5,
"adjusted_percentage_result":76.7,
"percentage_result":76.7,
"total_max_option_value":"15",
@danielpowney
danielpowney / rating-forms.json
Last active March 24, 2017 21:25
rating-forms REST API route endpoint e.g. https://<website>/wp-json/mrp/v1/rating-forms
{
"1":{
"name":"Coffee Rating",
"rating_form_id":"1",
"rating_items":{
"61":{
"max_option_value":5,
"rating_item_id":61,
"description":"Aroma",
"default_option_value":5,
@danielpowney
danielpowney / rating-items.json
Last active March 24, 2017 21:25
rating-items REST API route endpoint e.g. https://<website>/wp-json/mrp/v1/rating-items
{
"61":{
"max_option_value":5,
"rating_item_id":61,
"description":"Aroma",
"default_option_value":5,
"option_value_text":"1=1 star,2=2 stars,3=3 stars,4=4 stars,5=5 stars",
"type":"star_rating",
"only_show_text_options":false
},
@danielpowney
danielpowney / rating-entries.json
Last active March 24, 2017 21:25
rating-entries REST API route endpoint e.g. https://<website>/wp-json/mrp/v1/rating-entries
[
{
"title":"",
"name":"",
"comment":"",
"comment_id":0,
"entry_date":"2017-03-24 21:50:16",
"entry_status":"approved",
"post_id":1128,
"rating_form_id":1,
<?php
/**
* Turn off custom text settings.
*/
function my_mrp_before_init() {
add_filter( 'mrp_disable_custom_text', 'my_mrp_disable_custom_text', 10, 1 );
}
add_action( 'mrp_before_init', 'my_mrp_before_init', 11, 0 );
/**