<commit_before><?php 

namespace App\Libs;

use \App\Model\Plugin as Plugin;

class ShortCode extends Model{

	public $table = 'plugins';
	private static $widgets = array();

	public static function initalize(){

		$all_plugin = self::all();

		foreach($all_plugin as $plugin){
			if(Plugin::exists($plugin->root_dir) && $plugin->active==1){
				self::$widgets["{[".str_slug($plugin->root_dir,"_")."]}"] = (new Plugin($plugin->root_dir))->getWidget();
			}
		}

	}

	public static function getAll(){
		return self::$widgets;
	}

	public static function resolve($shortcode){

		return isset(self::$widgets["{[".$shortcode."]}"])? eval("?>".self::$widgets["{[".$shortcode."]}"]."<?php") : NULL;
	}


	public static function compile($page){


		return eval("?>".str_replace(array_keys(self::$widgets), array_values(self::$widgets), $page)."<?php"); <commit_msg>Shordcode compile only when there's one installed plugin at least.<commit_after><?php 

namespace App\Libs;

use \App\Model\Plugin as Plugin;

class ShortCode extends Model{

	public $table = 'plugins';
	private static $widgets = array();

	public static function initalize(){

		$all_plugin = self::all();

		foreach($all_plugin as $plugin){
			if(Plugin::exists($plugin->root_dir) && $plugin->active==1){
				self::$widgets["{[".str_slug($plugin->root_dir,"_")."]}"] = (new Plugin($plugin->root_dir))->getWidget();
			}
		}

	}

	public static function getAll(){
		return self::$widgets;
	}

	public static function resolve($shortcode){

		return isset(self::$widgets["{[".$shortcode."]}"])? eval("?>".self::$widgets["{[".$shortcode."]}"]."<?php") : NULL;
	}


	public static function compile($page){

		return count(self::$widgets) === 0? $page : eval("?>".str_replace(array_keys(self::$widgets), array_values(self::$widgets), $page)."<?php"); 
{'fraction_non_alphanumeric': 0.21440443213296398, 'fraction_numerical': 0.0016620498614958448, 'mean_word_length': 5.51985559566787, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3269116', 'n_tokens_mistral': 640, 'n_tokens_neox': 585, 'n_words': 120}