Skip to content

Instantly share code, notes, and snippets.

View zainaali's full-sized avatar

Zain Ali zainaali

  • Lahore Punjab, Pakistan
View GitHub Profile
@zainaali
zainaali / functions.php
Created September 27, 2018 10:26
Function for customize default design of comment template
//Function for customize default design of comment template
function glowlogix_comment($comment, $args, $depth) {
if ( 'div' === $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
@zainaali
zainaali / functions.php
Created September 27, 2018 10:29
Create post comment button and remove default post comment button
// create post comment button
function glowlogix_comment_button() {
echo '<input name="submit" type="submit" class="btn margin-top-20" value="Send">';
}
add_action( 'comment_form', 'glowlogix_comment_button' );
For remove default button add "display: none" property in your style.css file
@zainaali
zainaali / functions.php
Created September 27, 2018 10:30
Customize message field of comment form wordpress
function glowlogix_comment_field($comment_field){
$comment_field =
'<li class="col-sm-12">
<textarea required placeholder="MESSAGE" class="form-control" name="comment" aria-required="true"></textarea>
</li>';
return $comment_field;
}
add_filter('comment_form_field_comment', 'glowlogix_comment_field');
@zainaali
zainaali / comments.php
Created September 27, 2018 10:33
Add class and placeholder to name and email field of Wordpress comment template
$fields = array(
'author' => '<ul class="row"><li class="col-sm-6"><label>' . '<input class="form-control" id="author" name="author" type="text" placeholder="' . esc_attr__( "Name", "text-domain" ) . '" value="' . esc_attr( $commenter['comment_author'] ) . '" size=""' . $aria_req . ' /></label></li>',
'email' => '<li class="col-sm-6"><label>' . '<input class="form-control" name="email" type="text" placeholder="' . esc_attr__( "Email", "text-domain" ) . '" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size=""' . $aria_req . ' /></label></li>',
);
comment_form(array('fields'=>$fields));
@zainaali
zainaali / functions.php
Created September 28, 2018 04:35 — forked from musamamasood/functions.php
Shortcode to fetch post by post_type
// create shortcode to list all clothes which come in blue
function statesmen_news_shortcode( $atts ) {
$html = '';
// Attributes
$atts = shortcode_atts(
array(
'post_per_page' => '2',
'post_type' => 'post',
'id' => false
),
@zainaali
zainaali / functions.php
Created September 28, 2018 04:36 — forked from musamamasood/functions.php
Method to set order status failed or completed based on Stripe 3D.
add_action( 'wc_gateway_stripe_process_response', 'prefix_wc_gateway_stripe_process_response', 20, 2 );
function prefix_wc_gateway_stripe_process_response( $response, $order ){
if($response->source->type == 'three_d_secure'){
$order->update_status('completed', 'order_note'); ####
//WC_Stripe_Logger::log( 'wc_gateway_stripe_process_response three_d_secure response: ' . print_r( $response->source->type, true ) );
}elseif($response->source->type == 'card'){
$order->update_status('failed', 'order_note'); ####
//WC_Stripe_Logger::log( 'wc_gateway_stripe_process_response card response: ' . print_r( $response->source->type, true ) );
}
}
@zainaali
zainaali / functions.php
Created September 28, 2018 08:22
Redirect page after order is placed based on order status Woocommerce
add_action( 'woocommerce_thankyou', 'bbloomer_redirectcustom');
function bbloomer_redirectcustom( $order_id ){
$order = new WC_Order( $order_id );
$url = 'https://siteurl/thank-you-payment/'; //Thank you page
$mem_url = 'https://siteurl/payment-denied/'; // denied page
if ( $order->status == 'pending' ) {
wp_redirect($mem_url);
}
else{
@zainaali
zainaali / api.php
Created October 7, 2018 20:20
Get lat, lng, address, and square feet from zilow api curl php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://www.zillow.com/webservice/GetDeepSearchResults.htm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
@zainaali
zainaali / location.php
Last active October 13, 2018 13:52
Detect a Visitor's Country by his IP Address PHP
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$url = "http://api.wipmania.com/".$ip;
$country = file_get_contents($url);
echo $country;
@zainaali
zainaali / prefix.html
Last active October 15, 2018 10:20
change Phone prefix on basis of country jQuery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<select name="select1" id="select1">
<option country-code="pk" value="Pakistan">Pakistan</option>
<option country-code="in" value="India">India</option>
<option country-code="us" value="Usa">USA</option>
<option country-code="uk" value="Uk">United Kingdom</option>
<option country-code="fr" value="France">France</option>
<option country-code="gr" value="Germny">Germny</option>
<option country-code="it" value="Italy">Italy</option>
<option country-code="ch" value="China">China</option>