-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
226 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-autop', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-commands', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-editor', 'wp-element', 'wp-format-library', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keyboard-shortcuts', 'wp-keycodes', 'wp-media-utils', 'wp-notices', 'wp-plugins', 'wp-preferences', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '46b49db24e1bda579d52'); | ||
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-autop', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-commands', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-editor', 'wp-element', 'wp-format-library', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keyboard-shortcuts', 'wp-keycodes', 'wp-media-utils', 'wp-notices', 'wp-plugins', 'wp-preferences', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => 'c4e1c6273f0e4e1248fd'); |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,72 @@ | ||
<?php | ||
|
||
namespace Hizzle\Noptin\Objects; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Allows users to use dynamic tags in shortcodes. | ||
* | ||
* @internal | ||
* @access private | ||
* @since 3.0.0 | ||
* @ignore | ||
*/ | ||
class Tags extends \Noptin_Dynamic_Content_Tags { | ||
|
||
/** | ||
* @var string $object_type The object type for the tags. | ||
*/ | ||
private $object_type; | ||
|
||
/** | ||
* Parses a record's tags. | ||
* | ||
* @param string $object_type The object type. | ||
* @param array $fields | ||
*/ | ||
public function __construct( $object_type ) { | ||
$this->object_type = $object_type; | ||
$this->tags = Store::smart_tags( $object_type, true ); | ||
} | ||
|
||
/** | ||
* @param Record $record The record. | ||
* @param string $content The content containing dynamic content tags. | ||
* @param string $escape_function Escape mode for the replacement value. Leave empty for no escaping. | ||
* @return string | ||
*/ | ||
public function replace_record_fields( $record, $content, $escape_function = 'wp_kses_post' ) { | ||
global $noptin_current_objects; | ||
|
||
if ( ! is_string( $content ) || empty( $content ) ) { | ||
return $content; | ||
} | ||
|
||
// Store the current record. | ||
if ( ! is_array( $noptin_current_objects ) ) { | ||
$noptin_current_objects = array(); | ||
} | ||
|
||
$old_record = isset( $noptin_current_objects[ $this->object_type ] ) ? $noptin_current_objects[ $this->object_type ] : null; | ||
|
||
$noptin_current_objects[ $this->object_type ] = $record; | ||
|
||
$this->escape_function = $escape_function; | ||
|
||
// Replace strings like this: [[tagname attr="value"]]. | ||
$content = preg_replace_callback( '/\[\[([\w\.\/-]+)(\ +(?:(?!\[)[^\]\n])+)*\]\]/', array( $this, 'replace_tag' ), $content ); | ||
|
||
// Call again to take care of nested variables. | ||
$content = preg_replace_callback( '/\[\[([\w\.\/-]+)(\ +(?:(?!\[)[^\]\n])+)*\]\]/', array( $this, 'replace_tag' ), $content ); | ||
|
||
// Restore the old record. | ||
if ( null === $old_record ) { | ||
unset( $noptin_current_objects[ $this->object_type ] ); | ||
} else { | ||
$noptin_current_objects[ $this->object_type ] = $old_record; | ||
} | ||
|
||
return $content; | ||
} | ||
} |
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