GIF94;
| Path : /var/www/wordpress/wp-content/plugins/oxygen/plugin/partners/codebox/ |
| Current File : /var/www/wordpress/wp-content/plugins/oxygen/plugin/partners/codebox/api.php |
<?php
// @psalm-ignore-file
namespace BreakdanceWPCodeBox;
use function Breakdance\Partners\CodeBox\isCodeBoxInstalled;
// API for WPCodeBox To build
/**
* @param string $code
* @return int
*/
function saveSnippetToCodeBox($code)
{
if (isCodeBoxInstalled()) {
$wpcbApi = new \Wpcb2\Api\Api();
try {
$snippetId = $wpcbApi->createSnippet(
[
'code' => $code,
'codeType' => ['value' => 'php'],
'minify' => false,
'title' => 'Breakdance Snippet ' . date('Y-m-d H:i:s'),
'priority' => 10,
'conditions' => [],
'description' => '',
'location' => '',
'runType' => ['value' => 'never'],
]
);
return $snippetId;
} catch (\Exception $e) {
return 0;
}
}
}
/**
* @param int $id
*/
function runSnippet($id)
{
if (isCodeBoxInstalled()) {
$wpcbApi = new \Wpcb2\Api\Api();
$wpcbApi->runSnippet($id);
}
}