Enable a plugin by default

Post Reply
User avatar
abdulhalim
Master Bludit
Posts: 88
Joined: Thu Mar 10, 2016 6:25 pm

Mon Oct 21, 2019 9:11 pm

Hello,

There is a custom plugin for the Persian numbers, I want to enable it by default and repack the Bludit for Persian users to download the package, So how can I do it?

Plugin's code

Code: Select all

<?php

	class PluginNumbers extends Plugin{
		public function beforeSiteLoad(){
			ob_start();
		}

		public function afterSiteLoad(){
			$content = ob_get_contents();
			ob_end_clean();

			// Numbers Array
			$replace = array(
				"0" => '۰', "1" => '١', "2" => '٢', "3" => '٣', "4" => '۴',
				"5" => '۵', "6" => '۶', "7" => '٧', "8" => '٨', "9" => '٩'
			);

			// Convert Content
			$content = explode(">", $content);
			foreach($content AS &$inner){
				$inner = explode("<", $inner, 2);
				$inner[0] = strtr($inner[0], $replace);
				$inner = implode("<", $inner);
			}
			$content = implode(">", $content);
			print($content);
		}
	}

Regards,
Abdulhalim
User avatar
diego
Site Admin
Posts: 713
Joined: Sat May 16, 2015 2:53 pm
Contact:

Tue Oct 22, 2019 8:37 pm

Hi,
you can include in the installation file, install.php.

Add in the array the folder name
https://github.com/bludit/bludit/blob/m ... l.php#L281

And this is the content of the plugin database, you can copy from the following lines a do for your plugin.
https://github.com/bludit/bludit/blob/m ... #L473-L484

Regards
Post Reply