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: Post Keywords Shortcode | |
* Plugin URI: https://gist.github.com/sscovil/5779312 | |
* Description: Searches a post for keywords and displays them if found. | |
* Version: 0.1 | |
* Author: Shaun Scovil | |
* Author URI: http://shaunscovil.com | |
* License: GPL2 | |
*/ |
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 | |
/** | |
* CSV to SortTable: Remove First Row | |
* | |
* @param array $data | |
* @return array | |
*/ | |
function csv_to_sorttable_remove_first_row( $data ) { | |
array_shift( $data ); | |
return $data; |
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 | |
function my_archive_post_count( $echo = true ) { | |
global $wp_query; | |
$showing = ''; | |
if ( $wp_query->found_posts > 1 ) { | |
// Get previous & next page links. | |
$args = array( | |
'sep' => ' — ', |
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 | |
/** | |
* WordPress Conditional Redirect Function | |
* | |
* In this example, the conditional tag checks if the current page is a page with a slug of test and, | |
* if true, replaces example.com with test.example.com and redirects. | |
*/ | |
function my_custom_redirect() { | |
if ( is_page( 'test' ) ) { |
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 | |
/** | |
* CSV to SortTable: Add Header Row | |
* | |
* @param array $data | |
* @return array | |
*/ | |
function csv_to_sorttable_add_header_row( $data ) { | |
$header_row = array( 'Column 1', 'Column 2', 'Column 3' ); | |
array_unshift( $data, $header_row ); |
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: CSV to SortTable: Add Header Row | |
* Plugin URI: https://gist.github.com/sscovil/5919960 | |
* Description: Adds a custom header row to tables created by CSV to SortTable plugin. | |
* Version: 0.1 | |
* Author: sscovil | |
* Author URI: http://shaunscovil.com | |
* License: GPL2 | |
*/ |
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 | |
// Use WP_User_Query to grab an array of user IDs. | |
$user_query = new WP_User_Query( array( | |
'fields' => 'ID' | |
) ); | |
$user_ids = $user_query->get_results(); | |
// Loop through each user ID. | |
foreach( $user_ids as $user_id ) { | |
// Use get_userdata() to get a user object with info stored in the 'user' database table. |
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: My Plugin | |
* Description: A sample plugin with class autoloader, for object-oriented programming. | |
* Version: 0.1 | |
* Plugin URI: http://shaunscovil.com/ | |
* Author: Shaun Scovil | |
* Author URI: http://shaunscovil.com/ | |
* License: GPL2 | |
*/ |
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 | |
/** | |
* Percent | |
* | |
* @param $a integer Number that represents 100%. | |
* @param $b integer Number to compare to $a. | |
* | |
* @return string Number B as a percentage of Number A. | |
*/ |
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
public static String mapToString(Map<String, String> map, String kvSeparator, String setSeparator) { | |
StringBuilder stringBuilder = new StringBuilder(); | |
for (String key : map.keySet()) { | |
if (stringBuilder.length() > 0) stringBuilder.append(setSeparator); | |
String value = map.get(key); | |
stringBuilder.append((key != null ? key : "null")); | |
stringBuilder.append(kvSeparator); | |
stringBuilder.append(value != null ? value : "null"); | |
} |
OlderNewer