Skip to content

Commit

Permalink
Amapress Installer
Browse files Browse the repository at this point in the history
  • Loading branch information
sharevb committed Jul 17, 2019
1 parent 604eb35 commit b9528b1
Show file tree
Hide file tree
Showing 22 changed files with 1,929 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text=auto

.gitattributes export-ignore
.gitignore export-ignore
composer.json export-ignore
.travis.yml export-ignore
/bin export-ignore
/tests export-ignore
phpunit.xml export-ignore
/wiki-assets export-ignore
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
composer*.phar
/vendor/**/.git
.idea/
/tmp/
25 changes: 25 additions & 0 deletions amapress-installer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Plugin Name: Installateur du plugin Amapress
* Plugin URI: https://github.com/comptoirdesappli/amapress-installer
* Description: Installateur du plugin Amapress
* Version: 1.0
* Author: ShareVB
* Author URI: http://amapress.fr/
* License: License: GPLv2 or later
* Requires WP: 4.4
* Requires PHP: 5.6
* GitHub Plugin URI: comptoirdesappli/amapress-installer
*/

require_once __DIR__ . '/vendor/autoload.php';
WP_Dependency_Installer::instance()->run( __DIR__ );
add_filter(
'wp_dependency_timeout',
function( $timeout, $source ) {
$timeout = $source !== basename( __DIR__ ) ? $timeout : 14;
return $timeout;
},
10,
2
);
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "comptoirdesappli/amapress-installer",
"description": "Installateur du plugin Amapress",
"minimum-stability": "dev",
"license": "GPLv2",
"authors": [
{
"name": "ShareVB",
"email": "[email protected]"
}
],
"require": {
"afragen/wp-dependency-installer": "1.4.12"
}
}
91 changes: 91 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/afragen/wp-dependency-installer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Andy Fragen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
111 changes: 111 additions & 0 deletions vendor/afragen/wp-dependency-installer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# WP Dependency Installer
* Contributors: [Andy Fragen](https://github.com/afragen), [Matt Gibbs](https://github.com/mgibbs189), [contributors](https://github.com/afragen/wp-dependency-installer/graphs/contributors)
* Tags: plugin, dependency, install
* Requires at least: 3.8
* Requires PHP: 5.3
* Stable tag: master
* Donate link: <https://thefragens.com/wp-dependency-installer-donate>
* License: MIT

A lightweight class to add to WordPress plugins or themes to automatically install required plugin dependencies. Uses a JSON config file to declare plugin dependencies.

## Description

This is a drop in class for developers to optionally or automatically install plugin dependencies for their own plugins or themes. It can install a plugin from w.org, GitHub, Bitbucket, GitLab, Gitea, or a direct URL. You must include a JSON config file in the root directory of the plugin/theme file.

This contains an example plugin and an example JSON configuration file. Only required dependencies are installed automatically, optional dependencies are not. Required dependencies are always kept active.

## Installation

Install the package via composer.

Run the composer command: ```composer require afragen/wp-dependency-installer```

Then create a new `wp-dependencies.json` file.

```cp ./vendor/afragen/wp-dependency-installer/wp-dependencies-example.json wp-dependencies.json```

You will then need to update `wp-dependencies.json` to suit your requirements.

Add the following lines to your plugin or to your theme's `functions.php` file.

```php
include_once( __DIR__ . '/vendor/autoload.php' );
WP_Dependency_Installer::instance()->run( __DIR__ );
```

## JSON config file format

This file must be named `wp-dependencies.json` and it must be in the root directory of your plugin or theme.

```json
[
{
"name": "Query Monitor",
"host": "wordpress",
"slug": "query-monitor/query-monitor.php",
"uri": "https://wordpress.org/plugins/query-monitor/",
"optional": false
},
{
"name": "GitHub Updater",
"host": "github",
"slug": "github-updater/github-updater.php",
"uri": "afragen/github-updater",
"branch": "master",
"optional": false,
"token": null
},
{
"name": "Test Plugin Notags",
"host": "bitbucket",
"slug": "test-plugin-notags/test-plugin-notags.php",
"uri": "https://bitbucket.org/afragen/test-plugin-notags",
"branch": "master",
"optional": true
},
{
"name": "Test Gitlab Plugin2",
"host": "gitlab",
"slug": "test-gitlab-plugin2/test-gitlab-plugin2.php",
"uri": "https://gitlab.com/afragen/test-gitlab-plugin2",
"branch": "develop",
"optional": true,
"token": null
},
{
"name": "Test Direct Plugin Download",
"host": "direct",
"slug": "test-direct-plugin/test-plugin.php",
"uri": "https://direct-download.com/path/to.zip",
"optional": true
}
]
```

An example file is included, `wp-dependencies-example.json`. You may use a shorthand uri such as `<owner>/<repo>` in the JSON.

If you want to programmatically add dependencies you can send an associative array directly to

```php
WP_Dependency_Installer::instance()->register( $config )
```

where `$config` is an associative array as in identical format as `json_decode( wp-dependencies.json content )`

The default timeout for dismissal of a notification is 7 days. There is a filter `wp_dependency_timeout` to adjust this on a per project basis.

```php
add_filter(
'wp_dependency_timeout', function( $timeout, $source ) {
$timeout = $source !== basename( __DIR__ ) ? $timeout : 14;
return $timeout;
}, 10, 2
);
```

The download link can be filtered using the filter hook `wp_dependency_download_link`. The `$download_link` and the `$dependency` are passed as parameters.

## Development

PRs are welcome against the `develop` branch.
Loading

0 comments on commit b9528b1

Please sign in to comment.