This file contains 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
#/bin/bash | |
# Script for automating new account setups with WordPress installed | |
echo Lets setup a new WordPress dev site! | |
# Get user input | |
# Us RegEx to check for valid domain | |
read -p 'Enter the domain name: ' domain | |
result=`echo $domain | grep -P '(?=^.{1,254}$)(^(?>(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)'` | |
if [[ -z "$result" ]] |
This file contains 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
<form method="POST" action="https://api.pizza.com"> | |
<label for="name">Name</label> | |
<input id="name" name="name" /> | |
<label for="email">Email</label> | |
<input id="email" name="email" type="email" /> | |
<fieldset> | |
<legend>Pizza toppings</legend> | |
<input id="cheese" name="toppings" value="cheese" type="checkbox" /> |
This file contains 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
/** | |
* Remove hentry from post_class | |
* This is important to not get schema errors | |
*/ | |
function visceral_remove_hentry_class( $classes ) { | |
$classes = array_diff( $classes, array( 'hentry' ) ); | |
return $classes; | |
} | |
add_filter( 'post_class', 'visceral_remove_hentry_class' ); |
This file contains 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
/* | |
* This first function maps shortcodes to their respective resources, | |
* then checks whether those shortcodes exist in the content, | |
* then stores the required resource handles in a custom field. | |
* This way, we aren't running resource-intensive functions on every page load. | |
*/ | |
function check_post_shortcodes($post_id) { | |
// Map conditional shortcodes to their respective resource handle | |
// Remember to manually dequeue resource handles below as well. |
This file contains 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
/** | |
* A function that converts a number to another based on a weighted conversion function. | |
* @function applyConversion | |
* @param {number} responseCode | |
* @return {number} responseMessage | |
*/ | |
/** | |
* Creates a function that applies the weighted conversion between two ranges. | |
* @param { number } oldMin The old range minimum value |
This file contains 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 while (have_posts()) : the_post(); ?> | |
<?php | |
// Get the placeholder image and full size image URLs | |
if ( has_post_thumbnail() ) { | |
$image_id = get_post_thumbnail_id(); | |
$full_size_image = wp_get_attachment_image_src( $image_id,'full', true); | |
$full_size_image_url = $full_size_image[0]; | |
$placeholder_image = wp_get_attachment_image_src( $image_id,'thumbnail', true); |
This file contains 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
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /your/root/path; | |
index index.html; | |
server_name you.server.com; |
This file contains 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 assets() { | |
// enqueue your script | |
wp_enqueue_script('handle', get_template_directory_uri() . '/path/to/main.js', ['jquery'], '$ver', true); | |
// localize script | |
wp_localize_script('handle', 'custom_ajaxify', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); | |
} | |
add_action('wp_enqueue_scripts', 'assets', 100); | |
/** | |
* AJAX load template part |
This file contains 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
/** | |
* Takes a string and returns a truncated version. Also strips out shortcodes | |
* | |
* @param string $text String to truncate | |
* @param integer $length Character count limit for truncation | |
* @param string $append Appended to the end of the string if character count exceeds limit | |
* @return string Truncated string | |
*/ | |
function truncate_text( $text='', $length = 50, $append = '...') { | |
$new_text = preg_replace(" ([.*?])",'',$text); |
This file contains 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 | |
/** | |
* Template Name: Full Width | |
* | |
* Gets all posts that are missing default meta value, and gives them a default meta value. | |
* Add this file to your theme then add a page with this template. | |
* | |
* IMPORTANT: | |
* Visit that page and keep refreshing until you see no more posts left. | |
* Each page load adds the new post meta, so the loop count drops by the posts_per_page count each time. |
NewerOlder