Skip to content

Instantly share code, notes, and snippets.

View juniormiranda89's full-sized avatar

Junior Miranda juniormiranda89

View GitHub Profile
@swissspidy
swissspidy / web-stories-disable-feed-link.php
Created February 21, 2023 17:00
Mini-plugin to disable the Web Stories plugin's default feed link output
@swissspidy
swissspidy / web-stories-additional-gtag.php
Last active September 26, 2023 14:23
Mini-plugin to add an additional Google Analytics tracking code to web stories.
<?php
/**
* Plugin Name: Web Stories Custom Google Analytics
* Description: Mini-plugin to add an additional Google Analytics tracking code to web stories.
* Plugin URI: https://wp.stories.google/
* Author: Pascal Birchler, Google
* Author URI: https://opensource.google.com/
* Version: 0.0.1
* License: Apache License 2.0
* License URI: https://www.apache.org/licenses/LICENSE-2.0
@devinsays
devinsays / performance.php
Created November 19, 2021 18:17
Dequeue scripts and styles
<?php
namespace DevPress\Frontend;
/**
* Class Performance
*
* @package DevPress\Performance
*/
class Performance {
<?php
/**
* Elevate resource hints from link elements to headers.
*
* @link https://github.com/ampproject/amp-toolbox-php/issues/176
* @package Google\AmpElevateResourceHints
*/
namespace Google\AmpElevateResourceHints;
@westonruter
westonruter / amp-responsive-image-preload-link-srcset-opt-in.php
Last active October 26, 2022 15:02
Enable preload links for responsive hero images which have srcset and sizes attributes. This is disabled by default because only Chrome supports imagesrcset and imagesizes on preload links. This eliminates the Optimizer from raising this notice: CannotPreloadImage: Not preloading the hero image because of the presence of a srcset attribute…
@Aabill
Aabill / array_filter.php
Last active January 16, 2024 17:57
Filtering Array with in_array() function.
$products = [
["code" => 'btk', "name" => 'Butik'],
["code" => 'umt', "name" => 'Urmot'],
["code" => 'klo', "name" => 'Kalbo'],
];
$codes = ["umt","btk"];
$filtered = array_filter($products, function($p) use($codes) {
return in_array($p["code"], $codes);
});
@berkorbay
berkorbay / github_desktop_ubuntu.md
Last active July 25, 2024 10:23
To install Github Desktop for Ubuntu

IMPORTANT

See the following links for further updates to Github Desktop for Ubuntu. These are official instructions. (also mentioned by fetwar on Nov 3, 2023)

For the sake of "maintaining the tradition" here is the updated version.

@EngKhaledB
EngKhaledB / Fix Slow NGINX PHP on WSL.md
Last active December 12, 2023 15:30
If you have slow NGINX PHP-FPM performance on Windows Subsytem for Linux (WSL) .. here is the Solution!

1- Locate nginx.conf on your server, which almost on this path /etc/nginx/nginx.conf

2- Add this code under the http block fastcgi_buffering off;

Refrence: microsoft/WSL#2100 (comment)

@sabrina-zeidan
sabrina-zeidan / delete_empty_tags.php
Created July 22, 2017 15:00
Bulk delete unused tags [Wordpress]
function delete_empty_tags(){
$tags = get_tags( array('number' => 0,'hide_empty' => false));
foreach ( $tags as $tag ) {
$tag_count = $tag->count;
if ($tag_count < 1 ){
wp_delete_term( $tag->term_id, 'post_tag' );
}
}
}
add_action( 'wp_head', 'delete_empty_tags' );
@sabrina-zeidan
sabrina-zeidan / delete_tags_with_no_posts.php
Created July 22, 2017 14:59
Bulk delete tags with no posts (posts only check, may probable have cpt attached) [Wordpress]
function delete_tags_with_no_posts(){
$tags = get_tags( array('number' => 0,'hide_empty' => false));
foreach ( $tags as $tag ) {
$tag_id = $tag->term_id;
$args = array( 'post_type' => 'post', 'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => $tag_id