This repository was archived by the owner on Jul 28, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-14
lines changed Expand file tree Collapse file tree 2 files changed +24
-14
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ function get_from_context ( $ expr , $ context ) {
4
+ $ path = explode ( '. ' , $ expr );
5
+ if ( count ( $ path ) > 0 && 'context ' === $ path [0 ] ) {
6
+ array_shift ( $ path );
7
+ $ result = $ context ;
8
+ foreach ( $ path as $ key ) {
9
+ $ result = $ result [$ key ];
10
+ }
11
+ }
12
+ return $ result ;
13
+ }
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ require_once __DIR__ . '/utils.php ' ;
4
+
3
5
function process_wp_show ( &$ tags , &$ context ) {
4
6
if ( 'WP-SHOW ' === $ tags ->get_tag () ) {
5
7
$ value = $ tags ->get_attribute ( 'when ' );
6
8
} else {
7
9
$ value = $ tags ->get_attribute ( 'wp-data ' );
8
10
}
9
11
10
- if ( null !== $ value ) {
11
- // TODO: Properly parse $value.
12
- $ path = explode ( '. ' , $ value );
13
- if ( count ( $ path ) > 0 && 'context ' === $ path [0 ] ) {
14
- array_shift ( $ path );
15
- $ show = $ context ;
16
- foreach ( $ path as $ key ) {
17
- $ show = $ show [$ key ];
18
- }
19
- }
12
+ if ( null === $ value ) {
13
+ return ;
14
+ }
15
+
16
+ // TODO: Properly parse $value.
17
+ $ show = get_from_context ( $ value , $ context );
20
18
21
- if ( ! $ show ) {
22
- // $content = $tags->get_content_inside_balanced_tags()
23
- // $tags->set_content_inside_balanced_tags( '<template>' . $content . '</template>' );
24
- }
19
+ if ( ! $ show ) {
20
+ // $content = $tags->get_content_inside_balanced_tags()
21
+ // $tags->set_content_inside_balanced_tags( '<template>' . $content . '</template>' );
25
22
}
26
23
}
You can’t perform that action at this time.
0 commit comments