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 | |
// Remove WP admin bar for all users who can’t edit posts | |
add_action('set_current_user', 'intw_hide_admin_bar'); | |
function intw_hide_admin_bar() { | |
if (!current_user_can('edit_posts')) { | |
show_admin_bar(false); | |
} | |
} |
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 | |
/* Trim content, excerpt, or any other string of text to a specified number of words */ | |
wp_trim_words( $text, $num_words = 55, $more = '...' ); | |
/* Custom function to trim the title. Use in place of get_the_title() | |
Example usage showing max 10 words of the title: <?php echo intw_trim_title(10); ?> */ | |
function intw_trim_title($n) { | |
return wp_trim_words( get_the_title(), $n ); | |
} |
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 | |
// Disable search icon and input in admin bar | |
add_action( 'wp_before_admin_bar_render', 'intw_disable_admin_bar_search' ); | |
function intw_disable_admin_bar_search() { | |
global $wp_admin_bar; | |
$wp_admin_bar->remove_menu('search'); | |
} |
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 | |
// Custom shortcode to add logout link with optional redirect URL and link text attributes | |
// Defaults: [intw_logout redirect="HOME PAGE" text="Logout"] | |
add_shortcode( 'intw_logout', 'intw_logout_shortcode_func' ); | |
function intw_logout_shortcode_func( $atts ) { | |
$homepage = get_bloginfo('url'); | |
extract( shortcode_atts( array( | |
'redirect' => $homepage, | |
'text' => 'Logout', |
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 | |
// 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; | |
} |
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 | |
// 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' ); | |
} | |
} |
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 | |
// 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() { ?> |
OlderNewer