Skip to content

Instantly share code, notes, and snippets.

@slaffko1
slaffko1 / gist:ffa4faa401665b371bc8ffc9a42528b9
Created September 21, 2020 19:03 — forked from joshuabaker/gist:313648
Get all images in a HTML string
<?php
/**
* Returns all img tags in a HTML string with the option to include img tag attributes
*
* @author Joshua Baker
*
* @example $post_images[0]->html = <img src="example.jpg">
* $post_images[0]->attr->width = 500
*
@gareth-gillman
gareth-gillman / functions.php
Created March 8, 2018 17:46
WordPress Preconnect Google Fonts
function gg_gfonts_prefetch() {
echo '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>';
echo '<link rel="preconnect" href="https://fonts.googleapis.com/" crossorigin>';
}
add_action( 'wp_head', 'gg_gfonts_prefetch' );
@vidaaudrey
vidaaudrey / ie67891011-css-hacks.txt
Created June 19, 2016 20:52 — forked from ricardozea/ie67891011-css-hacks.txt
IE CSS hacks - IE6, 7, 8, 9, 10, 11
IE6 Only
==================
_selector {...}
IE6 & IE7
==================
*html or { _property: }
IE7 Only
==================
@Rhymes2k
Rhymes2k / cpt-gallery.php
Last active January 17, 2019 16:21
WordPress Gallery Page With Custom Post Type And Custom Taxonomy
@schilke
schilke / functions.php
Last active February 23, 2023 18:53
How to load CSS files asynchronously in WordPress (using Scott Jehl's "loadCSS")
<?php
// This is the cleaner code per request of a thread in the LinkedIn group "WordPress"
// ...
// register and enqueue loadCSS
function load_scripts_and_styles() {
// register loadCSS
wp_register_script( 'load-css-async', get_stylesheet_directory_uri() . '/path/to/js/loadCSS.js', array(), '', false );
@Neolot
Neolot / gist:3964380
Last active September 19, 2023 12:52
PHP Склонение числительных
<?php
/**
* Функция склонения числительных в русском языке
*
* @param int $number Число которое нужно просклонять
* @param array $titles Массив слов для склонения
* @return string
**/
$titles = array('Сидит %d котик', 'Сидят %d котика', 'Сидит %d котиков');
function declOfNum($number, $titles)