Skip to content

Instantly share code, notes, and snippets.

View craigedmonds's full-sized avatar

Craig Edmonds craigedmonds

  • JUCRA Digital SL
  • Marbella, Spain
View GitHub Profile
<?php
/*
Update an ACF custom field in wordpress with all the dealer id's when a select all
checbox is ticked.
Created by craig@123marbella.com on 24th of July 2017
The ACF plugin is great but its not possible to "select all" records in a multi select
so we need to find a way to select all records so the user does not have to select each
record one by one. So easiest thing to do is make an extra checkbox field called "select all",
@craigedmonds
craigedmonds / wordpress-redirect-user-based-on-country-and-page-id.php
Last active September 21, 2017 13:37
Wordpress Redirect User based on Country and Page ID
<?php
############################
// Block a country from accessing a certain wordpress page
// Put this script into your functions.php
// Author: craig@123marbella.com
// Date: 21/9/2017
############################
//define some page id's that you want to block
$array_of_page_ids_to_block = array(
@craigedmonds
craigedmonds / block-one-or-more-countries-from-accessing-one-or-more-pages-on-your-web-site.php
Last active September 21, 2017 13:40
Block one or more countries from accessing one or more pages on your web site
<?php
############################
// Block one or more countries from accessing one or more pages on your web site
// Using Wordpress? Put this script into your functions.php
// Author: craig@123marbella.com
// Date: 21/9/2017
// See: https://gist.github.com/craigedmonds/2c6bea241e5e2bd29ca64eab5a2c5a57
############################
//define some urls you wish to block
@craigedmonds
craigedmonds / create-email-password-for-rackspace-mail.php
Last active September 27, 2017 07:47
Create a complex login password for rackspace mail api
<?php
/*
Create a complex 8 character password which meets (exceeds actually) the rackspace mail requirements.
Author: craig@123marbella.com ON 27/9/2017
This function allows you to specify the length of the password and the specific characters to include in the password.
Compleletly random passwords look ugly, so this function will build the password into a random and complex, yet friendlier looking password.
@craigedmonds
craigedmonds / display-directory-contents.php
Created September 27, 2017 07:55
Display a list of files within a directory
<?php
/*
written by craig@123marbella.com on 19th Jan 2016
This script can be placed in a folder and will display the contents of the folder based on the file extensions you define in the settings below.
With this function you can:
- define a specific list of extensions to display on the page
- define a H1/title tag for the page
- define a custom logo
@craigedmonds
craigedmonds / block-one-or-more-countries-from-accessing-your-web-site.php
Last active October 3, 2017 23:42
Block one or more countries from accessing your web site
<?php
/*
Block one or more countries from accessing your web site
Written by craig@123marbella.com on 4th of October 2017
Wordpress users you can put this in the top of your functions.php file
to prevent visitors from certain countries.
*/
@craigedmonds
craigedmonds / get-files-and-folders-array.php
Last active October 11, 2017 10:23
Iterate through directories and sub directories and get list of files and folders in an array
<?php
###########################
/*
This script is useful if you wanted to get a list of the files and folders within a directory on your web site.
EG: Lets say you wanted to monitor your theme folder in wordpress. With this script you can generate a list of
all the files and folders and check for any changes.
You could extend this script to exclude certain folders or file names or file types.
@craigedmonds
craigedmonds / functions.php
Created October 19, 2018 09:11
Get a list of special offers for a dealer based on whether the dealer has special offers turned off, whether they are in a certain region or whether they have their own special offers.
<?php
######################################################
//get a list of specials assigned to a dealer so that we can display a list
//of post id's in the array_of_dealer
//added on 19/10/2018 by craig@jucra.com
######################################################
function white_label_get_array_of_special_offer_posts_for_dealer($dealer_id) {
###################################################
//STEP 1
@craigedmonds
craigedmonds / functions.php
Created October 19, 2018 18:47
This checks to see if the post being loaded is 1. a special offer 2. if the dealer is authorised to load the special offer on their dealer site and if not we force a 301 redirect back to the dealers home page
<?php
######################################################
//Here we will check to see if the special offer being presented
//is in the list of the dealers posts and if not do a 301 redirect
//back to the home page
//added on 19/10/2018 by craig@jucra.com
######################################################
function white_label_special_offer_301_redirect_check($array_of_dealer) {
###################################################
@craigedmonds
craigedmonds / sync_arctis-dealers.php
Created October 25, 2018 06:08
This is a special function whcih pulls in the remote data from the dealer core and stores a local json file with the dealers data. The dealers details pages will actually be populated from the local json file so we do not need to do any major database processed which will save database overhead.
<?php
############################
//sync the dealer store pages
############################
/*
This is a special function whcih pulls in the remote data from the dealer core
and stores a local json file with the dealers data. The dealers details pages will actually
be populated from the local json file so we do not need to do any major database processed
which will save database overhead.
*/