See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope> is optional
| import React from 'react'; | |
| import flattenInput from './utils/flattenInput'; | |
| /** | |
| * Store a component's previous value in a ref for use after the value changes. | |
| * | |
| * const prevProps = usePrevious(props); | |
| * const { children: prevChildren } = usePrevious(props) || {}; | |
| * const prevState = usePrevious(state); | |
| */ |
| /** | |
| * Each version gets a directory where I copy over all of the old block files, | |
| * then export them from here for use in your main block file. | |
| */ | |
| export { default as v1 } from './v1'; | |
| export { default as v1_01 } from './v1_01'; |
| // Camel case a thing! | |
| export const camelCase = str => `${str.charAt( 0 ).toLowerCase()}${str.replace( /[\W_]/g, '|' ).split( '|' ) | |
| .map( part => `${part.charAt( 0 ).toUpperCase()}${part.slice( 1 )}` ) | |
| .join( '' ) | |
| .slice( 1 )}`; | |
| // Debounce a thing! | |
| export const debounce = ( func, wait, immediate ) => { | |
| let timeout; | |
| return function() { |
| <?php | |
| /** | |
| * Truncate a string to a maximum number of characters to the nearest complete word. | |
| * | |
| * @param string $string String to truncate. | |
| * @param int $max_char_width Maximum number of characters. | |
| * @param string $append New string to append at the end of the truncated string. | |
| * @return string Truncated string. | |
| */ | |
| function truncate_string( $string = '', $max_char_width = 200, $append = '' ) { |
| INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) | |
| VALUES ('chance', MD5('Password123'), 'Chance Strickland', '[email protected]', '0'); | |
| INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) | |
| VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); | |
| INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) | |
| VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10'); |
| <?php | |
| /** | |
| * Get primary taxonomy term (YoastSEO). | |
| * | |
| * @param mixed $taxonomy Taxonomy to check for. | |
| * @param boolean $term_as_obj Whether to return an object or the term name. | |
| * @param int $post_id Post ID. | |
| * @return mixed The primary term. | |
| */ | |
| function xx_get_primary_tax_term( $taxonomy = 'category', $term_as_obj = true, $post_id = 0 ) { |
| <?php | |
| /** | |
| * Helper funnction to remove name suffixes. | |
| * | |
| * @param string $name Name. | |
| * @return array Suffix-free name parts. | |
| */ | |
| function xx_get_suffix_free_name_parts( $name ) { | |
| // Format first and last names. | |
| $parts = explode( ' ', (string) $name ); |
| ## Add to your bash or zsh profile | |
| ## Modify path to match where you keep your local WP installs | |
| ## Your install and theme names should match! | |
| function localwp() { | |
| cd ~/Desktop/local/"$@"/app/public/wp-content/themes/"$@" | |
| } | |
| ## To use, type `localwp themename` (replace themename obvi) | |
| ## Now you’re in your theme directory! Yay! |