Skip to content

Instantly share code, notes, and snippets.

Avatar

Q2A Market q2amarket

View GitHub Profile
@q2amarket
q2amarket / README.md
Last active Feb 14, 2018
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
View README.md

#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

View q2amarket-plugin-path-and-url.php
<?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 Sep 18, 2015
Remove + sign from upvote
View output_split.php
<?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 Aug 29, 2015
The function will add first image from the question content to the questions list
View qa_list_q_thumb.php
<?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 Aug 29, 2015
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.
View q2am-add-readmore-to-question-view.php
<?
/*
* 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 Aug 29, 2015
The hook will replace custom page name as body class instead of 'custom'
View body-class-custom-add.php
<?php
/*
* hook: page name as a body class
*
* hook by: Q2A Market
* author: Jatin Soni
* url: http://www.q2amarket.com
* version: 1.00
*
* Description:
View q2am-check-if-class-exists.php
<?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 Jan 13, 2014
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
View q2am-block-direct-access.php
<?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 Jan 3, 2016
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.
View q2am-hook-hide-meta-who-mod.php
<?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 Jan 10, 2014
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.
View q2am-hook-hide-meta-who.php
<?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