Skip to content

Instantly share code, notes, and snippets.

View wildiney's full-sized avatar

Wildiney Di Masi wildiney

View GitHub Profile
@wildiney
wildiney / filter_ptags_on_images.php
Created November 16, 2011 10:53
Removing the p tag on images into the content
<?php
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
?>
@wildiney
wildiney / wp_authorNotification.php
Created November 16, 2011 10:54
Notify author when his post is published
<?php
function wpr_authorNotification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = "
Hi ".$author->display_name.",
Your post, ".$post->post_title." has just been published. Well done!
";
wp_mail($author->user_email, "Your article is online", $message);
@wildiney
wildiney / copyright_meta.php
Created November 16, 2011 10:55
Inserting the copyright on Meta tag
@wildiney
wildiney / zend_view_helper_convertDate
Created November 16, 2011 10:57
Zend View Helper Convert Date
<?php
/**
* Zend View Helper Convert Date
*
* @author Niels Lange <info@semanticsamsterdam.nl>
* @copyright semantics <info@semanticsamsterdam.nl>
*/
class Zend_View_Helper_ConvertDate extends Zend_View_Helper_Abstract
{
/**
@wildiney
wildiney / wp_snapshot
Created November 16, 2011 10:59
Mostrar snapshot de qualquer site
<?php
function wpr_snap($atts, $content = null) {
extract(shortcode_atts(array(
"snap" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://www.escolawp.com',
"alt" => 'My image',
"w" => '400', // width
"h" => '300' // height
), $atts));
@wildiney
wildiney / paypal_donation
Created November 16, 2011 11:00
Link de doação Paypal
<?php
function cwc_donate_shortcode( $atts ) {
extract(shortcode_atts(array(
'text' => 'Make a donation',
'account' => 'REPLACE ME',
'for' => '',
), $atts));
global $post;
@wildiney
wildiney / wp_obfuscate
Created November 16, 2011 11:01
Ofuscar endereço de email
<?php
function cwc_mail_shortcode( $atts , $content=null ) {
for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';
return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>';
}
add_shortcode('mailto', 'cwc_mail_shortcode');
?>
<?php
[mailto]email@yourdomain.com[/mailto]
@wildiney
wildiney / view_pdf
Created November 16, 2011 11:02
Exibir pdf em iframe
<?php
function cwc_viewpdf($attr, $url) {
return '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width:' .$attr['width']. '; height:' .$attr['height']. ';" frameborder="0">Your browser should support iFrame to view this PDF document</iframe>';
}
add_shortcode('embedpdf', 'cwc_viewpdf');
?>
<?php
[embedpdf width="600px" height="500px"]http://infolab.stanford.edu/pub/papers/google.pdf[/embedpdf]
?>
@wildiney
wildiney / cwc_youtube
Created November 16, 2011 11:05
Embeber vídeos do youtube
<?php
function cwc_youtube($atts) {
extract(shortcode_atts(array(
"value" => 'http://',
"width" => '475',
"height" => '350',
"name"=> 'movie',
"allowFullScreen" => 'true',
"allowScriptAccess"=>'always',
), $atts));
@wildiney
wildiney / developer tool bar
Created November 17, 2011 18:21
Ligar e desligar Developer toolbar na URL
# Ligar developer toolbar
http://MAGENTOROOT/developertoolbar/index/hints/enabled/1/
# Desligar developer toolbar
http://MAGENTOROOT/developertoolbar/index/hints/enabled/0/