Skip to content

Instantly share code, notes, and snippets.


Darren Lambert Pamps

View GitHub Profile
Pamps / 3 digit country code list
Created Sep 2, 2022
3 digit country code list, useful for ACF
View 3 digit country code list
AFG : Afghanistan
ALA : Åland Islands
ALB : Albania
DZA : Algeria
ASM : American Samoa
AND : Andorra
AGO : Angola
AIA : Anguilla
ATA : Antarctica
ATG : Antigua and Barbuda
Pamps / various
Last active Apr 29, 2022
Default WordPress setup
View various
in wp-config.php
define( 'DISALLOW_FILE_EDIT', true ); // disable file editor
define( 'WP_POST_REVISIONS', 10 ); // keep last 10 revisions
in functions.php
add_filter( 'auto_update_plugin', '__return_true' ); // auto update plugins
Pamps / gist:d5fb83f474ea4b39eab1370f1fbbbcf5
Created Jan 24, 2020
Gitlab CI file with 3 manual deploy options
View gist:d5fb83f474ea4b39eab1370f1fbbbcf5
# Manual deployment to staging
# Manual deployment to CSB and AG
- apt-get update -qq && apt-get install -y -qq lftp
- lftp -c "set ftp:ssl-allow no; open -u $USERNAME,'$PASSWORD' $HOST; mirror -Rnv ./ public_html/wp-content/ --ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
- master
when: manual
Pamps / bitbucket-pipelines.yml
Last active Nov 13, 2022
Example Bitbucket Pipeline CI script to deploy a PHP/WordPress website using FTP.
View bitbucket-pipelines.yml
# Auto deploy staging to staging
# Manual deploy master to production
image: php:7.1.29
- step:
name: Deploy to Staging
Pamps /
Last active Feb 11, 2021
Dump MySql (MAMP) database tables to Dropbox for daily backups.
# Daily MySQL dump on OSX to use in conjuction with Time Machine
# 1) Save this file in some appropriate location like /usr/sbin/
# 2) Make sure it is executable: sudo chmod +x /usr/sbin/
# 3) Create the backup directory: mkdir ~/dbdumps
# 4) Create the cron entry to run it daily by executing the following:
# sudo echo "47 5 * * * /usr/sbin/" >> /usr/lib/cron/tabs/root
# (This will run the script at 05:47 am each day)
Pamps / wp_get_attachment_image_url
Created Oct 1, 2019
How to get a WordPress attachment image URL in the required size
View wp_get_attachment_image_url
Much is made of the WordPress function wp_get_attachment_image_src() which returns an array of data for an attachment image.
But dealing with the array is not alway welcome.
wp_get_attachment_image_url() is your friend here as it returns the URL of the attachment at the desired size.
#$ cat
# XXX: use at your own risk - do not run without understanding this first!
#exit 1
# safety directory
# TODO: detect or pick manually...
Pamps / .gitlab-ci.yml
Last active Feb 11, 2021
My default GitLab CI FTP deploy for WordPress sites, works well on SiteGround, SpeedyDot and others
View .gitlab-ci.yml
- apt-get update -qq && apt-get install -y -qq lftp
- lftp -c "set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD $HOST; mirror -Rnv ./ public_html/ --ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
- master
Pamps / add-admin-user-to-wordpress.php
Last active Feb 11, 2021
Add WordPress admin user via functions.php
View add-admin-user-to-wordpress.php
// Add admin user
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = '';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
View ChangeWooCommerceProductGalleryZoomImageSize.php
// Change the image size used for the WooCommerce product gallery image zoom
// 'medium' or 'large' are normally the best options
add_filter( 'woocommerce_gallery_full_size', function( $size ) {
return 'medium';
} );