Skip to content

Instantly share code, notes, and snippets.

@q2amarket
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save q2amarket/9680759 to your computer and use it in GitHub Desktop.
Save q2amarket/9680759 to your computer and use it in GitHub Desktop.
The hook will replace custom page name as body class instead of 'custom'
<?php
/*
* hook: page name as a body class
*
* hook by: Q2A Market
* author: Jatin Soni
* url: http://www.q2amarket.com
* version: 1.00
*
* Description:
* The hook will add custom page name
* as body class instead of 'custom'
*
* usage:
* Place below code into your theme or plugin layer
*
* function body_tags(){}
*
* There are two versions for this hook
*
* First:
* You can replace 'qa-template-custom' with
* the page name `qa-template-my-page
*
* Second:
* This will add aditinal class to the body tag
* <body class="qa-template-custom my-page">
*
* Disclaimer:
* This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*/
// To add aditional class for the custom page
// <body class="qa-template-custom my-page">
function body_tags()
{
$class = 'qa-template-' . qa_html($this->template);
if($this->template == 'custom')
$class.=' ' . qa_request();
if (isset($this->content['categoryids']))
foreach ($this->content['categoryids'] as $categoryid)
$class.=' qa-category-' . qa_html($categoryid);
$this->output('class="' . $class . ' qa-body-js-off"');
}
<?php
/*
* hook: page name as a body class
*
* hook by: Q2A Market
* author: Jatin Soni
* url: http://www.q2amarket.com
* version: 1.00
*
* Description:
* The hook will add custom page name
* as body class instead of 'custom'
*
* usage:
* Place below code into your theme or plugin layer
*
* function body_tags(){}
*
* There are two versions for this hook
*
* First:
* You can replace 'qa-template-custom' with
* the page name `qa-template-my-page
*
* Second:
* This will add aditinal class to the body tag
* <body class="qa-template-custom my-page">
*
* Disclaimer:
* This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*/
// To replace qa-template-custom to qa-template-my-page
function body_tags()
{
$class = (($this->template == 'custom') ? 'qa-template-' . qa_request() : 'qa-template-' . qa_html($this->template));
if (isset($this->content['categoryids']))
foreach ($this->content['categoryids'] as $categoryid)
$class.=' qa-category-' . qa_html($categoryid);
$this->output('class="' . $class . ' qa-body-js-off"');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment