Add some do_action() (2 posts)

  1. kabushi
    Posted 3 years ago #

    Is it possible to add some do_action in the plugin code ?

    For example, in include/admin.php at line 427 i added a

    do_action("polylang_register_string", $this);

    So my others plugins could register some strings which i'm able to modify in the Strings tab of Polylang.

    I think it'll be a good thing for polylang to be more integrated with external plugins.

    So the others plugins writer has just to add something like this in their code:

    add_action("polylang_register_string", array(&$this, 'add_strings'));
    public function add_strings($polylang) {
        $polylang->register_string(__("Hello"), "World");

    to have the string translated.

    Thanks in advance


  2. Chouby
    Plugin Author

    Posted 3 years ago #

    I am not against adding actions and filters on developers request.

    However, this one is not useful. Instead, you can use:

    add_action("plugins_loaded", array(&$this, 'add_strings'));
    public function add_strings() {
        pll_register_string('name', "your string to translate");

    I used the action 'plugins_loaded' to demonstrate that the function is available as soon as Polylang is loaded, but you can use another action available on admin side, provided that it is fired between 'plugins_loaded' and 'admin_init'

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic