Skip to content

Instantly share code, notes, and snippets.

View nikola-wd's full-sized avatar
💭
Available for full-time hire. React or Custom WordPress theme development.

Nikola Ivanov nikola-wd

💭
Available for full-time hire. React or Custom WordPress theme development.
View GitHub Profile
@nikola-wd
nikola-wd / gist:81fa71b8f5973611d65de51b6a5c6e62
Last active February 18, 2024 02:39
Useful .zshrc aliases
alias ll='ls -alF'
alias ls="ls --color -l -h" # add colors to ls
alias grep="grep -n --color" # add line numbers to grep
alias rnm="rm -rf node_modules" # remove node_modules
alias nlg="npm list -g --depth 0" #list global packages installed
alias vc="code"
alias vco="code ." # open current directory in vscode
alias la='ls -A'
alias l='ls -CF'
alias c='clear'
@nikola-wd
nikola-wd / isMobileOrTablet.js
Created November 21, 2021 17:23
Is mobileOrTablet js script
const isMobileOrTablet = () => {
let check = false;
(function (a) {
if (
/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(
a
) ||
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i23
@nikola-wd
nikola-wd / safari_bdrs_fix.css
Created May 31, 2021 18:34
[safari border-radius fix] border radius not working properly on safari fix #css #scss #safari
https://forum.webflow.com/t/overflow-hidden-round-corners-not-working-on-safari/67805
The issue is the combination of overflow, border-radius, and transition
This is the solution:
On the element with overflow:
.transitionfix() {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
@nikola-wd
nikola-wd / caseInsensitivePregReplaceAll.js
Created December 6, 2020 18:05
[case-insensitive preg replace all] Replace all substr occurencies no matter the case ("str", <mark>str</mark> #javascript
function matchCase(text, pattern, tag = '') {
var result = '';
for(var i = 0; i < text.length; i++) {
var c = text.charAt(i);
var p = pattern.charCodeAt(i);
if(p >= 65 && p < 65 + 26) {
result += c.toUpperCase();
} else {
@nikola-wd
nikola-wd / input_number_validation_filter.js
Created September 25, 2020 23:58
[Validation - allow only numbers onKeyPress] #javascript #validation
/**
* @param {event} evt = e (from the element)
* @param {bool} isZIP=false
* @returns {bool}
*/
const validateNumberHelper = (evt, isZIP = false) => {
var theEvent = evt || window.event;
// Handle paste
if (theEvent.type === "paste") {
@nikola-wd
nikola-wd / async_php_promise_all.php
Created September 24, 2020 20:02
[“Async” Promise.all PHP Guzzle version] Guzzle version of Promise.all #PHP, #async, #Guzzle
function ping_app_fetch_counts(WP_REST_Request $request)
{
if (is_request_not_from_the_same_domain()) {
wp_send_json_error( "Not authorized", 401 );
return false;
}
$ping_env_id = get_option('wrwps_ping_env_id');
$base_endpoint = 'https://api.pingone.com/v1/environments/' . $ping_env_id . '/';
$token = get_jwt_token_string();
@nikola-wd
nikola-wd / acf_remove_data_upon_field_deletion.php
Last active July 15, 2020 07:06
[clean ACF data] Removes data upon acf field deletion #wordpress #php
// removes ACF data upon field deletion
// this action is run by ACF whenever a field is deleted
// and is called for every field in a field group when a field group is deleted
add_action('acf/delete_field', 'delete_acf_content_on_delete_field');
function delete_acf_content_on_delete_field($field) {
// runs when acf deletes a field
// find all occurences of the field key in all tables and delete them
// and the custom field associated with them
global $wpdb;
@nikola-wd
nikola-wd / custom-search-acf-wordpress.php
Created July 14, 2020 13:28 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@nikola-wd
nikola-wd / full_list_of_wp_globals.php
Created March 1, 2020 20:32 — forked from kagg-design/full_list_of_wp_globals.php
Full list of WordPress global variables, extracted from WP Coding Standards
<?php
/**
* List of global WP variables.
*
* @since 0.3.0
* @since 0.11.0 Changed visibility from public to protected.
* @since 0.12.0 Renamed from `$globals` to `$wp_globals` to be more descriptive.
* @since 0.12.0 Moved from WordPress_Sniffs_Variables_GlobalVariablesSniff to WordPress_Sniff
*
* @var array
@nikola-wd
nikola-wd / cutom-recent-posts-widget-wp.php
Created February 10, 2020 11:21
[WrdPress custom widget] custom recent posts widget #wordpress #php #custom #widget
<?php
// Added by Nikola on 2/10/2020 to fix the footer recent articles issues that's been probably happening due the ome server missconfiguration
// or some added plugins that caused the conflict, and caused the original one not to work properly
class CustomRecentPostsWidget extends WP_Widget {
function CustomRecentPostsWidget() {
parent::WP_Widget(false, $name = 'Custom Recent Posts');
}
function form($instance) {
$title = esc_attr($instance['title']);