This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Generates the current year, for use in copyright notices | |
// Call with [auto-year] | |
// e.g., © [auto-year] Your Name | |
add_shortcode('auto-year', function(){ | |
$year = date('Y'); | |
return $year; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Prominently display the post ID in as an admin notice | |
add_action( 'admin_notices', function(){ | |
global $post; | |
if ( isset($_GET['post']) ) { | |
$class = 'notice notice-error'; | |
$id = $post->ID; | |
$message = __( 'Post ID: ' . $id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getPostID( $post ) { | |
if ( is_object( $post ) ) : | |
$id = $post->ID; | |
elseif ( is_array( $post ) ) : | |
$id = $post['ID']; | |
endif; | |
return $id; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Prevent users from accessing the native Login and Registration page | |
// NOTE: This will prevent *everyone* from logging in through the standard channel. | |
// Even you. | |
add_action( 'login_init', function () { | |
if( ! is_user_logged_in() ) { | |
// redirects to homepage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUrlVars() { | |
var vars = {}; | |
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { | |
vars[key] = value; | |
}); | |
return vars; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Short background behind text */ | |
.element::after { | |
display: block; | |
content: ""; | |
border-top: 18px solid #COLOR; | |
border-radius: 4px; | |
margin-top: -22px; | |
margin-left: -15px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
curl_setopt_array($ch = curl_init(), array( | |
CURLOPT_URL => "https://api.pushover.net/1/messages.json", | |
CURLOPT_POSTFIELDS => array( | |
"token" => "TOKEN", // Insert App Token | |
"user" => "TOKEN", // Insert User token | |
"title" => "TITLE", | |
"message" => "MESSAGE", | |
), | |
CURLOPT_SAFE_UPLOAD => true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Automatically add a WooCommerce coupon code | |
// Currently added when headed to checkout, but can be connected to different hook. | |
add_action('woocommerce_before_checkout_form', function() { | |
global $woocommerce; | |
$coupon_code = 'COUPON_CODE'; // Replace with your code | |
// Add additional logic if necessary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Avoid losing drafted changes by alerting other users with editing roles | |
// that the current page has a draft. | |
// Place the code below in a plugin file or in functions.php | |
// NOTES: | |
// The alert will only display for users with `edit_posts` capability | |
// when the builder is open. Triggered by the 'fl_body_open' hook, which is part |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- | |
Throw a message in a window via the URL parameter 'msg' | |
e.g. http://this-file.com?msg=Your+message | |
--> | |
<html> | |
<head> | |
<title>Your Message</title> |