diff --git a/.travis.yml b/.travis.yml index ac41869..d7ae14b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,16 +26,15 @@ before_script: fi - | if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then - composer global require wp-coding-standards/wpcs - composer global require wimg/php-compatibility - phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/wimg/php-compatibility + composer install; fi script: - | if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then - find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l - phpcs -p -s -v . --standard=./phpcs.xml --extensions=php --runtime-set testVersion $TRAVIS_PHP_VERSION + find . -name '*.php' ! -path "./vendor/*" ! -path "./wp-content/*" -print0 | xargs -0 -n 1 -P 4 php -l + echo Running phpcs for PHP version $TRAVIS_PHP_VERSION … + ./vendor/bin/phpcs --runtime-set testVersion $TRAVIS_PHP_VERSION fi notifications: diff --git a/CHANGELOG.md b/CHANGELOG.md index 886f0d9..cd2cf1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.1.3 +* Update module to new registration method introduced in [Hogan Core 1.1.7](https://github.com/DekodeInteraktiv/hogan-core/releases/tag/1.1.7) +* Set hogan-core dependency `"dekodeinteraktiv/hogan-core": ">=1.1.7"` +* Add Dekode Coding Standards. + ## 1.1.2 * Add `$item` and `$this` to before and after text action [#19](https://github.com/DekodeInteraktiv/hogan-linklist/pull/19) * Set link text if not set in WP link picker [#20](https://github.com/DekodeInteraktiv/hogan-linklist/pull/20) diff --git a/class-linklist.php b/class-linklist.php index 1c90432..554c04c 100644 --- a/class-linklist.php +++ b/class-linklist.php @@ -129,7 +129,7 @@ public function get_fields() : array { 'type' => 'select', 'allow_null' => 1, // Translators: %s: Link to navigation menu. - 'instructions' => sprintf( __( 'A predefined menu must be created here in order to show up in this dropdown.', 'hogan-links' ), admin_url() . 'nav-menus.php' ), + 'instructions' => sprintf( __( 'A predefined menu must be created here in order to show up in this dropdown.', 'hogan-linklist' ), admin_url() . 'nav-menus.php' ), 'choices' => [], 'ui' => 1, 'ajax' => 1, diff --git a/composer.json b/composer.json index 01a3016..7cd2741 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "require": { "php": ">=7.0", "composer/installers": "~1.2", - "dekodeinteraktiv/hogan-core": "^1.1.3" + "dekodeinteraktiv/hogan-core": ">=1.1.7" }, "archive": { "exclude": [ @@ -18,5 +18,14 @@ "LICENSE", "phpcs.xml" ] + }, + "require-dev": { + "dekodeinteraktiv/coding-standards": "^0.3.1" + }, + "scripts": { + "test": [ + "@composer install", + "./vendor/bin/phpcs" + ] } } diff --git a/composer.lock b/composer.lock index b864bc2..70760c1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "b8a06c3abc8917bb933e8be98525bf94", + "content-hash": "ae125d955a51078a813331a9cb10d041", "packages": [ { "name": "composer/installers", - "version": "v1.4.0", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/composer/installers.git", - "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b" + "reference": "049797d727261bf27f2690430d935067710049c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b", - "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b", + "url": "https://api.github.com/repos/composer/installers/zipball/049797d727261bf27f2690430d935067710049c2", + "reference": "049797d727261bf27f2690430d935067710049c2", "shasum": "" }, "require": { @@ -29,7 +29,7 @@ }, "require-dev": { "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "4.1.*" + "phpunit/phpunit": "^4.8.36" }, "type": "composer-plugin", "extra": { @@ -100,15 +100,18 @@ "lavalite", "lithium", "magento", + "majima", "mako", "mediawiki", "modulework", + "modx", "moodle", "osclass", "phpbb", "piwik", "ppi", "puppet", + "pxcms", "reindex", "roundcube", "shopware", @@ -121,37 +124,315 @@ "zend", "zikula" ], - "time": "2017-08-09T07:53:48+00:00" + "time": "2017-12-29T09:13:20+00:00" }, { "name": "dekodeinteraktiv/hogan-core", - "version": "1.0.3", + "version": "1.1.7", "source": { "type": "git", "url": "https://github.com/DekodeInteraktiv/hogan-core.git", - "reference": "010ce97f21587722e4d8c2c70860a49323647d29" + "reference": "46d5dd20ad7388ee014bc74efdde9261bb2c2ac0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/DekodeInteraktiv/hogan-core/zipball/010ce97f21587722e4d8c2c70860a49323647d29", - "reference": "010ce97f21587722e4d8c2c70860a49323647d29", + "url": "https://api.github.com/repos/DekodeInteraktiv/hogan-core/zipball/46d5dd20ad7388ee014bc74efdde9261bb2c2ac0", + "reference": "46d5dd20ad7388ee014bc74efdde9261bb2c2ac0", "shasum": "" }, "require": { "composer/installers": "~1.2", "php": ">=7.0" }, + "require-dev": { + "dekodeinteraktiv/coding-standards": "^0.3.1" + }, "type": "wordpress-plugin", "notification-url": "https://packagist.org/downloads/", "license": [ - "GPL-3.0" + "GPL-3.0-or-later" ], "description": "Modular Flexible Content System for ACF Pro", "homepage": "https://github.com/DekodeInteraktiv/hogan-core", - "time": "2017-12-06T08:05:41+00:00" + "time": "2018-04-04T09:25:18+00:00" + } + ], + "packages-dev": [ + { + "name": "automattic/phpcs-neutron-standard", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/Automattic/phpcs-neutron-standard.git", + "reference": "7491ee86f705082ebd318fc90d16f8b874440901" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Automattic/phpcs-neutron-standard/zipball/7491ee86f705082ebd318fc90d16f8b874440901", + "reference": "7491ee86f705082ebd318fc90d16f8b874440901", + "shasum": "" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "limedeck/phpunit-detailed-printer": "^3.1", + "phpunit/phpunit": "^6.4", + "sirbrillig/phpcs-variable-analysis": "^2.0.1", + "squizlabs/php_codesniffer": "^3.2.1" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A set of phpcs sniffs for modern php development.", + "time": "2018-03-16T03:07:32+00:00" + }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.4.4", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/2e41850d5f7797cbb1af7b030d245b3b24e63a08", + "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "^5.3|^7", + "squizlabs/php_codesniffer": "*" + }, + "require-dev": { + "composer/composer": "*", + "wimg/php-compatibility": "^8.0" + }, + "suggest": { + "dealerdirect/qa-tools": "All the PHP QA tools you'll need" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "f.nijhof@dealerdirect.nl", + "homepage": "http://workingatdealerdirect.eu", + "role": "Developer" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://workingatdealerdirect.eu", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "time": "2017-12-06T16:27:17+00:00" + }, + { + "name": "dekodeinteraktiv/coding-standards", + "version": "0.3.1", + "source": { + "type": "git", + "url": "https://github.com/DekodeInteraktiv/coding-standards.git", + "reference": "89e9a14ffbeb632fbe4a42a5a72648e08aeda573" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/DekodeInteraktiv/coding-standards/zipball/89e9a14ffbeb632fbe4a42a5a72648e08aeda573", + "reference": "89e9a14ffbeb632fbe4a42a5a72648e08aeda573", + "shasum": "" + }, + "require": { + "automattic/phpcs-neutron-standard": "^1.4", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "wimg/php-compatibility": "^8.1", + "wp-coding-standards/wpcs": "^0.14.1" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Dekode Coding Standards", + "time": "2018-03-23T08:47:02+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.2.3", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "4842476c434e375f9d3182ff7b89059583aa8b27" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27", + "reference": "4842476c434e375f9d3182ff7b89059583aa8b27", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2018-02-20T21:35:23+00:00" + }, + { + "name": "wimg/php-compatibility", + "version": "8.1.0", + "source": { + "type": "git", + "url": "https://github.com/wimg/PHPCompatibility.git", + "reference": "4ac01e4fe8faaa4f8d3b3cd06ea92e5418ce472e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/4ac01e4fe8faaa4f8d3b3cd06ea92e5418ce472e", + "reference": "4ac01e4fe8faaa4f8d3b3cd06ea92e5418ce472e", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.2 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "PHPCompatibility\\": "PHPCompatibility/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "time": "2017-12-27T21:58:38+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "0.14.1", + "source": { + "type": "git", + "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", + "reference": "cf6b310caad735816caef7573295f8a534374706" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/cf6b310caad735816caef7573295f8a534374706", + "reference": "cf6b310caad735816caef7573295f8a534374706", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "wordpress" + ], + "time": "2018-02-16T01:57:48+00:00" } ], - "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/hogan-linklist.php b/hogan-linklist.php index c70a35f..7ccbaa1 100644 --- a/hogan-linklist.php +++ b/hogan-linklist.php @@ -4,7 +4,7 @@ * Plugin URI: https://github.com/dekodeinteraktiv/hogan-linklist * GitHub Plugin URI: https://github.com/dekodeinteraktiv/hogan-linklist * Description: Link List Module for Hogan - * Version: 1.1.2 + * Version: 1.1.3 * Author: Dekode * Author URI: https://dekode.no * License: GPL-3.0-or-later @@ -25,7 +25,7 @@ } add_action( 'plugins_loaded', __NAMESPACE__ . '\\hogan_linklist_load_textdomain' ); -add_action( 'hogan/include_modules', __NAMESPACE__ . '\\hogan_linklist_register_module' ); +add_action( 'hogan/include_modules', __NAMESPACE__ . '\\hogan_linklist_register_module', 10, 1 ); /** * Register module text domain @@ -36,9 +36,12 @@ function hogan_linklist_load_textdomain() { /** * Register module in Hogan + * + * @param \Dekode\Hogan\Core $core Hogan Core instance. + * @return void */ -function hogan_linklist_register_module() { +function hogan_linklist_register_module( \Dekode\Hogan\Core $core ) { require_once 'class-linklist.php'; require_once 'includes/helper-functions.php'; - hogan_register_module( new \Dekode\Hogan\LinkList() ); + $core->register_module( new \Dekode\Hogan\LinkList() ); } diff --git a/includes/helper-functions.php b/includes/helper-functions.php index a5531f1..ce0f65a 100644 --- a/includes/helper-functions.php +++ b/includes/helper-functions.php @@ -5,15 +5,17 @@ * @package Hogan */ +declare( strict_types = 1 ); namespace Dekode\Hogan\LinkList; /** * Load nav_menu into select field. * * @param array $field Field array. + * @return array */ -function load_predefined_list_choices( $field ) { - $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); +function load_predefined_list_choices( array $field ) : array { + $menus = get_terms( 'nav_menu', [ 'hide_empty' => false ] ); if ( empty( $menus ) ) { return $field; @@ -25,4 +27,5 @@ function load_predefined_list_choices( $field ) { return $field; } + add_filter( 'acf/load_field/name=predefined_list', __NAMESPACE__ . '\\load_predefined_list_choices' ); diff --git a/languages/hogan-linklist-nb_NO.mo b/languages/hogan-linklist-nb_NO.mo index 963f172..ad8408e 100644 Binary files a/languages/hogan-linklist-nb_NO.mo and b/languages/hogan-linklist-nb_NO.mo differ diff --git a/languages/hogan-linklist-nb_NO.po b/languages/hogan-linklist-nb_NO.po index 824e0b2..58483b9 100644 --- a/languages/hogan-linklist-nb_NO.po +++ b/languages/hogan-linklist-nb_NO.po @@ -1,15 +1,15 @@ msgid "" msgstr "" "Project-Id-Version: Hogan Module: Link list\n" -"POT-Creation-Date: 2017-12-13 16:41+0100\n" -"PO-Revision-Date: 2017-12-13 16:47+0100\n" +"POT-Creation-Date: 2018-04-05 13:55+0200\n" +"PO-Revision-Date: 2018-04-05 13:55+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: nb_NO\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.0.5\n" +"X-Generator: Poedit 1.8.12\n" "X-Poedit-Basepath: ..\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Poedit-Flags-xgettext: --add-comments=translators:\n" @@ -25,35 +25,35 @@ msgstr "" msgid "Link lists" msgstr "Lenkelister" -#: class-linklist.php:80 +#: class-linklist.php:75 msgid "New list" msgstr "Ny liste" -#: class-linklist.php:88 +#: class-linklist.php:83 msgid "Manual" msgstr "Egendefinert liste" -#: class-linklist.php:93 class-linklist.php:125 +#: class-linklist.php:88 class-linklist.php:121 msgid "Heading" msgstr "Overskrift" -#: class-linklist.php:103 +#: class-linklist.php:99 msgid "New link" msgstr "Ny lenke" -#: class-linklist.php:107 +#: class-linklist.php:103 msgid "Set link and text" msgstr "Legg til lenke og lenketekst" -#: class-linklist.php:120 +#: class-linklist.php:116 msgid "Predefined" msgstr "Forhåndsdefinert meny" -#: class-linklist.php:131 +#: class-linklist.php:127 msgid "Select list" msgstr "Velg en forhåndsdefinert meny" -#: class-linklist.php:135 +#: class-linklist.php:132 #, php-format msgid "" "A predefined menu must be created here in order to show " @@ -61,7 +61,7 @@ msgid "" msgstr "" "En meny må opprettes her for å dukke opp i nedtrekkslisten." -#: class-linklist.php:140 +#: class-linklist.php:137 msgid "Select" msgstr "Velg" @@ -71,7 +71,7 @@ msgstr "Hogan-modul: Lenkelister" #. Plugin URI of the plugin/theme msgid "https://github.com/dekodeinteraktiv/hogan-linklist" -msgstr "" +msgstr "https://github.com/dekodeinteraktiv/hogan-linklist" #. Description of the plugin/theme msgid "Link List Module for Hogan" @@ -79,11 +79,11 @@ msgstr "Lenkelister for Hogan" #. Author of the plugin/theme msgid "Dekode" -msgstr "" +msgstr "Dekode" #. Author URI of the plugin/theme msgid "https://dekode.no" -msgstr "" +msgstr "https://dekode.no" #~ msgid "Define list under \"Menu\"." #~ msgstr "Lag lenkeliste under Meny." diff --git a/phpcs.xml b/phpcs.xml index f1caf37..2b12599 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,15 +1,10 @@ Write code using Hogan's standards and Hogan will stay happy! - - - - - - - - - + . + + +