Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
plugins
/
bricksforge
/
includes
/
api
:
Helper.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace Bricksforge\Api; class Helper { /** * Render CSS files for the global classes */ public function render_css_files($categories) { clearstatcache(); if (!file_exists(BRICKSFORGE_CUSTOM_STYLES_FILE) || !is_readable(BRICKSFORGE_CUSTOM_STYLES_FILE)) { return false; } if (!$categories || empty($categories)) { return false; } file_put_contents(BRICKSFORGE_CUSTOM_STYLES_FILE, ' '); $css_content = file_get_contents(BRICKSFORGE_CUSTOM_STYLES_FILE); $pattern = '/(?:[\.]{1})([a-zA-Z_]+[\w_]*)(?:[\s\.\,\{\>#\:]{0})/im'; foreach ($categories as $category) { $prefix = $category->prefix; $category->code = preg_replace($pattern, '.' . $prefix . '-${1}', $category->code); $css_content .= PHP_EOL . $category->code; } $result = file_put_contents(BRICKSFORGE_CUSTOM_STYLES_FILE, $css_content); return $result; } }