public static function find_by_id($id) { global $wpdb; $model = MPM::get_model("template", "SELECT * FROM `".self::table()."` WHERE id = '{$id}'"); if (!$model) { // this model is a little different - there's no notion of "creating" a template via MasterPress // (as you create one by creating a new file) // this model is simply a bucket to store information associated with the template, so we just auto-create one if it doesn't exist // get the current value of the page "supports" value // $page = MPM_PostType::find_by_name("page"); $wpdb->insert( self::table(), array("id" => $id, "supports" => "*", "visibility" => 'json:{"sites":"*","post_types":"page"}' ) ); $model = MPM::get_model("template", "SELECT * FROM `".self::table()."` WHERE id = '{$id}'"); } return $model; }
public static function find_by_id($model, $id, $table = null) { if (!$table) { $table = MPM::table($model); } return MPM::get_model($model, "SELECT * FROM `".$table."` WHERE id = {$id}", $table); }