WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom Search Function for plugin update (5 posts)

  1. onerock
    Member
    Posted 1 year ago #

    I am relatively new to WordPress and have never coded a plugin. I thought that this would be a great place to get my feet wet. :)

    I am working to update the "NextGEN Gallery Search" plugin (http://wordpress.org/plugins/nextgen-gallery-search/) that appears to have been abandoned since it has not been updated in over 2 years and the authors website is gone. It allows you to find the gallery you are looking for without browsing all the admin galleries pages.

    NextGen Gallery 2.0 is currently in beta and this plugin doesn't work any longer. I rely on the functionality of this plugin, so I have corrected most everything. I am getting stuck with the search portion of it.

    The plugin has the following code

    <form method="post" action="<?=$_SERVER['REQUEST_URI']?>">
    <table class="form-table" style="width:570px;">
    <tr valign="top">
    <th scope="row"><label for="ngs2_filter">Search Keyword</label></th>
    <td><input name="ngs2_filter" type="text" id="ngs2_filter" value="<?=$_POST['ngs2_filter'];?>" class="regular-text" /></td>
    <td><input type="submit" name="Submit" class="button-primary" value="Search" /></td>
    </tr>
    </table>
    </form>
    $gallerylist = ngs2_search_galleries($_POST['ngs2_filter']);

    With the code above, when you visit the admin page <?=$_POST['ngs2_filter'];?> appears in the search box. If you attempt a search, you receive a "404 Not found" with the address bar showing "192.168.0.105/wp-admin/<?=$_SERVER['REQUEST_URI']?>"

    I have attempted to follow the WordPress Codex (http://codex.wordpress.org/Function_Reference/get_search_form), but it doesn't explain the various varialbe the plugin seems to use.

    Can someone please advise me on what might be the issue with the above code or point me in the direction of information that will further explain how to fix this?

    I am unable to post a link as it is on a dev server without inbound service.

    The function works correctly on WordPress version 3.5.2 and current version 1.9.13 of Nextgen Gallery.

    Thanks so much in advance
    Scott

  2. bcworkz
    Member
    Posted 1 year ago #

    Change the 2 occurrences of "<?=" to "<?php ". It appears the file got slightly corrupted for some reason.

    There should also be a "<?php" between </form> and the $gallerylist line, though the original file does have this, you apparently have done other editing. Be careful that all tags balance when you edit and that PHP blocks are always separated from HTML content.

  3. onerock
    Member
    Posted 1 year ago #

    Thank You, Thank You, Thank You!!

    "<?=" was the problem. Strangely enough, my working source code uses "<?=". I incorrectly assumed that this was coding that I didn't understand.

    You are correct, I condensed the code above to only the pertinent form information where I thought the issue was.

    Is there a good source of information explaining forms and how it is being used in this plugin? I could only find what was in the Codex, but that seemed to pertain to only searching for blog posts.

    Thanks again for your help!
    Scott

  4. bcworkz
    Member
    Posted 1 year ago #

    There's plenty on generic HTML forms, such as W3 Schools. But as it pertains to the plugin? Very unlikely. All one could do is examine the source code, but one needs to understand PHP to do that.

    The PHP portions of this form are populating the fields with values from another form that was just submitted to get this form. As for what happens when this form is submitted, I've no idea, I didn't look any further than to confirm those were the only typos of that nature.

  5. onerock
    Member
    Posted 1 year ago #

    Thanks again for your help. Now that I know this form is driven by PHP and not a WordPress function, I will begin to see what I can learn about PHP.

    Those typos were the source of the issues and resolved the problem I was experiencing.

    Scott

Topic Closed

This topic has been closed to new replies.

About this Topic