| @@ -1,81 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -function acym_route(string $url, bool $xhtml = true): string | |
| 4 | -{ | |
| 5 | - return acym_baseURI().$url; | |
| 6 | -} | |
| 7 | - | |
| 8 | -function acym_addPageParam(string $url, bool $ajax = false, bool $front = false): string | |
| 9 | -{ | |
| 10 | - preg_match('#^([a-z]+)(?:[^a-z]|$)#Uis', $url, $ctrl); | |
| 11 | - | |
| 12 | - if ($front) { | |
| 13 | - $link = 'index.php?page='.ACYM_COMPONENT.'_front&ctrl='.$url; | |
| 14 | - if ($ajax) $link .= '&'.acym_noTemplate(); | |
| 15 | - } else { | |
| 16 | - $link = 'admin.php?page='.ACYM_COMPONENT.'_'.$ctrl[1].'&ctrl='.$url; | |
| 17 | - if ($ajax) { | |
| 18 | - $link .= '&action='.ACYM_COMPONENT.'_router&'.acym_noTemplate(); | |
| 19 | - } | |
| 20 | - } | |
| 21 | - | |
| 22 | - return $link; | |
| 23 | -} | |
| 24 | - | |
| 25 | -function acym_baseURI(bool $pathonly = false): string | |
| 26 | -{ | |
| 27 | - if (acym_isAdmin()) { | |
| 28 | - return admin_url(); | |
| 29 | - } | |
| 30 | - | |
| 31 | - return acym_rootURI(); | |
| 32 | -} | |
| 33 | - | |
| 34 | -function acym_rootURI(bool $pathonly = false, ?string $path = 'siteurl'): string | |
| 35 | -{ | |
| 36 | - $rootURI = rtrim(site_url(), '/').'/'; | |
| 37 | - | |
| 38 | - if (!acym_isAdmin()) { | |
| 39 | - $wpmlSiteUrl = apply_filters('wpml_home_url', $rootURI); | |
| 40 | - if ($wpmlSiteUrl !== $rootURI) { | |
| 41 | - $rootURI = rtrim($wpmlSiteUrl, '/').'/'; | |
| 42 | - } | |
| 43 | - } | |
| 44 | - | |
| 45 | - if (defined('CONTENT_DIR') && substr($rootURI, -3) === 'wp/') { | |
| 46 | - $rootURI = substr($rootURI, 0, -3); | |
| 47 | - } | |
| 48 | - | |
| 49 | - return $rootURI; | |
| 50 | -} | |
| 51 | - | |
| 52 | -function acym_completeLink(string $link, bool $popup = false, bool $redirect = false, bool $forceNoPopup = false): string | |
| 53 | -{ | |
| 54 | - if (($popup || acym_isNoTemplate()) && $forceNoPopup == false) { | |
| 55 | - $link .= '&'.acym_noTemplate(); | |
| 56 | - } | |
| 57 | - | |
| 58 | - $link = acym_addPageParam($link); | |
| 59 | - | |
| 60 | - return acym_route($link); | |
| 61 | -} | |
| 62 | - | |
| 63 | -function acym_prepareAjaxURL(string $url): string | |
| 64 | -{ | |
| 65 | - return htmlspecialchars_decode(acym_route(acym_addPageParam($url, true))); | |
| 66 | -} | |
| 67 | - | |
| 68 | -function acym_frontendLink(string $link, bool $complete = true, bool $sef = true): string | |
| 69 | -{ | |
| 70 | - return acym_rootURI().acym_addPageParam($link, true, true); | |
| 71 | -} | |
| 72 | - | |
| 73 | -function acym_backendLink(string $link): string | |
| 74 | -{ | |
| 75 | - return admin_url().acym_addPageParam($link); | |
| 76 | -} | |
| 77 | - | |
| 78 | -function acym_getMenu() | |
| 79 | -{ | |
| 80 | - return get_post(); | |
| 81 | -} | |