Skip to content

Instantly share code, notes, and snippets.

@jplouback
jplouback / text_cut.php
Created July 4, 2017 19:51 — forked from marcosbrasil/text_cut.php
FUnção PHP para limitar texto sem cortar palavras
<?php
function limitarTexto($texto, $limite){
$texto = substr($texto, 0, strrpos(substr($texto, 0, $limite), ' ')) . '...';
return $texto;
}
// String a ser limitada
$string = 'Como limitar caracteres sem cortar as palavras com PHP';
// Mostrando a string limitada em 25 caracteres.
@jplouback
jplouback / thumb_on_feed_wordpress.txt
Created June 7, 2018 15:39
Inserindo imagem destacada no feed do site - Wordpress
/* Adicionando post_thumbnail no feed */
add_action( 'rss2_item', 'custom_thumbnail_tag' );
function custom_thumbnail_tag() {
global $post;
if ( has_post_thumbnail( $post->ID ) ) {
$thumbnail = get_the_post_thumbnail_url( $post->ID );
echo("<image>{$thumbnail}</image>");
}
/* Bootstrap 4.1.0 - https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css */
.accordion
.active
.alert
.alert-danger
.alert-dark
.alert-dismissible
.alert-heading
.alert-info
@jplouback
jplouback / class-developer-import.php
Created September 2, 2019 21:28 — forked from tomazzaman/class-developer-import.php
Import JSON into WordPress
<?php
// Published under GPL
// tutorial here: https://codeable.io/community/how-to-import-json-into-wordpress/
class Developer_Import {
public function __construct() {
add_action( 'wp_ajax_import_developer', array( $this, 'import_developer' ) );