raise required PHP version to 5.6

This commit is contained in:
Stefan Kalscheuer 2020-04-09 14:26:20 +02:00
parent ca5c81356b
commit 4463fa7f1f
9 changed files with 62 additions and 53 deletions

View File

@ -9,8 +9,8 @@
* Contributors: Stefan Kalscheuer * Contributors: Stefan Kalscheuer
* Tags: liveticker, feed, rss * Tags: liveticker, feed, rss
* Requires at least: 4.0 * Requires at least: 4.0
* Tested up to: 5.3 * Tested up to: 5.4
* Requires PHP: 5.2 * Requires PHP: 5.6
* Stable tag: 1.0.0 * Stable tag: 1.0.0
* License: GPLv2 or later * License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html * License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -81,6 +81,7 @@ caching time of 12 hours obviously makes no sense.
### 1.1.0 - unreleased ### 1.1.0 - unreleased
* Requires PHP 5.6 or above
* Use GMT for automatic updates * Use GMT for automatic updates
* Gutenberg Block available * Gutenberg Block available

View File

@ -95,6 +95,8 @@ class RoboFile extends Tasks {
/** /**
* Run code style tests * Run code style tests
* *
* @param array $opts Options.
*
* @return void * @return void
*/ */
public function testCS( public function testCS(
@ -109,7 +111,7 @@ class RoboFile extends Tasks {
$this->say( 'Executing PHPCS...' ); $this->say( 'Executing PHPCS...' );
$this->_exec( __DIR__ . '/vendor/bin/phpcs --standard=phpcs.xml -s' ); $this->_exec( __DIR__ . '/vendor/bin/phpcs --standard=phpcs.xml -s' );
if ( $opts[self::OPT_NODE] ) { if ( $opts[ self::OPT_NODE ] ) {
$this->say( 'Executing ESLint...' ); $this->say( 'Executing ESLint...' );
$this->_exec( __DIR__ . '/node_modules/eslint/bin/eslint.js ' . __DIR__ . '/scripts/block.js' ); $this->_exec( __DIR__ . '/node_modules/eslint/bin/eslint.js ' . __DIR__ . '/scripts/block.js' );
$this->_exec( __DIR__ . '/node_modules/eslint/bin/eslint.js ' . __DIR__ . '/scripts/liveticker.js' ); $this->_exec( __DIR__ . '/node_modules/eslint/bin/eslint.js ' . __DIR__ . '/scripts/liveticker.js' );
@ -145,7 +147,7 @@ class RoboFile extends Tasks {
if ( isset( $opts[ self::OPT_SKIPSTYLE ] ) && true === $opts[ self::OPT_SKIPSTYLE ] ) { if ( isset( $opts[ self::OPT_SKIPSTYLE ] ) && true === $opts[ self::OPT_SKIPSTYLE ] ) {
$this->say( 'Style checks skipped' ); $this->say( 'Style checks skipped' );
} else { } else {
$this->testCS($opts); $this->testCS( $opts );
} }
$this->bundle(); $this->bundle();
} }
@ -157,12 +159,14 @@ class RoboFile extends Tasks {
*/ */
private function bundle() { private function bundle() {
$this->say( 'Bundling resources...' ); $this->say( 'Bundling resources...' );
$this->taskCopyDir( array( $this->taskCopyDir(
array(
'includes' => $this->target_dir . '/' . $this->final_name . '/includes', 'includes' => $this->target_dir . '/' . $this->final_name . '/includes',
'scripts' => $this->target_dir . '/' . $this->final_name . '/scripts', 'scripts' => $this->target_dir . '/' . $this->final_name . '/scripts',
'styles' => $this->target_dir . '/' . $this->final_name . '/styles', 'styles' => $this->target_dir . '/' . $this->final_name . '/styles',
'views' => $this->target_dir . '/' . $this->final_name . '/views', 'views' => $this->target_dir . '/' . $this->final_name . '/views',
) )->run(); )
)->run();
$this->_copy( 'stklcode-liveticker.php', $this->target_dir . '/' . $this->final_name . '/stklcode-liveticker.php' ); $this->_copy( 'stklcode-liveticker.php', $this->target_dir . '/' . $this->final_name . '/stklcode-liveticker.php' );
$this->_copy( 'README.md', $this->target_dir . '/' . $this->final_name . '/README.md' ); $this->_copy( 'README.md', $this->target_dir . '/' . $this->final_name . '/README.md' );
$this->_copy( 'LICENSE.md', $this->target_dir . '/' . $this->final_name . '/LICENSE.md' ); $this->_copy( 'LICENSE.md', $this->target_dir . '/' . $this->final_name . '/LICENSE.md' );

View File

@ -17,11 +17,11 @@
], ],
"type": "wordpress-plugin", "type": "wordpress-plugin",
"require": { "require": {
"php": ">=5.2", "php": ">=5.6",
"composer/installers": "~1.7" "composer/installers": "~1.7"
}, },
"require-dev": { "require-dev": {
"php": ">=5.2", "php": ">=7",
"consolidation/robo": "^2", "consolidation/robo": "^2",
"phpunit/phpunit": "*", "phpunit/phpunit": "*",
"phpunit/php-code-coverage": "*", "phpunit/php-code-coverage": "*",

View File

@ -4,9 +4,11 @@
* *
* This file contains the derived class for the plugin's administration features. * This file contains the derived class for the plugin's administration features.
* *
* @package Liveticker * @package SCLiveticker
*/ */
namespace SCLiveticker;
// Exit if accessed directly. // Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
@ -15,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/** /**
* Liveticker admin configuration. * Liveticker admin configuration.
*/ */
class SCLiveticker_Admin extends SCLiveticker { class Admin extends SCLiveticker {
/** /**
* Add to Right Now Widget * Add to Right Now Widget
* *

View File

@ -4,14 +4,19 @@
* *
* This file contains the plugin's base class. * This file contains the plugin's base class.
* *
* @package Liveticker * @package SCLiveticker
*/ */
namespace SCLiveticker;
use WP_Query;
// Exit if accessed directly. // Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
/** /**
* Liveticker. * Liveticker.
*/ */
@ -92,11 +97,11 @@ class SCLiveticker {
// Admin only actions. // Admin only actions.
if ( is_admin() ) { if ( is_admin() ) {
// Add dashboard "right now" functionality. // Add dashboard "right now" functionality.
add_action( 'right_now_content_table_end', array( 'SCLiveticker_Admin', 'dashboard_right_now' ) ); add_action( 'right_now_content_table_end', array( 'SCLiveticker\\Admin', 'dashboard_right_now' ) );
// Settings. // Settings.
add_action( 'admin_init', array( 'SCLiveticker_Admin', 'register_settings' ) ); add_action( 'admin_init', array( 'SCLiveticker\\Admin', 'register_settings' ) );
add_action( 'admin_menu', array( 'SCLiveticker_Admin', 'register_settings_page' ) ); add_action( 'admin_menu', array( 'SCLiveticker\\Admin', 'register_settings_page' ) );
} }
} }
@ -457,19 +462,7 @@ class SCLiveticker {
* @since 1.1 * @since 1.1
*/ */
private static function block_present() { private static function block_present() {
// We are in WP 5.x environment and blocks are generally present. return function_exists( 'has_block' ) && // We are in WP 5.x environment.
if ( function_exists( 'has_blocks' ) && has_blocks() ) { has_block( 'scliveticker/ticker' ); // Specific block is present.
/*
* The slightly faster call to has_block( 'scliveticker/ticker' ) produces an "undefined function" error for
* no good reason. Iteration over pased blocks however works fine.
*/
foreach ( parse_blocks( get_post()->post_content ) as $b ) {
if ( 'scliveticker/ticker' === $b['blockName'] ) {
return true;
}
}
}
return false;
} }
} }

View File

@ -4,9 +4,13 @@
* *
* This file contains the derived class for the plugin's system operations. * This file contains the derived class for the plugin's system operations.
* *
* @package Liveticker * @package SCLiveticker
*/ */
namespace SCLiveticker;
use WP_Query;
// Exit if accessed directly. // Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
@ -15,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/** /**
* Liveticker system configuration. * Liveticker system configuration.
*/ */
class SCLiveticker_System extends SCLiveticker { class System extends SCLiveticker {
/** /**
* Activation hook. * Activation hook.

View File

@ -4,17 +4,22 @@
* *
* This file contains the liveticker widget. * This file contains the liveticker widget.
* *
* @package Liveticker * @package SCLiveticker
*/ */
namespace SCLiveticker;
use WP_Query;
use WP_Widget;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
/** /**
* Class SCLiveticker_Widget. * Class Widget.
*/ */
class SCLiveticker_Widget extends WP_Widget { class Widget extends WP_Widget {
/** /**
* SCLiveticker_Widget constructor. * SCLiveticker_Widget constructor.

View File

@ -18,6 +18,6 @@
</rule> </rule>
<!-- PHP compatibility level --> <!-- PHP compatibility level -->
<config name="testVersion" value="5.2-"/> <config name="testVersion" value="5.6-"/>
<rule ref="PHPCompatibility"/> <rule ref="PHPCompatibility"/>
</ruleset> </ruleset>

View File

@ -41,22 +41,22 @@ define( 'SCLIVETICKER_BASE', plugin_dir_url( __FILE__ ) );
define( 'SCLIVETICKER_BASENAME', plugin_basename( __FILE__ ) ); define( 'SCLIVETICKER_BASENAME', plugin_basename( __FILE__ ) );
// System Hooks. // System Hooks.
add_action( 'init', array( 'SCLiveticker', 'register_types' ) ); add_action( 'init', array( 'SCLiveticker\\SCLiveticker', 'register_types' ) );
add_action( 'plugins_loaded', array( 'SCLiveticker', 'init' ) ); add_action( 'plugins_loaded', array( 'SCLiveticker\\SCLiveticker', 'init' ) );
register_activation_hook( SCLIVETICKER_FILE, array( 'SCLiveticker_System', 'activate' ) ); register_activation_hook( SCLIVETICKER_FILE, array( 'SCLiveticker\\System', 'activate' ) );
register_uninstall_hook( SCLIVETICKER_FILE, array( 'SCLiveticker_System', 'uninstall' ) ); register_uninstall_hook( SCLIVETICKER_FILE, array( 'SCLiveticker\\System', 'uninstall' ) );
// Allow shortcodes in widgets. // Allow shortcodes in widgets.
add_filter( 'widget_text', 'do_shortcode' ); add_filter( 'widget_text', 'do_shortcode' );
// Add shortcode. // Add shortcode.
add_shortcode( 'liveticker', array( 'SCLiveticker', 'shortcode_ticker_show' ) ); add_shortcode( 'liveticker', array( 'SCLiveticker\\SCLiveticker', 'shortcode_ticker_show' ) );
// Add Widget. // Add Widget.
add_action( 'widgets_init', array( 'SCLiveticker_Widget', 'register' ) ); add_action( 'widgets_init', array( 'SCLiveticker\\Widget', 'register' ) );
// Add Gutenberg block. // Add Gutenberg block.
add_action( 'enqueue_block_editor_assets', array( 'SCLiveticker_Admin', 'register_block' ) ); add_action( 'enqueue_block_editor_assets', array( 'SCLiveticker\\Admin', 'register_block' ) );
// Autoload. // Autoload.
spl_autoload_register( 'scliveticker_autoload' ); spl_autoload_register( 'scliveticker_autoload' );
@ -70,16 +70,16 @@ spl_autoload_register( 'scliveticker_autoload' );
*/ */
function scliveticker_autoload( $class ) { function scliveticker_autoload( $class ) {
$plugin_classes = array( $plugin_classes = array(
'SCLiveticker', 'SCLiveticker\\SCLiveticker',
'SCLiveticker_Admin', 'SCLiveticker\\Admin',
'SCLiveticker_System', 'SCLiveticker\\System',
'SCLiveticker_Widget', 'SCLiveticker\\Widget',
); );
if ( in_array( $class, $plugin_classes, true ) ) { if ( in_array( $class, $plugin_classes, true ) ) {
require_once sprintf( require_once sprintf(
'%s/includes/class-%s.php', '%s/includes/class-%s.php',
SCLIVETICKER_DIR, SCLIVETICKER_DIR,
strtolower( str_replace( '_', '-', $class ) ) strtolower( str_replace( '_', '-', substr( $class, 13 ) ) )
); );
} }
} }