id, Define::getAdminPages())) {
$ignore = [
'Screenshots',
'Requirements',
'Installation'
];
} elseif (in_array($screen->id, $help_short)) {
$include = [
'Shortcodes',
'Agents',
];
} else {
return;
}
// https://developer.wordpress.org/apis/filesystem/
$url = admin_url('admin.php?page=' . ALPACA_BOT);
$creds = request_filesystem_credentials($url, '', false, false, null);
if (!WP_Filesystem($creds)) {
request_filesystem_credentials($url, '', true, false, null);
return;
}
// Load README.md
global $wp_filesystem;
$readme = $wp_filesystem->get_contents(ALPACA_BOT_DIR_PATH . 'README.md');
// Parse README.md
$parsedown = new Parsedown();
// convert README like an array, create arrays from each h2 section
$readmeArray = explode('
', $parsedown->text($readme));
$sections = [];
foreach ($readmeArray as $section) {
$section = explode('
', $section);
if (count($section) > 1) {
$sections[trim($section[0])] = trim($section[1]);
}
}
// Add help tabs
foreach ($sections as $title => $content) {
if (in_array($title, $ignore)) {
continue;
}
if (!empty($include) and !in_array($title, $include)) {
continue;
}
$screen->add_help_tab(array(
'id' => Options::appendPrefix($title),
'title' => $title,
'content' => $content,
));
}
$sidebar = 'Support Alpaca Bot
';
$sidebar .= '';
$screen->set_help_sidebar($sidebar);
}
public function addPluginActionLinks($links)
{
$links[] = 'Chat';
$links[] = 'Settings';
return $links;
}
public function addPluginRowMeta($links, $file)
{
if ($file === ALPACA_BOT . '/' . ALPACA_BOT . '.php') {
$links[] = 'Discord';
$links[] = 'Patreon';
}
return $links;
}
}