Skip to content

Instantly share code, notes, and snippets.

@conkonig
conkonig / Wordpress-Attachment-Offloader-Metadata-Migration-Plugin.php
Created July 9, 2024 12:09
A plugin for converting WP Site from Humanmade/s3-uploads to deliciousbrains/wp-offload for Media Delivery.
<?php
/*
Plugin Name: WP Attachment Offloader Metadata Migration Plugin
Description: A plugin for converting WP Site from Humanmade/s3-uploads to deliciousbrains/wp-offload for Media Delivery. Not for use in production unless you know what you are doing..!
Version: 1.1
Author: Connor Stansfield + chatgpt
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
@conkonig
conkonig / upload.php
Created June 10, 2022 17:02
Upload a file to DO Spaces
<?php
require_once __DIR__ . '/vendor/autoload.php';
// using composer "sociallydev/spaces-api": "3.5"
use \SpacesAPI\Spaces;
$spaces = new Spaces('apikey', 'secret');
$space = $spaces->space('bucket');
$filename = 'image.png';
@conkonig
conkonig / accessing-log.sh
Last active September 2, 2021 17:30
Accessing custom error/output logging from a docker container running the standard wordpress image
# Accessing the logs when you want to test the output of a variable in PHP without using something totally outlandish like a php debugger because aint nobody got time for dat..
#### terminal into wp docker container
docker exec -it your_container_id bash
#### install nano / vim so you can actually change stuff
apt-get update && apt-get install vim nano
#### modify the php.ini file at /usr/local/etc/php/conf.d/conf.ini (use phpinfo(); on any page in your app to see where your php conf.ini is)
nano /usr/local/etc/php/conf.d/conf.ini
@conkonig
conkonig / get-latest-mailchimp-newsletters-from-api.php
Created June 23, 2021 15:13
Get latest mailchimp newsletters
<?php
// CREDIT:
// https://rudrastyh.com/mailchimp-api/get-lists.html
$api_key = 'xxxxxxxxxxxxxxxxx';
$us = 'xxx';
function rudr_mailchimp_curl_connect($url, $request_type, $api_key, $data = array())
{
if ($request_type == 'GET')
@conkonig
conkonig / enable-remote-connections.sh
Last active July 1, 2020 17:10
Enable remote connections to a mysql (mariadb) server running ubuntu 18.04
# edit the my.cnf file in /etc/mysql and add the line
bind-address=0.0.0.0
# and if you have the line:
skip-networking
# make sure to comment it:
#skip-networking
# restart mysql
sudo service mysql restart
@conkonig
conkonig / fresh-dev-env-setup.md
Last active May 13, 2020 13:38
Fresh Dev Environment Setup

1. Install / reset Windows 10

check clear all files on C drive (keeping other drives intact).

Run powershell as administrator

Install chrome with powershell

$Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path\$Installer

Run chrome and login, do not sync passwords and settings (because why taint your shiny new setup !?)

@conkonig
conkonig / ubuntu-18.04-server-setup-for-wp
Last active April 30, 2020 13:30
ubuntu 16.04, 18.04, server setup for wp hosting
# Initial Server Setup
- add a non root user
- give sudo privileges
- enable firewall
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04
# Also allow http and https through the firewall
sudo ufw allow http
sudo ufw allow https
@conkonig
conkonig / creating-react-plugins-for-wordpress.php
Created April 17, 2020 20:24
creating-react-plugins-for-wordpress
<?php
/* Commands to create the project. */
// mkdir <name> & cd <name>
// npm init react-app <name>
// cd <name>
// npm/yarn install
/* To build and deploy. */
@conkonig
conkonig / importing-bulk-tags-wp-from-csv.php
Created April 13, 2020 23:43
Bulk Importing tags and assigning to wordpress posts from csv file
<?php
class CsvImporter
{
private $fp;
private $parse_header;
private $header;
private $delimiter;
private $length;
//--------------------------------------------------------------------
function __construct($file_name, $parse_header = false, $delimiter = "\t", $length = 8000)
@conkonig
conkonig / useful-docker-commands.sh
Last active May 6, 2020 15:04
Useful Docker Commands
# see all running docker containers
docker ps
# terminal into docker container
docker exec -it container-name /bin/bash
# allow larger transfers for container - eg to import larger sql file
docker exec -it container_name bash -c "echo 'max_allowed_packet = 512M' >> /etc/mysql/mysql.conf.d/mysqld.cnf"
docker exec -it container_name bash -c "echo 'wait_timeout = 1500' >> /etc/mysql/mysql.conf.d/mysqld.cnf"