blocksy-tainacan/tainacan-blocksy/inc/integration.php

42 lines
1.0 KiB
PHP
Raw Normal View History

<?php
/**
* This is a dummy copy of the blc_call_fn function used in the blocksy-companion plugin
* Check their /framework/helpers/blocksy-integration.php file for more details
* I renamed the usage from 'fn' to 'fnc' to avoid future conflicts
*/
if (! function_exists('blc_call_fnc')) {
2021-04-27 17:19:14 +00:00
function blc_call_fnc($args = [], ...$params) {
$args = wp_parse_args(
$args,
[
'fnc' => null,
// string | null | array
'default' => ''
]
);
2021-04-27 17:19:14 +00:00
if (! $args['fnc']) {
throw new Error('$fnc must be specified!');
}
2021-04-27 17:19:14 +00:00
if (! function_exists($args['fnc'])) {
return $args['default'];
}
2021-04-27 17:19:14 +00:00
return call_user_func($args['fnc'], ...$params);
}
}
/**
* Return the url to be used in image picker from the child theme.
2021-02-23 02:09:46 +00:00
* The original function is on the /admin/helpers/options.php folder in the Blocksy parent theme.
*
* @param string $path image name.
*/
if (! function_exists('tainacan_blocksy_image_picker_url')) {
function tainacan_blocksy_image_picker_url($path) {
return TAINACAN_BLOCKSY_PLUGIN_URL_PATH . '/static/images/' . $path;
}
}