Skip to content

Instantly share code, notes, and snippets.

View annalinneajohansson's full-sized avatar
🐱

Anna annalinneajohansson

🐱
  • Frontwalker Group AB
  • Sweden
  • 17:27 (UTC +02:00)
View GitHub Profile
@gemmadlou
gemmadlou / remove-visual-composer-shortcodes.md
Last active April 20, 2024 14:56
Removing Visual Composer & Shortcodes From Wordpress Content

Adding @k1sul1's suggestion from the comments as it's more concise than what I had before:

I just wanted them all gone, so I ran this in the MySQL shell.

UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, "\\[\/?vc(.*?)\]", "");

Note the double backslash. If you forget it, you'll replace all v's and c's with nothing, and the shortcodes will still be there. This works for other shortcode as well, just replace vc.

@annalinneajohansson
annalinneajohansson / provision.sh
Created May 25, 2016 13:40
Basic LAMP Vagrant provision script for Ubuntu servers
#!/usr/bin/env bash
# update / upgrade
sudo apt-get update > /dev/null 2>&1
sudo apt-get -y upgrade > /dev/null 2>&1
# Install Apache and PHP
sudo apt-get install -y apache2 php5 php5-curl > /dev/null 2>&1
# install mysql and give password to installer
@Debadge
Debadge / fix_multisite_srcset.php
Created February 17, 2016 14:07
Fixes srcset URLs on WordPress Multisite installations when using Domain Mapping
// Fix the URLS generated by media srcset from WP 4.4+
//
// When viewing the srcset URLs for images on a 4.4+ WordPress installation,
// it was showing my multisite subdomain URL rather than the domain chosen during Domain Mapping
//
// Add to your functions.php and modify the URL fields
//
// See: https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/
function fix_multisite_srcset( $sources ){
foreach ( $sources as &$source ) {
@annalinneajohansson
annalinneajohansson / .htaccess
Last active November 18, 2019 09:55
# Attempt to load files from production if they're not in our local version. Adapted from: http://stevegrunwell.com/blog/keeping-wordpress-under-version-control-with-git
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^local.site\.com$
RewriteRule ^wp-content/uploads/(.*)$ https://production.site.com/wp-content/uploads/$1 [NC,L]
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@rrosiek
rrosiek / install_mysql.sh
Last active June 5, 2023 07:08
Vagrant provision script for php, Apache, MySQL, phpMyAdmin, Laravel, and javascript helpers. Tested with Ubuntu 16.04.
#! /usr/bin/env bash
###
#
# install_mysql.sh
#
# This script assumes your Vagrantfile has been configured to map the root of
# your application to /vagrant and that your web root is the "public" folder
# (Laravel standard). Standard and error output is sent to
# /vagrant/vm_build.log during provisioning.
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active January 8, 2024 13:24
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@alettieri
alettieri / Vagrantfile
Last active February 3, 2021 19:41
Vagrantfile and LAMP provisioning script. This is a set of scripts composed for a WordPress meetup talk. http://www.meetup.com/wordpress-sf/events/144084162/ The vagrantfile will build a lucid32 machine, then kicks off some provision scripts: provision.sh: Install LAMP stack, Ruby, SASS and Compass. apache.sh Updates the default apache config fi…
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@justintadlock
justintadlock / register-post-type.php
Last active October 22, 2023 05:55
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@chipbennett
chipbennett / gist:6173596
Created August 7, 2013 12:23
Reusable add_meta_box()
// Add the Meta Box
function add_custom_meta_box() {
// Post
add_meta_box(
'cram_post_meta_box', // $id
'Additional information for the post', // $title
'add_custom_meta_box_callback', // $callback
'post', // $page
'normal', // $context
'high' // $priority