Archive for the “Código” category

Código PHP para WordPress

Rober4th mar 2009Código, Wordpress, ,

Algunas de las llamadas a funciones PHP más utilizadas en WordPress y que te permitirán modificar la plantilla de tu blog reordenando y mostrando u ocultando algunos datos importantes:

<?php the_title() ?> ///Título del post.
<?php comment_author() ?> ///Autor del comentario.
<?php comment_date(’j F, Y’) ?> ///Fecha del comentario.
<?php comment_author_url() ?> ///URL del autor del comentario.
<?php comment_text() ?> ///Texto del comentario.
<?php the_time(’l, F jS, Y’) ?> ///Fecha de publicación del post.
<?php the_category(’, ‘) ?> ///Categoría del Post.
<?php comments_number(’No hay’, ‘1′, ‘%’ );?> ///Nº de comentarios.
<?php echo(str_word_count(get_the_content())); ?> ///Nº de palabras.
<?php get_header(); ?> ///Llamar al header.
<?php get_sidebar(); ?> ///Llamar al sidebar.
<?php get_footer(); ?> ///Llama al footer.
<?php bloginfo(’name’); ?> ///Nombre del blog.

<style type=”text/css” media=”screen”>
@import url( <?php bloginfo(’stylesheet_url’); ?> );
</style> /// Importar el style

Vía Skyandstars.net

Un poco de código PHP

Rober27th nov 2008Código, Tecnología, ,

Aquí van unos snippets de código PHP que pueden hacernos más sencillas algunas tareas a la hora de llevar nuestra web:

Validar una dirección de email:

include('EmailAddressValidator.php');

$validator = new EmailAddressValidator;
if ($validator->check_email_address('test@example.org')) {
    // Email address is technically valid
}
else {
    // Email not valid
}

Conseguir la dirección IP:

function getRealIpAddr(){
	if (!empty($_SERVER['HTTP_CLIENT_IP'])){
		//check ip from share internet
		$ip = $_SERVER['HTTP_CLIENT_IP'];
	}
	elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
		//to check ip is pass from proxy
		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
	}
	else{
		$ip = $_SERVER['REMOTE_ADDR'];
	}
	return $ip;
}

(más…)

Esta web está realizada con: