Skip to content

Commit

Permalink
add duster for lint and fix php
Browse files Browse the repository at this point in the history
  • Loading branch information
ipatate committed Apr 6, 2023
1 parent e074b8d commit 8870aee
Show file tree
Hide file tree
Showing 28 changed files with 409 additions and 412 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
],
"require-dev": {
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.0",
"tightenco/duster": "^1.1"
}
}
88 changes: 44 additions & 44 deletions config/global.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
<?php

return [
// directory target for assets generated
'iconsDir' => 'public',
// logo source for generate icons
// 'source' => './assets/media/icon.svg',
// 'manifest' => [
// 'appName' => 'PressWind',
// 'appShortName' => 'PressWind',
// 'appDescription' => 'Starter theme WordPress, Tailwind, ViteJS',
// 'background' => '#fff',
// 'theme_color' => 'rgb(190, 24, 93)',
// 'lang' => 'fr-FR',
// see settings https://www.npmjs.com/package/favicons#usage
// 'preferRelatedApplications' => false,
// 'pixel_art' => false,
// 'loadManifestWithCredentials' => false,
// 'manifestMaskable' => false,
// 'icons' => [
// 'favicons' => true,
// 'android' => true,
// 'appleIcon' => true,
// 'appleStartup' => false,
// 'coast' => false,
// 'yandex' => false,
// 'windows' => false,
// ],
// ],
// 'disable' => [
// // disable rss links
// 'rss' => true,
// // remove all comments views
// 'comment' => true,
// // disable emojis
// 'emoji' => true,
// // media page
// 'media' => true,
// // disable oembed
// 'oembed' => true,
// // disable xmlrpc
// 'xmlrpc' => true,
// // disble rest user endpoint
// 'rest_user' => true,
// // disable jquery
// 'jquery' => false
// ]
// directory target for assets generated
'iconsDir' => 'public',
// logo source for generate icons
// 'source' => './assets/media/icon.svg',
// 'manifest' => [
// 'appName' => 'PressWind',
// 'appShortName' => 'PressWind',
// 'appDescription' => 'Starter theme WordPress, Tailwind, ViteJS',
// 'background' => '#fff',
// 'theme_color' => 'rgb(190, 24, 93)',
// 'lang' => 'fr-FR',
// see settings https://www.npmjs.com/package/favicons#usage
// 'preferRelatedApplications' => false,
// 'pixel_art' => false,
// 'loadManifestWithCredentials' => false,
// 'manifestMaskable' => false,
// 'icons' => [
// 'favicons' => true,
// 'android' => true,
// 'appleIcon' => true,
// 'appleStartup' => false,
// 'coast' => false,
// 'yandex' => false,
// 'windows' => false,
// ],
// ],
// 'disable' => [
// // disable rss links
// 'rss' => true,
// // remove all comments views
// 'comment' => true,
// // disable emojis
// 'emoji' => true,
// // media page
// 'media' => true,
// // disable oembed
// 'oembed' => true,
// // disable xmlrpc
// 'xmlrpc' => true,
// // disble rest user endpoint
// 'rest_user' => true,
// // disable jquery
// 'jquery' => false
// ]
];
8 changes: 8 additions & 0 deletions duster.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"include": [
"functions.php",
"inc/*",
"config/*"
],
"exclude": []
}
3 changes: 0 additions & 3 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
* Contains the closing of the #content div and all content after.
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package blank
*/

?>

<footer id="colophon" class="site-footer">
Expand Down
67 changes: 32 additions & 35 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use function PressWind\Inc\Core\load_assets;

if (!defined('WP_ENV')) {
define('WP_ENV', 'development');
if (! defined('WP_ENV')) {
define('WP_ENV', 'development');
}

// include core files (don't touch this files !)
Expand All @@ -17,50 +17,47 @@

// pwa icons injected in head
if (file_exists(dirname(__FILE__) . '/inc/pwa_head.php')) {
include dirname(__FILE__) . '/inc/pwa_head.php';
include dirname(__FILE__) . '/inc/pwa_head.php';
}


/**
* Theme setup.
*/
function setup()
{
add_theme_support('automatic-feed-links');

add_theme_support('title-tag');

add_theme_support('post-thumbnails');

// add_theme_support('html5', [
// 'comment-form',
// 'comment-list',
// 'gallery',
// 'caption',
// ]);

// add_theme_support('post-formats', [
// 'aside',
// 'image',
// 'video',
// 'quote',
// 'link',
// 'gallery',
// 'audio',
// ]);

register_nav_menus(array(
'primary' => __('Primary Menu', 'press-wind'),
// 'secondary' => __('Secondary Menu', 'press-wind')
));


load_theme_textdomain('press-wind', get_template_directory() . '/languages');
add_theme_support('automatic-feed-links');

add_theme_support('title-tag');

add_theme_support('post-thumbnails');

// add_theme_support('html5', [
// 'comment-form',
// 'comment-list',
// 'gallery',
// 'caption',
// ]);

// add_theme_support('post-formats', [
// 'aside',
// 'image',
// 'video',
// 'quote',
// 'link',
// 'gallery',
// 'audio',
// ]);

register_nav_menus([
'primary' => __('Primary Menu', 'press-wind'),
// 'secondary' => __('Secondary Menu', 'press-wind')
]);

load_theme_textdomain('press-wind', get_template_directory() . '/languages');
}

add_action('after_setup_theme', __NAMESPACE__ . '\setup');


/**
* init assets front
*/
Expand Down
33 changes: 15 additions & 18 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package blank
*/

?>
<!doctype html>
<html <?php language_attributes(); ?>>
Expand All @@ -31,31 +28,31 @@
<div class="site-branding">
<?php
the_custom_logo();
if (is_front_page() && is_home()) :
?>
if (is_front_page() && is_home()) {
?>
<h1 class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a></h1>
<?php
else :
?>
} else {
?>
<p class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a></p>
<?php
endif;
$blank_description = get_bloginfo('description', 'display');
if ($blank_description || is_customize_preview()) :
?>
}
$blank_description = get_bloginfo('description', 'display');
if ($blank_description || is_customize_preview()) {
?>
<p class="site-description"><?php echo $blank_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?></p>
<?php endif; ?>
?></p>
<?php } ?>
</div><!-- .site-branding -->

<nav id="site-navigation" class="main-navigation">
<?php
wp_nav_menu(
array(
'theme_location' => 'primary',
'container_id' => 'primary-menu',
)
[
'theme_location' => 'primary',
'container_id' => 'primary-menu',
]
);
?>
?>
</nav><!-- #site-navigation -->
</header><!-- #masthead -->
4 changes: 2 additions & 2 deletions inc/core/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
// disble rest user endpoint
'rest_user' => true,
// disable jquery
'jquery' => true
]
'jquery' => true,
],
];
1 change: 0 additions & 1 deletion inc/core/disable/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function init_disable_comment()
{
$config = get_config();
if ($config['disable']['comment']) {

// Disable comments.
add_action('admin_init', function () {
// Redirect any user trying to access comments page
Expand Down
2 changes: 0 additions & 2 deletions inc/core/disable/emoji.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

require_once dirname(__FILE__) . '/../index.php';



function init_disable_emoji()
{
$config = get_config();
Expand Down
1 change: 0 additions & 1 deletion inc/core/disable/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

require_once dirname(__FILE__) . '/../index.php';


// Redirects all feeds to home page.
function disable_feeds_rss(): void
{
Expand Down
10 changes: 3 additions & 7 deletions inc/core/disable/jquery.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,23 @@
*/
function removeJquery()
{
if ($GLOBALS['pagenow'] !== 'wp-login.php' && !is_admin() && !is_user_logged_in()) {
if ($GLOBALS['pagenow'] !== 'wp-login.php' && ! is_admin() && ! is_user_logged_in()) {
wp_deregister_script('jquery');
wp_register_script('jquery', false);
}
}


function remove_jquery_migrate($scripts)
{

if (!is_admin() && isset($scripts->registered['jquery'])) {

if (! is_admin() && isset($scripts->registered['jquery'])) {
$script = $scripts->registered['jquery'];

if ($script->deps) {
$script->deps = array_diff($script->deps, array('jquery-migrate'));
$script->deps = array_diff($script->deps, ['jquery-migrate']);
}
}
}


function init_disable_jquery()
{
$config = get_config();
Expand Down
1 change: 0 additions & 1 deletion inc/core/disable/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

require_once dirname(__FILE__) . '/../index.php';


function init_disable_media()
{
$config = get_config();
Expand Down
2 changes: 0 additions & 2 deletions inc/core/disable/oembed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

require_once dirname(__FILE__) . '/../index.php';



function init_disable_oembed()
{
$config = get_config();
Expand Down
3 changes: 1 addition & 2 deletions inc/core/disable/rest_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

require_once dirname(__FILE__) . '/../index.php';


function init_disable_rest_user()
{
$config = get_config();
Expand All @@ -13,7 +12,7 @@ function init_disable_rest_user()
// https://www.wp-tweaks.com/hackers-can-find-your-wordpress-username/
function disable_rest_endpoints(array $endpoints): array
{
if (!is_user_logged_in()) {
if (! is_user_logged_in()) {
if (isset($endpoints['/wp/v2/users'])) {
unset($endpoints['/wp/v2/users']);
}
Expand Down
1 change: 0 additions & 1 deletion inc/core/disable/xmlrpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

require_once dirname(__FILE__) . '/../index.php';


function init_disable_xmlrpc()
{
$config = get_config();
Expand Down
13 changes: 7 additions & 6 deletions inc/core/helpers/get_manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/
function get_manifest($rootPath = 'dist/manifest.json')
{
$strJsonFileContents = file_get_contents(dirname(__FILE__) . "/../../../" . $rootPath);
return json_decode(str_replace(
'\u0000',
'',
$strJsonFileContents
));
$strJsonFileContents = file_get_contents(dirname(__FILE__) . '/../../../' . $rootPath);

return json_decode(str_replace(
'\u0000',
'',
$strJsonFileContents
));
}
Loading

0 comments on commit 8870aee

Please sign in to comment.