Skip to content

Instantly share code, notes, and snippets.

View danielpowney's full-sized avatar

Daniel Powney danielpowney

View GitHub Profile
@danielpowney
danielpowney / gist:f98e8c2bc64f6159d50c05adf2023107
Last active July 4, 2020 05:45
mr_custom_rating_form_validation_check.php
<?php
/**
* Custom rating form validation free version
*
* @param unknown $validation_results
* @param unknown $data
* @return $validation_results
*/
function mr_custom_rating_form_validation_check( $validation_results, $data ) {
<?php
/**
* Adds example mainEntityofPage to Product type based on WordPress SEO graph
*/
function mrp_structured_data_type_product_main_entity_example( $schema, $post_id ) {
$structured_data_type = get_post_meta( $post_id, MRP_Multi_Rating::STRUCTURED_DATA_TYPE_POST_META, true );
if ( $structured_data_type === 'Product' ) {
return '
<?php
/**
* Adds example address, priceRange and telephone data to the LocalBusiness type
*/
function mrp_structured_data_type_localbusiness_example( $schema, $post_id ) {
$structured_data_type = get_post_meta( $post_id, MRP_Multi_Rating::STRUCTURED_DATA_TYPE_POST_META, true );
if ( $structured_data_type === 'LocalBusiness' ) {
return '
@danielpowney
danielpowney / mrp_jsonld_example.php
Created November 9, 2019 03:36
Adds schema.org JSON-LD for MRP post ratings
/**
* Adds JSON-LD ratings for schema.org item types
*/
function mrp_jsonld_ratings() {
if ( is_page() || is_single() ) {
$post_id = get_queried_object_id();
if ($post_id == null) {
return;
<?php
/**
* If pretty permalinks are turned on, we need to make the following query string variables
* available to WP_Query to sort by highest rated posts
*/
function my_query_vars( $qvars ) {
$qvars[] = 'orderby';
$qvars[] = 'meta_key';
$qvars[] = 'order';
$qvars[] = 'ignore_sticky_posts';
<?php
$q1 = new WP_Query( array(
'meta_key' => 'mrp_rating_result_1_star_rating',
'orderby' => 'meta_value',
) );
@danielpowney
danielpowney / wp-loop-example.php
Last active October 26, 2017 22:27
The WordPress Loop example
<?php
// The Query
$q1 = new WP_Query( $args );
// The Loop
if ( $q1->have_posts() ) {
while ( $q1->have_posts() ) {
$q1->the_post();
// Post content here
}
<?php
function mr_check_auto_placement2( $filter, $post_id, $rating_form_id) {
// only apply filter once... hopefully, this is the post title...
if ( in_the_loop() && ( is_single() || is_page() || is_attachment() ) && get_the_ID() != 430 ) {
remove_filter( $filter, 'mr_filter_' . $filter );
}
}
remove_action( 'mr_after_auto_placement', 'mr_check_auto_placement', 10 );
add_action( 'mr_after_auto_placement', 'mr_check_auto_placement2', 10, 3);
{
"type" : 3,
"imageUrl": "https://danielpowney.com/wp-content/uploads/2017/05/photo-1434396505260-9ec0d649179
}
{
"type":2,
"title":"Choose one",
"replies":[
"A",
"B",
"C",
"D"
]
}