Skip to content

Instantly share code, notes, and snippets.

View leobaiano's full-sized avatar

Leo Baiano leobaiano

  • UX Agency
  • São Paulo, SP - Brasil
View GitHub Profile
@leobaiano
leobaiano / gist:6522e0e473c2a2fb2892
Created August 29, 2014 14:28
Migrar posts de um site WordPress para outro
<?php
ignore_user_abort(1);
set_time_limit(0);
@ini_set('max_execution_time', 0);
include(ABSPATH . "wp-blog-header.php");
$fotos = $wpdb->get_results("SELECT * FROM videos ORDER BY id DESC");
foreach( $fotos as $foto ){
@leobaiano
leobaiano / gist:f3f51e6a05b1a9a9eaf9
Created October 21, 2014 00:36
Remove menus do admin WordPress
function remove_menus () {
if (current_user_can( 'edit_themes' )) {
global $menu;
$restricted = array(
//Remova ou comente as linhas a seguir para exibir os itens.
__('Dashboard'),
__('Posts'),
__('Media'),
__('Links'),
__('Pages'),
@leobaiano
leobaiano / gist:1d121ed377b37ca55c65
Created October 31, 2014 15:27
Definir tamanho dos thumbs da [gallery] WordPress
function amethyst_gallery_atts( $out, $pairs, $atts ) {
$atts = shortcode_atts( array(
'columns' => '2',
'size' => 'medium',
), $atts );
$out['columns'] = $atts['columns'];
$out['size'] = $atts['size'];
@leobaiano
leobaiano / gist:46c536a502d56d204da8
Last active August 29, 2015 14:09
Páginação WordPress
$args = array( 'big_number' => 999999999,
'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query->max_num_pages,
'prev_next' => true,
'end_size' => 1,
'mid_size' => 4,
'type' => 'list'
);
@leobaiano
leobaiano / gist:5132e444c004f1e576f4
Created March 3, 2015 11:21
Impedir que usuário envie mais de uma vez o form ajax clicando várias vezes no botão
jQuery.fn.preventDoubleSubmit = function() {
jQuery(this).submit(function() {
if (this.beenSubmitted)
return false;
else
this.beenSubmitted = true;
});
};
jQuery('#my_form').preventDoubleSubmit();
@leobaiano
leobaiano / bomfinder.php
Created March 30, 2015 20:37
Assinatura BOM
<?php
// Tell me the root folder path.
// You can also try this one
// $home = $_SERVER['DOCUMENT_ROOT'];
// Or this
// dirname( __FILE__ )
$home = dirname( __FILE__ );
// Is this a Windows host ? If it is, change this line to $windows = true;
$windows = false;
@leobaiano
leobaiano / gist:7f090d2fbd6c35c54b87
Created April 24, 2015 01:39
MailPoet: Add new subscriber
<?php
// The ID of the lists you want to add a user to
$list_ids = array( 1 );
// User Data without the custom fields
$data_subscriber = array(
'user' => array(
'email' => 'johndoe@email.com',
'firstname' => 'John',
'lastname' => 'Doe',
@leobaiano
leobaiano / gist:5e0584bc8f63cd627ffa
Created April 24, 2015 19:15
WordPress: Exibir imagens de um post ou página
<?php
$argsThumb = array(
'order' => 'ASC',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_mime_type' => 'image',
'post_status' => null
);
$attachments = get_posts($argsThumb);
if ($attachments) {
@leobaiano
leobaiano / get_src_thumbnail
Created April 24, 2015 19:20
WordPress: Retorna a url da imagem thumbnail
<?php
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_size' );
$url = $thumb['0'];
?>
@leobaiano
leobaiano / gist:120f92de725779b77e3f
Created April 30, 2015 14:07
Usando vídeo como background
<style>
*,
html,
body {
margin: 0;
padding: 0;
}
video { display: block; }