Skip to content

Instantly share code, notes, and snippets.

@Nerd-Rush
Nerd-Rush / wp-discourage-se-alert.txt
Last active January 11, 2025 02:56
Discourage Search Engine Alert - WordPress
add_action('admin_head', 'custom_admin_bar_color');
add_action('wp_head', 'custom_admin_bar_color');
function custom_admin_bar_color() {
// Check if the "Discourage search engines from indexing this site" setting is enabled
if (get_option('blog_public') == '0') {
// Output CSS to change the admin bar color
echo '<style>
#wpadminbar {
border-top: 5px solid #cf0000 !important;
@broskees
broskees / anonymous-singleton.php
Last active July 20, 2023 16:09
PHP — Anonymous Singleton Class
<?php
$singleton = get_class(
new class
{
protected static $instance;
public static function getInstance()
{
if (! isset(self::$instance)) {
@Luna-Klatzer
Luna-Klatzer / __init__.py
Last active February 18, 2024 14:33
Anki Plugin for auto-filling data in Anki cards using the Jisho.org API
# Jisho.org Support for Anki
import os, re, json, requests, urllib.request, urllib.parse
from aqt import gui_hooks
from aqt import mw
from aqt.qt import qconnect
from aqt.editor import Editor
from aqt.utils import showInfo
from anki.utils import stripHTML
@broskees
broskees / becoming-a-webdev.md
Last active June 26, 2021 02:58
Becoming A Web Developer: A - Z
@davidwebca
davidwebca / override-wp-core-blocks-sage-10.php
Last active March 6, 2023 20:40
Add blade / override core block views in Sage 10.
<?php
/**
* Add this to your filters.php file in a Sage 10 theme.
* It will look at "resources/views/core/{blockname}.blade.php
* and render the view with "block_content" and "block" as variables.
*
* You can also use View Composers built in Sage 10 to pass more
* data to the block as you wish. For ACF blocks, I recommend
* generoi/sage-acfblocks which is definitely the cleanest
* method to include ACF blocks in Sage 10 I found so far.
@jonashackt
jonashackt / downgrade_brew_package.sh
Created September 24, 2018 12:07
Downgrade homebrew (cask) package
# Uninstall current version you want to downgrade
brew cask uninstall <PackageName>
# Edit Cask file
brew cask edit <PackageName>
# e.g. Vagrant
brew cask edit vagrant
```
cask 'vagrant' do
@ghassani
ghassani / QueryBuilder.php
Created September 19, 2018 18:28
Simple PHP SQL Query Builder for PDO
<?php
class QueryBuilder {
const QUERY_SELECT = 1;
const QUERY_INSERT = 2;
const QUERY_UPDATE = 3;
const QUERY_DELETE = 4;
const QUERY_REPLACE = 5;
const PARAMETER_STRING = 1;
@RiFi2k
RiFi2k / nginx.conf.j2
Last active April 7, 2021 22:50
Trellis nginx.conf file to include setting the real IP from Cloudflare if you use their DNS and SSL certs - https://github.com/roots/trellis/blob/master/roles/nginx/templates/nginx.conf.j2
# {{ ansible_managed }}
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
user {{ nginx_user }};
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
@thierrypigot
thierrypigot / acf-missing.php
Created June 3, 2016 10:13
WordPress mu plugins to check if "Advanced Custom Fields Pro" is active.
<?php
if( !class_exists('acf') )
{
$tp_acf_notice_msg = __( 'This website needs "Advanced Custom Fields Pro" to run. Please download and activate it', 'tp-notice-acf' );
/*
* Admin notice
*/
add_action( 'admin_notices', 'tp_notice_missing_acf' );
function tp_notice_missing_acf()