Skip to content

Instantly share code, notes, and snippets.

View anthonybudd's full-sized avatar

Anthony C. Budd anthonybudd

View GitHub Profile
<?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){
<?php
Class Event extends WP_Model{
public $postType = 'event';
public $attributes = [
'start_date',
];
public function _finderArchive($args){
<?php
$products = Product::finder('archive', [
'page' => 1,
]);
dd($products);
<?php
$products = Product::all();
dd($products);
<?php
Product::insert([
'color' => 'blue',
'weight' => '100'
]);
Product::insert([
'color' => 'red',
'weight' => '100'