Check the plugin is installed.

@param string $slug The slug of the plugin.
@return bool Return true if plugin is installed.
@throws \Exception
545538
public function is_plugin_installed( $slug )
	{
		$element = $this->search_plugin( $slug );
		if ( count( $element ) ) {
			return true;
		} else {
			return false;
		}
	}
1042428
public static function hasPosts($postTypeSlug)
    {
        $getPostType = self::findBySlug($postTypeSlug);
        if($getPostType) {
            if(DB::table($getPostType['slug'])->count() > 0) {
                return true;
            }
        }
        return false;
    }
290956
public function delete($slug)
    {
        $this->loadModel('Content.ContentTypes');
        $type = $this->ContentTypes->find()
            ->where(['slug' => $slug])
            ->first();

        if (!$type) {
            throw new NotFoundException(__d('content', 'Content type was not found!'));
        }

        if ($this->ContentTypes->delete($type)) {
            $this->Flash->success(__d('content', 'Content was deleted!'));
        } else {
            $$this->Flash->danger(__d('content', 'Content type could not be deleted, please try again.'));
        }

        $this->title(__d('content', 'Delete Content Type'));
        $this->redirect($this->referer());
    }
949153
public function setSlug($slug)
    {
        if ($slug !== null) {
            $slug = (string) $slug;
        }

        $this->slug = $slug;
    }
1203507
public function findBySlug($slug)
    {
        return $this->model
            ->whereSlug($slug)
            ->with($this->with)
            ->first();
    }
152034
public function the_plugin_should_be( $slug, $expect )
	{
		if ( ! $this->is_plugin_installed( $slug ) ) {
			throw new \Exception( sprintf(
				"The %s plugin is not installed.",
				$slug
			) );
		}

		if ( "activated" === $expect && ! $this->is_plugin_activated( $slug ) ) {
			throw new \Exception( sprintf(
				"The %s plugin should be activated, but not activated.",
				$slug
			) );
		}
	}
917243
public function checkIfSlugIsUnique($slug)
    {
        $i = 0;
        $this->base_slug = $slug;

        while ($this->post->whereSlug($slug)->get()->count() > 0) {
            $i++;
            $slug = "$this->base_slug-$i";
        }

        return $slug;
    }
879634
public function showAction($slug)
    {
        $securityContext = $this->container->get('security.authorization_checker');
        $question        = $this->getQuestionRepository()->findOneBySlug($slug);

        if (!$question || (!$question->isPublic() && !$securityContext->isGranted('ROLE_EDITOR'))) {
            throw $this->createNotFoundException('question not found');
        }

        return $this->render(
            'GenjFaqBundle:Question:show.html.twig',
            array(
                'question' => $question
            )
        );
    }
755857
public function deleteUserBySlug($slug)
    {
        $userToDelete = $this->getUserBySlug($slug);
        if (empty($userToDelete)) {
            throw new \Exception('Trying to delete a user that doesn\'t exist.');
        }
        $users = $this->getUsers();
        foreach ($users as $key => $user) {
            if ($user->slug == $userToDelete->slug) {
                unset($users[$key]);
                $this->repository->users = array_values($users);
            }
        }
        $this->save();
    }
644575
public function getActive($slug)
    {
        $bc = $this->getBreadCrumb();
        foreach ($bc as $bcItem) {
            if ($bcItem->getSlug() == $slug) {
                return true;
            }
        }

        return false;
    }
220450
private function canInstall()
    {
        $this->info("Validating");

        // Exists as a directory
        if(!file_exists(pluginsPath($this->pluginNamespace))) {
            throw new \Exception("Plugin ".$this->pluginNamespace." not found in plugins directory!");
        }

        // Remove composer autoloader
        exec('composer dump-autoload', $output, $return_var);

        // Clear laravel compiled files
        $this->callSilent('clear-compiled');

        // Plugin class exists
        $fullNamespace =  'Plugins\\'.str_replace('/', '\\', $this->pluginNamespace.'\\Plugin');

        if(!class_exists($fullNamespace)) {
            // When composer autoload was generated, we didn't have this plugin's classes
            // that's why we have to autoload all Plugin' classes manually
            spl_autoload_register(
                function ($class) {
                    $class = str_replace("\\", "/", $class);
                    $class = str_replace("Plugins", "plugins", $class);
                    include base_path().'/' . $class. '.php';
                }
            );
        }

        // Make sure Plugin namespace class exist
        if(!class_exists($fullNamespace)) {
            throw new \Exception("Class $fullNamespace not found!");
        }

        // Plugin needs to have an "install" method
        $this->pluginInstance = new $fullNamespace();
        if(!method_exists($this->pluginInstance, 'install')) {
            throw new \Exception("Plugin ".$this->pluginNamespace." does not have an install method!");
        }

        // Plugin should not be in DB Table
        if(Plugin::where('namespace', $this->pluginNamespace)->first()) {
            throw new \Exception("Plugin ".$this->pluginNamespace." already exists in DB!");
        }

        // Config file exist
        if(!file_exists(pluginsPath($this->pluginNamespace.'/config.json'))) {
            throw new \Exception("Plugin ".$this->pluginNamespace." config.file does not exists!");
        }
        return true;
    }
287056
protected function getExistingSlugs($slug)
    {
        // check for existing slugs in the slugs table or locally?
        if ($this->storeSlugLocally()) {
            return $this->cviebrockGetExistingSlugs($slug);
        }

        return $this->getAllSlugsForModuleFromCmsTable($slug);
    }
367785
private function get_plugin_slug( $url ) {
		if ( $this->app->utility->starts_with( $url, 'https://wordpress.org/plugins/' ) ) {
			return trim( str_replace( 'https://wordpress.org/plugins/', '', $url ), '/' );
		}

		return false;
	}
891497
private function call_plugin_api( $slug ) {
		include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );

		$call_api = get_transient( 'ti_plugin_info_' . $slug );

		if ( false === $call_api ) {
			$call_api = plugins_api(
				'plugin_information',
				array(
					'slug'   => $slug,
					'fields' => array(
						'downloaded'        => false,
						'rating'            => false,
						'description'       => false,
						'short_description' => true,
						'donate_link'       => false,
						'tags'              => false,
						'sections'          => true,
						'homepage'          => true,
						'added'             => false,
						'last_updated'      => false,
						'compatibility'     => false,
						'tested'            => false,
						'requires'          => false,
						'downloadlink'      => false,
						'icons'             => true,
						'banners'           => true,
					),
				)
			);
			set_transient( 'ti_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS );
		}

		return $call_api;
	}
902771
public function get( $option, $slug ) {

		if ( $this->is_active() ) {

			$this->prepare( $slug );

			$slug = $this->slug;

			if ( isset( $this->plugin[ $slug ][ $option ] ) ) {
				return $this->plugin[ $slug ][ $option ];
			} elseif ( '*' == $option && isset( $this->plugin[ $slug ] ) ) {
				return $this->plugin[ $slug ];
			}

			return false;
		}
	}
1350342
public function isLoaded($plugin)
    {
        $pluginClass = get_class($this->getBundle($plugin));

        foreach ($this->loadedBundles as $bundle => $isEnabled) {
            if ($bundle === $pluginClass && $isEnabled) {
                return true;
            }
        }

        return false;
    }
849453
protected function _init()
    {
        if (!parent::_init()) {
            return false;
        }

        if (!Plugin::exists($this->_plugin['name'])) {
            $this->err(__d('installer', 'The plugin "{0}" is not installed, you cannot update a plugin that is not installed in your system.', $this->_plugin['name']));

            return false;
        } else {
            $plugin = plugin($this->_plugin['name']);
            if (!$this->canBeDeleted($plugin->path)) {
                $this->err(__d('installer', 'Unable to update, please check write permissions for "{0}".', $plugin->path));

                return false;
            }
        }

        return true;
    }