This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Class Product{ | |
| ... | |
| public $virtual = [ | |
| 'humanWeight', | |
| 'seller', | |
| ]; | |
| public function _getHumanWeight(){ | |
| return $this->weight . 'Kg'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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."; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Class Post extends WP_Model | |
| { | |
| public $postType = 'post'; // Deault WordPress 'post' post type | |
| public $attributes = []; | |
| public $virtual = [ | |
| 'author' | |
| ]; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Class Product extends WP_Model | |
| { | |
| public $postType = 'product'; | |
| public $attributes = [ | |
| 'color', | |
| 'weight', | |
| ]; | |
| public $deafult = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Class Product extends WP_Model | |
| { | |
| ... | |
| public $filter = [ | |
| 'weight', | |
| ]; | |
| public function _filterWeight($value){ | |
| return intVal($value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Class Product extends WP_Model | |
| { | |
| ... | |
| public function _finderHeavy(){ | |
| return [ | |
| 'posts_per_page' => '50', | |
| 'meta_query' => [ | |
| [ | |
| 'key' => 'weight', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Class Product extends WP_Model | |
| { | |
| ... | |
| public function _finderHeavy($agrs){ | |
| return [ | |
| 'posts_per_page' => '50', | |
| 'meta_query' => [ | |
| [ | |
| 'key' => 'weight', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Class Product extends WP_Model | |
| { | |
| ... | |
| public function _finderHeavy($agrs){ | |
| ... | |
| } | |
| public function _postFinderHeavy($results, $args){ | |
| return array_map(function($model){ |