From: Stephen Cameron Date: Thu, 2 Apr 2020 20:22:24 +0000 (+0200) Subject: WIP #3445 @10 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1daa6ce7e2be79ef29fe190c4f91e10e1a1b35a1;p=ccv-wordpress.git WIP #3445 @10 --- diff --git a/wp-content/mu-plugins/cube/src/Forms/Base.php b/wp-content/mu-plugins/cube/src/Forms/Base.php index f01488c..e1aebef 100644 --- a/wp-content/mu-plugins/cube/src/Forms/Base.php +++ b/wp-content/mu-plugins/cube/src/Forms/Base.php @@ -16,6 +16,19 @@ class Base const TEXTAREA = 'textarea'; + public function __construct() { + $this->register_scripts(); + $this->register_fields(); + } + + public function register_scripts() { + + } + + public function register_fields() { + + } + /** * Output field HTML * @param $name @@ -40,10 +53,7 @@ class Base $settings = array_merge($default_settings, $settings); $res = ''; - - if ($settings['show_title']) { - $res .= '
'. $field['title'] .'
'; - } + $res .= $this->title($name, $settings); // Special input styling for checkbox / radio fields if (in_array($field['type'], [self::BINARY, self::CHECKBOX, self::RADIO])) { @@ -63,6 +73,24 @@ class Base return '
'. $res .'
'; } + /** + * Generate field title + * @param $name + * @param $settings + * @return bool|string + */ + public function title($name, $settings = []) { + + if (!isset($settings['show_title']) || !$settings['show_title']) return ''; + + $title_class = $settings['title_class'] ?? ''; + + $field = $this->getField($name); + if (!$field) return false; + + return '
'. $field['title'] .'
'; + } + /** * Generate a radio or checkbox input * @param $name @@ -82,7 +110,7 @@ class Base $res .= '