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 / gist:3112c09a9582cc9c356c32adb6ffa5e9
Created December 19, 2019 07:52
[Sloved] Fatal error: Uncaught TypeError: Argument 1 passed to WPML_Media_Post_Images_Translation::translate_images_in_post_content()
Fatal error: Uncaught TypeError: Argument 1 passed to WPML_Media_Post_Images_Translation::translate_images_in_post_content() must be an instance of WP_Post, null given, called in /www/htdocs/w0184db4/helmut-kostner.it/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php on line 107 and defined in /www/htdocs/w0184db4/helmut-kostner.it/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php:130 Stack trace: #0 /www/htdocs/w0184db4/helmut-kostner.it/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php(107): WPML_Media_Post_Images_Translation->translate_images_in_post_content(NULL, Object(WPML_Post_Element)) #1 /www/htdocs/w0184db4/helmut-kostner.it/wp-includes/class-wp-hook.php(288): WPML_Media_Post_Images_Translation->translate_images(5) #2 /www/htdocs/w0184db4/helmut-kostner.it/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters
@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 / newsletter-popup.js
Created January 7, 2020 05:30
Newsletter popup with session storage
if (typeof(Storage) !== "undefined") {
// Store
function showPopup(){
window.setTimeout(function () {
$('#newsletter-modal').modal('show');
sessionStorage.setItem("popup", 'hide');
},6000);
}
if( !sessionStorage.getItem("popup")){
sessionStorage.setItem("popup", 'show');
@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 / 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);
});