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

92 lines
2.1 KiB
Plaintext

/**
* 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
);
}