예제 #1
0
 /**
  * Get Meta Data
  *
  * Get meta data using custom syntax with brackets.
  *
  * @param string $name
  * @param string $fallBack
  * @param bool $groups
  * @param null $id
  *
  * @return mixed|null|string
  */
 static function meta($name = '', $fallBack = '', $groups = true, $id = null)
 {
     if (!acpt_validate::bracket($name)) {
         die("ACPT Error: You need to use brackets [{$name}]");
     }
     /*
      * Action start_acpt_meta
      *
      * Do anything you want with input data before it is gotten.
      */
     do_action('start_acpt_meta', $name, $fallBack, $groups, $id);
     global $post;
     empty($id) ? $id = $post->ID : true;
     if ($groups === true) {
         $data = self::get_groups($name, $id);
     } else {
         $data = self::get_single($name, $id);
     }
     /*
      * Action end_acpt_meta
      *
      * Do anything you like with resolved data before it is returned.
      */
     do_action('end_acpt_meta', $data);
     empty($data) ? $data = $fallBack : true;
     return $data;
 }
예제 #2
0
 /**
  * Sanitize Hex Color Value
  *
  * If the hex does not validate return a default instead.
  *
  * @param $hex
  * @param string $default
  *
  * @return string
  */
 static function hex($hex, $default = '#000000')
 {
     if (acpt_validate::hex($hex)) {
         return $hex;
     }
     return $default;
 }
예제 #3
0
 /**
  * Compile bracket syntax for usage
  *
  * @param $field
  * @param $group
  * @param $sub
  *
  * @return string
  */
 private function get_bracket_syntax($field, $group, $sub)
 {
     $group = $this->get_opt_by_test($group, $this->group);
     if (!acpt_validate::bracket($group) && $group != '') {
         $this->test_for(false, 'ACPT ERROR: You need to to the form group to an array format [' . $group . ']');
     }
     if (!acpt_validate::bracket($sub) && $sub != '') {
         $this->test_for(false, 'ACPT ERROR: You need to to the form sub group to an array format [' . $group . ']');
     }
     return "{$group}[{$field}]{$sub}";
 }