Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin prefix on multiple plugin installation #7

Open
mmaturan opened this issue Oct 22, 2018 · 3 comments
Open

plugin prefix on multiple plugin installation #7

mmaturan opened this issue Oct 22, 2018 · 3 comments
Labels

Comments

@mmaturan
Copy link

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!

@dmhendricks
Copy link
Owner

dmhendricks commented Oct 24, 2018

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.

@mvargasmoran
Copy link

@dmhendricks Whoa, that was a really quick answer, thanks man.
Good Guy Hendricks!

@dmhendricks
Copy link
Owner

No problem, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants