Skip to content

Instantly share code, notes, and snippets.

View Neshable's full-sized avatar
🎯
Focusing

Nesho Sabakov Neshable

🎯
Focusing
  • Sofia, Plovdiv
View GitHub Profile
@Neshable
Neshable / wp-common.conf
Created January 4, 2022 10:30
Nginx configuration file to be included with WordPress. Covers all major cases for 2021.
# WordPress COMMON SETTINGS - WordOps 3.13.2
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
# Limit access to avoid brute force attack
#Yoast SEO Sitemaps
location ~ ([^/]*)sitemap(.*).x(m|s)l$ {
## this rewrites sitemap.xml to /sitemap_index.xml
rewrite ^/sitemap.xml$ /sitemap_index.xml permanent;
## this makes the XML sitemaps work
rewrite ^/([a-z]+)?-?sitemap.xsl$ /index.php?yoast-sitemap-xsl=$1 last;
@Neshable
Neshable / functions.php
Created November 24, 2020 08:51
Manually verify all unverified users. Works with this plugin - https://wordpress.org/plugins/user-registration/, but can me modified to work with others as well.
/**
* Manually verify all unverified users
*
* @return bool
*/
function verify_all_users() {
// Get only user IDs for unverified users
$user_query = new WP_User_Query( array(
@Neshable
Neshable / wp-safe-update.sh
Created April 28, 2020 16:06
WordPress Safe Update Through CLI
#!/bin/sh
echo "Starting safe update"
# Display the WordPress version
current_wp_core=$(wp core version --path=./wordpress)
# Update the WordPress version
wp core update
wp core update-db
@Neshable
Neshable / class-woo-conditional-stripe-keys.php
Created July 8, 2019 10:20
Woocommerce Multiple Stripe Accounts Support
/**
* Dynamically change Stripe keys upon conditions
*/
if ( !class_exists( 'Woo_Conditional_Stripe_Keys' ) ) {
class Woo_Conditional_Stripe_Keys {
/**
* Stripe Live publishable key
@Neshable
Neshable / woocommerce-custom-meta-order.php
Created February 27, 2019 07:15
WooCommerce Add Custom Fields to Order
if ( ! function_exists('custom_meta_to_order') ) {
add_action('woocommerce_checkout_update_order_meta', 'custom_meta_to_order', 20, 1);
function custom_meta_to_order( $order_id ) {
$order = wc_get_order( $order_id );
$order->update_meta_data( '_order_custom_field', 'value' );
$order->save();
}
}
@Neshable
Neshable / docker-compose.yml
Created February 14, 2019 21:12 — forked from eduwass/docker-compose.yml
Adding Mailhog to Docker-compose and enabling in WordPress
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
@Neshable
Neshable / website.conf
Created January 8, 2019 13:13
Nginx site available conf
server {
listen 80;
listen [::]:80;
server_name neshable.com www.neshable.com;
return 301 https://neshable.com$request_uri;
}
server {
@Neshable
Neshable / functions.php
Created February 26, 2017 17:48
Adding Custom Post Type to WordPress
// Register Custom Post Type
function books_post() {
// Array of custom labels for our custom post type backend.
$labels = array(
'name' => 'Books', //general name for the post type, usually plural. Default is Posts/Pages
'singular_name' => 'Book', //name for single object of this post type. Default is Post/Page
'menu_name' => 'Books', // Name used in the menu
'name_admin_bar' => 'Book', // String for use in New in Admin menu bar. - New Book
'add_new_item' => 'Add New Book', // Default is Add New Post/Add New Page.
@Neshable
Neshable / app.js
Created January 23, 2017 08:45
JS Ajax Boilerplate
var ourRequest = new XMLHttpRequest();
ourRequest.open('GET', 'your-url');
ourRequest.onload = function() {
if (ourRequest.status >= 200 && ourRequest.status < 400) {
var data = JSON.parse(ourRequest.responseText);
} else {
console.log("Connected, but errors occurred.");
}
};