DEV Community

Cover image for Why Testing Our WordPress Plugin on One Website Wasn’t Enough
Webequipe
Webequipe

Posted on

Why Testing Our WordPress Plugin on One Website Wasn’t Enough

When we first tested our WordPress PDF search plugin, everything worked as expected.

We installed it on a clean WordPress website, added the search form using a shortcode, uploaded several PDFs, and tested the full process.

The form looked good.

The search button worked.

The results appeared correctly.

From our side, the feature looked ready.

Then we tested the plugin on another WordPress website using the Avada theme.

The search form appeared, but the layout was broken. The search button moved below the input field, some styles were overwritten, and in certain layouts the form width became much smaller than expected.

The plugin was working, but it did not feel like a working product.

That was when we learned an important lesson:

A WordPress plugin is not really tested until it has been tested outside the environment where it was developed.

The Issue We Found

Our PDF search form was added using a shortcode.

A website administrator could place something like this on any page:
[webequipe_pdf_search_form]
The shortcode generated a simple search form with:

A search input
A search button
A results container

On our test website, the input and button appeared in one row.

But on the Avada website, the theme’s global form styles affected our plugin.

Avada already included CSS rules for form inputs, buttons, containers, and responsive layouts. Some of those styles were more specific than our plugin styles, so the theme rules took priority.
The result looked something like this:

The input inherited an unexpected height
The button received theme padding
The button width changed
The form container inherited a maximum width
Mobile styles were triggered earlier than expected

This was not a PHP error or a fatal WordPress error.

It was a compatibility issue.

And from a customer’s point of view, a broken layout is still a plugin problem.

The Biggest Mistake in Our Code

Our original CSS was too general.

We used selectors like this:

.pdf-search-form { 
  display: flex; 
  gap: 10px; 
} 
.pdf-search-form input { 
  width: 100%; 
  padding: 12px; 
} 
.pdf-search-form button { 
  padding: 12px 20px; 
}
Enter fullscreen mode Exit fullscreen mode

This worked on a basic WordPress theme.

But it created two problems.

First, the class name was not specific enough. Another theme or plugin could use a similar class name.

Second, our selectors were weaker than some theme selectors.

A theme might use a rule like:

.fusion-body .post-content input[type="search"] {
   height: 50px; 
   border-radius: 0; 
}
Enter fullscreen mode Exit fullscreen mode

Because that selector was more specific, it could override our plugin styling.

Our code was not technically incorrect.

But it assumed that the plugin would control the page styling.

In WordPress, that assumption is risky.

How We Investigated the Problem

At first, we checked whether the shortcode output was different.

It was not.

The same HTML was generated on both websites.

Then we checked whether JavaScript was failing.

There were no console errors.

Next, we inspected the form using the browser developer tools.

That showed us the real issue.

Several styles were coming from the Avada theme instead of our plugin stylesheet.

We tested the same plugin with a default WordPress theme, and the form worked correctly again.

That confirmed that the problem was not the shortcode or search logic. It was the CSS interaction between the plugin and the theme.

How We Fixed It

We updated the plugin to use a unique wrapper class.

Instead of relying only on a general form class, we wrapped the full shortcode output inside a plugin-specific container.

function webequipe_render_pdf_search_form() {
    ob_start();
    ?>
    <div class="webequipe-pdf-search">
        <form class="webequipe-pdf-search__form" method="get">
            <input
                type="search"
                name="pdf_search"
                class="webequipe-pdf-search__input"
                placeholder="Search PDFs..."
            >

            <button
                type="submit"
                class="webequipe-pdf-search__button"
            >
                Search
            </button>
        </form>

        <div class="webequipe-pdf-search__results"></div>
    </div>
    <?php

    return ob_get_clean();
}

add_shortcode(
    'webequipe_pdf_search_form',
    'webequipe_render_pdf_search_form'
);
Enter fullscreen mode Exit fullscreen mode

Then we updated the CSS to target only elements inside our plugin.

.webequipe-pdf-search {
    width: 100%;
    max-width: 100%;
}

.webequipe-pdf-search .webequipe-pdf-search__form {
    display: flex;
    align-items: stretch;
    width: 100%;
    gap: 10px;
    margin: 0;
}

.webequipe-pdf-search .webequipe-pdf-search__input {
    flex: 1;
    width: auto;
    min-width: 0;
    height: 48px;
    margin: 0;
    padding: 10px 14px;
    box-sizing: border-box;
}

.webequipe-pdf-search .webequipe-pdf-search__button {
    width: auto;
    min-width: 110px;
    height: 48px;
    margin: 0;
    padding: 10px 18px;
    box-sizing: border-box;
    cursor: pointer;
}

@media screen and (max-width: 600px) {
    .webequipe-pdf-search .webequipe-pdf-search__form {
        flex-direction: column;
    }

    .webequipe-pdf-search .webequipe-pdf-search__button {
        width: 100%;
    }
}
Enter fullscreen mode Exit fullscreen mode

This made the styles more specific without depending on Avada itself.

We did not add code such as:

.avada-theme .pdf-search-form {
    /* Avada-specific fix */
}
Enter fullscreen mode Exit fullscreen mode

That would have solved only one theme problem.
Instead, we improved the plugin’s own CSS structure so it would be safer across many themes.

We Also Changed How the Styles Were Loaded

Previously, the stylesheet was loaded everywhere.

We improved this by loading the required assets when the shortcode was used.

function webequipe_pdf_search_shortcode() {
    wp_enqueue_style(
        'webequipe-pdf-search',
        plugin_dir_url(__FILE__) . 'assets/css/pdf-search.css',
        array(),
        '1.0.1'
    );

    return webequipe_render_pdf_search_form();
}

add_shortcode(
    'webequipe_pdf_search_form',
    'webequipe_pdf_search_shortcode'
);
Enter fullscreen mode Exit fullscreen mode

This helped us keep the plugin assets connected to the feature that needed them.

It also reduced the chance of unnecessary styles affecting other parts of the website.

How We Tested the Fix

After updating the code, we did not test it only on the same development website.

We checked the shortcode on:

A clean WordPress installation
A website using Avada
A website using Elementor
A default WordPress block theme
Desktop, tablet, and mobile screen sizes
Pages with narrow and full-width containers

We also tested the form inside different page sections.

That was important because the same theme can behave differently depending on whether the shortcode is placed inside a full-width section, column, widget area, or normal content area.

What We Learned

The biggest lesson was not that Avada caused a problem.

Avada was doing what a WordPress theme normally does: applying consistent styles across the website.

The real issue was that our plugin was not isolated enough from the surrounding website.

We learned a few important things from this:

Use unique names

Plugin classes, CSS selectors, functions, hooks, and database keys should use a unique prefix.

A general name may work today but conflict with another theme or plugin later.

Test inside real page builders

A shortcode should not only be tested inside the standard WordPress editor.

It should also be tested inside popular themes and page builders where users are likely to place it.

Do not test only functionality

The search feature technically worked on the Avada website.

But the layout problem still affected the customer experience.

Plugin QA should include both functionality and visual behaviour.

Avoid theme-specific fixes when possible

Adding separate fixes for every theme can become difficult to maintain.

It is usually better to strengthen the plugin’s own structure first.

One WordPress website is only one environment

A successful test on one website does not prove that a plugin is ready for every WordPress website.

Each site may have a different theme, page builder, CSS structure, plugin combination, PHP version, and hosting setup.

Final Thought

WebEquipe PDF Search did not fail because its PDF indexing or search logic was broken.

The issue appeared because we had tested the search form in an environment that was too controlled. Once we placed the same shortcode on a website using the Avada theme, we saw how easily theme styles could affect the plugin’s layout.

This experience changed how we test WebEquipe PDF Search.

We now understand that building a WordPress plugin is not only about making its main feature work. It is also about making sure that feature continues to work across themes, page builders, screen sizes, and website configurations we do not control.

A successful test on our development website is no longer the end of QA.

For WebEquipe PDF Search, it is only the beginning.

Top comments (0)