Closed dimayakovlev closed 3 years ago
Maybe better to add filter to filter clone page object instead page-clone
action.
Maybe better to add filter to filter clone page object instead
page-clone
action.
Function XMLsave()
execute filter xmlsave
, so no need to add another filter. Plugins developers can use page-clone
action to register xmlsave
filter and it will be executed before saving cloned page object.
Example of using page-clone
action to register filter xmlsave
.
add_action('page-clone', function() {
add_filter('xmlsave', function($xml) {
$xml = new SimpleXMLElement($xml);
$attr = $xml->attributes();
if (isset($attr['counter'])) {
$xml->attributes()->cloned = (int)$attr['counter'] + 1;
} else {
$xml->addAttribute('counter', 1);
}
return $xml->asXML();
});
});
New actions:
page-clone
- executed if page data file copied successfully, after modifying cloned page object;page-clone-success
- executed if cloned page object saved successfully to cloned page data file;page-clone-error
- executed if error acquired while page cloning.