View gist:d5fb83f474ea4b39eab1370f1fbbbcf5
# Manual deployment to staging | |
# Manual deployment to CSB and AG | |
deploy-to-staging: | |
script: | |
- 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/" | |
only: | |
- master | |
when: manual |
View bitbucket-pipelines.yml
# Auto deploy staging to staging | |
# Manual deploy master to production | |
image: php:7.1.29 | |
pipelines: | |
branches: | |
staging: | |
- step: | |
name: Deploy to Staging | |
script: |
View MacMySqlBackup.sh
#!/bin/bash | |
#-------------------------------------------------------------------------- | |
# Daily MySQL dump on OSX to use in conjuction with Time Machine | |
# | |
# 1) Save this file in some appropriate location like /usr/sbin/dbbackup.sh | |
# 2) Make sure it is executable: sudo chmod +x /usr/sbin/dbbackup.sh | |
# 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/dbbackup.sh" >> /usr/lib/cron/tabs/root | |
# (This will run the script at 05:47 am each day) |
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. |
View fix-dropbox-permissions.sh
#$ cat fix-dropbox.sh | |
#!/bin/bash | |
# XXX: use at your own risk - do not run without understanding this first! | |
#exit 1 | |
# safety directory | |
BACKUP='/tmp/fix-dropbox/' | |
# TODO: detect or pick manually... |
View .gitlab-ci.yml
deploy: | |
script: | |
- 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/" | |
only: | |
- master |
View add-admin-user-to-wordpress.php
<?php | |
// Add admin user | |
add_action( 'init', function () { | |
$username = 'admin'; | |
$password = 'password'; | |
$email_address = 'webmaster@mydomain.com'; | |
if ( ! username_exists( $username ) ) { | |
$user_id = wp_create_user( $username, $password, $email_address ); |
View ChangeWooCommerceProductGalleryZoomImageSize.php
<?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'; | |
} ); | |
?> |
View country_is_in_europe.php
<?php | |
// Returns if a country is in Europe | |
// Pass in country name or code e.g. 'Spain' or 'ES'. | |
function country_is_in_europe( $country ) { | |
// Our list of countries | |
$countries = array( | |
'AT' => 'Austria', | |
'BE' => 'Belgium', |
View wordpress-set-new-post-title-placeholder.php
<?php | |
// Add this to your theme functions.php file, or in a plugin file | |
// This example shows how to change the title field placeholder | |
// Post types titles | |
function cpm_change_default_title( $title ) { | |
$screen = get_current_screen(); | |
if ( 'product' == $screen->post_type ) { // Change product for your post_type (.e.g post, page, etc) |