Skip to content

Instantly share code, notes, and snippets.

View anthonybudd's full-sized avatar

Anthony C. Budd anthonybudd

View GitHub Profile
<?php
Class Product extends WP_Model
{
...
public $virtual = [
'humanWeight'
];
public $serialize = [
'humanWeight',
<?php
$product = Product::find(15);
$product->hardDelete();
echo $product->color; // NULL
<?php
$where = [
'meta_relation' => 'AND',
[
'meta_key' => 'color',
'meta_vale' => 'blue'
],
[
'meta_key' => 'weight',
<?php
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
<?php
add_filter('show_admin_bar', '__return_false');
import numpy as np;
import tensorflow as tf;
import pylab;
xAxis = []
yAxis = []
def make_data(n):
np.random.seed(42) # To ensure same data for multiple runs
x = 2.0 * np.array(range(n))
<?php
Product::register();
function randomString($length = 10) {
return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length);
}
function seedButton($wp_admin_bar){
$wp_admin_bar->add_node([
<?php
function seedHook(){
if(@$_REQUEST['seed'] === 'true'){
for($i = 0; $i < 50; $i++){
Product::insert([
"title" => "Product ". (count(Product::all())+1),
"color" => array_values(["green", "red", "blue"])[rand(0, 2)],
"price" => rand(50, 2000),
]);
<?php //functions.php
add_action('wp_head', ['WP_AJAX', 'ajaxURL']);
<?php
Class Example extends WP_AJAX
{
protected $action = 'example';
protected function run(){
echo "Success!";
}
}