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 | |
// Make sure we have a theme domain for localization | |
if( ! defined( 'THEME_DOMAIN' ) ) | |
define( 'THEME_DOMAIN', get_stylesheet() ); // Any translation has to go in your stylesheet directory | |
/** | |
* Makes a custom widget to display any published post. | |
* | |
* @package WordPress |
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 | |
// Retrieved from: http://wp-snippets.com/disable-self-trackbacks/ | |
add_action( 'pre_ping', 'disable_self_ping' ); | |
function disable_self_ping( &$links ) { | |
foreach ( $links as $l => $link ) | |
if ( 0 === strpos( $link, get_option( 'home' ) ) ) | |
unset($links[$l]); | |
} |
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_action( 'init', 'custom_init_function' ); | |
function custom_init_function() { | |
global $pagenow; | |
if( ! is_user_logged_in() && 'wp-login.php' == $pagenow ) { | |
wp_redirect( home_url() ); // redirect URL | |
exit(); |
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 | |
/** | |
* Conditional tag to check whether current page is wp-login.php or wp-register.php. | |
*/ | |
if( ! function_exists( 'wp_is_login' ) ) { | |
function wp_is_login() { | |
return in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php' , 'wp-register.php' ) ); | |
} | |
} |
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 | |
/** | |
* Goes in function widget(…) inside class Your_Widget | |
*/ | |
// 1. Get all active widgets from all sidebars. | |
$all_sidebars_widgets = wp_get_sidebars_widgets(); | |
// 2. Get only the active widgets in our currently inhabitated sidebar. |
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 | |
/** | |
* Append a sub-heading to WordPress post titles | |
* | |
* Input: My title | my sub-title | |
* Output: My title <small>my sub-title</small> | |
* | |
* The filter the_title() is used for posts/pages AND nav menus in WordPress. | |
* In order to filter only post/page titles, not nav menu items, we need to |
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
/* | |
* Assuming your post/page content happens in .entry-content and you structured it semantically using h3 elements, | |
* these functions will create a clickable index list at the top of your content. | |
* Modify hard-coded selectors as you see fit; I used .indexlist for the ul element, | |
* .indexitem for each li item and h3 elements within .entry-content to create the list items from. | |
*/ | |
$.fn.inlineScrolling = function(options) { | |
return this.each(function(event) { | |
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 shortcode for e-mail link | |
* [email_link address="[email protected]" text="E-Mail me!"] | |
* | |
* @param address (required) E-Mail address | |
* @param text (required) Link text | |
* @param before (optional) HTML to go before the <a> tag | |
* @param after (optional) HTML to go after the </a> tag | |
* @param before_text (optional) HTML to go before the link text |
OlderNewer