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) | |
{ |
/* | |
Enable the "Request Desktop Site" functions on mobile chrome (android and iOS) allow users to see desktop layouts on responsive sites. Note that this is distinct from "opt out of mobile!" buttons built into your site: this is meant to work with the browser's native opt-in/opt-out functionality. | |
Since these functions work, in part, by simply spoofing the user agent to pretend to be desktop browsers, all we have to do is just remember that the browser once claimed to be android earlier in the same session and then alter the viewport tag in response to its fib. | |
Here's an example viewport tag <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> that we'd be setting to scaleable-yes,max scale=2. That's just an example of something that works on the site I was building: you should customize the "desktop" viewport content setting to whatever works for your site's needs. If you wanted, you could stick this code in the head just after the primary viewport tag so that the br |
This should help you get Sendmail installed with basic configuration on Ubuntu.
sudo apt-get install sendmail
/etc/hosts
file: nano /etc/hosts
127.0.0.1 localhost yourhostname
sudo sendmailconfig
sudo service apache2 restart
<?php | |
function time_elapsed_string($ptime) | |
{ | |
$etime = time() - $ptime; | |
if ($etime < 1) | |
{ | |
return '0 seconds'; | |
} |
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; |