Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
// 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`
@dexit
dexit / functions.php
Created July 2, 2025 14:25 — forked from paulcollett/functions.php
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin”
// 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...
@dexit
dexit / functions.php
Created July 2, 2025 14:25 — forked from robwent/functions.php
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin” with Yoast v11
//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);
}
}
<?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 ) {
@dexit
dexit / yoast-schema.php
Created July 2, 2025 14:25 — forked from robwent/yoast-schema.php
Extends Yoast schema to add event data
<?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.
@dexit
dexit / Schema_Event.php
Created July 2, 2025 14:25 — forked from robwent/Schema_Event.php
Extends Yoast schema data to add events
<?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
<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') ||
@dexit
dexit / gist:3e635c45470a425b67341550507e9ad0
Created July 2, 2025 14:06 — forked from jdevalk/gist:0b2ddd13d27cf869a976
Change WP SEO JSON+LD search URL from ?s= to /search/
<?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' );
@dexit
dexit / microdata-cpt.php
Created July 2, 2025 14:02 — forked from neilgee/microdata-cpt.php
Genesis Microdata Example - Changing a CPT SChema
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 );

Schema.org, top snippets for your portfolio or blog with spatie/schema-org