Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Get a list of enabled plugins #47

@lusimeon

Description

@lusimeon

Summary

Hey @studiometa/wordpress what do you think about an helper function to get a list of enabled plugins.

Basic example

function get_enabled_plugins() : array
{
     $plugins_enabled = [];
     $plugins_directory = 'wp-content/plugins/';

     foreach ($plugins_directory as $key => $value) {
        if ( file_exists($plugins_directory . $value) && is_plugin_active($value) ) {
             array_push($plugins_enabled, $key);
        }
    }

    return $plugins_enabled;
}

$plugins = Helper::get_enabled_plugins();

if ( in_array( 'my_plugin', $plugins, true ) ) {
     // Call my_plugin function
}

Motivation

It can be usefull to test if a plugin is enabled or not to do an action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions