Accessing an instanciated class

I’ve done something like that: <?php class Cart { protected static $_instance = null; public static function instance() { if ( is_null( self::$_instance ) ) { self::$_instance = new self(); } return self::$_instance; } //…. } $cart = new Cart(); $cart->init(); function EVA_Cart() { return Cart::instance(); } function deposit_total(){ $cart = EVA_Cart(); $totals = array_sum( … Read more

How to show categories and date on posts

Something like this for the category term should work. That’s for the slug you probably want the name. <?php $terms = get_the_terms( $post->ID, ‘category’ ); ?> <?php foreach( $terms as $term ) echo ‘,’ . $term->slug; ?> The date is pretty simple just follow the documentation https://developer.wordpress.org/reference/functions/get_the_date/ it has lots of examples at the bottom.

add_action in namespace not working

Before going too far down this path I would suggest that you familiarize yourself with PHP name resolution rules. To answer your actual question – When you namespace functions, the fully qualified name of those functions includes the namespace. In your example, you have defined two functions: \myPlugin\add_activation_notice and \myPlugin\activation_notice. When calling either of these … Read more