[theme-reviewers] FavePersonal Theme

Otto otto at ottodestruct.com
Thu Nov 14 00:47:58 UTC 2013

Yes, TGM is great and all, but it's a bit heavy. Rolling your own isn't
very hard to do.

I'll use the Slides theme I made as an example. It has no config screen,
using just the Customizer for the options. One of those customizer sections
I called "Plugins".

Slides supports the Simple Page Ordering plugin as an option. This works
well with this theme in particular for various reasons. So, to prompt the
user to install it, I made a special customizer control with a link to
install the plugin. Here's the code for that control:

(Note: The theme is unfinished, in the extreme, so it lacks may things like
correct I18N support and such at present, this is just an example bit of
code to demonstrate the point.)

if (class_exists('WP_Customize_Control')) {
class Slides_Customize_PluginCheck_Control extends WP_Customize_Control {
public $type = 'none';

public function render_content() {
if ( ! class_exists( 'Simple_Page_Ordering' ) ) {
<p>The Slides theme has special functionality to support use of the <a
href="http://wordpress.org/plugins/simple-page-ordering/">Simple Page
Ordering</a> plugin. You can install this plugin to get support for
drag/drop of your posts/slides and thus allow reordering of them to be done
$plugins = get_plugins();
$uris = wp_list_pluck($plugins, 'PluginURI');

if ( ( $plugin_file = array_search('
http://10up.com/plugins/simple-page-ordering-wordpress/', $uris) ) !==
false ) {
 // plugin installed, but not active
<p>Plugin already installed, but not activated. <a href="<?php echo
'activate-plugin_'.$plugin_file); ?>">Click here to activate the Simple
Page Ordering plugin</a></p>
} else {
// plugin not installed
 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
$info = plugins_api('plugin_information', array('slug' =>
'simple-page-ordering' ));
 if ( is_wp_error( $info ) ) {
<p>Plugin not installed. <a href="<?php echo
'install-plugin_simple-page-ordering'); ?>">Click here to install the
Simple Page Ordering plugin</a></p>
} else {
echo '<p>'.__('Simple Page Ordering plugin installed and active!','slides')

Bit big, but follow it through.

First, the code checks to see if the plugin is already installed and
activated by simply checking for the class_exists. Easy.

Next, if the class isn't there, it checks for the plugin by calling
get_plugins and looking for the specific Plugin URI for that plugin. That
part of the code is heavy, but this only shows up on the Customizer screen,
so it's only infrequently done. Not a big deal. This is so if the plugin is
installed but not active, then an activation link is built and displayed to
the user. Clicking the link activates the already-installed plugin.

Finally, if the plugin is not installed, an installation link is built.
Same deal, one-click to install the pugin.

Now, this is a simplistic example. I'm just using basic a href links here.
You could use buttons, or style it differently to fit with your theme's own
configuration. Whatever, the point being that a) detecting a plugin is
pretty easy and b) building activate and install links for a one-click
approach is also easy. Making the theme detect plugins and change behavior
accordingly isn't at all hard to do. Making it easy for the user to install
the plugin separately and then for the theme to take advantage of that can
be any sort of user-experience you want.

Having a plugin built into the theme, and then have to deactivate it in
order to re-install it and upgrade it and so on, well, that's only a
"better" experience from the point of view of the initial usage. It doesn't
consider maintenance, or additional learning curve for other developers who
have no experience with your theme previously, or site maintainers who do
know about plugins and themes but don't know that your theme is doing
something strange with one of them.

Best to keep that separation solid, but do the integration in a
non-threatening and user-friendly way. Give the user a one-click
experience. It's not difficult to do.


On Wed, Nov 13, 2013 at 6:25 PM, Mario Peshev <mario at peshev.net> wrote:

> In addition to the TGM recommendation, Otto's
> http://ottopress.com/2012/themeplugin-dependencies/
> Mario Peshev
> WordPress Engineer, Open Source Consultant
> http://www.linkedin.com/in/mpeshev
> http://me.peshev.net
> On Thu, Nov 14, 2013 at 2:24 AM, WordPress (thinkupthemes) <
> wordpress at thinkupthemes.com> wrote:
>> Why are you including the plugin in your theme? Why not just use TGM to
>> recommend it as an install after the theme is activated?
>> Afzaal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20131113/5b2d7cba/attachment.html>

More information about the theme-reviewers mailing list