170 posts Amazing WordPress Themes
  • Elite Author
  • Most Wanted Bounty Winner
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Egypt
  • Author had a Free File of the Month
  • Referred between 50 and 99 users
  • Bought between 100 and 499 items
  • Exclusive Author
Code125 says

Hello Guys,

I have a question about having your shortcodes into a plugin and make your theme require it using TGM.

the question is:

1-Can i use exit() function in the header.php to put a blank message if the plugin is not activated with theme ? something like this
if(!function_exists('any_function_in_the_plugin')){
    echo '<p>Hey go and activate "Plugin Name" Plugin</p><p>Thank you !</p>';
    exit();
}

If not what is the best practice to avoid any errors related to the new theme-plugin relationship :)

2-As most of the shortcode we made are making the main theme functions, thats mean now i have to ship most of the code in the plugin leaving just the layout handler in the theme ?

Any help here is appreciated :)

1470 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
OriginalEXE says

1.) You should not do that. Theme should still work normally if no plugin is active, it will only have no added features.

Also, instead of exit(), use wp_die() .

2.) Yeah pretty much.

170 posts Amazing WordPress Themes
  • Elite Author
  • Most Wanted Bounty Winner
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Egypt
  • Author had a Free File of the Month
  • Referred between 50 and 99 users
  • Bought between 100 and 499 items
  • Exclusive Author
Code125 says

1.) You should not do that. Theme should still work normally if no plugin is active, it will only have no added features. Also, instead of exit(), use wp_die() .

This is pretty weird … the theme is around shortcodes to give the user ability to create different layouts so without shortcodes the page will be full of text.

170 posts Amazing WordPress Themes
  • Elite Author
  • Most Wanted Bounty Winner
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Egypt
  • Author had a Free File of the Month
  • Referred between 50 and 99 users
  • Bought between 100 and 499 items
  • Exclusive Author
Code125 says

Another thing might be a work around …

i can manage my functions to be some how relative in a folder and and ship it as a plugin in the download folder so if the user decided to change the theme, he will just upload this plugin and it will contain everything to maintain the shortcodes, custom post types and everything.

By that way, users wont have the puzzle of install this mandatory plugin, and still they keep everything in order when they switch the theme.

1470 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
OriginalEXE says


1.) You should not do that. Theme should still work normally if no plugin is active, it will only have no added features. Also, instead of exit(), use wp_die() .
This is pretty weird … the theme is around shortcodes to give the user ability to create different layouts so without shortcodes the page will be full of text.
That is why you should move shortcodes to plugins and have plugins include necessary js/css, so even when someone switches to another theme, it at least looks half-decent.

Regarding having separate plugin shipped with the theme that needs to be installed if theme get’s deactivated, I don’t know if that’s allowed, you should probably ask Envato.

170 posts Amazing WordPress Themes
  • Elite Author
  • Most Wanted Bounty Winner
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Egypt
  • Author had a Free File of the Month
  • Referred between 50 and 99 users
  • Bought between 100 and 499 items
  • Exclusive Author
Code125 says



1.) You should not do that. Theme should still work normally if no plugin is active, it will only have no added features. Also, instead of exit(), use wp_die() .
This is pretty weird … the theme is around shortcodes to give the user ability to create different layouts so without shortcodes the page will be full of text.
That is why you should move shortcodes to plugins and have plugins include necessary js/css, so even when someone switches to another theme, it at least looks half-decent. Regarding having separate plugin shipped with the theme that needs to be installed if theme get’s deactivated, I don’t know if that’s allowed, you should probably ask Envato.

Just asked for a staff reply… hopefully we will get any soon.

1110 posts
  • Most Wanted Bounty Winner
  • Envato Studio (Microlancer) Beta Tester
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Referred between 50 and 99 users
  • Europe
  • Has been a member for 4-5 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
Smartik says

From what I’ve read somewhere on forums, your theme must work properly(default WP pages), without any plugins. Also you should know that is not a good idea to make a theme dependent by any plugins.

170 posts Amazing WordPress Themes
  • Elite Author
  • Most Wanted Bounty Winner
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Egypt
  • Author had a Free File of the Month
  • Referred between 50 and 99 users
  • Bought between 100 and 499 items
  • Exclusive Author
Code125 says

From what I’ve read somewhere on forums, your theme must work properly(default WP pages), without any plugins. Also you should know that is not a good idea to make a theme dependent by any plugins.

It’s not a plugin … it’s my own functions presented as shortcodes :), so according to the new requirements i should pull them off the theme and get them into a plugin.

I dont have a problem in that, i Just want to include the plugin as a seperate file the download package and have it included without calling an action from the user.

For example the download package will contain 2 files theme.zip theme-plugin.zip

theme wont require any plugin to be activated, and if you needed to deactivate the theme and keep the shortcodes/custom post types .. u will activate theme-plugin.zip as a plugin.

158 posts
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Sold between 1 000 and 5 000 dollars
  • United States
greenshady says

1) Absolutely not. That’s the worst experience you could ever offer a user. You’d be forcibly breaking their site for no reason at all.

You’ve already got half the solution to avoid errors in your above code. Check if a custom function exists before trying to use it. If the function exists, use it. If the function doesn’t exist, don’t try to use it; move along to the next thing.

Your theme should function correctly as a WordPress theme without any plugins installed.

2) Themes are for handling the design/presentation of data.

Shortcodes have nothing to do with that. Shortcodes are for wrapping up complex functionality into a simplified piece of code for users to enter into their post editor.

If the shortcode output needs additional styling to look good with your theme, then your theme should handle those additional styles.

by
by
by
by
by
by