Custom "Open with" actions

Creating a custom “Open with..” file contextual menu option:

The plugin folder structure

  • Create a new empty folder inside “customizables/custom_actions/”. For this example we'll name it “hello”.
  • Create a file “customizables/custom_actions/hello/app.php

The PHP class

Inside “customizables/custom_actions/hello/app.php”, start with the following example:

class custom_hello {//required class name "custom_<folder-name>"
	var $online = true; //set this to true if the plugin requires Internet connection. it also makes the option show after the plugins that FileRun comes with.
	var $disabled = false; //you can use this or the method bellow
	function isDisabled() {//optional method for dynamically enabling/disabling this plugin
		return false;
	function init() {//required method
		//contains only configuration data
		//no other functionality here
		$this->JSconfig = array(
			"title" => self::t("Hello World"),
			"popup" => true, //opens a popup and runs the method run() inside
				//popup styling
				'iconCls' => 'fa fa-fw fa-file-text-o', //CSS class for menu item icon, remove the bellow if using this
				"icon" => 'url/to/icon.png', //image file for menu item icon, remove the above if using this
				"loadingMsg" => self::t('The plugin is loading. Please wait.'),
				"width" => 500,
				"height" => 500,
				"external" => true, //makes the popup an actual browser popup instead of an in-page one
			"ajax" => true, //instead of the popup above, it makes an Ajax call for the run() method
			"multiple" => true, //show menu item also when multiple files are being selected
			"onlyMultiple" => true, //show menu item ONLY when multiple files are being selected
			"folder" => true, //show menu item only for folders
			'extensions' => array(
				'pdf' //show only for PDF files
			'useWith' => array(//the above setting takes precedence over this one
				'txt',  //show only for plain text files
				'office', //show only for office files
				'noext' //.. and files without extension
			"requiredUserPerms" => array(
	static function t($text) {//utility method for allowing the plugin to be translated to various languages
		$section = 'Custom Actions: Hello World'; //the translation section
		return FileRunLang::t($text, $section);
	function run() {//called inside the popup, or by the Ajax request
		FileRun::checkPerms("download");//important security stuff!
		echo 'Hello World!';
		echo '\\';
		echo 'Relative file path: '.$this->data[['filePath']];
		echo '\\';
		echo 'Full file path: '.$this->data[['fileName']];
		echo '\\';
		echo 'File name: '.$this->data[['relativePath']];
		echo '\\';
		echo 'Full path of plugin folder: '.$this->path;
		//add the action to the user activity log
		FileRunLog::add(false, "preview", array(
			"relative_path" => $this->data[['relativePath']],
			"full_path" => $this->data[['filePath']],
			"method" => "Hello"
	function dummy() {
		//your popup can access this method through the following URL: ?module=custom_actions&action=hello&method=dummy