Skip to content

Instantly share code, notes, and snippets.

View rahularyan's full-sized avatar
🏠
Working from home

Rahul Arya rahularyan

🏠
Working from home
View GitHub Profile
@rahularyan
rahularyan / pre-commit
Created October 1, 2018 14:40
Auto increment version number using git-hook on commit
#!/bin/sh
MESSAGE="$1"
VERSION_PATH=`git rev-parse --show-toplevel`"/style.css"
VER_TOKEN="Version:"
VER_STR=$(grep "$VER_TOKEN" $VERSION_PATH | awk '{print $2}' | tr -d '"')
VER_MAJ=$(echo $VER_STR | awk -F. '{print $1}')
VER_MIN=$(echo $VER_STR | awk -F. '{print $2}')
@rahularyan
rahularyan / 00.howto_install_phantomjs.md
Last active February 7, 2024 02:47 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 2.1.1

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@rahularyan
rahularyan / override-ask-form.php
Created October 24, 2017 01:45
Add custom fields to AnsPress ask form.
<?php
/**
* Add custom fields to AnsPress question form.
*
* This hook will add two new fields in ask form.
*
* @param array $form Form arguments.
* @return void
*/
function my_custom_question_field( $form ) {
@rahularyan
rahularyan / functions.php
Created February 17, 2021 18:05
Allow question title to be more than 100 characters
<?php
/**
* This hook will make question title to be more than 100 characters.
*
* @param array $form Form arguments.
* @return array
*/
function my_ap_make_question_description_optional( $form ) {
$validate = $form['fields']['post_title']['validate'];
<?php
/**
* Override AnsPress form category field selection list.
*
* @param mixed $form
* @return mixed
*/
function anspress_override_category_field( $form ){
$form['fields']['category'] = array(
'label' => __( 'Category', 'anspress-question-answer' ),
@rahularyan
rahularyan / featured_image.php
Created October 28, 2015 02:13
Add featured image support in AnsPress question
@rahularyan
rahularyan / anspress-top-users.php
Last active September 11, 2018 14:14
AnsPress - top users widget
<?php
/**
* Top users widget class
*
* Shows top users by reputation
*
* @link http://anspress.io
* @since 1.01
*
* @package AskBug
@rahularyan
rahularyan / rest-questions.php
Created April 25, 2018 04:04
Get AnsPress questions using WP REST api
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* The version 1 endpoint for AnsPress questions.
*/
<?php
/**
* Hook to filter comments form.
*
* @param array $form Comment form
*/
add_filter( 'ap_comment_form_fields', function( $form ) {
$form['fields']['content']['min_length'] = 1;
return $form;
@rahularyan
rahularyan / functions.php
Created February 13, 2018 02:35
AnsPress: output custom questions list
<?php
$args = array(
'post__in' => [ 1, 2, 3 ];
);
anspress()->questions = new Question_Query( $args );
ap_get_template_part( 'archive' );