Schema.org, top snippets for your portfolio or blog with spatie/schema-org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// There seems to be a few algorithms floating around for brightness/luminance detection. | |
// One uses NTSC `(299*R + 587*G + 114*B)` which is incorrect for web colors (sRGB) see | |
// `rgbLuminance` for "better" coefficients (seems subjective but agreed apon). To be more | |
// accurate you need to also convert RGB from sRGB color space (which gives more spectrum to lighter colors) | |
// to linear rgb which normalizes colors across the spectrum - better for processing. | |
// see https://stackoverflow.com/questions/596216/formula-to-determine-perceived-brightness-of-rgb-color | |
// convert sRGB to linear RGB values | |
// - channel ** 2.218 same as Math.pow((channel + 0.055) / 1.055, 2.4) | |
// - i've seen this simplified to be just `(channel / 255) ** 2.21` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For Yoast SEO Plugin Version: 14.1+ add to your Wordpress Theme's functions.php... | |
// Remove All Yoast HTML Comments | |
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 | |
// Credit @devendrabhandari (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-3303423) | |
add_filter( 'wpseo_debug_markers', '__return_false' ); | |
// For Yoast SEO Plugin Version: < 14.1 add to your Wordpress Theme's functions.php... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Remove Yoast HTML Comments | |
//https://gist.github.com/robwent/f36e97fdd648a40775379a86bd97b332 | |
function go_yoast() { | |
if (defined('WPSEO_VERSION')){ | |
add_action('get_header',function (){ ob_start(function ($o){ | |
return preg_replace('/\n?<.*?Yoast SEO plugin.*?>/mi','',$o); }); }); | |
add_action('wp_head',function (){ ob_end_flush(); }, 999); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change min password strength. | |
* | |
* @author James Kemp (Iconic) | |
* @link http://iconicwp.com/decrease-strength-required-woocommerce-passwords/ | |
* @param int $strength | |
* @return int | |
*/ | |
function myclass_min_password_strength( $strength ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include ("classes/Schema_Event.php"); | |
add_filter( 'wpseo_schema_graph_pieces', 'PREFIX_add_graph_pieces', 11, 2 ); | |
/** | |
* Adds Schema pieces to our output. | |
* | |
* @param array $pieces Graph pieces to output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \Yoast\WP\SEO\Generators\Schema\Abstract_Schema_Piece; | |
class Schema_Event extends Abstract_Schema_Piece { | |
/** | |
* Determines whether or not a piece should be added to the graph. | |
* | |
* @return bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
if (window.jQuery) { | |
jQuery(document).ready(function() { | |
jQuery(document).on('submit_success', '.elementor-form', function(event) { | |
// Push the event to the dataLayer for Google Tag Manager | |
window.dataLayer = window.dataLayer || []; | |
window.dataLayer.push({ | |
event: 'elementor_form_submission', | |
formName: event.target.getAttribute('name') || | |
(event.target.querySelector('[name="form_id"]') ? event.target.querySelector('[name="form_id"]').value : 'unknown') || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Changes the search slug to /search/ for the JSON+LD output | |
*/ | |
function yst_change_json_ld_search_url() { | |
return trailingslashit( home_url() ) . 'search/{search_term}'; | |
} | |
add_filter( 'wpseo_json_ld_search_url', 'yst_change_json_ld_search_url' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'get_header', 'themeprefix_cpt_microdata' ); | |
//Change microdata for events custom post type | |
function themeprefix_cpt_microdata() { | |
if ('event' == get_post_type()) {//change to your cpt | |
//add in the microdata changes | |
add_filter( 'genesis_attr_entry', 'themeprefix_genesis_attributes_entry', 20 ); |