🚚📝 - Réorganisation des fichiers et ajout de documentation pour les fonctions existantes
This commit is contained in:
parent
e67d1f86d7
commit
a0b5f2033f
@ -1,12 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
// Add some functions to quickly load template
|
// Add some functions to quickly load template
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the appropriate topbar template file.
|
||||||
|
*
|
||||||
|
* @param string|null $name Optional. The specific topbar name to load.
|
||||||
|
* @param array $args Optional. Additional arguments to pass to the template.
|
||||||
|
* @return bool True if the template was found and loaded, false otherwise.
|
||||||
|
*/
|
||||||
function tree_get_topbar($name = null, $args = array()) {
|
function tree_get_topbar($name = null, $args = array()) {
|
||||||
|
|
||||||
do_action("get_topbar", $name, $args);
|
do_action("get_topbar", $name, $args);
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
$templates = array();
|
$templates = array();
|
||||||
$name = (string) $name;
|
$name = (string) $name;
|
||||||
if ( '' !== $name ) {
|
if ( '' !== $name ) {
|
||||||
@ -19,11 +24,3 @@ function tree_get_topbar($name = null, $args = array()) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_blog_url($blog_id = null) {
|
|
||||||
if (null === $blog_id) $blog_id = get_current_blog_id();
|
|
||||||
|
|
||||||
if (get_current_blog_id() !== $blog_id && get_blogaddress_by_id($blog_id)) switch_to_blog($blog_id);
|
|
||||||
|
|
||||||
return get_post_type_archive_link( 'post' );
|
|
||||||
}
|
|
@ -1,4 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges multiple arrays recursively without duplicating scalar values for numeric keys
|
||||||
|
* and overriding values for associative keys.
|
||||||
|
*
|
||||||
|
* @param array ...$arrays Arrays to be merged.
|
||||||
|
* @return array The resulting merged array.
|
||||||
|
*/
|
||||||
function array_merge_recursive_distinct(array ...$arrays): array {
|
function array_merge_recursive_distinct(array ...$arrays): array {
|
||||||
$merged = [];
|
$merged = [];
|
||||||
|
|
||||||
@ -27,6 +36,26 @@ function array_merge_recursive_distinct(array ...$arrays): array {
|
|||||||
return $merged;
|
return $merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a directory is empty.
|
||||||
|
*
|
||||||
|
* @param string $dir Path to the directory to check.
|
||||||
|
* @return bool True if the directory is empty, false otherwise.
|
||||||
|
*/
|
||||||
function is_dir_empty($dir): bool {
|
function is_dir_empty($dir): bool {
|
||||||
return (count(scandir($dir)) == 2);
|
return (count(scandir($dir)) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the URL of the blog archive for the specified blog ID.
|
||||||
|
*
|
||||||
|
* @param int|null $blog_id The ID of the blog. If null, uses the current blog ID.
|
||||||
|
* @return string The URL of the blog archive.
|
||||||
|
*/
|
||||||
|
function get_blog_url($blog_id = null) {
|
||||||
|
if (null === $blog_id) $blog_id = get_current_blog_id();
|
||||||
|
|
||||||
|
if (get_current_blog_id() !== $blog_id && get_blogaddress_by_id($blog_id)) switch_to_blog($blog_id);
|
||||||
|
|
||||||
|
return get_post_type_archive_link( 'post' );
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user