• Hello,

    I have a PHP program which essentially an HTML form. Changes in some input fields are causing JS running and changes made in the form without calling the server.
    There is also a button ‘submit’ which of course called script itself.

    I am pretty good at managing WP, but have no idea about how the best include this program into wp. A want it to convert into a page.

    Isn’t writing plugin an overkill for this task?
    What’s the shortest and simplest way to do that?

    Thanks in advance.
    Gershon

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey Gregaizi,

    Personally I would go the plugin route. This way, that piece of functionality isn’t directly tied to your theme. So in future if you wanted to switch themes, your plugins will follow.

    Writing a plugin can be a very quick and dirty task, depending on how detailed you want to get. A plugin can range in size from 2-20000 lines of code.

    Personally, I’d set it up so you can use a shortcode (or just a simple php snippet) to display your forms wherever you want.

    But that’s just my personal opinion and other developers may prefer a separate route.

    Evan

    Thread Starter gregaizi57

    (@gregaizi57)

    Thanks Evan for quick response.
    The problem is that it looks scary to learn writing plugins…
    I have a book Prof WP by Hal Stern, David Damstra, …
    which scored highly at Amazon, but it starts describing the process of creating plugins with internationalization, and ‘creating plugin file’ without explaining what its filename is, suggesting having img folder under plugin…

    I need only one page with the form. Is it truly necessary to write plugin?

    Thread Starter gregaizi57

    (@gregaizi57)

    No settings needed, but in future, I plan to use some subscriber’s info to customize the form for every subscriber.

    Don’t worry about internationalizing the plugin, that’s really only necessary if you plan on spreading the plugin world wide. That step gets very intricate.

    Take a look at this file on GitHub:
    https://github.com/Wysija/barebone

    It is a barebones, plugin with just the necessary files. The CSS and JS folders are not needed, you can delete them if you want. You can use this as a starting point, and just add what you need.

    Notice how the main plugin file, index.php, has all that commented out code at the top of the file. This tells WordPress that it’s a Plugin, and the name, the author, version and a bunch of other meta-data.

    If you don’t want to go the plugin route, you can always set up everything inside of Functions.php and then execute the necessary code as needed.

    Thread Starter gregaizi57

    (@gregaizi57)

    Thanks a lot, Evan.
    That’s a real help.
    If I change Functions.php it can be lost in future if I upgrade WP?
    Bare Bone plugin is looking great.

    If you add anything to your main parent theme, into style or functions, yes you will lose it if you upgrade your theme, not wordpress.

    It’s smart to create a child theme if that’s the route you want to take. But again, personally I love plugin development, so I’d stick with the plugin (but that’s all preference)

    Thread Starter gregaizi57

    (@gregaizi57)

    Thanks a lot, Evan. I’ll try plugin development. It’s needed sooner or later anyway.
    Thanks again.

    Gershon

    BTW, I loved singer Anna Herman 😉

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘PHP code/form inclusion into a page’ is closed to new replies.