Skip to content

Commit ee4ccec

Browse files
author
Miika Arponen
committed
A method to rename current model's name in the data tree for use with set_template()
1 parent 30679c2 commit ee4ccec

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

classes/model.php

+24-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ public function set_template( $template ) {
425425
$ancestor = $this->get_ancestor();
426426

427427
if ( $template ) {
428-
if ( $this == $ancestor ) {
428+
429+
if ( $this === $ancestor ) {
429430
$this->template = $template;
430431
}
431432
else {
@@ -675,6 +676,28 @@ public function run_restricted( $function ) {
675676
}
676677
}
677678

679+
/**
680+
* Rename current model's data block. Probably for template changing purposes.
681+
*
682+
* @type function
683+
* @date 14/09/2016
684+
* @since 1.2.0
685+
*
686+
*
687+
* @param $function (string)
688+
* @param $args (array)
689+
* @return mixed
690+
*/
691+
protected function rename_model( $name ) {
692+
$original = $this->class_name;
693+
$this->class_name = $name;
694+
695+
if ( isset( $this->data[ $original ] ) ) {
696+
$this->data[ $name ] = $this->data[ $original ];
697+
unset( $this->data[ $original ] );
698+
}
699+
}
700+
678701
/**
679702
* A recursive array search.
680703
*

dustpress.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Author: Miika Arponen & Ville Siltala / Geniem Oy
77
Author URI: http://www.geniem.com
88
License: GPLv3
9-
Version: 1.1.23
9+
Version: 1.2.0
1010
*/
1111

1212
final class DustPress {

0 commit comments

Comments
 (0)