Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@llgruff
llgruff / How to detect if a WordPress plugin is active.php
Last active October 25, 2022 09:29
A function you can use to check if plugin is active/loaded for your plugins/themes
<?php
/**
* Detect if a WordPress plugin is active
* A function you can use to check if plugin is active/loaded for your plugins/themes
* @link //gist.github.com/llgruff/c5666bfeded5de69b1aa424aa80cc14f
*/
// When coding plugins that rely on another one, like Private Content for bbPress or Visual Attributes for WooCommerce, you need to make if the WordPress Plugin is active to initialize your plugin routines or display a notice saying that the required plugin must be activated. In this tutorial we’ll see how to detect whether a certain plugin is active in a couple of ways.
## 1. Check whether a certain class or function or constant exists
@bekarice
bekarice / wc-add-order-item-meta-to-rest-response.php
Created December 28, 2016 20:18
Example: Add order item meta to WC REST API
<?php // only copy if needed
/**
* Example: Add order meta to the REST API
* WC 2.6+
*
* @param \WP_REST_Response $response The response object.
* @param \WP_Post $post Post object.
* @param \WP_REST_Request $request Request object.
* @return object updated response object
@tripflex
tripflex / functions.php
Created December 23, 2016 00:45
How to set/use image URL from user's meta value as WordPress Avatar throughout entire site
<?php
add_filter( 'pre_get_avatar_data', 'smyles_set_avatar_based_on_user_meta', 10, 2 );
/**
* Use URL from User Meta for Avatar
*
* This will return a URL value set in the user's meta to use as an avatar, if it
* exists, and is a valid URL. Should work everywhere on the site unless you're
* using a custom avatar plugin that overrides or does not call core get_avatar_data()
*
@maxsummers
maxsummers / ubuntu-install-zeromq.sh
Last active March 29, 2018 05:43
How to install ZeroMQ 4 on Ubuntu 16.10 from source
#!/usr/bin/env bash
# As in: http://stackoverflow.com/a/41289659/7331008
# Exiting on errors
set -e
# Set required version
VERSION="4.2.0"
@monecchi
monecchi / get-users-first-last-name-wordpress.php
Created December 1, 2016 23:28 — forked from kellenmace/get-users-first-last-name-wordpress.php
Get User's First and Last Name in WordPress
<?php
/**
* Get user's first and last name, else just their first name, else their
* display name. Defalts to the current user if $user_id is not provided.
*
* @param mixed $user_id The user ID or object. Default is current user.
* @return string The user's name.
*/
function km_get_users_name( $user_id = null ) {

Scraping iFood and Pedidos Já

iFood

The iFood's search queries are made with ajax under the hood sending a POST request to this variable - _ctx+URL_SEARCH+URL_SEARCH_RESTAURANT_AND_DISH (the variable output is /search/restaurantdish).

$.ajax({
  type: "POST",
  data: {
    queryString: $("#searchField").val()
 },
@wsargent
wsargent / win10-dev.md
Last active August 7, 2024 18:20
Windows Development Environment for Scala

Windows 10 Development Environment for Scala

This is a guide for Scala and Java development on Windows, using Windows Subsystem for Linux, although a bunch of it is applicable to a VirtualBox / Vagrant / Docker subsystem environment. This is not complete, but is intended to be as step by step as possible.

Harden Windows 10

Read the entire Decent Security guide, and follow the instructions, especially:

@travega
travega / moveLauncher.js
Created November 7, 2016 10:43
Dynamically adjust the location of Intercom launcher.
// DESCRIPTION: This script allows you to monitor your window width and move the Intercom messenger
// launcher at a given threshold. I used this in a Wordpress instance to change where the launcher
// appears when WooCommerce responsive quickmenu appears.
// DEPENDENCIES: jQuery
// Monitors window width and triggers the move functions when the width threshold is reached.
$(document).ready(function() {
var $window = $(window);
function checkSize() {
@jaredatch
jaredatch / functions.php
Last active August 7, 2024 15:24
WordPress Search Autocomplete using WP REST API v2
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@sn3p
sn3p / index.html
Last active February 25, 2018 18:14
Gist for blog post "Customizing the Intercom Launcher" http://blog.learningspaces.io/customizing-the-intercom-launcher
<a class="intercom-launcher" href="mailto:[email protected]">
<div class="intercom-icon-close"></div>
<div class="intercom-icon-open"></div>
<span class="intercom-unread-count"></span>
</a>