Skip to content

Instantly share code, notes, and snippets.

View daviddarke's full-sized avatar
🚀

David Darke daviddarke

🚀
View GitHub Profile
@daviddarke
daviddarke / gitlab-ci.yml
Last active May 21, 2024 14:17
Gitlab pipeline to push to WP Engine
stages:
- deploy
Deploy:
before_script:
## Install ssh-agent if not already installed, it is required by Docker.
## (change apt-get to yum if you use an RPM-based image)
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
## Create the SSH directory and give it the right permissions
@daviddarke
daviddarke / update-woo-subscriptions-pricing
Last active October 2, 2019 10:51
Update WooCommerce subscription pricing for future subscription orders
if ( defined( 'WP_CLI' ) && WP_CLI ) {
class Woo_Subs_Cli extends WP_CLI_Command {
public function update_sub_pricing( $args ){
// Quick check to make sure all the require args are available
if( count( $args ) != 2 && is_numeric( $args[1] ) && floor( $args[1] ) != $args[1] ){
WP_CLI::line( 'Please provide 1 subscription ID and new price in this format:' );
WP_CLI::line( 'woosubscriptions update_sub_pricing 1111 30' );
echo "-> Getting rid of local SQL file"
mkdir data
rm -rf data/development.sql
touch data/development.sql
echo "-> Booting Docker"
docker-compose up --build -d
echo "-> Removing vendor folder"
rm -rf vendor
echo "-> Updating composer"
docker-compose exec php composer update
// Check that required variables exist
if( ( process.argv[2] == undefined ) || ( process.argv[3] == undefined ) ){
console.log('Missing variables')
console.log('1, local path to coverage file. 2, url to target css file')
return;
}
(async () => {
var fs = require("fs");
$(".header .user__menu a[href*='/students/sign_out']").on({
'click' : function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: "https://app.examfit.co.uk/students/sign_out",
crossDomain: true,
success: function( data, textStatus, jQxhr ){
alert('hi');
}
function gdpr_fields( $subscription_data ) {
$subscription_data['marketing_permissions'][0]['marketing_permission_id'] = '45e116b06';
$subscription_data['marketing_permissions'][0]['enabled'] = true;
$subscription_data['marketing_permissions'][1]['marketing_permission_id'] = '188d4ee19';
$subscription_data['marketing_permissions'][1]['enabled'] = false;
$subscription_data['marketing_permissions'][2]['marketing_permission_id'] = '2af3be3ab';
$subscription_data['marketing_permissions'][2]['enabled'] = true;
return $subscription_data;
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Bootstrap</title>
add_action('wp_head', 'remove_one_wpseo_og', 1);
function remove_one_wpseo_og() {
global $post;
if( $post->post_type == 'shorthand_story' ){
remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
}
}
<?php get_header();
if ( post_password_required( $post->ID ) ) {
echo get_the_password_form();
} else {
while ( have_posts() ) : the_post();
$meta = get_post_meta($post->ID);
?>
@daviddarke
daviddarke / gist:60b472cd85fefbdd44e9a4971a58a64a
Created November 22, 2017 15:33
Clear CPT archives when a CPT single is created or updated
$custom_post_types = array( "my_post" => "my_post");
$max_archive_pages = 0; // 0 == all archive page #s
function post_status( $new_status, $old_status, $post )
{
global $custom_post_types, $max_archive_pages;
if ( array_key_exists( $post->post_type, $custom_post_types ) && ( $new_status === "publish" || $old_status === "publish" ) )
{