Skip to content

Instantly share code, notes, and snippets.

View q2amarket's full-sized avatar

Q2A Market q2amarket

View GitHub Profile
@q2amarket
q2amarket / README.md
Last active February 14, 2018 06:16
This code will allows to create custom page without creating a page in admin > page area. This will create automatically and doesn't require any page creation in plugin section too. Replace your-page to what you like

#Create Page With Plugin

This code will allows you to create page without adding page in Admin > Pages area. This page can be set as a home page by defining constant path in qa-config.php. Also you can create menu link by adding page request (page slug e.g. your-page).

##Usage

  • Create directory in qa-plugin. for example: your-site/qa-plugin/your-page
  • Place qa-plugin.php and your-page.php file in your-page directory you created in above step

###Optional To make page as a home page

@q2amarket
q2amarket / q2amarket-plugin-path-and-url.php
Created March 28, 2016 12:00
Get plugin path and url
<?php
/**
* To set pluign path I used below
*
* Since my core class is in sub-directory of plugin, I had to point upward to get root directory
*/
define( 'Q2AM_DIR', q2am_trailingslash_dir( realpath( __DIR__ . '/../..' ) ) );
/*
@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
@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 / 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 / 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:
<?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 / 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
*
@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-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