View single_post_widget.php
<?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 |
View disable_self_ping.php
<?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]); | |
} |
View block-wp-login.php
<?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(); |
View wp-is-login.php
<?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' ) ); | |
} | |
} |
View is_first_widget.php
<?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. |
View wp-bootstrap-subheading.php
<?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 |
View jquery.indexlist.js
/* | |
* 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) { | |
View wp-shortcode-email-link.php
<?php | |
/** | |
* WordPress shortcode for e-mail link | |
* [email_link address="user@domain.tld" 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