# formidable/5.4.4/classes/models/FrmInstallPlugin.php

Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes &amp; More, version 5.4.4. 49 lines.

- Page: https://pluginprobe.com/plugins/formidable/5.4.4/code/classes/models/FrmInstallPlugin.php
- Raw: https://pluginprobe.com/plugins/formidable/5.4.4/raw/classes/models/FrmInstallPlugin.php
- Modified: 2020-12-07T20:56:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/formidable/5.4.4/code/classes/models/FrmInstallPlugin.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	die( 'You are not allowed to call this page directly.' );
}

/**
 * @since 4.04.04
 */
class FrmInstallPlugin {

	protected $plugin_file; // format: folder/filename.php
	protected $plugin_slug;

	public function __construct( $atts ) {
		$this->plugin_file = $atts['plugin_file'];
		list( $slug, $file ) = explode( '/', $this->plugin_file );
		$this->plugin_slug = $slug;
	}

	public function get_activate_link() {
		if ( $this->is_installed() && $this->is_active() ) {
			return '';
		}

		if ( $this->is_installed() ) {
			$url = $this->activate_url();
		} else {
			$url = $this->install_url();
		}
		return $url;
	}

	public function is_installed() {
		return is_dir( WP_PLUGIN_DIR . '/' . $this->plugin_slug );
	}

	public function is_active() {
		return is_plugin_active( $this->plugin_file );
	}

	protected function install_url() {
		return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $this->plugin_slug ), 'install-plugin_' . $this->plugin_slug );
	}

	protected function activate_url() {
		return wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $this->plugin_file ), 'activate-plugin_' . $this->plugin_file );
	}
}

```
