Skip to content

Instantly share code, notes, and snippets.

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

Ronak J Vanpariya vanpariyar

🏠
Working from home
View GitHub Profile
@vanpariyar
vanpariyar / .htaccess
Created March 29, 2019 12:54
The .htaccess file for local wordpress installation.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /LocalSetupFolder/
#link will be localhost/LocalSetupFolder/wp-admin
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /LocalSetupFolder/index.php [L]
</IfModule>
@vanpariyar
vanpariyar / wp-install.sh
Created April 17, 2019 19:10
This script for the setup fresh wordpress project very easily
DB_USER=root
DB_PASS=
project_name=amer1
project_host=localhost
db_host=localhost
wp_user=
wp_pass=
wp_email=
wp_title=$project_name
@vanpariyar
vanpariyar / PHP associative array Phone codes
Created January 7, 2020 05:32
PHP associative array Phone codes for general purpose
array(
"+1"=>"+1",
"+7"=>"+7",
"+20"=>"+20",
"+27"=>"+27",
"+30"=>"+30",
"+31"=>"+31",
"+32"=>"+32",
"+33"=>"+33",
"+34"=>"+34",
@vanpariyar
vanpariyar / CURL post JSON data example
Last active January 7, 2020 05:32
In this gist i have putted the snippets that any one can use in their project development requirement in PHP development if have time i am creating this type of the snippets. You will thanks later.
$data = array("name" => "Hagrid", "age" => "36");
$data_string = json_encode($data);
$ch = curl_init('http://api.local/rest/users');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
@vanpariyar
vanpariyar / image-upload-field-custom-taxonomy
Created February 14, 2020 04:57 — forked from mathetos/image-upload-field-custom-taxonomy
Add Image Upload Field to Custom Taxonomy
<?php
/* Add Image Upload to Series Taxonomy */
// Add Upload fields to "Add New Taxonomy" form
function add_series_image_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="series_image"><?php _e( 'Series Image:', 'journey' ); ?></label>
@vanpariyar
vanpariyar / form-image-submit.php
Last active February 18, 2020 08:28
POST THUMBNAIL OR FILE UPLOADING FROM THE FRONT END
/*POST THUMBNAIL OR FILE UPLOADING FROM THE FRONT END*/
function textDomain_thumbnail_uploading_function( $file, $post_id , $set_as_featured = false ) {
require( ABSPATH.'/wp-load.php' );
if ( !function_exists('wp_handle_upload') ) {
require_once(ABSPATH . 'wp-admin/includes/file.php');
}
$upload = wp_upload_bits( $file['name'], null, file_get_contents( $file['tmp_name'] ) );
$wp_filetype = wp_check_filetype( basename( $upload['file'] ), null );
$wp_upload_dir = wp_upload_dir();
$attachment = array(
@vanpariyar
vanpariyar / block.js
Created February 28, 2020 18:29
Gutenberg Demo
wp.blocks.registerBlockType('guten/guten-box',{
title: 'my cool Border box',
icon: 'smiley',
category: 'common',
attributes: {
content:{type: 'string'},
color: {type: 'string'}
},
edit: function( props ){
@vanpariyar
vanpariyar / downloadImage.js
Last active March 6, 2020 07:51
Download all images in all pages add to console in your site.
jQuery('.galleryblock>a').each((ind , value) => {
console.log(jQuery(value).prop('href'));
var link = document.createElement('a');
link.href = jQuery(value).prop('href');
link.download = link.href.substring(link.href.lastIndexOf('/')+1);;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
@vanpariyar
vanpariyar / get_youtube_thumbnail.php
Created March 17, 2020 05:20
Get the thumbnail image of Youtube by Youtube Video URL.
function get_youtube_thumb($video_url)
{
if(preg_match('/src="([^"]+)"/', $video_url, $match))
$video_url = $match[1];
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $video_url, $ytMatch);
$large = "";
if ($ytMatch && strlen($ytMatch[1]) === 11)
@vanpariyar
vanpariyar / master.yml
Created May 2, 2020 18:28 — forked from christeredvartsen/master.yml
Commit back to the repository from a workflow
name: Commit from workflow
on:
push:
branches:
- master
paths-ignore:
- file.txt
jobs:
build:
runs-on: ubuntu-latest