Skip to content

Instantly share code, notes, and snippets.

View anthonybudd's full-sized avatar

Anthony C. Budd anthonybudd

View GitHub Profile
<?php
Class ContactFormAction extends WP_AJAX{
protected $action = 'contat-form';
protected function run(){
WP_Mail::init()
->to('[email protected]')
<h3>You have a new contact from enquirey!</h3><br>
<p>
<strong>Name:</strong><?= $name ?>
</p>
<p>
<strong>email:</strong>
<a href="mailto:<?= $email ?>"><?= $email ?></a>
</p>
@anthonybudd
anthonybudd / backup.sh
Created January 22, 2018 17:25
Simple shell script to dump a whole MySQL instance to files
#!/bin/bash
USER="root"
PASSWORD="root"
OUTPUT="/Users/anthonybudd/sql/backup"
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
#!/bin/bash
rm -rf /home/bitnami/www/demo.gdprplug.in
cp -a /home/bitnami/demo.gdprplug.in /home/bitnami/www/demo.gdprplug.in
/opt/bitnami/mysql/bin/mysql -u root --password=YOUR_MYSQL_PASSWORD demo_gdprplug_in < /home/bitnami/export.sql
<?php
function explicitPermissionGrantedCallback($user){
if(!is_null($user)){
var_dump($user); // WP_User
echo $user->user_nicename . 'has just just given permission';
}else{
// User is not logged in.
}
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
.......
<?php if(@call_user_func('hasUserGivenPermissionFor', 'google-analytics')): ?>
<!-- Google Analytics -->
<script>
<?php
$array = ['quick', 'fox'];
$string = 'the quick brown fox jumps over the lazy dog';
if(in_array(1,array_map(function($e)use($string){return(strpos($string, $e)!== FALSE)?1:0;},$array))){
echo "The string contains an element in the array.";
}
<?php
$salary = 60000;
$oneMonth = ($salary / 12);
$twoMonths = ($salary / 6);
$halfMonth = ($salary / 24);
$monthlyCommission = 10000;
<form action="<?= admin_url('/admin-ajax.php') ?>" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="register">
<input type="email" name="email" value="">
<input type="password" name="password" value="">
</form>
<?php if(isset($_GET['suceess'])): ?>
<p>succesfil blah blah blah</p>
<?php enif; ?>
function hasSeenBreakingNewsBanner(){
var name = "has_seen_breaking_news_banner" + "=";
var cookies = document.cookie.split(';');
for(var i = 0; i < cookies.length; i++){
var cookie = cookies[i];
while(cookie.charAt(0) == ' ') {
cookie = cookie.substring(1);
}
if(cookie.indexOf(name) == 0){