From d49336dee56e4e6b97e500387cb85b1f34c5cd02 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Thu, 1 Nov 2018 13:55:43 +0100 Subject: [PATCH] Minor code style adjustments --- .stylelintrc.json | 3 + composer.json | 2 +- includes/class-wpliveticker2-admin.php | 4 +- includes/class-wpliveticker2-system.php | 4 +- includes/class-wpliveticker2-widget.php | 6 ++ includes/class-wpliveticker2.php | 16 +++-- package-lock.json | 88 +++++++++++++++++++++++++ package.json | 5 +- phpcs.xml | 6 +- styles/wp-liveticker2.css | 10 +-- views/settings-page.php | 2 +- wp-liveticker2.php | 20 +++--- 12 files changed, 140 insertions(+), 26 deletions(-) create mode 100644 .stylelintrc.json create mode 100644 package-lock.json diff --git a/.stylelintrc.json b/.stylelintrc.json new file mode 100644 index 0000000..58c6190 --- /dev/null +++ b/.stylelintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "stylelint-config-wordpress" +} diff --git a/composer.json b/composer.json index e27023e..2d27383 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "stklcode/wp-liveticker2", - "version": "1.0.0-beta", + "version": "1.0.0-rc1", "description": "A simple Liveticker for Wordpress.", "keywords": [ "wordpress", diff --git a/includes/class-wpliveticker2-admin.php b/includes/class-wpliveticker2-admin.php index fc1a7ca..e8ac016 100644 --- a/includes/class-wpliveticker2-admin.php +++ b/includes/class-wpliveticker2-admin.php @@ -8,7 +8,9 @@ */ // Exit if accessed directly. -defined( 'ABSPATH' ) || exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** * WP Liveticker 2 admin configuration. diff --git a/includes/class-wpliveticker2-system.php b/includes/class-wpliveticker2-system.php index e96fb31..1247345 100644 --- a/includes/class-wpliveticker2-system.php +++ b/includes/class-wpliveticker2-system.php @@ -8,7 +8,9 @@ */ // Exit if accessed directly. -defined( 'ABSPATH' ) || exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** * WP Liveticker 2 system configuration. diff --git a/includes/class-wpliveticker2-widget.php b/includes/class-wpliveticker2-widget.php index 53f3c94..ebdd2ce 100644 --- a/includes/class-wpliveticker2-widget.php +++ b/includes/class-wpliveticker2-widget.php @@ -7,6 +7,10 @@ * @package WPLiveticker2 */ +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + /** * Class WPLiveticker2_Widget. */ @@ -32,6 +36,8 @@ class WPLiveticker2_Widget extends WP_Widget { * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance The settings for the particular instance of the widget. + * + * @return void */ public function widget( $args, $instance ) { // Notify WPLT2 class that widget is present. diff --git a/includes/class-wpliveticker2.php b/includes/class-wpliveticker2.php index da96786..3d5ff22 100644 --- a/includes/class-wpliveticker2.php +++ b/includes/class-wpliveticker2.php @@ -8,7 +8,9 @@ */ // Exit if accessed directly. -defined( 'ABSPATH' ) || exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** * WP Liveticker 2. @@ -237,13 +239,15 @@ class WPLiveticker2 { } $output .= 'Feed'; } - }// End if(). + } return $output; } /** * Register frontend CSS. + * + * @return void */ public static function enqueue_styles() { // Only add if shortcode is present. @@ -259,6 +263,8 @@ class WPLiveticker2 { /** * Register frontend JS. + * + * @return void */ public static function enqueue_scripts() { // Only add if shortcode is present. @@ -294,7 +300,7 @@ class WPLiveticker2 { check_ajax_referer( 'wplt2_update-ticks' ); // Extract update requests. - if ( isset( $_POST['update'] ) && is_array( $_POST['update'] ) ) { + if ( isset( $_POST['update'] ) && is_array( $_POST['update'] ) ) { // Input var okay. $res = array(); // @codingStandardsIgnoreLine Sanitization of arrayhandled on field level. foreach ( wp_unslash( $_POST['update'] ) as $update_req ) { @@ -357,7 +363,7 @@ class WPLiveticker2 { } } // Echo JSON encoded result set. - echo json_encode( $res ); + echo wp_json_encode( $res ); } exit; @@ -376,6 +382,8 @@ class WPLiveticker2 { * Update options. * * @param array $options Optional. New options to save. + * + * @return void */ protected static function update_options( $options = null ) { self::$_options = wp_parse_args( diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..bd9221b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,88 @@ +{ + "name": "wp-liveticker2", + "version": "1.0.0-beta", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "cssesc": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-1.0.1.tgz", + "integrity": "sha512-S2hzrpWvE6G/rW7i7IxJfWBYn27QWfOIncUW++8Rbo1VB5zsJDSVPcnI+Q8z7rhxT6/yZeLOCja4cZnghJrNGA==" + }, + "indexes-of": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/indexes-of/-/indexes-of-1.0.1.tgz", + "integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=" + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "postcss-media-query-parser": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/postcss-media-query-parser/-/postcss-media-query-parser-0.2.3.tgz", + "integrity": "sha1-J7Ocb02U+Bsac7j3Y1HGCeXO8kQ=" + }, + "postcss-resolve-nested-selector": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/postcss-resolve-nested-selector/-/postcss-resolve-nested-selector-0.1.1.tgz", + "integrity": "sha1-Kcy8fDfe36wwTp//C/FZaz9qDk4=" + }, + "postcss-selector-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-4.0.0.tgz", + "integrity": "sha512-5h+MvEjnzu1qy6MabjuoPatsGAjjDV9B24e7Cktjl+ClNtjVjmvAXjOFQr1u7RlWULKNGYaYVE4s+DIIQ4bOGA==", + "requires": { + "cssesc": "^1.0.1", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1" + } + }, + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==" + }, + "stylelint-config-recommended": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/stylelint-config-recommended/-/stylelint-config-recommended-2.1.0.tgz", + "integrity": "sha512-ajMbivOD7JxdsnlS5945KYhvt7L/HwN6YeYF2BH6kE4UCLJR0YvXMf+2j7nQpJyYLZx9uZzU5G1ZOSBiWAc6yA==" + }, + "stylelint-config-recommended-scss": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/stylelint-config-recommended-scss/-/stylelint-config-recommended-scss-3.2.0.tgz", + "integrity": "sha512-M8BFHMRf8KNz5EQPKJd8nMCGmBd2o5coDEObfHVbEkyLDgjIf1V+U5dHjaGgvhm0zToUxshxN+Gc5wpbOOew4g==", + "requires": { + "stylelint-config-recommended": "^2.0.0" + } + }, + "stylelint-config-wordpress": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/stylelint-config-wordpress/-/stylelint-config-wordpress-13.1.0.tgz", + "integrity": "sha512-dpKj2/d3/XjDVoOvQzd54GoM8Rj5zldluOZKkVhBCc4JYMc6r1VYL5hpcgIjqy/i2Hyqg4Rh7zTafE/2AWq//w==", + "requires": { + "stylelint-config-recommended": "^2.1.0", + "stylelint-config-recommended-scss": "^3.2.0", + "stylelint-scss": "^3.3.0" + } + }, + "stylelint-scss": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/stylelint-scss/-/stylelint-scss-3.3.2.tgz", + "integrity": "sha512-0x+nD1heoMJYOfi3FfGcz3Hrwhcm+Qyq+BuvoBv5v9xrZZ1aziRXQauuhjwb87gWAa9MBzxhfUqBnvTUrHlLjA==", + "requires": { + "lodash": "^4.17.10", + "postcss-media-query-parser": "^0.2.3", + "postcss-resolve-nested-selector": "^0.1.1", + "postcss-selector-parser": "^4.0.0", + "postcss-value-parser": "^3.3.0" + } + }, + "uniq": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", + "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=" + } + } +} diff --git a/package.json b/package.json index 5b82622..7b492aa 100644 --- a/package.json +++ b/package.json @@ -3,5 +3,8 @@ "version": "1.0.0-beta", "description": "A simple Liveticker for Wordpress.", "author": "Stefan Kalscheuer", - "license": "GPL-2.0+" + "license": "GPL-2.0+", + "dependencies": { + "stylelint-config-wordpress": "^13.1.0" + } } diff --git a/phpcs.xml b/phpcs.xml index 2c8ea97..3b66263 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -3,7 +3,7 @@ Derived from WordPress Coding Standard - + @@ -13,7 +13,9 @@ - + + + diff --git a/styles/wp-liveticker2.css b/styles/wp-liveticker2.css index 2d4678a..eee769c 100644 --- a/styles/wp-liveticker2.css +++ b/styles/wp-liveticker2.css @@ -3,7 +3,7 @@ ul.wplt2-ticker { } ul.wplt2-ticker > li.wplt2-tick { - background-color: #F5F5F5; + background-color: #f5f5f5; list-style-type: none; margin: 0.1em; padding: 0.1em 0.3em; @@ -14,14 +14,14 @@ li.wplt2-tick p { } span.wplt2-tick-time { - color: #002C58; + color: #002c58; font-size: 0.7em; font-style: italic; } span.wplt2-tick-title { - color: #002C58; - font-weight: bold; + color: #002c58; + font-weight: 700; margin-left: 0.5em; } @@ -45,7 +45,7 @@ span.wplt2-widget-time { } span.wplt2-widget-content { - color: #002C58; + color: #002c58; text-indent: 0.2em; } diff --git a/views/settings-page.php b/views/settings-page.php index df86c1c..083339a 100644 --- a/views/settings-page.php +++ b/views/settings-page.php @@ -13,7 +13,7 @@ defined( 'ABSPATH' ) || exit;

Liveticker

' . esc_html__( 'Settings updated successfully.', 'wplt2' ) . '

'; } ?> diff --git a/wp-liveticker2.php b/wp-liveticker2.php index 461a96b..dcbfcbb 100644 --- a/wp-liveticker2.php +++ b/wp-liveticker2.php @@ -8,8 +8,8 @@ * * @wordpress-plugin * Plugin Name: WP Liveticker 2 - * Description: A simple Liveticker for Wordpress. - * Version: 1.0.0 alpha + * Description: A simple Liveticker for WordPress. + * Version: 1.0.0-beta * Author: Stefan Kalscheuer * Author URI: https://www.stklcode.de * Text Domain: wplt2 @@ -31,7 +31,9 @@ */ // Exit if accessed directly. -defined( 'ABSPATH' ) || exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} // Constants. define( 'WPLT2_FILE', __FILE__ ); @@ -61,7 +63,7 @@ spl_autoload_register( 'wplt2_autoload' ); * * @param string $class Name of the class to load. * - * @since 1.0.0 + * @return void */ function wplt2_autoload( $class ) { $plugin_classes = array( @@ -71,12 +73,10 @@ function wplt2_autoload( $class ) { 'WPLiveticker2_Widget', ); if ( in_array( $class, $plugin_classes, true ) ) { - require_once( - sprintf( - '%s/includes/class-%s.php', - WPLT2_DIR, - strtolower( str_replace( '_', '-', $class ) ) - ) + require_once sprintf( + '%s/includes/class-%s.php', + WPLT2_DIR, + strtolower( str_replace( '_', '-', $class ) ) ); } }