morningtrain/wp-plugin-info

Helper class to handle info about a plugin

v3.2.0 2023-08-18 12:40 UTC

This package is auto-updated.

Last update: 2024-11-18 15:30:53 UTC


README

Get information information about a plugin, based on the plugin file.

Table of Contents

Introduction

Get information information about a plugin, based on the plugin file.

Getting Started

To get started install the package as described below in Installation.

To use the tool have a look at Usage

Installation

Install with composer

composer require morningtrain/wp-plugin-info

Usage

Initialize

To get started register a plugin file;

// plugin.php
require __DIR__ . "/vendor/autoload.php";

$plugin_info = Morningtrain\WP\PluginUpdater\PluginInfo::register(__FILE__);

Set Slug

You can set a slug by setting Plugin Slug header in the plugin header. Alternatively you can set the slug with the setSlug method on the PluginInfo instance. This is useful get the information about your plugin later.

Set a named path

You can set a named path, that you can use to get the path later. It must be an absolute path. You can set a path in the plugin folder or any other place.

$plugin_info->setNamedPath('app', __DIR__ . '/app');
$plugin_info->setNamedPath('logs', WP_CONTENT_DIR . '/logs');

Set a named URL

You can set a named URL, that you can use to get the URL later. It must be an absolute URL. You can set a URL in the plugin folder or any other place.

$plugin_info->setNamedUrl('images', $plugin_info->getRootUrl() . 'public/iamges');
$plugin_info->setNamedUrl('invoices', content_url('private/invoices'));

Set a named Parameter

You can set a named parameter, that you can use to get the parameter later. You can set anything with relevance to your plugin.

$plugin_info->setNamedParameter('license', $license);

Retrieve a PluginInfo instance

You can retrieve a PluginInfo instance by using the get method on the PluginInfo class.

$plugin_info = Morningtrain\WP\PluginUpdater\PluginInfo::get('pluginSlug');

Retrieve Information

Contributing

Thank you for your interest in contributing to the project.

Bug Report

If you found a bug, we encourage you to make a pull request.

To add a bug report, create a new issue. Please remember to add a telling title, detailed description and how to reproduce the problem.

Support Questions

We do not provide support for this package.

Pull Requests

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contributors

License

The MIT License (MIT). Please see License File for more information.

Developed by

Morningtrain logo