Categoría: Sin categoría
Examen
Película mp4
Enlaces intra página
Ejemplo promesa
function promiseSqrt(value){
return new Promise(function (fulfill, reject){
console.log(‘START execution with value =’, value);
setTimeout(function() {
fulfill({ value: value, result: value * value });
}, 0 | Math.random() * 1000);
});
}
var p = [0,1,2,3,4,5,6,7,8,9];
p.reduce(
function (sequence, value) {
return sequence.then(function() {
return promiseSqrt(value);
}).then(function(obj) {
console.log(‘END execution with value =’, obj.value,
‘and result =’, obj.result);
});
},
Promise.resolve()
).then(function() {
console.log(‘COMPLETED’);
});
Github y netbeans
Plugin formulario de contacto
Un ejemplo tomado de aquí:
<?php
/*
Plugin Name: Formulario de contacto ejemplo
Plugin URI: http://example.com
Description: Un formulario de contacto de ejemplo para probar plugins
Version: 1.0
Author: Intelisen
Author URI: http://intelisen.com
*/
function html_form_code() {
echo '<form method="post">';
echo '<p>';
echo 'Nombre (requerido) <br/>';
echo '<input type="text" name="cf-name" pattern="[a-zA-Z0-9 ]+" value="' . ( isset( $_POST["cf-name"] ) ? esc_attr( $_POST["cf-name"] ) : '' ) . '" size="40" />';
echo '</p>';
echo '<p>';
echo 'Email (requerido) <br/>';
echo '<input type="email" name="cf-email" value="' . ( isset( $_POST["cf-email"] ) ? esc_attr( $_POST["cf-email"] ) : '' ) . '" size="40" />';
echo '</p>';
echo '<p>';
echo 'Asunto (requerido) <br/>';
echo '<input type="text" name="cf-subject" pattern="[a-zA-Z ]+" value="' . ( isset( $_POST["cf-subject"] ) ? esc_attr( $_POST["cf-subject"] ) : '' ) . '" size="40" />';
echo '</p>';
echo '<p>';
echo 'Mensaje (requerido) <br/>';
echo '<textarea rows="10" cols="35" name="cf-message">' . ( isset( $_POST["cf-message"] ) ? esc_attr( $_POST["cf-message"] ) : '' ) . '</textarea>';
echo '</p>';
echo '<p><input type="submit" name="cf-submitted" value="Enviar"></p>';
echo '</form>';
}
function deliver_mail() {
// Si se han enviado los datos, procesar
if ( isset( $_POST['cf-submitted'] ) ) {
// Sanear valores
$name = sanitize_text_field( $_POST["cf-name"] );
$email = sanitize_email( $_POST["cf-email"] );
$subject = sanitize_text_field( $_POST["cf-subject"] );
$message = esc_textarea( $_POST["cf-message"] );
// Conseguir el mail del administrador
$to = get_option( 'admin_email' );
$headers = "From: $name <$email>" . "\r\n";
// Si todo va bien, mensaje ok
if ( wp_mail( $to, $subject, $message, $headers ) ) {
echo '<div>';
echo '<p>Gracias por contactar.</p>';
echo '</div>';
} else {
echo 'Error inesperado';
}
}
}
function cf_shortcode() {
deliver_mail();
html_form_code();
}
add_shortcode( 'intelisen_contact_form', 'cf_shortcode' );