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
#!/usr/bin/env bash | |
# ============================================================================= | |
# | |
# *** WARNING: THIS SCRIPT IS NO LONGER MAINTAINED *** | |
# | |
# use https://github.com/keesiemeijer/wp-update instead | |
# | |
# ============================================================================= |
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
#!/usr/bin/env bash | |
# =============================================================================== | |
# Script to install PHPUnit in the Local by Flywheel Mac app | |
# These packages are installed | |
# | |
# PHPUnit, curl wget, rsync, git, subversion and composer. | |
# | |
# WordPress is installed in the `/tmp/wordpress` directory for use by PHPUnit. | |
# The WordPress test suite is installed in the `/tmp/wordpress-tests-lib` directory. |
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
add_filter( 'the_content', 'MyTheme_do_first_shortcode' ); | |
function MyTheme_do_first_shortcode( $content ) { | |
// EDIT: Shortcode name (without brackets) | |
$shortcode = 'shortcode-name'; | |
if ( has_shortcode( $content, $shortcode ) ) { | |
$regex = get_shortcode_regex( array( $shortcode ) ); | |
$i = 0; |
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 | |
/** | |
* Insert HTML between paragraphs in WordPress post content using php DOMDocument(). | |
* | |
* Inserts HTML in the middle of top level paragraphs. | |
* For example: | |
* | |
* <p>Hello</p> | |
* <blockquote> | |
* <p>Awesome</p><!-- not a top level paragraph --> |
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 a new public query variable: taxonomy_archive | |
add_filter ( 'query_vars', 'add_taxonomy_query_var' ); | |
function add_taxonomy_query_var( $query_vars ) { | |
$query_vars['taxonomy_archive'] = ''; | |
return $query_vars; | |
} | |
add_action( 'posts_clauses', 'taxonomy_archive_clauses', 10, 2 ); |
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_filter( 'related_posts_by_taxonomy_posts_clauses', 'rpbt_post_where', 10, 4 ); | |
function rpbt_post_where( $pieces, $post_id, $taxonomies, $args ) { | |
global $wpdb; | |
$pieces['select_sql'] .= " , GROUP_CONCAT( DISTINCT tt.term_id SEPARATOR ',' ) as related_terms "; | |
return $pieces; | |
} |
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_filter( 'attachment_fields_to_edit', 'km_attachment_text_link_field', 10, 2 ); | |
function km_attachment_text_link_field( $form_fields, $post ) { | |
$form_fields['km-text-link'] = array( | |
'label' => 'Text Link', | |
'input' => 'text', | |
'value' => '', | |
'helps' => 'If Text Link is provided, the image will be linked from a text link', |
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 | |
$_tests_dir = '/tmp/wordpress-tests-lib'; | |
require_once $_tests_dir . '/includes/functions.php'; | |
function _manually_load_plugin() { | |
require dirname( dirname( __FILE__ ) ) . '/ddd.php'; | |
} | |
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); |
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 | |
$post_templates = array(); | |
$theme = wp_get_theme(); | |
$files = (array) $theme->get_files( 'php', 1 ); | |
foreach ( $files as $file => $full_path ) { | |
$headers = get_file_data( $full_path, array( 'Template Name' => 'Template Name' ) ); | |
if ( empty( $headers['Template Name'] ) ) { | |
continue; |
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 | |
/** | |
* Plugin Name: Shortcode Regex Finder | |
* Plugin URI: | |
* Description: This plugin creates the regex WordPress would use to find a specific shortcode in content. | |
* Author: keesiemijer | |
* License: GPL v2 | |
* Version: 1.0 | |
* Text Domain: shortcode-regex-finder | |
*/ |