/** * Returns the internal custom post type slug * @return string */ public function getWordpressKey() { $name = $this->getShortName(); $name = Inflector::underscore($name); return $this->wpPrefix . $name; }
/** * Generates a valid class name from the $name value. * @param string $name A possible class name. * @return string a Valid class name. */ public static function generateClassName($name) { $name = str_replace("-", "_", $name); if (strstr($name, "\\")) { $composedName = ""; foreach (explode("\\", $name) as $namespace) { $namespace = Inflector::underscore($namespace); $namespace = Inflector::classify($namespace); $composedName .= $namespace . "\\"; } } else { $name = Inflector::underscore($name); $name = Inflector::classify($name); } $suffix = self::getClassNameSuffix(); if (!preg_match("/{$suffix}\$/", $name)) { $name .= $suffix; } if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/', $name)) { throw new Exception(sprintf("We could not generate a valid PHP classname from %s", $name)); } return $name; }
/** * Per Wordpress' configuration, shortcodes must be * formatted roughly as underscored function names. * @param string $shortcode * @return string Shortcode with enforced formatting */ private function formatCode($shortcode) { return Inflector::underscore($shortcode); }