super-powers/src/3cf76fbf-fd95-4a33-878e-7aff6d36b7f6/code.power

92 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-04-15 14:49:41 +00:00
/**
* Making plugin folder name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeFolderName(string $codeName, string $group): string
{
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'plg_' . strtolower($group) . '_' . strtolower(
$codeName
);
}
/**
* Making plugin class name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeClassName(string $codeName, string $group): string
{
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'Plg' . ucfirst($group) . ucfirst(
$codeName
);
}
/**
* Making plugin install class name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeInstallClassName(string $codeName, string $group): string
{
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'plg' . ucfirst($group) . ucfirst(
$codeName
) . 'InstallerScript';
}
/**
* Making language prefix safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeLangPrefix(string $codeName, string $group): string
{
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'PLG_' . strtoupper($group) . '_' . strtoupper(
$codeName
);
}