-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into fix/command-palette-delete-template-nav
- Loading branch information
Showing
159 changed files
with
4,696 additions
and
949 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ coverage | |
*.log | ||
yarn.lock | ||
/artifacts | ||
/test/e2e/artifacts | ||
/perf-envs | ||
/composer.lock | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
77 changes: 77 additions & 0 deletions
77
lib/experimental/interactivity-api/class-wp-directive-context.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* Context data implementation. | ||
* | ||
* @package Gutenberg | ||
* @subpackage Interactivity API | ||
*/ | ||
|
||
/** | ||
* This is a data structure to hold the current context. | ||
* | ||
* Whenever encountering a `data-wp-context` directive, we need to update | ||
* the context with the data found in that directive. Conversely, | ||
* when "leaving" that context (by encountering a closing tag), we | ||
* need to reset the context to its previous state. This means that | ||
* we actually need sort of a stack to keep track of all nested contexts. | ||
* | ||
* Example: | ||
* | ||
* <div data-wp-context='{ "foo": 123 }'> | ||
* <!-- foo should be 123 here. --> | ||
* <div data-wp-context='{ "foo": 456 }'> | ||
* <!-- foo should be 456 here. --> | ||
* </div> | ||
* <!-- foo should be reset to 123 here. --> | ||
* </div> | ||
*/ | ||
class WP_Directive_Context { | ||
/** | ||
* The stack used to store contexts internally. | ||
* | ||
* @var array An array of contexts. | ||
*/ | ||
protected $stack = array( array() ); | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* Accepts a context as an argument to initialize this with. | ||
* | ||
* @param array $context A context. | ||
*/ | ||
function __construct( $context = array() ) { | ||
$this->set_context( $context ); | ||
} | ||
|
||
/** | ||
* Return the current context. | ||
* | ||
* @return array The current context. | ||
*/ | ||
public function get_context() { | ||
return end( $this->stack ); | ||
} | ||
|
||
/** | ||
* Set the current context. | ||
* | ||
* @param array $context The context to be set. | ||
* | ||
* @return void | ||
*/ | ||
public function set_context( $context ) { | ||
if ( $context ) { | ||
array_push( $this->stack, array_replace_recursive( $this->get_context(), $context ) ); | ||
} | ||
} | ||
|
||
/** | ||
* Reset the context to its previous state. | ||
* | ||
* @return void | ||
*/ | ||
public function rewind_context() { | ||
array_pop( $this->stack ); | ||
} | ||
} |
Oops, something went wrong.