Beispiel #1
0
 /**
  * Setup arguments.
  *
  * @param  array $args
  */
 protected function setup_args(array $args)
 {
     foreach ($args as $key => $value) {
         if (isset($this->{$key})) {
             $this->{$key} = papi_esc_html($value);
         }
     }
     if (empty($this->id)) {
         $this->id = strtolower(papi_f(papi_underscorify(papify($this->title))));
     }
 }
Beispiel #2
0
 /**
  * Setup arguments.
  *
  * @param  array $args
  */
 private function setup_args(array $args)
 {
     $excluded_keys = ['properties'];
     foreach ($args as $key => $value) {
         if (isset($this->{$key}) && !in_array($key, $excluded_keys)) {
             $this->{$key} = papi_esc_html($value);
         }
     }
     if (empty($this->id)) {
         $this->id = strtolower(papi_f(papi_underscorify(papify($this->title))));
     }
 }
 /**
  * Get meta box id.
  *
  * @param string $slug
  *
  * @return string
  */
 private function get_meta_box_id($slug)
 {
     return papi_f(papi_underscorify(papify($slug)));
 }
 /**
  * Get the html id attribute value.
  *
  * @param  object|string $suffix
  * @param  int $row
  *
  * @return string
  */
 public function html_id($suffix = '', $row = null)
 {
     if (is_array($suffix) || is_object($suffix)) {
         return papi_f($this->html_name($suffix, $row));
     } else {
         $suffix = empty($suffix) || !is_string($suffix) ? '' : '_' . $suffix;
         $suffix = papi_underscorify(papi_slugify($suffix));
     }
     $name = $this->html_name();
     $len = strlen($name);
     if (isset($name[$len - 1]) && $name[$len - 1] === ']') {
         return papi_f(sprintf('%s%s]', substr($name, 0, $len - 1), $suffix));
     }
     return papi_f(sprintf('%s%s', $this->html_name(), $suffix));
 }
Beispiel #5
0
/**
 * Get a php friendly name.
 *
 * @param  string $name
 *
 * @return string
 */
function papi_html_name($name)
{
    if (!is_string($name)) {
        return '';
    }
    if (!preg_match('/^\\_\\_papi|^\\_papi/', $name)) {
        $name = papify($name);
        if (!preg_match('/\\[.*\\]/', $name)) {
            $name = papi_slugify($name);
        }
        return papi_underscorify($name);
    }
    return $name;
}