Skip to content

u/SeeBeen

In this archive from Aug 2013 to Dec 2026

6
posts
16
comments
4
media
741
score

And to illustrate my point further.

If you compare v2.2.0 version of the entry class for the plugin with v.3.9.4 version - you can note the following.

Instead of manual construction of dependencies (new this, new that), all dependencies are listed in the handlers array of the entry class - so everything is loaded when needed, and not at once.

All in all:

  • Cleaner code
  • Faster code
  • Faster development
0 points

Imagine having a class in which each function is hooked into an action or a filter. You'd have something like this:

<?php
/**
 * Handles order statuses for TIS payment methods
 */
class Order_Statuses {
    /**
     * Class constructor
     */
    public function __construct() {
        \add_filter(
            'woocommerce_cod_process_payment_order_status',
            array( $this, 'change_payment_order_status' ),
            10,
            2,
        );
        \add_filter(
            'woocommerce_register_shop_order_post_statuses',
            array( $this, 'register_custom_order_statuses' ),
            99,
            1,
        );
        \add_filter( 'wc_order_statuses', array( $this, 'modify_order_statuses' ), 99, 1 );
        \add_action( 'admin_head', array( $this, 'custom_order_button_colors' ), 99 );
    }
    // Class continues
}

With PHP-DI

<?php

use XWP\DI\Decorators\Action;

class Order_Statuses {
    #[Action(tag: 'woocommerce_cod_process_payment_order_status', priority: 10)]
    public function change_payment_order_status( string $status, WC_Order $order) : string {
        // Snipped
    }
}

It reduces the amount of boilerplate code needed by an order of magnitude.

I recommend reading about DI and IoC. If you cba to read the wikipedia and long-form articles, freecodecamp has you covered

3 points

Gutenberge, FSE and all the other bells and whistles are, IMHO, bloated steaming pile of cow dung.
Using json for anything in PHP means that a file access is necessary because JSON can't be opcached.

I stick with classic editor and a page builder I need at that specific moment. (Bricks for presentation websites, WPB for WooCommerce).

4 points

End of this list.

Back to top

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

โ†orโ†’
Previous / next file
โ†‘orโ†“
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.