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
/** | |
* Get a nested object value by path. | |
* | |
* @example | |
* var obj = {foo: {bar: 'baz'}}; | |
* getNestedValue(obj, 'foo.bar'); // returns 'baz' | |
* | |
* @param {Object} obj The nested object. | |
* @param {String} path The object path. | |
* @return {any} The object value at the specified path. |
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
import { useRef, useState, useEffect } from 'react'; | |
/** | |
* Get the size of a component on render and resize | |
* | |
* @example | |
* const sizeRef = useRef(null); | |
* const { height, width } = useSize(sizeRef) | |
* | |
* <div ref={sizeRef}> |
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
/** | |
* Escape RegExp special characters | |
* | |
* @param {string} str String to escape | |
* @return {string} Escaped string | |
*/ | |
const escapeRegExp = (str = '') => str.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'); | |
/** |
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 | |
/** | |
* Add Registration Date as a sortable column for users | |
*/ | |
class NH_User_Registration_Column { | |
function __construct() { | |
add_filter( 'manage_users_columns', array($this, 'manage_users_columns') ); | |
add_filter( 'manage_users_custom_column', array($this, 'manage_users_custom_column'), 10, 3 ); | |
add_filter( 'manage_users_sortable_columns', array($this, 'manage_users_sortable_columns') ); |
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
jQuery(function($) { | |
// Test for file API support. | |
var fileApiSuport = !!(window.File && window.FileReader ); | |
/** | |
* Resize images that exceed the maximum size (in pixels) | |
* @param {object} input The file input. | |
* @param {Function} callback Callback function run after the image has been resized. | |
* @return {null} | |
*/ |
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 | |
/** | |
* Create a button that generates a shortcode to be added to TinyMCE. | |
* | |
* @todo Add an option to change the template file path. | |
* Add the ability to specify what admin pages the button is displayed on. | |
*/ | |
class NH_Shortcode_Generator { | |
private $form_id = null; |
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 | |
class NH_MailChimp_Archive { | |
private $_args, $max_page, | |
public function __construct($args = array()) { | |
global $paged; | |
$defaults = array( | |
'apikey' => false, | |
'start' => 0, | |
'limit' => 12, |
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 | |
class NH_Post_Type_Pages { | |
private $pfpt, $post_types; | |
function __construct() { | |
$this->get_post_type_pages(); | |
add_action( 'admin_init', array(&$this, 'reading_settings_section') ); | |
if(!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)): | |
add_filter( 'pre_option_show_on_front', array(&$this, 'filter_show_on_front')); |
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 | |
// Extract the first gallery from a page/post | |
function first_gallery_401($id = false, $echo = true) { | |
global $post; | |
if(!$id) $id = $post->ID; | |
if ( $gallery = get_post_gallery() ) : | |
add_filter( 'post_gallery', 'remove_the_first_gallery' ); | |
if($echo): | |
echo $gallery; | |
else: |
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 | |
// Debug Custom Page Templates | |
function custom_page_templates_page() { | |
$templates = wp_get_theme()->get_page_templates(); | |
$done = array(); | |
$row = '<tr><td><a href="%s">%s</a></td><td width="60"><em>%s</em></td><td width="20"><a href="%s">edit</a></td></tr>'; | |
$not_found = '<tr><td colspan="3"><em>No pages found using this template.</em></td></tr>'; | |
echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; | |
echo '<h2>Custom Page Templates</h2>'; | |
foreach ( $templates as $template_name => $template_filename ): |
NewerOlder