* @link https://TheTempusProject.com/Core * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ namespace TheTempusProject\Classes; use TheTempusProject\Houdini\Classes\Forms; use TheTempusProject\Canary\Bin\Canary as Debug; use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Classes\Config as BedrockConfig; class Config extends BedrockConfig { public static function getFieldEditHtml( $name, $includeProtected = false ) { // @todo: includeProtected is unused here $node = self::get( $name ); if ( empty( $node ) ) { return; } if ( true === $node['protected'] ) { return; } $fieldname = str_ireplace( '/', '-', $name ); $html = Forms::getFormFieldHtml( $fieldname, $node['pretty'], $node['type'], $node['value'], ); return $html; } public static function getCategoryEditHtml( $category ) { $html = ''; if ( self::$config === false ) { Debug::warn( 'Config not loaded.' ); return; } if ( empty( self::$config[$category] ) ) { Debug::warn( "Config category not found: $category" ); return; } $categoryHeader = '

'; foreach ( self::$config[$category] as $field => $node ) { $html .= self::getFieldEditHtml( $category . '/' . $field ); } if ( !empty( $html ) ) { $html = $categoryHeader . $html; } return $html; } public static function getEditHtml() { if ( self::$config === false ) { Debug::warn( 'Config not loaded.' ); return; } $html = ''; foreach ( self::$config as $category => $fields ) { $html .= self::getCategoryEditHtml( $category ); } return $html; } }