I've published a plugin on WP repository that allows some theming for Gravity Forms.

This plugin as been tested with Twenty Ten, and Twenty Eleven. When I've tried to test it in a site that uses Thesis 1.8.5, I've found out that something wasn't working.

What this plugin does is to extend the Gravity Forms shortcode with a new action. When this action is called, the whole form is wrapped in a div with an appropriate class, then in this case the plugin includes a skin's function.php for further customizations.

Basically the plugin checks two directories: - /themes directory inside the plugin directory - /mgft-themes directory inside /wp-content

For both directories, it lists all subdirectories and consider them as available themes.

When a GF shortcode has a 'theme' action and a 'themename' value, my plugin check what is available in the selected theme folder: - It enqueue all *.js and *.css files located in theme's root - It includes all *.php files located in theme's root

For the moment I always have a functions.php file like this:

wp_enqueue_style("misamee-themed-form-$theme[name]", "$theme[url]css/misamee.themed.form.$theme[name].css");
wp_enqueue_script('tooltipsy', "$theme[url]js/tooltipsy.min.js", array('jquery'));
wp_enqueue_script("misamee-themed-form-$theme[name]-js", "$theme[url]js/misamee.themed.form.$theme[name].js", array('jquery'));

This function.php is included as such (you can grab the full code here):

  1. __construct()

    add_filter("gform_shortcode_theme", array(&$this, "misamee_themed_form_theme"), 10, 3);
  2. The misamee_themed_form_theme method:

    function misamee_themed_form_theme($string, $attributes, $content)
        'title' => true,
        'description' => true,
        'id' => 0,
        'name' => '',
        'field_values' => "",
        'ajax' => false,
        'tabindex' => 1,
        'action' => 'form',
        'themename' => '',
        'cssclass' => ''
    ), $attributes));
    /** @var $themename string */
    /** @var $selectedTheme string */
    $selectedTheme = $themename;
    /** @var $id int */
    $theme = $this->misamee_themed_form_setTemplate($selectedTheme, $id);
    $additionalClasses = ($theme['name'] != '') ? " class=\"themed_form $theme[name]\"" : "";
    //$newString = str_replace('action="prettify"', 'action="form"', $string);
    $attributes['action'] = 'form';
    $formString = RGForms::parse_shortcode($attributes, $content = null);
    //$formString = do_shortcode($newString);
    if ($additionalClasses != '') {
        return "<div$additionalClasses>$formString</div>";
    return $formString;
  3. $this->misamee_themed_form_setTemplate():

    private function misamee_themed_form_setTemplate($themeName, $formId)
    $theme = $this->misamee_themed_form_getThemeByName($themeName);
    //echo "<pre>";
    if (strtolower($theme['name']) != "none") {
        if ($theme['name'] == 'default') {
            wp_enqueue_style('misamee-themed-form-css', $theme['url'] . 'css/misamee.themed.form.css');
            wp_enqueue_script('tooltipsy', $theme['url'] . 'js/tooltipsy.source.js', array('jquery'));
            wp_enqueue_script('misamee-themed-form-js', $theme['url'] . 'js/misamee.themed.form.js', array('jquery'));
        } elseif (is_dir($theme['dir'])) {
            //get all files in specified directory
            $files = glob($theme['dir'] . "/*.*");
            foreach ($files as $file) {
                $fileData = pathinfo($file);
                switch ($fileData['extension']) {
                    case 'css':
                        wp_enqueue_style($fileData['filename'], $theme['url'] . $fileData['basename']);
                        //echo "wp_enqueue_style('$fileData[filename]', '$theme[url]$fileData[basename]')\n";
                    case 'js':
                        wp_enqueue_script($fileData['filename'], $theme['url'] . $fileData['basename']);
                        //echo "wp_enqueue_script('$fileData[filename]', '$theme[url]$fileData[basename]')\n";
                    case 'php':
                        include($theme['dir'] . '/' . $fileData['basename']);
                        //echo "include($theme[dir]/$fileData[basename])\n";
        add_action("gform_field_css_class", array(&$this, "add_custom_class"), 10, 3);
    return $theme;

It works, at least with the default theme, but with Thesis, this php file doesn't seem to work. It doesn't raise any error: simply id doesn't do anything.

If I add a echo 'OK'; in this file, I can see the "OK" string in the HTML, but enqueuing doesn't work. With other themes my code works though, so I can't see how to solve this issue.

I've tried any other option, including hooking the three lines to 'wp_print_footer_scripts', 'wp_print_scripts', 'wp_enqueue_scripts', 'init' (I know I should user wp_print_* or init hooks, but desperate times, desperate measures): nothing helped.

Right now the only way to "make it work" seem to replace the wp_enqueue_* function with straight rendering of the '<script ...>' and '<link ...>' tags: something I really don't like.

1 Answer 1


Well, I've just realized that my client's theme was a custom version of Thesis with an incomprehensibly commented wp_footer(): as soon as I've uncommented it, the issue (obviously) disappeared.

  • Comment everything! I once inherited a theme with no wp_footer() in footer.php. Took hours to figure out why nothing worked. Jun 25, 2013 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.