Skip to content

Instantly share code, notes, and snippets.

View sureshHARDIYA's full-sized avatar
🎯
Learning by burning ...

Suresh KUMAR Mukhiya sureshHARDIYA

🎯
Learning by burning ...
View GitHub Profile
@sureshHARDIYA
sureshHARDIYA / webpack.config.js
Last active July 31, 2017 06:13
Autoimporting `react` using Webpack’s ProvidePlugin:
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index'
],
@sureshHARDIYA
sureshHARDIYA / index.css
Created August 12, 2017 10:19
Media Query cheatsheet
/*
## Device = Desktops
## Screen = 1281px to any higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
}
@sureshHARDIYA
sureshHARDIYA / index.sql
Created August 29, 2017 13:52
Create admin user from WordPress database
// Make sure to replace `username`, `password`, `first_name`, `last name` & `email` with your desired data.
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('NEW_USERNAME', MD5('NEW_PASSWORD'), 'FIRST_NAME LAST_NAME', '[email protected]', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
@sureshHARDIYA
sureshHARDIYA / functions.php
Last active October 6, 2017 13:44
The right hooks for registering custom fields in woo commerce products page
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
// Save Fields
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
@sureshHARDIYA
sureshHARDIYA / productsPageFunctions.php
Last active October 6, 2017 13:48
Adding custom fields to products page
<?php
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Number Field
woocommerce_wp_text_input(
array(
@sureshHARDIYA
sureshHARDIYA / savingFunctionsWoocommerce.php
Created October 6, 2017 13:49
Saving custom fields in woocommerce
<?php
function woo_add_custom_general_fields_save( $post_id ){
// Text Field
$woocommerce_text_field = $_POST['_text_field'];
if( !empty( $woocommerce_text_field ) )
update_post_meta( $post_id, '_text_field', esc_attr( $woocommerce_text_field ) );
// Number Field
$woocommerce_number_field = $_POST['_number_field'];
@sureshHARDIYA
sureshHARDIYA / retreieveFunctions.php
Created October 6, 2017 13:51
Retrieving custom fields
<?php
<?php
// Display Custom Field Value
echo get_post_meta( $post->ID, 'my-field-slug', true );
// You can also use
echo get_post_meta( get_the_ID(), 'my-field-slug', true );
?>
@sureshHARDIYA
sureshHARDIYA / query.js
Last active February 22, 2021 10:23
Check if a URL has query string
/**
* Return value if the current location has a query string.
*
* @params {string} lookUpString - The query string to search for.
* @returns {string} value of the query string if present.
*
* Example: getValueIfHasQueryString("v") <= "2"
**/
function getValueIfHasQueryString(lookUpString) {
const url = new URL(window.location.href);
@sureshHARDIYA
sureshHARDIYA / adsense.js
Last active January 15, 2024 06:25
Create Google Adsense ad using JavaScript
var adUnit = document.getElementsByClassName("section-below-title")[0];
var parentElement = adUnit.childNodes[0];
// Create script element
var script = document.createElement('script');
script.async = true;
script.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
parentElement.appendChild(script);
// Create INS element