Skip to content

Commit

Permalink
Merge pull request #9 from inpsyde/package-updates
Browse files Browse the repository at this point in the history
Support Inpsyde Assets 2.5+ & Composer 2
  • Loading branch information
Biont authored Apr 12, 2021
2 parents 4cd9c7e + 907460c commit f931e62
Show file tree
Hide file tree
Showing 39 changed files with 275 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer:v1
tools: composer:v2

- name: Check syntax error in sources
run: find ./src/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-compile-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: 7.3
tools: composer:v1
tools: composer:v2

- name: "Install dependencies"
run: composer install --no-interaction --prefer-dist --classmap-authoritative
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,7 @@ report-*.txt

# Generated files
/svn-assets
/*.zip
/*.zip

# Composer Assets Compiler
.composer_compiled_assets
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# CHANGELOG

## 1.4.0

### Updated
- Updated `inpsyde/assets` to version `~2.5`
- Updated `inpsyde/php-coding-standards` to version `1.0.0-RC1`.
- Update most of the codebase to follow the updated standards
- Update dependencies to support composer 2


## 1.3.1

### Updated
- change psr/container to ~1.0 because of https://github.com/php-fig/container/pull/27

## 1.3

### Updated
- Updated `inpsyde/assets` to version `~2.1`

## 1.2

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ Documentation can be found in [readme.txt](readme.txt).
* WordPress >= 4.6.
* PHP 7 or higher.

## How to start develop
## How to start development

This plugin does not include build assets and PHP-dependencies. Therefore, after loading that repository via Composer or git checkout you have to install them.

**With Yarn:**

```js
yarn install && yarn run develop
```shell
yarn install && yarn encore dev
```

**With NPM:**
```js
npm install && npm run develop
```shell
npm install && npm run dev
```

The `develop`-script generates all JavaScript- and CSS-files and also runs `composer install` to create the autoloading.
For more information, please refer to the [Symfony Encore docs](https://symfony.com/doc/current/frontend.html#webpack-encore)

## Testing & Quality
To run all tests you've to install composer dev-dependencies first.
Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
"psr/container": "~1.0",
"brain/nonces": "1.0.*",
"chrico/wp-fields": "~1.0",
"inpsyde/assets": "~2.1"
"inpsyde/assets": "~2.5"
},
"require-dev": {
"php": ">=7",
"php": ">=7.1",
"phpunit/phpunit": "6.3.*",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.2",
"inpsyde/php-coding-standards": "^0.12",
"squizlabs/php_codesniffer": "~3.2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"inpsyde/php-coding-standards": "1.0.0-RC.1",
"brain/monkey": "^2",
"inpsyde/composer-assets-compiler": "v2.x-dev"
},
Expand Down
6 changes: 5 additions & 1 deletion src/App/BootableProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App;

Expand Down
10 changes: 7 additions & 3 deletions src/App/ConfigBuilder.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App;

Expand Down Expand Up @@ -40,7 +44,7 @@ public static function fromFile(string $file): PluginConfig
'assets.suffix' => $config->get('debug.mode')
? ''
: '.min',
'assets.url' => $config->get('plugin.url').'assets/',
'assets.url' => $config->get('plugin.url') . 'assets/',
]
);

Expand All @@ -57,7 +61,7 @@ public static function fromFile(string $file): PluginConfig
private static function generatePluginHeaders(string $file): array
{
if (defined('ABSPATH')) {
$pluginsFile = ABSPATH.'/wp-admin/includes/plugin.php';
$pluginsFile = ABSPATH . '/wp-admin/includes/plugin.php';
if (! function_exists('get_config') && file_exists($pluginsFile)) {
require_once($pluginsFile);
}
Expand Down
8 changes: 6 additions & 2 deletions src/App/PluginConfig.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App;

Expand Down Expand Up @@ -100,7 +104,7 @@ public function import($var): PluginConfig
if (! is_array($var) && ! is_object($var)) {
$this->stop(
'Cannot import this variable.
Use arrays and objects only, not a "'.gettype($var).'".'
Use arrays and objects only, not a "' . gettype($var) . '".'
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/App/Provider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php # -*- coding: utf-8 -*-
<?php

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App;

Expand Down
12 changes: 8 additions & 4 deletions src/App/Provider/AssetProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App\Provider;

Expand Down Expand Up @@ -27,17 +31,17 @@ public function register(GoogleTagManager $plugin)
$config = $plugin->get('config');
add_action(
AssetManager::ACTION_SETUP,
function (AssetManager $manager) use ($config) {
static function (AssetManager $manager) use ($config) {
$assetUrl = $config->get('assets.url');
$manager->register(
(new Script(
'inpsyde-google-tag-manager-admin',
$assetUrl.'inpsyde-google-tag-manager-admin.js',
$assetUrl . 'inpsyde-google-tag-manager-admin.js',
Asset::BACKEND
))->withDependencies('jquery-ui-tabs'),
(new Style(
'inpsyde-google-tag-manager-admin',
$assetUrl.'inpsyde-google-tag-manager-admin.css',
$assetUrl . 'inpsyde-google-tag-manager-admin.css',
Asset::BACKEND
))
);
Expand Down
12 changes: 8 additions & 4 deletions src/App/Provider/DataLayerProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App\Provider;

Expand All @@ -23,21 +27,21 @@ public function register(GoogleTagManager $plugin)
{
$plugin->set(
'DataLayer',
function (GoogleTagManager $plugin): DataLayer {
static function (GoogleTagManager $plugin): DataLayer {
return new DataLayer($plugin->get('Settings.SettingsRepository'));
}
);

$plugin->set(
'DataLayer.User.UserDataCollector',
function (GoogleTagManager $plugin): UserDataCollector {
static function (GoogleTagManager $plugin): UserDataCollector {
return new UserDataCollector($plugin->get('Settings.SettingsRepository'));
}
);

$plugin->set(
'DataLayer.Site.SiteInfoDataCollector',
function (GoogleTagManager $plugin): SiteInfoDataCollector {
static function (GoogleTagManager $plugin): SiteInfoDataCollector {
return new SiteInfoDataCollector($plugin->get('Settings.SettingsRepository'));
}
);
Expand Down
8 changes: 6 additions & 2 deletions src/App/Provider/FormProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App\Provider;

Expand All @@ -20,7 +24,7 @@ public function register(GoogleTagManager $plugin)
{
$plugin->set(
'ChriCo.Fields.ElementFactory',
function (): ElementFactory {
static function (): ElementFactory {
return new ElementFactory();
}
);
Expand Down
12 changes: 8 additions & 4 deletions src/App/Provider/RendererProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App\Provider;

Expand Down Expand Up @@ -27,21 +31,21 @@ public function register(GoogleTagManager $plugin)
{
$plugin->set(
'Renderer.GtmScriptTagRenderer',
function (GoogleTagManager $plugin): GtmScriptTagRenderer {
static function (GoogleTagManager $plugin): GtmScriptTagRenderer {
return new GtmScriptTagRenderer($plugin->get('DataLayer'));
}
);

$plugin->set(
'Renderer.DataLayerRenderer',
function (GoogleTagManager $plugin): DataLayerRenderer {
static function (GoogleTagManager $plugin): DataLayerRenderer {
return new DataLayerRenderer($plugin->get('DataLayer'));
}
);

$plugin->set(
'Renderer.NoscriptTagRenderer',
function (GoogleTagManager $plugin): NoscriptTagRenderer {
static function (GoogleTagManager $plugin): NoscriptTagRenderer {
return new NoscriptTagRenderer($plugin->get('DataLayer'));
}
);
Expand Down
10 changes: 7 additions & 3 deletions src/App/Provider/SettingsProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\App\Provider;

Expand All @@ -23,14 +27,14 @@ public function register(GoogleTagManager $plugin)
{
$plugin->set(
'Settings.SettingsRepository',
function (GoogleTagManager $plugin): SettingsRepository {
static function (GoogleTagManager $plugin): SettingsRepository {
return new SettingsRepository($plugin->get('config')->get('plugin.textdomain'));
}
);

$plugin->set(
'Settings.Page',
function (GoogleTagManager $plugin): SettingsPage {
static function (GoogleTagManager $plugin): SettingsPage {
return new SettingsPage(
new TabbedSettingsPageView($plugin->get('config')),
$plugin->get('Settings.SettingsRepository')
Expand Down
10 changes: 7 additions & 3 deletions src/DataLayer/DataCollectorInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\DataLayer;

Expand All @@ -8,8 +12,8 @@
interface DataCollectorInterface
{

const VALUE_ENABLED = 'enabled';
const VALUE_DISABLED = 'disabled';
public const VALUE_ENABLED = 'enabled';
public const VALUE_DISABLED = 'disabled';

/**
* Checks if for the current page this is usable.
Expand Down
21 changes: 12 additions & 9 deletions src/DataLayer/DataLayer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1); # -*- coding: utf-8 -*-
<?php

declare(strict_types=1);

# -*- coding: utf-8 -*-

namespace Inpsyde\GoogleTagManager\DataLayer;

Expand All @@ -16,11 +20,11 @@
class DataLayer implements SettingsSpecAwareInterface
{

const DATALAYER_NAME = 'dataLayer';
const SETTING__KEY = 'dataLayer';
const SETTING__GTM_ID = 'gtm_id';
const SETTING__AUTO_INSERT_NOSCRIPT = 'auto_insert_noscript';
const SETTING__DATALAYER_NAME = 'datalayer_name';
public const DATALAYER_NAME = 'dataLayer';
public const SETTING__KEY = 'dataLayer';
public const SETTING__GTM_ID = 'gtm_id';
public const SETTING__AUTO_INSERT_NOSCRIPT = 'auto_insert_noscript';
public const SETTING__DATALAYER_NAME = 'datalayer_name';

/**
* @var DataCollectorInterface[]
Expand Down Expand Up @@ -88,7 +92,7 @@ public function data(): array
{
return array_filter(
$this->data,
function (DataCollectorInterface $data): bool {
static function (DataCollectorInterface $data): bool {
return $data->isAllowed();
}
);
Expand Down Expand Up @@ -128,9 +132,8 @@ public function settingsSpec(): array
'inpsyde-google-tag-manager'
),
'<code>&lt;body&gt;</code>',
'<pre><code>&lt;?php do_action( "'.NoscriptTagRendererEvent::ACTION_RENDER.'" ); ?&gt;</code></pre>'
'<pre><code>&lt;?php do_action( "' . NoscriptTagRendererEvent::ACTION_RENDER . '" ); ?&gt;</code></pre>'
);
// phpcs:enable

$noscript = [
'label' => __('Auto insert noscript in body', 'inpsyde-google-tag-manager'),
Expand Down
Loading

0 comments on commit f931e62

Please sign in to comment.