Skip to content

Instantly share code, notes, and snippets.

View lukasfarina's full-sized avatar
💭
Working on

Lucas Farina lukasfarina

💭
Working on
  • Myself
  • São Paulo, SP, Brazil
View GitHub Profile
@lukasfarina
lukasfarina / explanation.md
Last active April 30, 2020 02:00
[SOLVED] Respomnse woocommerce_rest_cannot_view at POSTMAN using Wordpress REST API on localhost,

Testing with postman.
If you're running on localhost for example, simply use OAuth 1.0, providing only the consumer key and consumer secret and leaving all other properties blank.

If Basic Auth with HTTPS not working, do this:
You have to configure apache http.conf or .htaccess and add this line to be sure that apache will return authorization header:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

@lukasfarina
lukasfarina / Substring de palavras.php
Created May 23, 2016 18:38
Substring de caractéres não deixando as palavras no meio.
if(preg_match('/^.{1,109}\b/s', $this->content, $match))
return strip_tags($match[0]);
else
return false;
@lukasfarina
lukasfarina / FacebookMicroSDK.php
Created March 11, 2016 14:31
Classe para acessar OpenGraph do Facebook usando app e secret id e pegar os últimos posts de uma página.
<?php
/*
* FacebookMicroSDK
* @Author: Lucas Farina
* @Author URI: http://www.lucasfarina.com.br
* @Version 0.0.1
* */
class FacebookMicroSDK {
@lukasfarina
lukasfarina / stripTags.php
Created February 22, 2016 17:22
Strip HTML tags from string in PHP
<?php
ob_start();
the_content();
$old_content = ob_get_clean();
$new_content = strip_tags($old_content);
$content_excerpt = substr($new_content, 0 ,130).'...';
@lukasfarina
lukasfarina / get_posts.php
Created February 22, 2016 17:12
Pega posts de um blog usando WP Rest Api junto da Thumbnail
<?php
function get_recent_posts($per_page = 2) {
// featured_media
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_SERVER['SERVER_NAME'] . "/blog/wp-json/wp/v2/posts?per_page={$per_page}");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
@lukasfarina
lukasfarina / sendForm.js
Last active January 27, 2016 02:14
Ideia em edição, futura lib para facilitar a validação e submissão de um formulário visando resolver os maiores problemas existentes no mundo de agências e desenvolvedores que buscam soluções pouco extensas na hora de executar um comportamento.
var sendForm = (function () {
// Constructor
function _construct () {
return {
host: '',
// Methods
_config: config
@lukasfarina
lukasfarina / functions.php
Last active September 18, 2018 12:10
PT-BR: Trocar o output do Breadcrumb do plugin Yoast para uma versão com microdata. | EN: Change output of your Yoast breadcrumbs to version with microdata
<?php
/*
* Plugin Name: Fix Microdata Yoast Breadcrumb
* Plugin URI: https://gist.github.com/lukasfarina/83cdb2e8c2661b2b8017/
* Author: Lucas Farina
* Author URI: lucasfarina.com.br
* */
// Change Wrap of Breadcrumb