This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1: clone the main repo: | |
git clone sample.com/component.git | |
Get inside the cloned repo cd folder_name. Now you have a working directory with latest version pulled | |
and you want to move back to a specific commit id, here's how you can do it: | |
Step 2: | |
git reset --hard 9a36b9e79tbb9132c7 # (takes you back to that commit) | |
Step 3: | |
git clean -df # (cleans any untracked files/folders) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function removeParamAndRefresh(paramToRemove) { | |
const url = new URL(window.location.href); | |
if (url.searchParams.has(paramToRemove)) { | |
url.searchParams.delete(paramToRemove); | |
// Update the URL in the address bar without reloading | |
window.history.pushState({}, '', url); | |
// Now, reload the page | |
window.location.reload(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VALUE UNIT STRIPPING AND CONVERSION FUNCTION TOOLS | |
// By Nicolas Giethlen (aka Chmood) | |
// VARIABLES | |
$browser-fontsize-base: 16 !default; // Default browser font-size in px (unitless) | |
$pixels-per-rem: 10 !default; // Root font-size in px (unitless) | |
// FUNCTIONS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var el = document.getElementById('target'); | |
function extractHexBackgroundColorFromElement(element) { | |
return getComputedStyle(element)['background-color'].split('(')[1].split(')')[0].split(',').map((x) => x.trim()).map((x) => { x = parseInt(x).toString(16); return (x.length === 1) ? '0' + x : x }).join(''); | |
} | |
console.log(extractHexBackgroundColorFromElement(el)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function em2px(em) { | |
return Number(em) * Number(window.getComputedStyle(document.body).getPropertyValue('font-size').match(/\d+/)[0]); | |
} | |
console.log(em2px(2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// While not foolproof, you can check the USER_AGENT string and only run that code if 'bot' does not exist. | |
if(stripos($_SERVER['HTTP_USER_AGENT'],'bot') === false){ } | |
// This would stop any bot that actually has bot in the user agent string that also does not pay attention to robots.txt. | |
// Source: https://stackoverflow.com/a/17600047/1090042 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*********************************** | |
* | |
* ! DISABLE COMMENTS | |
* | |
* *********************************/ | |
function df_disable_comments_post_types_support() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WPSVG{ | |
function __construct(){ | |
add_action( 'admin_init', array( $this, 'add_svg_support' ) ); | |
add_action( 'admin_footer', array( $this, 'fix_svg_thumbnail_size' ) ); | |
add_filter( 'upload_mimes', array( $this, 'add_svg_mime' ) ); | |
add_filter( 'wp_check_filetype_and_ext', array( $this, 'wp_check_filetype_and_ext' ), 100, 4 ); | |
add_filter( 'wp_generate_attachment_metadata', array( $this, 'wp_generate_attachment_metadata' ), 10, 2 ); | |
add_filter( 'fl_module_upload_regex', array( $this, 'fl_module_upload_regex' ), 10, 4 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ChatGPT generated answer | |
// To access data from a WordPress plugin PHP class in a page template file, you need to follow a few steps: | |
/* Step 1: Instantiate the Plugin Class in Your Template File | |
In your WordPress page template file (usually named page-{template_name}.php), you need to instantiate the plugin class. First, make sure the plugin is active. Then, instantiate the class using the global keyword.*/ | |
global $your_plugin_class_instance; | |
$your_plugin_class_instance = new Your_Plugin_Class(); | |
// Replace Your_Plugin_Class with the actual name of your plugin class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Limit How Many Checkboxes Can Be Checked | |
* http://gravitywiz.com/2012/06/11/limiting-how-many-checkboxes-can-be-checked/ | |
*/ | |
class GFLimitCheckboxes { | |
public static $field_limits; |