Skip to content

Instantly share code, notes, and snippets.

View diogenesjup's full-sized avatar
🏠
Working from home

Diogenes Oliveira Junior diogenesjup

🏠
Working from home
View GitHub Profile
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@diogenesjup
diogenesjup / custom-my-account-endpoint.php
Created November 26, 2021 19:12 — forked from claudiosanches/custom-my-account-endpoint.php
Example of custom My Account endpoint.
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@diogenesjup
diogenesjup / functions.php
Created November 14, 2021 04:58 — forked from paaljoachim/functions.php
Tutorial: WooCommerce Checkout: Add multiple custom fields to billing area. This code adds priority placement of field. Shows the custom fields in the backend Order Details screen and in e-mails to the admin and customer. I have also adjusted the checkbox field to give a text result instead of a value of 1. Checkbox is also pre-selected.
/* --------- Adds custom fields using filters. ------
The below custom fields shows various types one can use.
It is then displayed in the backend Order Details page and in admin and customer e-mails.
Checkboxes by default result only show the number 1 when clicked. I have added code so that when the a checkbox is clicked it will
show text such as On and Yes. Checkbox is also pre-selected.
Tutorial: https://easywebdesigntutorials.com/woocommerce-modifying-the-checkout-page/
*/
// Initial inspiration: https://businessbloomer.com/woocommerce-add-shipping-phone-checkout/
// My Custom Fields
@diogenesjup
diogenesjup / wp_usermeta.md
Created September 1, 2021 01:20 — forked from magnific0/wp_usermeta.md
Show and Edit User Meta in Wordpress

#Show and Edit User Meta in Wordpress

Description

This simple procedure will allow you to:

  1. Display user meta fields under in the user list as additional columsn (Users > All Users).
  2. Display these fields on user profiles.
  3. Edit these fields under user edit.

This method works completely without plugins and involves just some functions and hooks in functions.php. Plugins like "User Meta Display" achieve this to some level, but treat custom meta fiedlds completely different from the regular fields. They are shown and edited in seperate environment and fail to show the meta data is a table list. This method integrates custom user meta along with regular user (meta).

@diogenesjup
diogenesjup / 1-file_get_contents.php
Created August 30, 2021 19:12 — forked from daveh/1-file_get_contents.php
How to call APIs from PHP: file_get_contents, cURL, Guzzle and SDKs (code to accompany https://youtu.be/wMyP-q3nPd4)
<?php
$payload = json_encode([
"title" => "Updated title"
]);
$options = [
"http" => [
"method" => "PATCH",
"header" => "Content-type: application/json; charset=UTF-8\r\n" .
<?php
if ( ! function_exists( 'wpcfu_output_file_upload_form' ) ) {
/**
* Output the form.
*
* @param array $atts User defined attributes in shortcode tag
*/
function wpcfu_output_file_upload_form( $atts ) {
@diogenesjup
diogenesjup / remover-acentos.js
Created February 8, 2021 11:32 — forked from marioplumbarius/remover-acentos.js
Funcao marota para remover acentos de strings. Foi utilizado expressao regular em cima de caracteres representados na base hexadecimal.
/**
* Remove acentos de caracteres
* @param {String} stringComAcento [string que contem os acentos]
* @return {String} [string sem acentos]
*/
function removerAcentos( newStringComAcento ) {
var string = newStringComAcento;
var mapaAcentosHex = {
a : /[\xE0-\xE6]/g,
e : /[\xE8-\xEB]/g,
@diogenesjup
diogenesjup / gist:9f45072cf19a9c8b42c4ac17ba7aa5f5
Created May 13, 2020 14:17 — forked from jorgeguberte/gist:1275767
Cálculo de diferença de dias javascript
//Substituir por valores reais.
var data1 = new Date('YYYY', 'MM','DD');
var data2 = new Date('YYYY', 'MM','DD');
var diferenca = parseInt((data1-data2)/(24*3600*1000));
@diogenesjup
diogenesjup / git.md
Created May 2, 2020 15:49 — forked from leocomelli/git.md
Lista de comandos úteis do GIT

GIT

Estados

  • Modificado (modified);
  • Preparado (staged/index)
  • Consolidado (comitted);

Ajuda

@diogenesjup
diogenesjup / distance.sql
Created March 8, 2020 23:42 — forked from Usse/distance.sql
MySQL calculate distance between two latitude/longitude coordinates
CREATE FUNCTION `lat_lng_distance` (lat1 FLOAT, lng1 FLOAT, lat2 FLOAT, lng2 FLOAT)
RETURNS FLOAT
DETERMINISTIC
BEGIN
RETURN 6371 * 2 * ASIN(SQRT(
POWER(SIN((lat1 - abs(lat2)) * pi()/180 / 2),
2) + COS(lat1 * pi()/180 ) * COS(abs(lat2) *
pi()/180) * POWER(SIN((lng1 - lng2) *
pi()/180 / 2), 2) ));
END