Use this function to cutting text to a specific length, with the ability to prevent that the last word be cutted in half.
require 'cutText.php';
$text1 = 'Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut laboredo.';| function number_format(amount, decimals) { | |
| amount += ''; // por si pasan un numero en vez de un string | |
| amount = parseFloat(amount.replace(/[^0-9\.]/g, '')); // elimino cualquier cosa que no sea numero o punto | |
| decimals = decimals || 0; // por si la variable no fue fue pasada | |
| // si no es un numero o es igual a cero retorno el mismo cero | |
| if (isNaN(amount) || amount === 0) | |
| return parseFloat(0).toFixed(decimals); |
| <?php | |
| function regenerateThumbnails() | |
| { | |
| global $wpdb; | |
| $images = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%'"); | |
| foreach ($images as $image) | |
| { |
| <?php | |
| function time_elapsed_string($ptime) | |
| { | |
| $etime = time() - $ptime; | |
| if ($etime < 1) | |
| { | |
| return '0 seconds'; | |
| } |
| {"1":{"Pais":"Republica Dominicana","Provincia":{"1":{"Nombre":"Distrito Nacional","Capital":"Santo Domingo de Guzmán"},"2":{"Nombre":"Azua","Capital":"Azua de Compostela","Municipio":{"1":{"Nombre":"Azua de Compostela","Distrito":{"1":"Barreras ","2":"Barro Arriba ","3":"Clavellina ","4":"Emma Balaguer Viuda Vallejo ","5":"Las Barías-La Estancia ","6":"Las Lomas ","7":"Los Jovillos ","8":"Puerto Viejo"}},"2":{"Nombre":"Estebanía"},"3":{"Nombre":"Guayabal"},"4":{"Nombre":"Las Charcas","Distrito":{"9":"Hatillo ","10":"Palmar de Ocoa"}},"5":{"Nombre":"Las Yayas de Viajama","Distrito":{"11":"Villarpando ","12":"Hato Nuevo-Cortés"}},"6":{"Nombre":"Padre Las Casas","Distrito":{"13":"La Siembra ","14":"Las Lagunas ","15":"Los Fríos"}},"7":{"Nombre":"Peralta"},"8":{"Nombre":"Pueblo Viejo","Distrito":{"16":"El Rosario"}},"9":{"Nombre":"Sabana Yegua","Distrito":{"17":"Proyecto 4 ","18":"Ganadero ","19":"Proyecto 2-C"}},"10":{"Nombre":"Tábara Arriba","Distrito":{"20":"Amiama Gómez ","21":"Los Toros ","22":"Tábara Abajo |
| <!doctype html> | |
| <html lang="es"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> | |
| <title>Formulario de contacto</title> | |
| <link rel="stylesheet" type="text/css" href="styles.css"> | |
https://codepen.io/jrobinsonc/pen/jYrxwb
To transpile the JavaScript, can use:
| <?php | |
| function get_twitter_access_token($consumer_key, $consumer_secret) | |
| { | |
| $options = array( | |
| CURLOPT_POSTFIELDS => array('grant_type' => 'client_credentials'), | |
| CURLOPT_HTTPHEADER => array('Authorization: Basic ' . base64_encode($consumer_key . ':' . $consumer_secret)), | |
| CURLOPT_HEADER => FALSE, | |
| CURLOPT_URL => 'https://api.twitter.com/oauth2/token', | |
| CURLOPT_RETURNTRANSFER => TRUE |
| <?php | |
| /** | |
| * linkify | |
| * | |
| * @link Github: https://gist.github.com/jrobinsonc/e79578c41ca48bac9bde | |
| * @param string $value | |
| * @param array $protocols | |
| * @param array $attributes | |
| * @param string $mode |
| <?php | |
| /** | |
| * Default: | |
| */ | |
| $post_thumbnail_id = get_post_thumbnail_id(get_the_ID()); | |
| $width = 640; | |
| $height = 480; |