texnixe / kirby-secrets

Unofficial documentation for Kirby CMS. It's is NOT maintained by the Kirby crew.
130 stars 3 forks source link

Get array with loaded plugins - kirby()->plugins #7

Closed jenstornell closed 7 years ago

jenstornell commented 7 years ago

Tested with: 2.4.1

print_r( kirby()->plugins );

My plugin list looked like this:

Array
(
    [category-checkboxes] => 1
    [controlledlist] => 1
    [kirby-crop-top] => 1
    [kirby-menu-editor] => 1
    [kirby-panel-prevnext] => 1
    [kirby-ratings] => 1
    [kirby-sitemap-query] => 1
    [load-assets] => 1
    [magic-number-format] => 1
    [modules] => 1
    [modules-field] => 1
    [previewer] => 1
)

If a plugin has been loaded

if( a::get( kirby()->plugins, 'modules' ) ) {
    echo 'The Modules plugin has been loaded';
}

Plugin loaded function

function pluginLoaded($plugin_name) {
  if( a::get( kirby()->plugins, 'modules' ) ) {
    return true;
  }
}
lukasbestle commented 7 years ago

@jenstornell Could you please add a disclaimer to the README that the tricks are not published by the Kirby team and that not all of them may work in the future? Would also help to mark the "internal" ones with a tag and/or in the title of the issues.

jenstornell commented 7 years ago

I can add a disclaimer tomorrow if I don't forget it.

But I will probably have a hard task of discovering what you see as internal and what is more official solutions. The whole idea of this repo is to cover things that can be really helpful but that is missing in the docs (maybe for a reason).

But if I write a disclaimer that says that everything here is experimental and at own risk I think we should be fine?

lukasbestle commented 7 years ago

Yes, should be fine.

jenstornell commented 7 years ago

I've added it now. =)