WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
Add some do_action() (2 posts)

  1. kabushi
    Member
    Posted 1 year 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

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 1 year 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

About this Topic

Tags