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
_______ | |
| | |.-----.--.--.--. | |
| || -__| | | | | |
|__|____||_____|________| | |
_______ __ __ | |
|_ _| |--.|__|.-----.-----.-----. | |
| | | || || | _ |__ --| | |
|___| |__|__||__||__|__|___ |_____| | |
______ |_____| | |
| |.-----. |
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 | |
/** | |
* Search and replaces text. | |
* | |
* @param String $text Text to be replaced | |
* @param Array $args Key value pairs representing search and replace respectively | |
* @return String Text with search and replace applied. | |
*/ | |
function search_and_replace( $text = '', $args = [ ] ) { | |
if ( empty( $args ) || ! array( $args ) ) return $text; |
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
const data = [ | |
{ "name": "A" }, | |
{ "name": "C" }, | |
{ "name": "B" }, | |
{ "name": "D" } | |
]; | |
/** | |
* sortObjectArrayByKey | |
* |
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 | |
/** | |
* This example uses 'main-category' as a custom taxonomy and values | |
* from Carbon Fields for sorting https://carbonfields.net | |
*/ | |
// Add custom column title | |
add_filter( 'manage_edit-main-category_columns', function( $columns ) { | |
$column_position = 2; | |
$before = array_slice( $columns, 0, $column_position, true ); |
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 | |
global $post; | |
$args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => null ); | |
$attachments = get_posts( $args ); | |
$csv = "ID, Name, Title, Alt, Description, Caption, URL,\n"; | |
if ( $attachments ) { | |
foreach ( $attachments as $post ) { | |
setup_postdata( $post ); | |
$attachment = wp_prepare_attachment_for_js( get_the_ID() ); | |
$csv .= '"' . str_replace( '"', '\"', $attachment[ 'id' ] ) . '"' . ","; |
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
{ | |
"ab": "abk", | |
"ae": "ave", | |
"af": "afr", | |
"ak": "aka", | |
"am": "amh", | |
"an": "arg", | |
"ar": "ara", | |
"as": "asm", | |
"av": "ava", |
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 | |
/** | |
* Prints out entire stylesheet in the <head> section of the site. | |
* Supports replacing relative URLs | |
*/ | |
add_action( 'wp_head', function() { | |
$stylesheet = get_stylesheet_directory() . '/style.min.css'; | |
if ( ! file_exists( $stylesheet ) ) return echo '<!--404-CSS-->'; | |
$stylesheet = file_get_contents( $stylesheet ); |
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 | |
/** | |
* Converts URLs in a string into hyperlinks. | |
* | |
* Example: <?php echo new ConvertLinks( 'Text containing a link http://gist.github.com', 'external', '_blank' ); ?> | |
* Output: Text containing a link <a href="http://gist.github.com" rel="external" target="_blank">http://gist.github.com</a> | |
* | |
* @param string $input Text containing links | |
* @param string $rel Rel attribute value (optional) | |
* @param string $target Target attribute value (optional) |
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 | |
// Both login and register page | |
if ( isset( $GLOBALS[ 'pagenow' ] ) && ( false === in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php', 'wp-register.php' ) ) ) ) { | |
// Do something | |
} | |
// Login page only | |
if ( isset( $GLOBALS[ 'pagenow' ] ) && ( false === in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php' ) ) ) ) { | |
// Do something | |
} |
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 | |
/** | |
* Override Jetpack Open Graph sharing image | |
* | |
* @link https://jetpack.com/tag/open-graph/ | |
*/ | |
add_filter( 'jetpack_images_get_images', 'override_jetpack_images_get_images', 20, 3 ); | |
function override_jetpack_images_get_images( $media, $post_id, $args ) { | |
$root_directory = get_bloginfo( 'stylesheet_directory' ); |
NewerOlder