0
votes

This is my first plugin that i am developing. I have only one file in my plugin folder which has all the code that is handling my admin part. I have my own custom tables. I'm not using any wordpress table for it.

Structure:

plugin/amt

  • amt.php (This file has all the code which is dealing with admin part)
  • js/amt.js

Now I have got amt.php file working for my admin part. It is retrieving and saving data into the database. Till here its all fine.

Now, I want to add some functionality in the plugin which will be shown on frontend of the website. Please guide me, how can this be done? I could think of following options:

  1. Add front end code in amt.php as well and use some kind of short code to display on front end of website under 'Sample Page'.
  2. Need to create a new folder/file for front end?

I'll be thankful if some one can guide me please.

1
there are so many possible answers to this, you need to be more specific with what you're asking. Use cases differ so shortcodes are obviously good for flexibility of use by plugin users, creating pages or templates from the plugin obviously more rigid use.David
Thank You David!. I have simple form with three fields on admin side in my plugin. 1- Clan Name 2- Clan Preferred Name 3- Clan Properties, now on admin side i can save this and retrieve these fields easily. What I want is to give user a form on front end where he can select Clan name and Clan Preferred names and I will display clan properties based on selection of first two fields. Will short code work for this one please? or if there is any other suitable option, please guide. :)Bilal Ahmad
I have got it working with the help of short code. Here is what i did. added this code in my main plugin file i.e: amt.php add_shortcode( 'clan', 'clan_fn' ); function clan_fn() { } Create a new page from word press admin and simply call the short code as below and it will display what ever functionality you add in clan_fn. [clan]Bilal Ahmad

1 Answers

1
votes

I have got it working with the help of short code. Here is what i did. added this code in my main plugin file i.e: amt.php

add_shortcode( 'clan', 'clan_fn' ); 
function clan_fn() { } 

Create a new page from word press admin and simply call the short code as below and it will display what ever functionality you add in clan_fn.

[clan]