Skip to content

Instantly share code, notes, and snippets.

View ihorvorotnov's full-sized avatar
🇺🇦
Working remotely since 1999

Ihor Vorotnov ihorvorotnov

🇺🇦
Working remotely since 1999
View GitHub Profile
@slaFFik
slaFFik / expose.php
Created January 31, 2021 19:27
Fix Expose by BeyondCode issues when working with the local WordPress site
<?php
// phpcs:ignoreFile
define( 'EXPOSED_DOMAIN', 'example.sharedwithexpose.com' );
// Load only if we are running under Expose.
if ( empty( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) || $_SERVER['HTTP_X_ORIGINAL_HOST'] !== EXPOSED_DOMAIN ) {
return;
}
@Alfa-Q
Alfa-Q / listjs-infinite-pagination.html
Last active November 22, 2022 19:15
list.js - Infinite Scroll with Pagination
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Infinite Scroll Example</title>
<!-- Styles -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
@janispritzkau
janispritzkau / analytics.js
Last active April 5, 2022 17:51
Minimal Google Analytics Script (677 bytes minified)
((document, location, navigator) => {
const domain = location.hostname.split(".")
const match = document.cookie.match(/(^|; ?)_ga=GA1\.\d\.(\d+\.\d+)(;|$)/)
// use existing client id or generate one
const cid = match ? match[2] : ~~(2147483648 * Math.random()) + "." + ~~(Date.now() / 1000)
// set cookie at highest possible domain level
for (let i = domain.length; i--;) {
const cookie = `_ga=GA1.${domain.length - i}.${cid}`
@mishterk
mishterk / responsive-oembeds-class-for-wp.php
Created January 9, 2020 07:48
Wraps oEmbed output in markup which we can then target with CSS for fluid responsiveness.
<?php
class ResponsiveOEmbeds {
/**
* Regex patterns for matching specific embeddable URLs
*
* @var array
*/
@gokulkrishh
gokulkrishh / useful-npx-commands.md
Last active November 24, 2023 04:25
List of useful npx (Node Package Runner) commands (https://git.io/useful-npx-commands)

NPX (NPM Package Runner) Commands

List of useful npx (NPM Package Runner) commands.

What is NPX?

Using NPX we can execute/run node binaries without the need to install it locally or globally.

Commands

@mtunjic
mtunjic / disable.sh
Last active March 31, 2024 18:12
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
<?php
add_filter( 'woocommerce_order_actions', function ( $actions ) {
// Unset whatever actions you don't need available in the
// WooCommerce order edit screen.
unset( $actions['send_order_details_admin'] );
unset( $actions['send_order_details'] );
unset( $actions['regenerate_download_permissions'] );
@mishterk
mishterk / class-make-release-command.php
Last active July 1, 2020 11:19
Use a WP CLI command to prepare your plugins for release. For more info see https://philkurth.com.au/tips/use-a-wp-cli-command-to-prepare-your-plugins-for-release/
<?php
namespace WpLandingKitPlugin;
use WP_CLI;
use WP_CLI_Command;
@mishterk
mishterk / class-view.php
Last active May 14, 2021 06:28
Using generic views inside WordPress for a more flexible UI system. For more info see https://philkurth.com.au/articles/use-generic-views-with-data-arrays-for-a-flexible-context-independent-ui-system/
<?php
class View {
public static $view_dir = '';
/**
* Render View Template With Data
@mishterk
mishterk / app.php
Last active July 1, 2020 11:18
An example illustrating PHP's ability to return data from included files. For more info, see https://philkurth.com.au/tips/included-files-can-return-values-which-is-a-great-way-to-manage-app-configurations/
<?php
$config = include 'config.php';
echo $config['some']; // 'config'