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

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@nikola-wd
nikola-wd / async-await.js
Created January 26, 2020 20:38 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@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']);
@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 / 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 / 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 / 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 / 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 / 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 / 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;