const response = await fetch(_ymc_fg_object.ajax_url,
{
method: 'POST',
//headers: {'Content-Type': 'application/x-www-form-urlencoded'},
//body: new URLSearchParams(params).toString()
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest" // Важно для WordPress
},
body: JSON.stringify({
action: "ajax_get_taxonomies",
nonce_code: _ymc_fg_object.getTaxAjax_nonce,
data: {
username: "JohnDoe",
message: "Hello from fetch!"
}
})
})
$content = $post->post_excerpt;
if( empty($content) ) {
$content = $post->post_content;
}
$content = preg_replace('#\[[^\]]+\]#', '', $content);
$c_length = apply_filters('post_excerpt_length_'.$filter_id.'_'.$target_id, $length_excerpt);
$content = wp_trim_words($content, $c_length);
get_categories_tree(string $taxonomy = 'category'): array?
get_categories_tree()мне нужно внутри цикла передавать рекурсивно. Поделитесь вашим решением, не совсем понимаю как теперь эту функцию запихнуть во внутрь моей функции с рекурсией. Спасибо.
function debugEntries( $data, $flag=false )
{
if( !$flag ) {
echo '<pre class="debugCode">';
print_r($data);
echo '</pre>';
}
else {
echo '<pre class="debugCode">';
var_dump($data);
echo '</pre>';
}
?>
<script>
window.addEventListener("load", () => {
if ( !window.debug_entries_moved ) {
window.debug_entries_moved = true;
const $container = document.createElement(`div`);
const $debugEntry = document.createElement(`div`);
const $button = document.createElement(`div`);
$container.classList.add(`mc__debugger`);
$debugEntry.classList.add(`debug-entry`);
$button.classList.add(`control-button`);
$container.appendChild($button);
[...document.querySelectorAll(`.debugCode`)].forEach(($entry) => {
$debugEntry.appendChild($entry);
});
$container.appendChild($debugEntry);
document.body.appendChild($container);
}
});
</script>
<?php
}
$post = get_post();
$post_content = $post->post_content;
спасибо, но по ходу использование - URLSearchParams
- это пока что единственный вариант решения задачи