wordpress-base-plugin
wordpress-base-plugin copied to clipboard
plugin prefix on multiple plugin installation
Hi , I don't know if im doing something wrong, but I edit and installed the pluggin twice, in the same wordpress installation. I did all the steps in the Documentation, Installing carbon field with composer in both of them. both have a custom posttype with custom fields created with carbon fields. but the fields in the second plugin are saved with a wrong prefix . Both custom posts, from two different plugins, get the same prefix for theirs metas. if I deactivate the first plugin, the other plugin gets fixed, and its custom fields are saved right.
Thanks!
I have verified and you are correct. This is, indeed, a bug that surfaced at some point. I will have to look into it (it is located in one of my dependencies, not this code).
In the mean time, you can fix it by adding the following function to your app/Plugin.php
files:
/**
* Append a field prefix as defined in $config
*
* @param string $field_name The string/field to prefix
* @param string $before String to add before the prefix
* @param string $after String to add after the prefix
* @return string Prefixed string/field value
*/
public static function prefix( $field_name = null, $before = '', $after = '_' ) {
$prefix = $before . self::$config->get( 'prefix' ) . $after;
return $field_name !== null ? $prefix . $field_name : $prefix;
}
Thank you for the report! This is a major bug that needs to be fixed properly.
@dmhendricks Whoa, that was a really quick answer, thanks man. Good Guy Hendricks!
No problem, thanks!