$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugin development - do_action from within a class does not seem to work|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugin development - do_action from within a class does not seem to work

matteradmin9PV0评论

I have a class within a plugin which is loaded via the below code:

<?php

add_action(
    'plugins_loaded',
    array ( 'Company_Store_Locator', 'init' )
);

class Company_Store_Locator{

public static function init() {
    $class = __CLASS__;
    new $class;
}

And I have a constructor with a number of add_actions which are within my construct - these all work fine, however when I try and do_action for one of these nothing appears to happen. I am trying to return an admin notice only if certain criteria within a function occurs. The function is running as expected but nothing happens for do_action as I need to pass a variable to the admin notice function I cannot use add action here.

public function __construct() {

    add_action( 'admin_notices', array($this,'sample_admin_notice__success'));

Inside my public function create_tables() function:

$message = 'Tables created successfully';

do_action( 'sample_admin_notice__success', $message);

How would I get the do action to run in this scenario?

Post a comment

comment list (0)

  1. No comments so far