This file contains hidden or 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 | |
// Diferentes menus para usuários logados e não logados | |
function my_wp_nav_menu_args( $args = '' ) { | |
if( is_user_logged_in() ) { | |
$args['menu'] = 'logado'; | |
} else { | |
$args['menu'] = 'Naologado'; | |
} |
This file contains hidden or 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
//Automatic Year, Copyright and Site Name linked to Home | |
<span>© <?php echo date("Y") ?> <a href="<?php bloginfo('siteurl'); ?>/" title="<?php bloginfo('description'); ?>"><?php bloginfo('name'); ?></a></span> |
This file contains hidden or 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 | |
// Tradução Ou Substituição de textos | |
function change_translate_text( $translated ) { | |
$text = array( | |
'Comments' => 'Comentários', | |
'Next' => 'Próximo', | |
'Previous' => 'Anterior', | |
); | |
$translated = str_ireplace( array_keys($text), $text, $translated ); | |
return $translated; |
This file contains hidden or 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 | |
// Open Comment Author Link In New Window | |
add_filter( 'get_comment_author_link', 'open_comment_author_link_in_new_window' ); | |
function open_comment_author_link_in_new_window( $author_link ) { | |
return str_replace( "<a", "<a target='_blank'", $author_link ); | |
} | |
// END Open Comment Author Link In New Window |
This file contains hidden or 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 | |
//Righlight Current parent and child menu | |
add_filter('nav_menu_css_class', 'add_active_class', 10, 2 ); | |
function add_active_class($classes, $item) { | |
if( in_array( 'current-menu-item', $classes ) || | |
in_array( 'current-menu-ancestor', $classes ) || | |
in_array( 'current-menu-parent', $classes ) || | |
in_array( 'current_page_parent', $classes ) || |
This file contains hidden or 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 | |
// Imagem relacionada é a Primeira imagem do post | |
function ds_get_first_image() { | |
global $post, $posts; | |
$first_img = ''; | |
ob_start(); | |
ob_end_clean(); | |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); | |
$first_img = $matches [1] [0]; |
This file contains hidden or 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 | |
//Tamanho do resumo | |
function new_excerpt_length($length) { | |
return 160; | |
} | |
add_filter('excerpt_length', 'new_excerpt_length'); |
This file contains hidden or 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
//Coluna com Imagem Relacionada na lista de posts | |
if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) { | |
// for post and page | |
add_theme_support('post-thumbnails', array( 'post', 'page' ) ); | |
function fb_AddThumbColumn($cols) { | |
$cols['thumbnail'] = __('Thumbnail'); | |
This file contains hidden or 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 Dashboard widgets | |
function remove_dashboard_widgets() { | |
global $wp_meta_boxes; | |
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_custom_feed']); | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']); | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); |
This file contains hidden or 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 | |
// Super User | |
function add_theme_caps() { | |
//to add capability to user | |
$user = new WP_User( $user_id = 1 ); //ID of user | |
$user->add_cap( 'custom_apability'); | |
} | |
add_action( 'admin_init', 'add_theme_caps'); | |
// |