Skip to content

Instantly share code, notes, and snippets.

@mateusneves
mateusneves / bp-custom.php
Created March 30, 2016 14:21
Country custom profile field
/*
If you are using BP 2.1+, this will insert a Country selectbox.
Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
Remove this function after the field is created.
*/
function bp_add_custom_country_list() {
if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup' == $_GET['page'] ) {
@mateusneves
mateusneves / style.css
Created March 8, 2016 19:47
Element vertical align
.elment{
position: $position;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
@mateusneves
mateusneves / functions.php
Created October 26, 2015 12:34
Remove the taxonomy name from wp_title() function
function mamaduka_remove_tax_name( $title, $sep, $seplocation ) {
if ( is_tax() ) {
$term_title = single_term_title( '', false );
// Determines position of separator
if ( 'right' == $seplocation ) {
$title = $term_title . " $sep ";
} else {
$title = " $sep " . $term_title;
}
@mateusneves
mateusneves / functions.php
Created March 25, 2015 20:16
Get all dates in a month of an specific week day
function dias($dia_semana, $mes, $ano) {
$Date = new DateTime();
$dias = cal_days_in_month(CAL_GREGORIAN, $mes, $ano);
for ($dia = 0; $dia <= $dias; $dia++) {
$Date->setDate( $ano, $mes, $dia );
if ($Date->format( "w" ) == $dia_semana) {
$datas[] = $dia."/".$mes."/".$ano;
}
}
return $datas;
@mateusneves
mateusneves / functions.php
Created March 18, 2015 21:06
Activate registered users in the members list of the Buddypress
// Execute only one time, then remove from your code
$all_users = get_users();
foreach( $all_users as $user ):
bp_update_user_last_activity( $user->ID );
endforeach;
@mateusneves
mateusneves / functions.js
Created March 6, 2015 20:58
Share buttons function for work with ajax loaded content
function showSocialShareButtons( target ){
/*
Instructions:
This funciton work with ajax load content
<!-- Your HTML -->
<div id="content-to-share">
<div class="share"
data-url="<?php echo $attachment_link; ?>"
@mateusneves
mateusneves / functions.js
Created February 19, 2015 12:45
Callback on image load
$("img").one("load", function() {
// do stuff
}).each(function() {
if(this.complete) $(this).load();
});
@mateusneves
mateusneves / sreen.php
Created February 13, 2015 16:23
How to fix empty dashboard issue in WordPress
Open file blog/wp-admin/includes/screen.php in your favorite text editor.
On line 706 find the following PHP statement: <?php echo self::$this->_help_sidebar; ?>
Replace it with the statement: <?php echo $this->_help_sidebar; ?>
Save your changes.
@mateusneves
mateusneves / wp-config.php
Created February 10, 2015 21:02
Enable WordPress core auto update
define( 'WP_AUTO_UPDATE_CORE', false );
@mateusneves
mateusneves / wp-config.php
Created February 10, 2015 14:06
Disable Theme and Plugin Editors from WordPress Admin Panel
define( 'DISALLOW_FILE_EDIT', true );