Skip to content

Instantly share code, notes, and snippets.

View ctalkington's full-sized avatar

Chris Talkington ctalkington

View GitHub Profile
@remcotolsma
remcotolsma / gist:6103897
Last active July 19, 2018 21:19
Analytics tracking code per language (WPML)
<?php
/**
* Google Analytics tracking code per language (WPML)
*
* @param array $options
* @see http://plugins.trac.wordpress.org/browser/google-analytics-for-wordpress/tags/4.3.3/frontend/class-frontend.php#L12
*/
function prefix_ga_init( $options ) {
global $yoast_ga;
@ericrasch
ericrasch / database encoding fix.sql
Last active July 17, 2018 07:48
Fix WordPress database encoding issues with these MySQL queries... source #1: http://tanyanam.com/technology/fixing-encoding-issues-on-wordpress-comments-display-as-question-marks source #2: http://stackoverflow.com/a/3568144/284091 The 3 groups of repeated queries include the post content, post title, and the post slug.
ALTER DATABASE 'my_wp_database' CHARACTER SET utf8;
ALTER TABLE 'wp_comments' CHARACTER SET utf8;
alter table 'wp_comments' change comment_content comment_content LONGTEXT CHARACTER SET utf8;
alter table 'wp_comments' change comment_author comment_author LONGTEXT CHARACTER SET utf8;
update `wp_posts` set `post_content` = replace(`post_content` ,'á','á');
update `wp_posts` set `post_content` = replace(`post_content` ,'é','é');
update `wp_posts` set `post_content` = replace(`post_content` ,'í©','é');
update `wp_posts` set `post_content` = replace(`post_content` ,'ó','ó');
proxy_cache_path /var/cache/nginx levels=2 keys_zone=my_diskcached:50m inactive=365d max_size=7g;
server {
listen 80;
server_name cdn.jsdelivr.net HOSTNAME.jsdelivr.net;
location / {
access_log off;
gzip on;
gzip_min_length 100;
gzip_types text/plain text/xml application/xml text/css text/javascript application/javascript application/x-javascript text/x-component application/json application/xhtml+xml application/rss+xml application/atom+xml application/vnd.ms-fontobject image/svg+xml application/x-font-ttf font/opentype;
@davidmh
davidmh / custom-post-type-archive-menu-links.php
Last active October 14, 2016 08:11 — forked from helgatheviking/custom-post-type-archive-menu-links.php
Adds Custom Post Type archives to the WordPress-powered menus. Compatible with WP 3.8
<?php
/*
Plugin Name: Custom Post Type Archive Menu Links
Plugin URI: http://codeseekah.com/2012/03/01/custom-post-type-archives-in-wordpress-menus-2/
Description: Easily Add Custom Post Type Archives to the Nav Menus
Version: 1.1
Author: soulseekah
Author URI: http://codeseekah.com
License: GPL2
@jchristopher
jchristopher / gist:8833e71f1d9c8afaf58b
Created August 14, 2014 15:56
Make [video] in WordPress 3.9 responsive
// still not sure why
video {
width: 100%;
height: 100%;
max-width: 100%;
}
.wp-video {
width: 100% !important;
}
@domenic
domenic / 0-github-actions.md
Last active April 8, 2024 23:35
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
@shanebp
shanebp / bp-profile-tab-and-subnav.php
Last active June 28, 2023 18:11
BuddyPress add profile tab and subnav
function add_animal_tabs() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Animals',
'slug' => 'animals',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'animals_screen',
'position' => 200,
@gbot
gbot / wp-xmlrpc-jail.local
Last active July 26, 2023 17:07
Fail2Ban WordPress XMLRPC Jail and Filter. Notes: log path is set for Plesk v12.x. Change this to appropriate path for your set up. Only works if WordPress is installed in webroot, edit the Filter failregex if installed in sub-directory.
[wp-xmlrpc]
enabled = true
filter = wp-xmlrpc
action = iptables-multiport[name=wp-xmlrpc, port="http,https"]
logpath = /var/www/vhosts/system/*/logs/*access*log
/var/log/httpd/*access_log
bantime = 86400
maxretry = 0
@nathanrice
nathanrice / functions.php
Created January 6, 2016 16:41
Add back blogPosting Schema to Genesis sites
<?php
/*
Add back Schema.org/blogPosting microdata to post entries.
Replace all instances of "themedemo" with something unique to your site.
User input is required in the last function. Be sure to fill these fields in with your own information.
Instances where you need to fill in information will be marked with a comment that indicates so.
*/
@willbroderick
willbroderick / seo-hacks.liquid
Last active March 22, 2021 16:50
Shopify SEO - attempt to avoid duplicate meta descriptions
Two changes to make in theme.liquid
It will add 'Page 2' etc to the meta description for collection/blog pages, to make those different.
It adds a canonical tag for tag-filtered pages, back to the base collection/blog page.
*** This is the standard meta description code: ***
{% if page_description %}
<meta name="description" content="{{ page_description | escape }}" />
{% endif %}