How Can I Add PHP to the Ultimate Branding Header Content?

Dear Team WPMU:

Okay, here's the deal:

I'm using a plugin called "Shortcode Exec PHP" to transform snippets of php into shortcode.

So, for example, I've created a shortcode called [search_form_global] that uses a php include command to pull in the local search field.

You can see the shortcode in action on the following page:

http://www.aur.edu/xyz2/

Password: searchTest

In essence, this shows that the shortcode works.

Now, when I try to put this shortcode in the Ultimate Branding Header content, it does not pull in the search form, but instead shows the shortcode text: "[search_form_global]"

So my questions are:

A. Is there a way to activate short code that is embedded in the Ultimate Branding Header Content box?

B. If not, how can I embed php code?

C. If neither, then how can I "widgetize" the Header Content area so that I can add a search widget.

I look forward to your reply. Many thanks for your help!

Cheers,

Tim

  • Jack Kitterhing

    Hi there Tim,

    Hope you're well today! :slight_smile:

    Just to confirm, the code there is for the front-end, or was you looking for admin side?

    WordPress have a excellent API for this and of course we're here to help http://codex.wordpress.org/Dashboard_Widgets_API

    Or if you are looking for front-end content, do all your sites use the same theme? If they do we can just modify the header.php of the theme.

    Please advise.

    Thanks!

    Kind Regards
    Jack.

  • Hypergolica

    Hi Jack,

    Just to confirm, the code there is for the front-end, or were you looking for admin side?

    I'm not sure I understand the question, but, the goal is to add a "search field" to the Ultimate Branding Header Content. (See attached screenshot.)

    Since I'm only allowed a box similar to a post/page, I thought I could use the shortcode trick... but that doesn't seem to work.

    The main site--www.aur.edu--uses one theme, while the rest of the subsites use a different one.

    I hope that helps. Please advise.

    Cheers,

    Tim

  • Hypergolica

    Dear All,

    I figured out a way to "hack the system," so I thought I'd share:

    1. Download the Ultimate Branding plugin folder.

    2. Open the file modules > "global-header-content.php"

    3. On line 137 the code reads:

    if ( !empty( $global_header_content ) ) {
    
    			// original:
    			//echo stripslashes( $global_header_content );
    			// tim code:
    			include ('wp-content/themes/xtheme/searchform-global.php');
    
    		}

    4. The above code shows you where I commented out the line "echo stripslashes" (which thus ignores whatever content you've put in the "header content" section via the admin) and then, after, I added an include command.

    5. I created the file "searchform-global.php" and put in that file whatever I want to appear in the global header. In this case, I have links + a search box. You can see the result here:

    http://www.aur.edu/

    Of course, if you do this, anytime the Ultimate Branding plugin is updated it will over-write the custom file, so be sure to save a copy of this change to your local machine.

    Cheers,

    Tim