Skip to content

Instantly share code, notes, and snippets.

View jonbrockett's full-sized avatar

Jon Brockett jonbrockett

View GitHub Profile
@jonbrockett
jonbrockett / _parallax.scss
Last active January 17, 2019 14:33
Parallax (Foundation SCSS Class)
// Parallax
.parallax {
@include breakpoint(small) {
background-size: cover;
background-position: top center;
}
@include breakpoint(medium) {
background-attachment: fixed;
}
}
@jonbrockett
jonbrockett / _lined-heading.scss
Created October 3, 2017 15:26
Line on Sides Heading
h2 {
overflow: hidden;
text-align: center;
&:before, &:after {
background-color: $color; //Color of the line
content: "";
display: inline-block;
height: .2rem; //Size of the line
position: relative;
vertical-align: middle;
@jonbrockett
jonbrockett / .htaccess
Created January 15, 2019 20:20
HTTP to HTTPS Redirect
# Force Redirect HTTP to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
@jonbrockett
jonbrockett / functions.php
Created January 15, 2019 20:21
WP - Private Page Redirect to Login with Custom Message
/** Redirect private pages/posts to login */
require_once( 'library/private-redirect.php' );
@jonbrockett
jonbrockett / functions.php
Created January 15, 2019 20:22
TinyMCE Custom Styles
/** TinyMCE Styles Changes **/
require_once( 'library/tinymce-styles.php' );
@jonbrockett
jonbrockett / Readme.md
Created January 17, 2019 14:22
YouTube Link Auto Open Subscribe Popup

Adding ?sub_confirmation=1 to the end of any YouTube link will auto-open the subscription popup.

@jonbrockett
jonbrockett / archive-slug-to-title.php
Created January 17, 2019 14:23
CPT Archive Slug to Title
<?php
/**
* Archive Slug to Title
*
* Gets `this` post's post type, then gets the archive slug of the post
* then outputs the slug, replacing `-` with ` ` and uppercasing every word
*
* @NOTE: This is not a perfect solution but will work for 90% of use cases.
* For more control, create an ACF `options` page of that post type with a
* text input. Then use this for the title. If doing this, it's also a
@jonbrockett
jonbrockett / gravity-forms-enforce-honeypot.php
Created January 17, 2019 14:25
Gravity Forms Enforce Honeypot
<?php
add_filter( 'gform_form_post_get_meta', __NAMESPACE__ . '\\enforce_gravity_forms_anti_spam_honeypot' );
/**
* Enforce anti-spam honeypot on all Gravity forms.
*
* @param array $form The current form to be filtered.
*
* @return array
*/
function enforce_gravity_forms_anti_spam_honeypot( $form ): array {
@jonbrockett
jonbrockett / rest-api-existing-cpt.php
Created January 17, 2019 14:25
WP REST API on Existing Custom Post Types
<?php
/**
* Add REST API to an existing custom post type
* Remember to add existing custom fields
*/
function add_cpts_to_api( $args, $post_type ) {
if ( 'post_name' === $post_type ) {
$args['show_in_rest'] = true;
}
@jonbrockett
jonbrockett / Readme.md
Created January 17, 2019 14:26
WP - Reorganize Media Library Image Order

This is important when adding custom image sizes. The FoundationPress theme add new sizes by default. What happens is when you add new images sizes they go at the end of the list, so it would be, "Thumbnail, Medium, Large, Full Size, Small, XLarge". This is confusing to the user and will auto select medium normally. The best order is to have the image sizes in order from smallest to largest, then full size, then the thumbnail.

The important piece is after the comment "Unset WP Default sizes so they can be reordered with new custom sizes". This removes them from the list of available image sizes. Then right after you re-add them in order as well as custom sizes.

FoundationPress theme you can edit to add the "unset" rules then add them into the $sizes array. More generically, you can add this to functions.php.