Skip to content

Instantly share code, notes, and snippets.

View FerFuego's full-sized avatar

FeR.Catalano FerFuego

View GitHub Profile
SELECT
p.ID as 'Order ID',
p.post_status as 'Order Status',
p.post_date as 'Order Date',
max( CASE WHEN pm.meta_key = '_billing_email' and p.ID = pm.post_id THEN pm.meta_value END ) as Email,
max( CASE WHEN pm.meta_key = '_billing_first_name' and p.ID = pm.post_id THEN pm.meta_value END ) as first_name,
max( CASE WHEN pm.meta_key = '_billing_last_name' and p.ID = pm.post_id THEN pm.meta_value END ) as last_name,
max( CASE WHEN pm.meta_key = '_billing_address_1' and p.ID = pm.post_id THEN pm.meta_value END ) as billing_address,
max( CASE WHEN pm.meta_key = '_shipping_address_1' and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_address,
max( CASE WHEN pm.meta_key = '_order_total' and p.ID = pm.post_id THEN pm.meta_value END ) as order_total,
@FerFuego
FerFuego / get_user_location_by_ip.php
Created January 8, 2022 23:19
This snippet is for get complete location users by your ip address
<?php
/**
* Get My Location object
* Request to API endpoint https://geolocation-db.com
* @param REMOTE_ADDR
*/
function get_user_location_by_ip () {
$response = file_get_contents('https://geolocation-db.com/json/'.$_SERVER['REMOTE_ADDR']);
$location = json_decode($response, true);
return $location;
@FerFuego
FerFuego / add_filter_to_admin_menu.php
Created October 22, 2020 15:47
Add filter to Admin Menu
<?php
/**
* Add filter to Admin Menu
* Change: my_custom_post_type_1, my_custom_post_type_2, my_meta_type, my_meta_value and options of select
*/
add_filter( 'parse_query', 'acf_admin_posts_filter' );
add_action( 'restrict_manage_posts', 'acf_admin_posts_filter_restrict_manage_posts' );
function acf_admin_posts_filter( $query ) {
global $pagenow;
@FerFuego
FerFuego / time_to_posted.php
Created October 8, 2020 21:12
Calc time to posted
<?php
/**
* Return time to posted
*/
function time_to_post($post = null) {
$current_day = date('Y-m-d h:i');
$post_day = ( $post ) ? get_the_time('Y-m-d h:i', $post) : get_the_time('Y-m-d h:i');
@FerFuego
FerFuego / fmc_items_login_logout.php
Created September 1, 2020 01:29
Add Dropdown into Main Menu Login / Logout
<?php
/**
* Add Dropdown into Main Menu Login / Logout
*/
add_filter( 'wp_nav_menu_items', 'fmc_items_login_logout', 10, 2);
function fmc_items_login_logout( $items, $args ) {
if ($args->theme_location == 'primary') {
@FerFuego
FerFuego / remove_core_updates.php
Created September 1, 2020 01:26
Ocultar todos los avisos de actualizaciones
<?php
/*
* Hide all updates
*/
function remove_core_updates(){
global $wp_version;
return(object) array(
'last_checked'=> time(),
'version_checked'=> $wp_version
@FerFuego
FerFuego / related_post_category.php
Last active August 12, 2020 13:04
Related Post Category
<?php
/**
* Return html
*/
function related_post() {
$post_id = get_the_ID();
$post_type = get_post_type($post_id);
$cat_ids = array();
$categories = get_the_category( $post_id );
@FerFuego
FerFuego / class_abstract.php
Created July 21, 2020 19:22
Simple example of Abstract Class and Extends Class
<?php
abstract class Person {
protected $name;
protected $age;
public function __construct($name, $age) {
$this->name = $name;
@FerFuego
FerFuego / update_users_meta_acf.php
Created July 21, 2020 17:47
Example update user meta ACF
$user_id = wp_get_current_user()->ID;
update_user_meta( $user_id, 'first_name', $_POST['user_firstname'] );
update_user_meta( $user_id, 'last_name',$_POST['user_lastname'] );
update_user_meta( $user_id, 'linkedin', $_POST['user_linkedin'] );
update_user_meta( $user_id, 'facebook', $_POST['user_facebook'] );
update_user_meta( $user_id, 'instagram', $_POST['user_instagram'] );
update_user_meta( $user_id, 'twitter', $_POST['user_twitter'] );
update_user_meta( $user_id, 'biography', $_POST['user_description'] );
update_user_meta( $user_id, 'education', $_POST['user_education'] );
@FerFuego
FerFuego / custom_trim_excerpt.php
Last active February 5, 2021 18:32
Trim text, strip shortcodes and excerpt return - Wordpress
/**
* Trim text, strip shortcodes and excerpt return
*
* @param Int $post - Post ID (optional)
* @param String $text - Text or get_the_conten() (optional)
* @param Int $words - Number of words to return
*
* @return string - "Ex: This is my text trim and..."
*
* Use: echo custom_trim_excerpt($post_id, '', 20 );