Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store temp content per post, Fixes #84 #85

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions includes/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class Core {
private $_module_counter = 0;

/**
* Flexible content store
* Flexible content stored for reuse if the_content is applied multiple times.
*
* @var string
* @var array
*/
private $_flexible_content = '';
private $_flexible_content = [];

/**
* Enqueued module assets
Expand Down Expand Up @@ -441,7 +441,7 @@ public function append_modules_content( string $content ) : string {
* @return string
*/
private function get_modules_content( \WP_Post $post ) : string {
$flexible_content = $this->_flexible_content;
$flexible_content = $this->_flexible_content[ $post->ID ] ?? null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bør det ikke være ?? []?

Siden du har sagt at det er en array?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glem det. Jeg som tenkte feil

Copy link
Member Author

@stian-overasen stian-overasen Apr 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, nei. $flexible_content (den lokale i funksjonen) skal ikke være array.


if ( empty( $flexible_content ) ) {
$layouts = $this->get_current_post_layouts( $post );
Expand All @@ -461,7 +461,7 @@ private function get_modules_content( \WP_Post $post ) : string {
* Store the flexible content to reuse it if `the_content` is
* runned more than once.
*/
$this->_flexible_content = $flexible_content;
$this->_flexible_content[ $post->ID ] = $flexible_content;
}

return (string) $flexible_content;
Expand Down