Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Working on

Lucas Farina lukasfarina

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

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
Substring de caractéres não deixando as palavras no meio.
View Substring de palavras.php
if(preg_match('/^.{1,109}\b/s', $this->content, $match))
return strip_tags($match[0]);
else
return false;
@lukasfarina
lukasfarina / FacebookMicroSDK.php
Created Mar 11, 2016
Classe para acessar OpenGraph do Facebook usando app e secret id e pegar os últimos posts de uma página.
View FacebookMicroSDK.php
<?php
/*
* FacebookMicroSDK
* @Author: Lucas Farina
* @Author URI: http://www.lucasfarina.com.br
* @Version 0.0.1
* */
class FacebookMicroSDK {
@lukasfarina
lukasfarina / stripTags.php
Created Feb 22, 2016
Strip HTML tags from string in PHP
View stripTags.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 Feb 22, 2016
Pega posts de um blog usando WP Rest Api junto da Thumbnail
View get_posts.php
<?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 Jan 27, 2016
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.
View sendForm.js
var sendForm = (function () {
// Constructor
function _construct () {
return {
host: '',
// Methods
_config: config
@lukasfarina
lukasfarina / functions.php
Last active Sep 18, 2018
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
View functions.php
<?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