Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies for PHP 8 compatibility #117

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-versions: ['7.4']
php-versions: ['7.4', '8.2']
steps:
- uses: actions/[email protected]
- name: Setup PHP
Expand All @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-versions: ['7.4']
php-versions: ['7.4', '8.2']
steps:
- uses: actions/[email protected]
- name: Setup PHP
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ vendor/
## Temporary files
tmp/
## Build artifacts
.php_cs.cache
.sass-cache/
*.bak*
/.php-cs-fixer.cache
/composer.lock
File renamed without changes.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.5.2] - 2024-09-10

### Changed
- Upgrade dependencies for PHP 8 compatibility

## [v0.5.1] - 2024-08-08

### Changed
Expand Down
8 changes: 4 additions & 4 deletions app/Blocks/BlockEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class BlockEditor implements \Dxw\Iguana\Registerable
{
public function register()
{
remove_theme_support('core-block-patterns');
}
public function register()
{
remove_theme_support('core-block-patterns');
}
}
94 changes: 47 additions & 47 deletions app/Lib/Whippet/TemplateTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,66 @@

class TemplateTags
{
public function __construct(\Dxw\Iguana\Theme\Helpers $helpers)
{
$helpers->registerFunction('w_template_title', [$this, 'w_template_title']);
}

public static function w_template_warning()
{
?>
public function __construct(\Dxw\Iguana\Theme\Helpers $helpers)
{
$helpers->registerFunction('w_template_title', [$this, 'w_template_title']);
}

public static function w_template_warning()
{
?>
<div class="whippet alert template-warning" style="background: rgb(255,100,100); width: 100%; padding: 10px;"><h1>You're using a fallback template: <?php echo basename(\Dxw\GovukTheme\Lib\Whippet\Layout::$wordpress_template); ?></h1> <p>Did you really mean to? If you can, define a specific template and use it. Like single-post.php.</p></div>
<?php
}
}

public function w_template_title()
{
if (is_home()) {
if (get_option('page_for_posts', true)) {
return get_the_title(get_option('page_for_posts', true));
}
public function w_template_title()
{
if (is_home()) {
if (get_option('page_for_posts', true)) {
return get_the_title(get_option('page_for_posts', true));
}

return __('Latest Posts', 'roots');
} elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
return __('Latest Posts', 'roots');
} elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));

if ($term) {
return apply_filters('single_term_title', $term->name);
}
if ($term) {
return apply_filters('single_term_title', $term->name);
}

if (is_post_type_archive()) {
return apply_filters('the_title', get_queried_object()->labels->name);
}
if (is_post_type_archive()) {
return apply_filters('the_title', get_queried_object()->labels->name);
}

if (is_day()) {
return sprintf(__('Daily Archives: %s', 'roots'), get_the_date());
}
if (is_day()) {
return sprintf(__('Daily Archives: %s', 'roots'), get_the_date());
}

if (is_month()) {
return sprintf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
}
if (is_month()) {
return sprintf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
}

if (is_year()) {
return sprintf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
}
if (is_year()) {
return sprintf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
}

if (is_author()) {
$author = get_queried_object();
if (is_author()) {
$author = get_queried_object();

return sprintf(__('Author Archives: %s', 'roots'), apply_filters('the_author', is_object($author) ? $author->display_name : null));
}
return sprintf(__('Author Archives: %s', 'roots'), apply_filters('the_author', is_object($author) ? $author->display_name : null));
}

return single_cat_title('', false);
}
return single_cat_title('', false);
}

if (is_search()) {
return sprintf(__('Search Results for %s', 'roots'), get_search_query());
}
if (is_search()) {
return sprintf(__('Search Results for %s', 'roots'), get_search_query());
}

if (is_404()) {
return __('Not Found', 'roots');
}
if (is_404()) {
return __('Not Found', 'roots');
}

return get_the_title();
}
return get_the_title();
}
}
8 changes: 4 additions & 4 deletions app/Posts/CustomFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class CustomFields implements \Dxw\Iguana\Registerable
{
public function register()
{
// ...
}
public function register()
{
// ...
}
}
8 changes: 4 additions & 4 deletions app/Posts/PostTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class PostTypes implements \Dxw\Iguana\Registerable
{
public function register()
{
// ...
}
public function register()
{
// ...
}
}
12 changes: 6 additions & 6 deletions app/Theme/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

class Media implements \Dxw\Iguana\Registerable
{
public function register()
{
set_post_thumbnail_size(150, 150, true);
add_image_size('medium', 200, 200, true);
add_image_size('large', 800, 300, true);
}
public function register()
{
set_post_thumbnail_size(150, 150, true);
add_image_size('medium', 200, 200, true);
add_image_size('large', 800, 300, true);
}
}
10 changes: 5 additions & 5 deletions app/Theme/Menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class Menus implements \Dxw\Iguana\Registerable
{
public function register()
{
register_nav_menu('header', 'Header Menu');
register_nav_menu('footer', 'Footer Menu');
}
public function register()
{
register_nav_menu('header', 'Header Menu');
register_nav_menu('footer', 'Footer Menu');
}
}
100 changes: 50 additions & 50 deletions app/Theme/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,54 @@

class Scripts implements \Dxw\Iguana\Registerable
{
public function __construct(\Dxw\Iguana\Theme\Helpers $helpers)
{
$helpers->registerFunction('assetPath', [$this, 'assetPath']);
$helpers->registerFunction('getAssetPath', [$this, 'getAssetPath']);
}

public function register()
{
add_action('wp_enqueue_scripts', [$this, 'wpEnqueueScripts']);
add_action('enqueue_block_editor_assets', [$this, 'wpEnqueueEditorScripts']);
add_theme_support('editor-styles');
add_editor_style('../static/editor.min.css');
}

public function getAssetPath($path)
{
return dirname(get_template_directory_uri()).'/static/'.$path;
}

public function assetPath($path)
{
echo esc_url($this->getAssetPath($path));
}

public function wpEnqueueScripts()
{
//
// Do not add javascript to your theme here, unless you're sure you should.
//
// Normally, you should add Javascript to assets/js/main.js or make a file in assets/js/plugins.
//
// You can/should enqueue a script here only if it is a widely used library that is required by a plugin (or is likely to be later)
//

// We need to register our own jQuery, because WP is on jQuery 2.x which breaks support for IE 6-8.
// This will not affect admin pages
// This will break any plugin that requires a feature/behaviour in jQuery 2.x which is missing/different in jQuery 1.10.x
wp_deregister_script('jquery');
wp_enqueue_script('jquery', $this->getAssetPath('lib/jquery.min.js'));

// Pretty much everything else should be compiled by Grunt.
wp_enqueue_script('main', $this->getAssetPath('main.min.js'), ['jquery'], '', true);

wp_enqueue_style('main', $this->getAssetPath('main.min.css'));
}

public function wpEnqueueEditorScripts()
{
wp_enqueue_script('theme-editor', $this->getAssetPath('editor.min.js'), ['wp-blocks', 'wp-dom'], filemtime(get_stylesheet_directory() . '/../assets/js/editor.js'), true);
}
public function __construct(\Dxw\Iguana\Theme\Helpers $helpers)
{
$helpers->registerFunction('assetPath', [$this, 'assetPath']);
$helpers->registerFunction('getAssetPath', [$this, 'getAssetPath']);
}

public function register()
{
add_action('wp_enqueue_scripts', [$this, 'wpEnqueueScripts']);
add_action('enqueue_block_editor_assets', [$this, 'wpEnqueueEditorScripts']);
add_theme_support('editor-styles');
add_editor_style('../static/editor.min.css');
}

public function getAssetPath($path)
{
return dirname(get_template_directory_uri()).'/static/'.$path;
}

public function assetPath($path)
{
echo esc_url($this->getAssetPath($path));
}

public function wpEnqueueScripts()
{
//
// Do not add javascript to your theme here, unless you're sure you should.
//
// Normally, you should add Javascript to assets/js/main.js or make a file in assets/js/plugins.
//
// You can/should enqueue a script here only if it is a widely used library that is required by a plugin (or is likely to be later)
//

// We need to register our own jQuery, because WP is on jQuery 2.x which breaks support for IE 6-8.
// This will not affect admin pages
// This will break any plugin that requires a feature/behaviour in jQuery 2.x which is missing/different in jQuery 1.10.x
wp_deregister_script('jquery');
wp_enqueue_script('jquery', $this->getAssetPath('lib/jquery.min.js'));

// Pretty much everything else should be compiled by Grunt.
wp_enqueue_script('main', $this->getAssetPath('main.min.js'), ['jquery'], '', true);

wp_enqueue_style('main', $this->getAssetPath('main.min.css'));
}

public function wpEnqueueEditorScripts()
{
wp_enqueue_script('theme-editor', $this->getAssetPath('editor.min.js'), ['wp-blocks', 'wp-dom'], filemtime(get_stylesheet_directory() . '/../assets/js/editor.js'), true);
}
}
62 changes: 31 additions & 31 deletions app/Theme/Tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@

class Tables implements \Dxw\Iguana\Registerable
{
public function register()
{
add_filter('render_block', [$this, 'useGovukMarkup'], 10, 2);
}
public function register()
{
add_filter('render_block', [$this, 'useGovukMarkup'], 10, 2);
}

public function useGovukMarkup($blockContent, $block)
{
if ($block['blockName'] === 'core/table') {
$blockContent = $this->replaceMarkup($blockContent);
}
return $blockContent;
}
public function useGovukMarkup($blockContent, $block)
{
if ($block['blockName'] === 'core/table') {
$blockContent = $this->replaceMarkup($blockContent);
}
return $blockContent;
}

private function replaceMarkup($blockContent)
{
$elementReplacements = $this->getElementReplacements();
foreach ($elementReplacements as $element => $replacement) {
$blockContent = str_replace($element, $replacement, $blockContent);
}
return $blockContent;
}
private function replaceMarkup($blockContent)
{
$elementReplacements = $this->getElementReplacements();
foreach ($elementReplacements as $element => $replacement) {
$blockContent = str_replace($element, $replacement, $blockContent);
}
return $blockContent;
}

private function getElementReplacements()
{
return [
'<table>' => '<table class="' . apply_filters('govuk_theme_class', 'govuk-table') . '">',
'<caption>' => '<caption class="' . apply_filters('govuk_theme_class', 'govuk-table__caption') . '">',
'<thead>' => '<thead class="' . apply_filters('govuk_theme_class', 'govuk-table__head') . '">',
'<tr>' => '<tr class="' . apply_filters('govuk_theme_class', 'govuk-table__row') . '">',
'<th>' => '<th class="' . apply_filters('govuk_theme_class', 'govuk-table__header') . '">',
'<tbody>' => '<tbody class="' . apply_filters('govuk_theme_class', 'govuk-table__body') . '">',
'<td>' => '<td class="' . apply_filters('govuk_theme_class', 'govuk-table__cell') . '">'
];
}
private function getElementReplacements()
{
return [
'<table>' => '<table class="' . apply_filters('govuk_theme_class', 'govuk-table') . '">',
'<caption>' => '<caption class="' . apply_filters('govuk_theme_class', 'govuk-table__caption') . '">',
'<thead>' => '<thead class="' . apply_filters('govuk_theme_class', 'govuk-table__head') . '">',
'<tr>' => '<tr class="' . apply_filters('govuk_theme_class', 'govuk-table__row') . '">',
'<th>' => '<th class="' . apply_filters('govuk_theme_class', 'govuk-table__header') . '">',
'<tbody>' => '<tbody class="' . apply_filters('govuk_theme_class', 'govuk-table__body') . '">',
'<td>' => '<td class="' . apply_filters('govuk_theme_class', 'govuk-table__cell') . '">'
];
}
}
Loading
Loading