Skip to content

Instantly share code, notes, and snippets.

View hellofromtonya's full-sized avatar

Tonya Mork hellofromtonya

View GitHub Profile
@hellofromtonya
hellofromtonya / post.php
Created December 15, 2016 18:49
Example of registered callback hook - to the "the_title" event
add_action( 'the_title', 'add_markup_to_post_title' );
/**
* Adds the HTML Markup to the Post Title.
*
* @since 1.0.0
*
* @param string $title
*
* @return string
*/
@hellofromtonya
hellofromtonya / post.php
Last active December 13, 2016 02:21
Check if the post's submission is an "edit" action and not a "add new post" action - WordPress
/**
* Checks if the post's submission is an "edit"
*
* Details provided in this answer on Stack Overflow
* @link http://stackoverflow.com/questions/41110437/condition-only-when-the-post-is-complete-edited-not-added-or-trash/41110996#41110996
*
* @since 1.0.0
*
* @param int $post_id Post ID to evaluate
*
@hellofromtonya
hellofromtonya / formatting.php
Created November 27, 2016 21:51
Content Limiter - truncate to number of words
<?php
/**
* Limit the content by the number of words.
*
* @package -
* @since 1.0.0
* @author hellofromTonya
* @link https://UpTechLabs.io
* @license GPL-2+
*/
@hellofromtonya
hellofromtonya / hard-unregister.php
Last active June 7, 2019 21:40
Hard Unregister for an Object's callback where you do not have access to the instance itself.
/**
* Do a hard unregister of an object's callback for the specified event name
* and priority level.
*
* In WordPress, the callback key (or unique ID) is generated using the hash ID of
* the object concatenated with the method name. In the event that you do not have
* the object itself, then we use this hard approach to first first the callback
* function and then do the remove.
*
* This process works for both filter and action events.
@hellofromtonya
hellofromtonya / header-right.php
Created November 22, 2016 00:32
How to change the Header Right sidebar registration parameters
add_action( 'register_sidebar', 'change_header_right_registration', 9999 );
/**
* Change the Header Right Sidebar registration parameters.
*
* To change the header right (or any) sidebar registration parameter, you'll
* need to use the global after the sidebar is registered. Within the function
* `register_sidebar()` in WordPress Core, there is an action event after
* the sidebar is registered. We register to that event and then change
* each parameter in the global `$$wp_registered_sidebars`.
*
@hellofromtonya
hellofromtonya / helpers.php
Created October 1, 2016 18:55
Get all posts grouped by term
/**
* Gets all of the posts grouped by terms for the specified
* post type and taxonomy.
*
* Results are grouped by terms and ordered by the term and post IDs.
*
* @since 1.0.0
*
* @param string $post_type_name Post type to limit query to
* @param string $taxonomy_name Taxonomy to limit query to
@hellofromtonya
hellofromtonya / adjacent-parent-post.php
Created September 25, 2016 19:51
Limits the adjacent post to just parents (no children)
<?php
/**
* Get the next adjacent parent post.
*
* This function extends the SQL WHERE query of the WordPress get_adjacent_post()
* function. It registers a callback to the `get_next_post_where` event filter,
* which then adds a new WHERE parameter.
*
* @uses get_next_post()
<?php
class Form {
//..
/**
* Render a repeatable group row
* @since 1.0.2
* @param Field $field_group Field group field object
* @param string $remove_disabled Attribute string to disable the remove button
*/
@hellofromtonya
hellofromtonya / _episode-list.scss
Created July 22, 2016 15:16
KnowTheCode.io episode list Sass module
//
// Episodes
//======================
.episode-header {
text-align: center;
margin: 30px -9999rem 40px;
padding: 20px 9999rem;
background: $titleBannerColor;
}
@hellofromtonya
hellofromtonya / _site-containers.scss
Created July 15, 2016 21:33
Site containers with media queries embedded
/* ## Site Containers
--------------------------------------------- */
.site-inner,
.wrap {
margin: 0 auto;
max-width: 1280px;
@media only screen and (max-width: 1340px) {
max-width: 1140px;