Skip to content

Instantly share code, notes, and snippets.

View q2amarket's full-sized avatar

Q2A Market q2amarket

View GitHub Profile
@q2amarket
q2amarket / q2am-question-excerpt.php
Last active July 26, 2018 14:41
Question2Answer: Get excerpt of the question to display on the question list. Make sure your q2a function should get post id in array otherwise this code won't work.
<?php
$pid = $q_item['raw']['postid'];
$query = qa_db_query_sub("SELECT postid, content, format FROM ^posts WHERE postid = $pid");
$cont = qa_db_read_one_assoc($query);
$blockwordspreg = qa_get_block_words_preg();
$text=qa_viewer_text($cont['content'], $cont['format'], array('blockwordspreg' => $blockwordspreg));
$text=qa_shorten_string_line(qa_html($text), 200); //200 is the length
@q2amarket
q2amarket / q2am-block-category.php
Last active January 2, 2016 05:39
Override main() function to display question view page content only for looged in user for defined category. If condition fails than we will throw error message and provide login link to user for better usability.
<?php
/*
* Q2A Market Block Category Content for Loggedin user
*
*
* @author Q2A Market
* @category Hook
* @Version: 1.00
* @author URL: http://www.q2amarket.com
*
@q2amarket
q2amarket / q2am-hook-hide-meta-who.php
Created January 10, 2014 15:36
Hide meta who hook will allows to hide question who meta from everywhere or for the template you specify. For more details read usage in cooment.
<?php
/*
* hook: hide meta who from questions
*
* hook by: Q2A Market
* author: Jatin Soni
* url: http://www.q2amarket.com
*
* usage:
* Place below code into your theme or plugin layer
@q2amarket
q2amarket / q2am-hook-hide-meta-who-mod.php
Last active January 3, 2016 03:59
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:
@q2amarket
q2amarket / q2am-block-direct-access.php
Created January 13, 2014 19:31
This core hook will allows to throw 404 error if user is trying to direct access the page which menu item is hidden (not active) in Admin > pages
<?php
/*
* hook: 404 for non visible menu
*
* hook by: Q2A Market
* hook type: core
* author: Jatin Soni
* url: http://www.q2amarket.com
* version: 1.00
*
<?php
/*
* These functions will goes to your qa-plugin.php
*/
//registering plugin stuffs
qa_register_plugin_layer('q2am-item-output.php', 'Q2AM Item Layer');
qa_register_plugin_module('page', 'q2am-item-page.php', 'q2am_item_page', 'Q2AM Item Page');
qa_register_plugin_module('module', 'q2am-item-admin.php', 'q2am_item_admin', 'Q2AM Item Settings');
qa_register_plugin_phrases('q2am-Item-lang.php', 'q2am_item_lang');
@q2amarket
q2amarket / body-class-custom-add.php
Last active August 29, 2015 13:57
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:
@q2amarket
q2amarket / q2am-add-readmore-to-question-view.php
Last active August 29, 2015 13:58
The hook will allows to limiting display long characters (as defined in condition) for Question view and will add `read more` link. It will expand all question content when click on read more link.
<?
/*
* hook: Add read more link to the question view q-content
*
* hook by: Q2A Market
* author: Jatin Soni
* url: http://www.q2amarket.com
* version: 1.00
*
* Description:
@q2amarket
q2amarket / qa_list_q_thumb.php
Last active August 29, 2015 14:16
The function will add first image from the question content to the questions list
<?php
/**
* Add first image to the question list
*
* Declearation
* Base code is taken from Mouseover Layer plugin
*
* Than I have extracted content using preg_match_all to get first image
* and assing that to the q_list
*
@q2amarket
q2amarket / output_split.php
Created September 18, 2015 05:01
Remove + sign from upvote
<?php
/**
* The hook allows to remove + sing from upvote count
*
* How to use it:
* Nothing complicated, just place 'output_split' method into your theme file or plugin layer and done.
*
* Important:
* Make sure your theme should not have this function already. If there is than add this code