Skip to content

Instantly share code, notes, and snippets.

View anthonybudd's full-sized avatar

Anthony C. Budd anthonybudd

View GitHub Profile
<?php
Abstract Class WP_Model implements JsonSerializable{
...
public function isFilterProperty($attribute){
return (
(
isset($this->filter) &&
in_array($attribute, $this->filter) &&
method_exists($this, ('_filter'. ucfirst($attribute)))
<?php
Class Product extends WP_Model{
...
public $filter = [
'weight' => 'intval'
];
}
$product = Product::insert([
'weight' => '250',
]);
<?php
function isAssoc($array){
return count(array_filter(array_keys($array), 'is_string')) > 0;
}
$indexed = [
'apple',
'pear',
'grape'
<?php
Class Product extends WP_Model{
...
public $filter = [
'weight'
];
public function _filterWeight($value){
return intval($value);
<h3>You have a new contact from enquirey!</h3><br>
<p>
<strong>Time:</strong><?= $time ?>
</p>
<p>
<strong>Name:</strong><?= $name ?>
</p>
<?php
require 'ContactFormAction.php';
<?php
/*
Template Name: Contact Page
*/
?>
<form action="<?= ContactFormAction::url() ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="from_action" value="<?= ContactFormAction::getActionName() ?>">
<input type="text" name="full_name"><br />
<h1>Hello {{name}},</h1>
<p>I have found a great class from a developer in {{location}}.</p>
<a href="{{link}}">Check it out on GitHub</a>
<?php
$email = WP_Mail::init()
->to('[email protected]')
->subject('WP_Mail is great!')
->attach(ABSPATH . 'wp-content/uploads/2018/6/image.png')
->template(get_template_directory() .'/emails/demo.php', [
'name' => 'Anthony Budd',
'location' => 'London',
'skills' => [