Skip to content

Instantly share code, notes, and snippets.

/*-----------------------------------------------------------------------------------*/
/* Question Actions
/*-----------------------------------------------------------------------------------*/
add_filter('dwqa_filter_bar','custom_dwqa_question_filter');
function custom_dwqa_question_filter( $tag_field ) {
ob_start();
?>
<div class="filter-by-tags select">
<?php
$selected = get_query_var( 'dwqa-question_tag');
@rambuvn
rambuvn / rb_eta.php
Created February 13, 2014 07:40
Estimate Reading Time For Wordpress
/** Estimate Reading Time
*----------------*/
if( !function_exists('rb_timeline_eta') ) {
function rb_timeline_eta(){
global $post;
$words_per_minute = 270;
$words_per_second = $words_per_minute / 60;
$post_content = $post->post_content;
$word_count = str_word_count(strip_tags($post_content));
@rambuvn
rambuvn / experts.php
Created February 18, 2014 04:43
Experts list style like Designwall
<?php
/**
* Template Name: Experts List
*/
get_header(); ?>
<div id="content">
<?php while ( have_posts() ) : the_post(); ?>
<article <?php post_class(); ?>>
<header class="page-header">
<h1 class="page-title"><?php the_title(); ?></h1>
@rambuvn
rambuvn / content-end-wrapper.php
Created February 28, 2014 10:14
Show sidebar of DW QA
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
global $dwqa_options;
if( ( $dwqa_options['pages']['archive-question'] && is_page( $dwqa_options['pages']['archive-question'] ) ) || is_archive() ) { ?>
</div>
<div id="secondary">
<?php if (is_user_logged_in()) : ?>
<?php dwqa_get_ask_question_link( true, false, 'btn btn-block btn-success' ); ?>
<?php else : ?>
<a data-toggle="modal" class="open-login-modal btn btn-block btn-success" data-referer="http://www.designwall.com/ask-question/" href="#loginModal" alt="signin-tab">Login to Ask question</a>
@rambuvn
rambuvn / dwqa-submit-question-form-2.php
Created March 18, 2014 10:04
The shortcode for show question of one category
<?php
function dwqa_submit_question_form_varius_category_shortcode($atts){
global $dwqa_sript_vars, $script_version;
extract( shortcode_atts( array(
'category' => 0
), $atts ) );
if( ! $category ) {
@rambuvn
rambuvn / gist:11311568
Last active August 29, 2015 14:00
dwqa submit question page
<?php get_header('dwqa'); ?>
<?php do_action( 'dwqa_before_page' ) ?>
<div id="submit-question" class="dwqa-submit-question">
<?php
global $dwqa_options, $dwqa_current_error;
if( is_wp_error( $dwqa_current_error ) ) {
<?php get_header('dwqa'); ?>
<?php do_action( 'dwqa_before_page' ) ?>
<?php if (is_user_logged_in()) : ?>
<div id="submit-question" class="dwqa-submit-question">
<?php
global $dwqa_options, $dwqa_current_error;
if( is_wp_error( $dwqa_current_error ) ) {
$error_messages = $dwqa_current_error->get_error_messages();
@rambuvn
rambuvn / gist:2650827
Created May 10, 2012 03:20
Time stamp ago function like facebook comment, post,...
function time_stamp($from){
$cmt_date = $from;
$from = strtotime($from);
if ( empty($to) )
$to = time();
$diff = (int) abs($to - $from);
if($diff <= 1){
$since = '1 second';
} else if($diff <= 60 ){
$since = sprintf(_n('%s second', '%s seconds', $diff), $diff);
@rambuvn
rambuvn / gist:2650837
Created May 10, 2012 03:23
set cursor to end point when focus or change value of input text field
function SetEnd(txt) {
if (txt.createTextRange) {
//IE
var FieldRange = txt.createTextRange();
FieldRange.moveStart('character', txt.value.length);
FieldRange.collapse();
FieldRange.select();
}
else {
//Firefox and Opera
@rambuvn
rambuvn / gist:2761421
Created May 21, 2012 09:12
Checking password complexity This regular expression will tests if the input consists of 6 or more letters, digits, underscores and hyphens. The input must contain at least one upper case letter, one lower case letter and one digit.
$password_regular = 'A(?=[-_a-zA-Z0-9]*?[A-Z])(?=[-_a-zA-Z0-9]*?[a-z])(?=[-_a-zA-Z0-9]*?[0-9])[-_a-zA-Z0-9]{6,}z'