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 / functions.php
Created December 17, 2020 05:03
How To make custom variables for the Automate woo
<?php
add_filter( 'automatewoo/variables', 'automatewoo_custom_variable' );
function automatewoo_custom_variable( $variables ) {
/**
* Add Path of the file create folder in the theme file and see below file location.
*/
$variables['order']['veriable_name'] = require_once get_theme_file_path().'/automatewoo/includes/variables/order-variable-name.php';
return $variables;
}
@vanpariyar
vanpariyar / Functions.php
Created December 17, 2020 05:14
Skip the Js for the cloudflare rocket loader functionality, so we can solve the conflict created by rocket Loader
<?php
/**
* We are adding the data-cfasync="false" attribute right before the src attribute
* To Prevent Rocket Loader to effect javascript functionality
*
* @link https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-specific-JavaScripts-
*
* For Filter @see https://developer.wordpress.org/reference/functions/wp_enqueue_script/#comment-content-4246
*
* @param $html
@vanpariyar
vanpariyar / enqueue-js-and-css-files-from-folder-bulk.php
Created December 28, 2020 11:03
This code for enqueue JavaScript and CSS in WordPress Whole folder no need to separate enqueue the Files.
<?php
function enqueue_my_scripts(){
    foreach( glob( get_stylesheet_directory(). '/js/*.js' ) as $file ) {        
$filename = substr($file, strrpos($file, '/') + 1);      
wp_enqueue_script( $filename, get_template_directory_uri().'/js/'.$filename);
    }
foreach( glob( get_stylesheet_directory(). '/css/*.css' ) as $file {        
$filename = substr($file, strrpos($file, '/') + 1);      
wp_enqueue_style( $filename, get_template_directory_uri().'/css/'.$filename);
    }

Symptoms The following message is displayed when trying to push to a Bitbucket Server repository:

error: Issuer certificate is invalid. while accessing https://@<BITBUCKET_HOST>:8443/ABC/test.git/info/refs fatal: HTTP request failed You just added a self signed certificate to Bitbucket Server and now your users are getting errors:

fatal: unable to access 'https://@<bitbucket_server>://scm///': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none Cause The Bitbucket Server certificate is not trusted by the git client.

@vanpariyar
vanpariyar / functions.md
Created January 26, 2021 09:04
how to select all of the urls email encoded in wordpress rewrite api

Hook the function

$regexMatchParameter = '([^/]+)'; is very useful

/**
 * Add User key parameter to the Query
 *
 * @hooked 'init'
 */
function addUserOptLinksEndpoint()
@vanpariyar
vanpariyar / widget from caching.md
Created April 29, 2021 06:21
caching the widget on the html file from the API and increase site speed

Caching widget in HTML file so we can direclty call from the wp-content folder

this will improve the speed of the site

we are storing the response in the Wp-content folder, there are also a cron job that reflect changes on the server

<?php

/**
 * Adds Widget_Top_Article_Poc_Portrait widget.
@vanpariyar
vanpariyar / create-user-in-wordpress-using-php.php
Created August 24, 2021 08:47
Create a user in the wordpress dashboard using the PHP in the wordpress.
<?php
/**
* Create a user in the wordpress dashboard using the PHP in the wordpress.
*/
add_action('init', 'create_user_account');
function create_user_account() {
$username = 'username123';
$email = '[email protected]';
$password = 'pasword123';
$user_id = username_exists( $username );
@vanpariyar
vanpariyar / update-value-of-array-of-object.md
Last active October 5, 2021 19:42
Javascript : Update Values on the array of object
"stats": [
  { "id":"0", "count": "22", "text": "Years of experience" },
  { "id":"1", "count": "186", "text": "Projects delivered" },
  { "id":"2", "count": "200+", "text": "Satisfied clients" }
],
	<div className="inner-block" key={ key } data-id={ key }>
    <RichText
@vanpariyar
vanpariyar / how to add anyone at ssh server.md
Last active October 12, 2021 07:48
How to add some one to server ssh

To Add Someone's ssh-key on the dev server

$ ssh to your server
$ cd .ssh/
$ nano authorized_keys
@vanpariyar
vanpariyar / dynamic-select-gutenberg.md
Created January 6, 2022 12:23
create dynamic selecting block for the website of post or any taxonomy in the WordPress Gutenberg block editor

Selcte and set the data on the attributes on the gutenberg fetch posts

  • This can be used as the many application like select articles based in custom post, custom section etc.
const SectionSelector = ( { props } ) => {
    const { attributes:{ exclude_section, section, tag, author }, setAttributes } = props;
    const [ searchTerm, setSearchTerm ] = useState('');

    const options = useSelect( (select) => {