Skip to content

Instantly share code, notes, and snippets.

@maxyudin
maxyudin / wordpress_low-quality-image-placeholders_lqip.md
Created October 5, 2019 10:32 — forked from ctlcltd/wordpress_low-quality-image-placeholders_lqip.md
How to easily generate low quality image placeholders (lqip) in WordPress

How to easily generate low quality image placeholders (lqip) in WordPress

I have made this function using the WP_Image_Editor class and I have filtered through the "wp_generate_attachment_metadata" hook. You can modify the "theme" namespace into function names with your theme name or in anyway you like.

Applying the filter directly to wp_generate_attachment_metadata the image placeholders are auto added into WordPress metadata, so when your add/modify/delete an image (or regenerate it via a plugin), it accomplishes to modify also to the image placeholders.

The use of the native theme support can prevent the generation of lqip or target specific image sizes to generate.

It contains an hook filter lqip_quality to modify the quality without have to modify the function.

@maxyudin
maxyudin / custom_menu_admin.php
Created September 29, 2019 12:44 — forked from carlodaniele/custom_menu_admin.php
A basic plugin showing how to add menu metaboxes to admin menu page
<?php
/**
* @package Custom_menu_admin
* @version 1.0
*/
/*
Plugin Name: Custom menu admin
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}
@maxyudin
maxyudin / 2018-https-localhost.md
Last active October 21, 2020 15:14 — forked from cecilemuller/2019-https-localhost.md
Как создать сертификат HTTPS для доменов и субдоменов на localhost

How to create an HTTPS certificate for localhost domains

Как создать HTTPS сертификат для доменов и субдоменов на localhost

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only. Этот пример служит для создания сертификатов для виртуальных хостов (доменов и поддоменов) на локалхосте.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial). Нельзя использовать этот пример для сайтов «в продакшне», для них есть Let's Encrypt (Урок).

<?php
// Modified from https://gist.github.com/ericclemmons/6275346#gistcomment-2248160
// Add to: path/to/wp-content/wp-themes/your-theme/functions.php
/**
* Activate required plugins
*/
include_once ( ABSPATH . 'wp-admin/includes/plugin.php' );
foreach ( array('plugin-name',) as $plugin ) {
@maxyudin
maxyudin / wordpress-foundation-interchange.php
Last active April 22, 2017 11:02 — forked from Shelob9/foundation-interchange.php
Function to use Foundation's Interchange to make WordPress images automatically responsive. Also included is a function to add Interchange to the theme if Foundation is not already being used.http://foundation.zurb.com/docs/components/interchange.html
add_filter('post_thumbnail_html', 'slug_responsive_img', 5, 5);
//Image sizes for Interchange
add_image_size( 'fd-lrg', 1024, 99999);
add_image_size( 'fd-med', 768, 99999);
add_image_size( 'fd-sm', 320, 9999);
function slug_responsive_img($html, $post_id, $post_thumbnail_id, $size, $attr) {
//make image links
$attachment_id = $post_thumbnail_id;
$default = wp_get_attachment_image_src($attachment_id);
<?php
/**
* Plugin Name: WooCommerce Plugin Templates
* Plugin URI: http://jeroensormani.com
* Description: A simple demo plugin on how to use template files within your plugin.
*/
/**
* Locate template.
@maxyudin
maxyudin / [WordPress] Recursive wp_parse_args
Last active April 19, 2017 16:03 — forked from boonebgorges/gist:5510970
A recursive sorta-version of wp_parse_args()
<?php
/**
* Recursive argument parsing
*
* This acts like a multi-dimensional version of wp_parse_args() (minus
* the querystring parsing - you must pass arrays).
*
* Values from $a override those from $b; keys in $b that don't exist
* in $a are passed through.