WordPress.org

Ready to get started?Download WordPress

Forums

Plugin not working (7 posts)

  1. mrdedenroth
    Member
    Posted 11 months ago #

    hi
    i downloaded the plugin Alchemist Ajax Upload. to upload images from fronted.
    it works just fine when i use the shortcode [AAIU] in the backend site editor.
    but i want to use it in my theme code. but i cannot get the button to work it just links to #.
    i have got the plugin to show in the theme using the code
    <?php echo do_shortcode('[AAIU]');?>

    what could be the problem?

  2. ianhaycox
    Member
    Posted 11 months ago #

    I'm guessing that there is a Javascript error in the theme or one of the plugins preventing the button from working.

    Check in the Browser's console log to see any errors.

    Got a URL to the site ?

  3. Krishna
    Volunteer Moderator
    Posted 11 months ago #

    Where did you download the plugin from?

  4. mrdedenroth
    Member
    Posted 11 months ago #

    ianhaycox
    it does not make any sense that it should be a plugin because it works when i insert in the correct site from the site editor.

    but it stops working when i want to insert it in the correct place, with the echo. in the theme code.

    krishna
    i downloadet it from official wordpress. :)

  5. bcworkz
    Member
    Posted 11 months ago #

    Linking to # is normal for submit buttons that rely on javascript events to run instead of having the browser submit the form. This plugin politely will not enqueue its scripts unless it "sees" that its shortcode is in the post content. Since it cannot "see" itself in a do_shortcode() call, no scripts are loaded and nothing works.

    You could extend the conditions under which the scripts load by modifying line 66 of the main plugin file, but your change would need to be reapplied each time the plugin is updated. With upload plugins, it is critical you apply updates ASAP.

  6. mrdedenroth
    Member
    Posted 11 months ago #

    how do i extend the conditions?

  7. bcworkz
    Member
    Posted 11 months ago #

    Depends on where you need the scripts loaded. Perhaps use one of the various is_*() template tags like is_home() or is_archive() etc. Link the required conditions inside the parenthesis after 'if' with the double bar OR operator: ||. Something like this:
    if ($this->has_shortcode('AAIU') || is_home()) {

Reply

You must log in to post.

About this Topic