• Resolved azdenapier

    (@azdenapier)


    With the recent code changes to the plugin, I’m having problems hooking this into the Schema plugin, to create schema markup in Posts. This is the function I have in functions.php – before I dive into this, can you see any obvious changes needed to reflect the new structure?

    Thanks in advance!
    Az

    function schema_wp_extend_output_987345256( $schema ) {
    		
        global $post;
        global $readingTimeWP;
    	
    	if ( empty($schema) ) return;
    		
    	// Modify NewType to present the actual schema.org type
    	if ( $schema['@type'] == 'Article' && $post->post_type == 'post') {
            
            $reading_time = $readingTimeWP->rt_calculate_reading_time($post->ID, get_option('rt_reading_time_options') );
    	
            //Check for articles less than a minute read.
              if ($reading_time == '< 1') $reading_time = '1';
        
    	    // Create the Schema duration as per the ISO format: https://en.wikipedia.org/wiki/ISO_8601#Durations
    	      $schema['timeRequired'] = 'PT' . strval($reading_time) . 'M';
    
            // Debug - will only be presented when a post/page is edited and saved, forcing the schema to be regenerated.
            //echo '<pre>'; print_r($schema); echo '</pre>';
        }
        
        else {   
            // Debug - will only be presented when a post/page is edited and saved, forcing the schema to be regenerated.
            //echo '<pre>'; print_r($schema); echo '</pre>';
    
            return $schema;
        }
        	
    	return $schema;
    }
    • This topic was modified 5 years, 12 months ago by azdenapier.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jason Yingling

    (@yingling017)

    Hi there,

    It’s probably due to the changes made to match the WordPress coding standards. Mainly switching variables from camel case to snake case. Looking at your code it should be fixable by switching each occurrence of $readingTimeWP to $reading_time_wp.

    Let me know if that works for you.

    Thread Starter azdenapier

    (@azdenapier)

    That did the trick – thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Impact of recent code changes’ is closed to new replies.