Title: Creating plugin from existing code
Last modified: August 30, 2016

---

# Creating plugin from existing code

 *  [kinghippo](https://wordpress.org/support/users/kinghippo/)
 * (@kinghippo)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/creating-plugin-from-existing-code-1/)
 * Hello
 * I have written some code in PHP/MySQL and jQuery that creates a live search suggestion
   in a search box. The data for the search is populated from a table on my server.
   I am trying to now use this code as a plugin for WordPress.
 * I have read over the codex and done a few tutorials to create a plugin, but I’m
   still lost when it comes to making my code work in WordPress. Based on my reading
   I think I need to create a few custom functions that input data into some of 
   WP’s built in functions?
 * I know I need to use the $wpdb class to query the database, but I’m not sure 
   how to display all the data. Do I create a custom page type that uses my html/
   css/js?
 * My code is can be seen [here](https://github.com/KingHippo/auto-complete). I’m
   sure it’s not secure at all and fairly sloppy, but this is all pretty new to 
   me still. I’m kind of lost and feel like I’m running in circles so any help would
   be greatly appreciated.
 * Thanks

Viewing 1 replies (of 1 total)

 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/creating-plugin-from-existing-code-1/#post-6417651)
 * A) Study some other plugins to see how they bundle their code and look after 
   activation/deactivation.
 * Getting your functions invoked by and feeding text/data back to WordPress can
   be done several ways:
    B) Using shortcodes: [http://codex.wordpress.org/Shortcode_API](http://codex.wordpress.org/Shortcode_API)
 * C) Using custom page templates, do this in a child theme.
 * D) Using hooks and filters:
    List here: [http://adambrown.info/p/wp_hooks/hook](http://adambrown.info/p/wp_hooks/hook)
   Details here: [http://codex.wordpress.org/Plugin_API/Filter_Reference](http://codex.wordpress.org/Plugin_API/Filter_Reference)
 * E) As for security, this is important, you must defend against user supplied 
   input being let loose upon your database, there is a “prepare” function as part
   of $wpdb class which will help you.

Viewing 1 replies (of 1 total)

The topic ‘Creating plugin from existing code’ is closed to new replies.

## Tags

 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/creating-plugin-from-existing-code-1/#post-6417651)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
