PHP Class VersionPress\Database\ShortcodesReplacer

!!! This class uses many functions of wp-includes/shortcodes.php, there is no easy way around it.
Show file Open project: versionpress/versionpress Class Usage Examples

Public Methods

Method Description
__construct ( ShortcodesInfo $shortcodeInfo, VpidRepository $vpidRepository )
entityCanContainShortcodes ( string $entityName ) : boolean Return true if entity can contain shortcodes
fieldCanContainShortcodes ( string $entityName, string $field ) : boolean Return true if a field on an entity can contain shortcodes
replaceShortcodesInEntity ( string $entityName, array $entity ) : array Translates IDs to VPIDs in shortcodes for an entity
restoreShortcodesInEntity ( string $entityName, array $entity ) : array Translates VPIDs to IDs in shortcodes for an entity

Private Methods

Method Description
createReplaceCallback ( $idProvider )
getIdByVpid ( $entityName, $vpid )
getVpidByEntityNameAndId ( $entityName, $id )
replaceShortcodes ( string $string ) : string Translates IDs to VPIDs in shortcodes.
restoreShortcodes ( string $string ) : string Translates VPIDs to IDs in shortcodes.

Method Details

__construct() public method

public __construct ( ShortcodesInfo $shortcodeInfo, VpidRepository $vpidRepository )
$shortcodeInfo ShortcodesInfo
$vpidRepository VpidRepository

entityCanContainShortcodes() public method

Return true if entity can contain shortcodes
public entityCanContainShortcodes ( string $entityName ) : boolean
$entityName string
return boolean

fieldCanContainShortcodes() public method

Return true if a field on an entity can contain shortcodes
public fieldCanContainShortcodes ( string $entityName, string $field ) : boolean
$entityName string E.g., 'post'
$field string E.g., 'post_content'
return boolean

replaceShortcodesInEntity() public method

Translates IDs to VPIDs in shortcodes for an entity
public replaceShortcodesInEntity ( string $entityName, array $entity ) : array
$entityName string
$entity array Entity data, see {@link WpdbMirrorBridge}
return array Entity data

restoreShortcodesInEntity() public method

Translates VPIDs to IDs in shortcodes for an entity
public restoreShortcodesInEntity ( string $entityName, array $entity ) : array
$entityName string
$entity array Entity data, see {@link WpdbMirrorBridge}
return array Entity data