0

Must use a do_action (); to pass values ​​to my class. How do I do that??

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

class someClassy {

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

    public function __construct($options = null, $initialize = true, $error_messages = null, $path, $qnty) {
           //construct what you see fit here....
    }

    //etc..
}
1

1 Answer 1

3
<?php
class someClass {

    public function __construct($options = null, $initialize = true, $error_messages = null, $path, $qnty) {
        //construct what you see fit here....
    }

    //etc..
}

// Action listener
add_action(
    'action_name',
    create_function('', "new someClass(implode(',',func_get_args()));"),
    10,
    5 // IMPORTANT, number of arguments your construct function accept
);

// Call the action
$options = "options";
$initialize = "initialize";
$error_messages = "error_messages";
$path = "path";
$qnty = "qnty";
do_action('action_name', $options, $initialize, $error_messages, $path, $qnty);
?>
2
  • ERROR: implode() [function.implode]: Invalid arguments passed in... Commented May 26, 2015 at 14:49
  • @Lollipop just fixed it Commented May 27, 2015 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.