Skip to content

Instantly share code, notes, and snippets.

@q2amarket
Last active January 3, 2016 03:59
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/8405467 to your computer and use it in GitHub Desktop.
Save q2amarket/8405467 to your computer and use it in GitHub Desktop.
Hide who meta from the question page. Display who meta if question, answer or comment is in moderation queue. It will be visible to moderator and higher level user.
<?php
/*
* hook: hide meta who
*
* hook by: Q2A Market
* author: Jatin Soni
* url: http://www.q2amarket.com
* version: 1.01
*
* Description:
* Hide who meta from the question page.
* display who meta if question, answer or comment
* is in moderation queue. It will be visible to
* moderator and higher level user
*
* usage:
* Place below code into your theme or plugin layer
* if you want to hide from everywhere than just use
*
* function post_meta_who($post, $class){}
*
* if you want to display on particular template
* than load base method conditionally. In this case
* I have set for 'question' (question view 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 show wometa to only moderator and above use below
function post_meta_who($post, $class)
{
$type = $post['raw']['type'];
$level = qa_get_logged_in_level();
$type_array = array('Q_QUEUED', 'A_QUEUED', 'C_QUEUED');
if($this->template == 'question' || (in_array($type, $type_array) && $level >= QA_USER_LEVEL_MODERATOR))
qa_html_theme_base::post_meta_who($post, $class);
}
// to show wometa to only admin and above use below
function post_meta_who($post, $class)
{
$type = $post['raw']['type'];
$level = qa_get_logged_in_level();
$type_array = array('Q_QUEUED', 'A_QUEUED', 'C_QUEUED');
if($this->template == 'question' || (in_array($type, $type_array) && $level >= QA_USER_LEVEL_ADMIN))
qa_html_theme_base::post_meta_who($post, $class);
}
// to hide who meta from everyone except admin and above
// from everywhere Question, Answer, Comment etc..
// in all mode, moderation and published
function post_meta_who($post, $class)
{
/*
uncomment below line if you want to
perform check by type
*/
// $type = @$post['raw']['type'];
$level = qa_get_logged_in_level();
if(qa_is_logged_in() && $level >= QA_USER_LEVEL_ADMIN)
qa_html_theme_base::post_meta_who($post, $class);
}
<?php
/*
* hook: hide meta who 1 and 2
*
* hook by: Q2A Market
* author: Jatin Soni
* url: http://www.q2amarket.com
* version: 1.01
*
* Description:
* Hide who meta from everywhere.
* this hook will hide who meta 1
* and who meta 2 as well.
* means hide for added and edited both
*
* usage:
* Place below code into your theme or plugin layer
* if you want to hide from everywhere than just use
*
* function post_meta_who($post, $class){}
*
* if you want to display on particular template
* than add $this->template == 'your-template' within
* the condition
*
* 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.
*/
function post_meta($post, $class, $prefix = null, $separator = '<br/>')
{
$level = qa_get_logged_in_level();
$this->output('<span class="' . $class . '-meta">');
if (isset($prefix))
$this->output($prefix);
$order = explode('^', @$post['meta_order']);
foreach ($order as $element)
switch ($element)
{
case 'what':
$this->post_meta_what($post, $class);
break;
case 'when':
$this->post_meta_when($post, $class);
break;
case 'where':
$this->post_meta_where($post, $class);
break;
case 'who':
if (qa_is_logged_in() && $level >= QA_USER_LEVEL_ADMIN)
$this->post_meta_who($post, $class);
break;
}
$this->post_meta_flags($post, $class);
if (!empty($post['what_2']))
{
$this->output($separator);
foreach ($order as $element)
switch ($element)
{
case 'what':
$this->output('<span class="' . $class . '-what">' . $post['what_2'] . '</span>');
break;
case 'when':
$this->output_split(@$post['when_2'], $class . '-when');
break;
case 'who':
if (qa_is_logged_in() && $level >= QA_USER_LEVEL_ADMIN)
$this->output_split(@$post['who_2'], $class . '-who');
break;
}
}
$this->output('</span>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment