Visit the documentation and follow the instructions.
- Copy your API key, and add the following snippet to your
functions.php
.- Replace
YOUR_API_KEY
with your key you copied.
- Replace
<?php | |
/** | |
* Get all of the strings between 2 strings. | |
* | |
* @param string $string The string to search | |
* @param string $start The string to start with | |
* @param string $end The string to end with | |
* @param boolean $case_sensitive Whether to make the search case sensitive or not | |
* @return array An array of all the string that were found between $start and $end | |
*/ |
<?php | |
/** | |
* Get the ID of an attachment image using the file URL. | |
* | |
* @param string $url The URL of the image | |
* @return int $attachment The attachment image ID | |
*/ | |
function wp_url_to_attachmentid( $url ) { | |
// Split the $url into two parts with the wp-content directory as the separator | |
$parsed_url = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), $url ); |
<?php | |
/** | |
* Remove empty values from an array. | |
* | |
* @param array $arr The array to remove values from | |
* @return array The new array without the empty values | |
*/ | |
function remove_empty_values( $arr ) { | |
if( ! is_array( $arr ) ) return $arr; |
<?php | |
/** | |
* Get a string between 2 strings. | |
* | |
* @param string $string The string to search | |
* @param string $start The string to start with | |
* @param string $end The string to end with | |
* @param boolean $case_sensitive Whether to make the search case sensitive or not | |
* @return string The string that was found between the start and end | |
*/ |
<?php | |
/** | |
* Allow users to login to the site with their username or email. | |
* | |
* @param object $user WP_User object | |
* @param string $username_email The username or email entered for login | |
* @param string $password The users password | |
* @return object The authenticated WP_User object | |
*/ | |
function wp_allow_user_login_with_email( $user, $username_email, $password ) { |
Visit the documentation and follow the instructions.
functions.php
.
YOUR_API_KEY
with your key you copied.<?php | |
/** | |
* Prettify a range of times. | |
* | |
* @param mixed $start The start date, with time | |
* @param mixed $end The end date, with time | |
* @return string A prettified date() string for the time range | |
*/ | |
function get_pretty_time_range( $start='', $end='' ) { | |
$diff_meridiem = false; |
<?php | |
/** | |
* Prettify a range of dates. | |
* | |
* @param mixed $start The start date | |
* @param mixed $end The end date | |
* @param string $format A date() string for formatting if the dates match | |
* @param string $format_day A date() string for formatting if they are different days | |
* @param string $format_month A date() string for formatting if they are different months | |
* @param string $format_year A date() string for formatting if they are different years |
.full-image { | |
position: relative; | |
left: calc(-50vw + 50%); | |
width: 100vw; | |
margin: 2rem 0; | |
img { | |
width: 100%; | |
} | |
} |
<?php | |
/** | |
* Remove the h1 tag from the WordPress editor. | |
* | |
* @param array $settings The array of editor settings | |
* @return array The modified edit settings | |
*/ | |
function remove_h1_from_editor( $settings ) { | |
$settings['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre;'; | |
return $settings; |