WordPress.org

Ready to get started?Download WordPress

Forums

parse variable through add_action (5 posts)

  1. Sjeiti
    Member
    Posted 7 years ago #

    Hi...

    I'm trying to make a plugin but I'm stuck.

    When initializing the plugin like so:
    add_action('plugins_loaded', 'myInitFunction');

    I want to parse a variable through the 'myInitFunction'. S o basicly is has to do this: myInitFunction($sSomeString);

    I did search this forum and googled and stuff... maybe I was searching wrong or maybe it's just not possible.

    gr...

    Sjeiti

  2. Fortes
    Member
    Posted 7 years ago #

    Sjeiti -- Can you give more detail? Where is this variable coming from?

  3. Sjeiti
    Member
    Posted 7 years ago #

    Detail... I don't see how that could clarify the question but here goes: I've build a sparkline library with which I want to be able to make multiple widgets. Now the input for the widget could be a static list but could also be a variable one (sql query and some data alteration). Since it's a bit hard to put such a sql query into an options-form I thought it would be better if people just copied the php plugin source and altered the sql query to their needs. But most of the php files would be similar apart from the data retreival (and renaming all the functions) so I thought why not just have these files include one other where all these similar functions reside. So the files would just have a $uniquename variable, the include, and then the data retreival function (which will probably have to be renamed to suit the unique name). But then I'd have to be able to parse the unique name variable through functions like: add_action (and maybe register_sidebar_widget and register_widget_control).
    I think the first post was less confusing.

  4. EthanC
    Member
    Posted 6 years ago #

    Sjeiti,

    Did you ever figure this out? I was wondering the same thing.

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Try something like this:

    add_action('plugins_loaded', create_function('$sSomeString', 'myInitFunction($sSomeString)'));

Topic Closed

This topic has been closed to new replies.

About this Topic