{$class}; $propsKeys = array_keys($props); $styleObject = '{'; foreach ($propsKeys as $property) { $value = $props[$property]; if (empty($value)) { continue; } if (is_object($value)) { continue; } $styleObject .= "{$property}:{$value}{$important};"; } $styleObject = rtrim($styleObject, ';'); $styleObject .= '}'; $css .= $styleObject; } return $css; } public static function convertToCSS(array $styles): string { $css = ''; foreach ($styles as $selector => $properties) { $css .= "$selector{"; // Check if the properties are an array, meaning it's a nested rule (e.g., media queries, keyframes) if (is_array($properties)) { // If it's a nested array (media query or keyframe), recursively handle it foreach ($properties as $property => $value) { if (is_array($value)) { // Recursively process nested arrays (media queries, keyframes, etc.) $css .= self::convertToCSS([$property => $value]); } else { // Regular CSS property $css .= "$property:$value;"; } } } $css .= '}'; } return $css; } public static function appendCSS($formId, $css, $mode = 'a') { $fileName = ''; $path = ''; $path = 'form-styles'; $fileName = "bitform-{$formId}.css"; Helpers::saveFile($path, $fileName, $css, $mode); $fileName = "bitform-{$formId}-formid.css"; Helpers::saveFile($path, $fileName, $css, $mode); } public static function duplicateDbTable($oldTableName, $newTableName) { global $wpdb; $oldTable = "{$wpdb->prefix}bitforms_{$oldTableName}"; $newTable = "{$wpdb->prefix}bitforms_{$newTableName}"; // Schema operation: table name interpolation only (no user input). $wpdb->prepare() cannot parameterize DDL statements. $wpdb->query("CREATE TABLE IF NOT EXISTS `{$newTable}` LIKE `{$oldTable}`"); $wpdb->query("INSERT INTO `{$newTable}` SELECT * FROM `{$oldTable}`"); } }