Skip to content

Instantly share code, notes, and snippets.

import urllib.request
class HtmlDownloader(object):
def download(self, url):
if url is None:
return None
response = urllib.request.urlopen(url)
if response.getcode() != 200:
return None
return response.read()
@lukecav
lukecav / Links
Last active December 29, 2018 23:17
Plugins and themes that work with or have issues with WordPress 5.0 Gutenberg block editor
@damiencarbery
damiencarbery / remove-script-style-type.php
Last active December 19, 2018 10:44
Remove 'type' attribute from 'script' and 'style' tags to reduce W3C Validator warnings: https://www.damiencarbery.com/2018/11/remove-type-from-script-and-style-markup/
<?php
/*
Plugin Name: Remove type from script and style tags
Plugin URI: https://www.damiencarbery.com/2018/11/remove-type-from-script-and-style-markup/
Description: Remove 'type="text/javascript"' from 'script' tags and 'type="text/css"' from 'style' tags.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.2
*/
@anastransvelo
anastransvelo / function.php
Last active January 26, 2019 17:08
Electro mobile menu currency and language switcher
function ec_child_wpml_switcher() {
echo do_shortcode('[wpml_language_switcher type="widget" flags=1]');
do_action('wcml_currency_switcher', array('format' => '%symbol% %code%'));
}
add_action( 'electro_mobile_header_v1', 'ec_child_wpml_switcher', 25 );
add_action( 'electro_mobile_header_v2', 'ec_child_wpml_switcher', 25 );
@thierrypigot
thierrypigot / wearewp-disable-gutenberg.php
Created October 31, 2018 10:00
Disable Gutenberg in WordPress 5.0
<?php
/*
Plugin Name: WeAreWP Gutenberg
Description: Disable Gutenberg in WordPress 5.0
Plugin URI: https://www.wearewp.pro
Version: 1.0
Author: WeAre[WP]
Author URI: https://www.wearewp.pro
*/
@fernandiez
fernandiez / functions.php
Last active December 20, 2018 09:58
Shortcode Placeholder Image dummyimage_shortcode_function
// Añadir Shortcode
function dummyimage_shortcode_function( $atts ) {
// Atributos
$atts = shortcode_atts(
array(
'width' => '600',
'height' => '300',
'background' => 'eeeeee',
'text' => 'ffffff',
@haroldparis
haroldparis / functions.php
Last active December 19, 2018 11:09
Force Yoast SEO to only use Featured Image for og:image on singular
<?php
// Tell WordPress SEO to use only full featured image for og:image output... and nothing else on singular
function only_full_og_featured_image() {
global $post;
if ( is_singular() ) {
if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail( $post->ID ) ) {
$featured_image_url = wp_get_attachment_image_src(get_post_thumbnail_ID( $post->ID ), 'full' );
return $featured_image_url[0];
}
}
@zArubaru
zArubaru / the_seo_framework_image_output.php
Last active February 21, 2019 03:36
Limit The SEO Framework og:image and twitter:image sizes.
<?php
// Edit these to suit your needs
add_image_size( 'og-image', 1200, 630, true );
add_image_size( 'twitter-image', 1024, 512, true );
/**
* Limit The SEO Framework og:image and twitter:image sizes.
*
* For: https://fi.wordpress.org/plugins/autodescription/
*/
@chriswiggins
chriswiggins / snippet.php
Created August 17, 2018 05:19
Snippet to add images to Yoast sitemap from Impreza Wordpress theme
<?php
/* Add impreza images to Yoast sitemap, since Yoast doesn't read impreza's Page
* Builder code - borrowed from (https://github.com/Yoast/wordpress-seo/issues/4808) */
function impreza_filter_wpseo_sitemap_urlimages($images, $post_id)
{
$post = get_post($post_id);
if (is_object($post)) {
$content = $post->post_content;
@contemplate
contemplate / functions.php
Created July 14, 2018 04:58
WPBakery Page Builder ACF EXTRA Grid Item
/**************************************
* VC ACF GRID ITEM W/ RELATIONSHIP
***************************************/
add_filter( 'vc_grid_item_shortcodes', 'vc_grid_item_shortcode_acf_extra' );
function vc_grid_item_shortcode_acf_extra( $shortcodes ) {
$groups = function_exists( 'acf_get_field_groups' ) ? acf_get_field_groups() : apply_filters( 'acf/get_field_groups', array() );
$groups_param_values = $fields_params = array();
foreach ( $groups as $group ) {
$id = isset( $group['id'] ) ? 'id' : ( isset( $group['ID'] ) ? 'ID' : 'id' );
$groups_param_values[ $group['title'] ] = $group[ $id ];