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{
...
public $virtual = [
'humanWeight',
'seller',
];
public function _getHumanWeight(){
return $this->weight . 'Kg';
<?php
Class Product extends WP_Model
{
...
public function saving($model){
echo "The save method has been called, but nothing has been
written to the database yet.";
}
<?php
$product = new Product;
$product->new; // Returns (bool) true
$product = Product::find(15);
$product->new; // Returns (bool) false
$product->color = 'red';
$product->dirty; // Returns (bool) true
$product->save();
$product->dirty; // Returns (bool) false
<?php
Product::single(); // Returns the current model if on a single page or in the loop
Product::exists(15); // Returns (bool) true or false
$product->post() // Returns WP_Post object
$product->permalink() // Returns post permalink
$product->featuredImage($defaultURL) // Returns featured image URL
<?php
Class Post extends WP_Model
{
public $postType = 'post'; // Deault WordPress 'post' post type
public $attributes = [];
public $virtual = [
'author'
];
<?php
Class Product extends WP_Model
{
public $postType = 'product';
public $attributes = [
'color',
'weight',
];
public $deafult = [
<?php
Class Product extends WP_Model
{
...
public $filter = [
'weight',
];
public function _filterWeight($value){
return intVal($value);
<?php
Class Product extends WP_Model
{
...
public function _finderHeavy(){
return [
'posts_per_page' => '50',
'meta_query' => [
[
'key' => 'weight',
<?php
Class Product extends WP_Model
{
...
public function _finderHeavy($agrs){
return [
'posts_per_page' => '50',
'meta_query' => [
[
'key' => 'weight',
<?php
Class Product extends WP_Model
{
...
public function _finderHeavy($agrs){
...
}
public function _postFinderHeavy($results, $args){
return array_map(function($model){