Skip to content

Instantly share code, notes, and snippets.

View developer-anuragsingh's full-sized avatar

Anurag Singh developer-anuragsingh

  • Cendyn
  • Gurugram
View GitHub Profile
@developer-anuragsingh
developer-anuragsingh / get-content-by-curl.php
Last active December 13, 2019 13:10
How to use Curl in php
<?php
// ref - http://codular.com/curl-with-php
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://localhost/wp/r&d/wp-json/wp/v2/posts/375',
CURLOPT_USERAGENT => 'Codular Sample cURL Request'
));
@developer-anuragsingh
developer-anuragsingh / Imp Hooks - Jquery
Created June 8, 2017 06:42
Some Important and very often used jquery funtions
// Find and Replace whole word with new one
// Would replace the word egg, as a word boundary. So should replace egg but not eggplant.
jQuery("span").text(function () {
return jQuery(this).text().replace(/\bContactta drd\b/, "Home");
});
// Remove Height and Width parameters from the_post_thumbnail function
add_filter('post_thumbnail_html', 'remove_thumbnail_dimensions', 10);
add_filter('image_send_to_editor', 'remove_thumbnail_dimensions', 10);
function remove_thumbnail_dimensions($html)
{
$html = preg_replace('/(width|height)=\"\d*\"\s/', "", $html);
return $html;
}
/**
@developer-anuragsingh
developer-anuragsingh / as-comment-at-bottom.php
Created August 4, 2017 07:32
Move comment box in bottom of the form
// Move comment box in bottom of the form
function wpb_move_comment_field_to_bottom( $fields ) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
return $fields;
}
add_filter( 'comment_form_fields', 'wpb_move_comment_field_to_bottom' );
@developer-anuragsingh
developer-anuragsingh / change-woocommerce-product-review-login-link.php
Created August 4, 2017 11:55
Change login link for Woocommerce product review's "Login" link
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
// Move comment box in bottom of the form
function wpb_move_comment_field_to_bottom( $fields ) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
return $fields;
}
add_filter( 'comment_form_fields', 'wpb_move_comment_field_to_bottom' );
@developer-anuragsingh
developer-anuragsingh / Run Git shell script file
Created August 11, 2017 05:04
Create a clone repository with new folder and file name
// ref - https://stackoverflow.com/questions/26522789/how-to-run-sh-on-windows-command-prompt
- open "Git Bash
- navigate to desitination drive, ie - cd f:
- navigate to desitination directory, ie - cd foldername/sub-folder/..
- download github repository to destination folder
- run "shell script" file, ie - bash build-plugin.sh
- thats it