Skip to content

Instantly share code, notes, and snippets.

@intelliweb
intelliweb / logout_link_shortcode.php
Last active December 11, 2015 22:09
Custom shortcode to add logout link with optional redirect URL and link text attributes
@intelliweb
intelliweb / user_meta_shortcode.php
Created January 29, 2013 21:28
Custom shortcode to display user meta for currently logged in user
<?php
// Custom shortcode to display user meta for currently logged in user
add_shortcode('intw_user_meta', 'intw_user_meta_func');
function intw_user_meta_func($atts) {
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$content = '<p>Welcome, ' . $current_user->display_name . '!</p>';
return $content;
}
@intelliweb
intelliweb / WP Headway: custom header and footer
Created January 29, 2013 21:34
Custom header and footer in Headway 2.x
@intelliweb
intelliweb / builder_nav_style_to_menu.php
Last active December 14, 2015 21:39
Builder: Add navigation module styling to custom nav menu
<?php
/********************************************
Add the following to functions.php
********************************************/
// Register custom nav menu locations
register_nav_menus( array(
'main_nav' => 'Main Navigation Menu',
'footer_menu' => 'Footer Menu'
) );
@intelliweb
intelliweb / builder_custom_module_css_class.php
Created March 14, 2013 19:32
Builder: Add custom CSS class names to Builder modules
<?php
// Custom Builder module CSS classes for styling
if ( ! function_exists( 'it_builder_loaded' ) ) {
add_action( 'it_libraries_loaded', 'it_builder_loaded' );
function it_builder_loaded() {
builder_register_module_style( array('html','widget-bar','content'), 'Sample Style Name', 'sample-style-class' );
}
}
@intelliweb
intelliweb / before_after_body.php
Created March 21, 2013 02:05
Builder: Add code just after <body> and just before </body>
<?php
// Hook right after opening <body> tag
add_action('builder_layout_engine_render_header', 'intw_add_after_opening_body', 20 );
function intw_add_after_opening_body() { ?>
HTML code that you want just after the opening body tag should be placed here
<?php }
// Hook right before closing </body> tag
add_action('builder_finish', 'intw_add_before_closing_body', 0 );
function intw_add_before_closing_body() { ?>
@intelliweb
intelliweb / builder_modify_widget_title_wrappers.php
Created March 21, 2013 02:08
Builder: Change default widget title HTML wrapper. How to replace H4 tags around widget titles
<?php
// Modify default widget wrappers
add_filter( 'builder_filter_register_sidebar_options', 'intw_modify_widget_wrappers' );
function intw_modify_widget_wrappers( $options ) {
$options['before_title'] = '<div class="widget-title">';
$options['after_title'] = '</div>';
return $options;
}
?>
@intelliweb
intelliweb / is_tree.php
Last active March 1, 2021 20:57
WP: is_tree() function to check if the current page is the page or a sub page of the page ID specified. Can be used as conditional tag with Widget Logic. Source: http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
<?php
// This function will return true if we are looking at the page in question or one of its sub pages
function is_tree( $pid ) { // $pid = The ID of the page we're looking for pages underneath
global $post; // load details about this page
if ( is_page($pid) )
return TRUE; // we're at the page or at a sub page
$anc = get_post_ancestors( $post->ID );
<?php
class Intw_User_Caps {
// Add our filters
function Intw_User_Caps(){
add_filter( 'editable_roles', array(&$this, 'editable_roles'));
add_filter( 'map_meta_cap', array(&$this, 'map_meta_cap'),10,4);
}
@intelliweb
intelliweb / related_posts_category.php
Created April 9, 2013 03:05
WP: related posts by category