Skip to content

Instantly share code, notes, and snippets.

View guilhermealveslopes's full-sized avatar

Guilherme Lopes guilhermealveslopes

View GitHub Profile
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.3.2 (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
@guilhermealveslopes
guilhermealveslopes / Upload files via ajax wordpress
Last active June 12, 2021 15:02
Upload file via ajax WORDPRESS
///////////////////////////////////////////////
// PHP
///////////////////////////////////////////////
// Create a function to handle files sent through ajax
function image_wp_handle_upload($file_handler) {
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
@guilhermealveslopes
guilhermealveslopes / Android Check Permissions
Created May 28, 2019 00:53
Check for user permissions, on current activity.
/**
* permissions request code
*/
private final static int REQUEST_CODE_ASK_PERMISSIONS = 1;
/**
* Permissions that need to be explicitly requested from end user.
*/
private static final String[] REQUIRED_SDK_PERMISSIONS = new String[]{
Manifest.permission.CAMERA,
@guilhermealveslopes
guilhermealveslopes / Fix VPS WP permissions
Last active May 2, 2019 14:38
Fix Installation failed: Could not create directory
// Fix the problem "Installation failed: Could not create directory" when try to install some plugin
or make any file changes.
// Find WebServer Owner eg: daemon, apache
ps aux | egrep '(apache|httpd)'
// Give this user ownership to project folder
chown -R {WEB_SERVER OWNER} /opt/lampp/htdocs
@guilhermealveslopes
guilhermealveslopes / ACF_repeater_post_object.txt
Created May 24, 2018 16:34
Get Post Object from ACF Repeater Field
<?php $contador = 0; if( have_rows('produtos_relacionados') ): ?>
<?php while ( have_rows('produtos_relacionados') ) : the_row(); ?>
<?php $post_object = get_sub_field('produtos'); ?>
<?php if( $post_object ): ?>
<?php $post = $post_object; setup_postdata( $post ); ?>
@guilhermealveslopes
guilhermealveslopes / Background Mask
Created January 19, 2018 14:24
Background Mask
div::before {
background: rgba(0, 0, 0, 0.9) none repeat scroll 0 0;
content: "";
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: -1;
}
@guilhermealveslopes
guilhermealveslopes / Track Refer PHP
Created January 11, 2018 16:45
Track Reffer PHP
<? $httpReferer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
echo $httpReferer;
echo $_SERVER['REDIRECT_URL']; ?>
@guilhermealveslopes
guilhermealveslopes / functions.php
Created October 25, 2017 17:50
Remove 'adivinhação' de URL por parte do Wordpress
// Por padrão ao digitar uma URL incompleta, o wordpress faz uma busca por algum post ou página
com slug similar. Com o snippet abaixo, ele simplesmente redireciona para a página 404 se o termo digitado não existe.
function no_redirect_guess_404_permalink( $header ){
global $wp_query;
if( is_404() )
unset( $wp_query->query_vars['name'] );
return $header;
@guilhermealveslopes
guilhermealveslopes / functions.php
Created September 19, 2017 11:55
Custom Endpoint Woocommerce
/* Endpoints */
/* pedidosantigos */
function endChamados() {
add_rewrite_endpoint( 'chamados', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'endChamados' );
@guilhermealveslopes
guilhermealveslopes / functions.php
Created April 25, 2017 22:06
Append content after the_content Wordpresss
add_filter( 'the_content', 'my_the_content_filter', 0 );
function my_the_content_filter( $content ) {
if (is_single()) {
global $post;
$meta=get_post_meta($post->ID, 'meta', true);
ob_start();
?>
<div class="row">
... and the rest of the html
... and field you want to add to content