-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnpnl.inc.php
More file actions
38 lines (32 loc) · 1 KB
/
Copy pathnpnl.inc.php
File metadata and controls
38 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* ページの有無でリンクを制御するプラグイン
*
* @version 0.2.1
* @author kanateko
* @link https://jpngamerswiki.com/?f51cd63681
* @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3
* -- Updates --
* 2026-03-30 v0.2.1 ブラケットを取り除く処理を追加
* 2026-02-12 v0.2.0 相対パスに対応
* ベースネームで表示するオプションを追加
* 2026-01-31 v0.1.0 初版作成
*/
function plugin_npnl_inline(string ...$args): string
{
global $vars;
$text = strip_bracket(trim(array_pop($args)));
$options = [];
if (! empty($args)) {
foreach ($args as $arg) {
$arg = trim(htmlsc($arg));
if ($arg === 'base') $options['base'] = true;
}
}
if (str_contains($text, './')) $text = get_fullname($text, $vars['page']);
if (is_page($text)) {
$text = $options['base'] ? basename($text) . '>' . $text : $text;
return make_link('[[' . $text . ']]');
}
return $text;
}