Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / plugin.php
Created September 6, 2018 23:29 — forked from igorbenic/plugin.php
Show a WordPress Post in a Modal - Article on Ibenic.com
<?php
/**
* Plugin Name: IBenic Bootstrap Modal
* Plugin URI: http://www.ibenic.com/show-a-wordpress-post-in-a-modal/
* Description: Show an article in a modal on the same page.
* Version: 1.0
* Author: Igor benić
* Author URI: http://www.ibenic.com
* License: GPL2
*
@monecchi
monecchi / README.md
Created August 28, 2018 03:08 — forked from itzikbenh/README.md
WordPress - How to upload images from a frontend form via the rest-api.

Before you go over the snippets I will summarize which functions are being used.

media_handle_upload('image', 0);

That's it! one function that would insert the image into the DB, create four copies with different sizes, and upload to the uploads directory. Regarding the arguments:

'image' is what holds all the data about the image. It comes from the POST request. In the JS file you will see what I mean.

'0' This is the $post_id. I set it to zero, because i'm not asigning this image to any post at the moment. In order for this function to work we need to add above it:

@monecchi
monecchi / restapi.txt
Created July 23, 2018 20:11 — forked from chrismccoy/restapi.txt
WordPress REST API Resources
Allow ALL cross origin requests to WordPress REST API
https://github.com/Shelob9/rest-all-cors
WordPress theme using Rest API and Vue.js
https://github.com/rtCamp/VueTheme
WordPress Post from Front End using REST API and Vue.js
http://jimfrenette.com/2017/01/post-from-front-end-wp-api-vuejs/
An offline-first SPA using Vue.js, the WordPress REST API and Progressive Web Apps
@monecchi
monecchi / yoast_seo_meta_remove_dates.php
Created June 19, 2018 21:49 — forked from amboutwe/yoast_seo_meta_remove_dates.php
Remove Date Meta Tags Output by Yoast SEO
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Date Meta Tags Output by Yoast SEO
* Credit: Yoast development team
* Last Tested: Mar 01 2017 using Yoast SEO 4.4 on WordPress 4.7.2
*/
add_action('wpseo_dc_'.'DC.date.issued', '__return_false'); // Premium only
add_filter( 'wpseo_og_article_published_time', '__return_false' );
@monecchi
monecchi / functions.php
Created April 30, 2018 14:30 — forked from tripflex/functions.php
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()
*
@monecchi
monecchi / ubuntu-install-zeromq.sh
Created March 29, 2018 05:43 — forked from maxsummers/ubuntu-install-zeromq.sh
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"
jQuery(document).ready(function($) {
/**
* Media Uploader
*/
var media_uploader = null;
function open_media_uploader_video(img, field) {
media_uploader = wp.media({
title: 'Select or Upload Media',
button: {
text: 'Use this media'
@monecchi
monecchi / epsforwordpress.php
Created March 2, 2018 00:27 — forked from dovy/epsforwordpress.php
Add to your functions.php
<?php
function custom_upload_mimes ( $existing_mimes=array() ) {
// Add *.EPS files to Media upload
$existing_mimes['eps'] = 'application/postscript';
return $existing_mimes;
}
add_filter('upload_mimes', 'custom_upload_mimes');
/**
* WooCommerce Quanity buttons add-back
*/
jQuery( function( $ ) {
var $testProp = $( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).find('qty');
if ($testProp && $testProp.prop('type') != 'date') {
// Quantity buttons
$( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '<input type="button" value="+" class="plus" />' ).prepend( '<input type="button" value="-" class="minus" />' );
// Target quantity inputs on product pages
@monecchi
monecchi / functions.php
Created February 23, 2018 20:02 — forked from claudiosanches/functions.php
WooCommerce - Botão orçar
<?php
function cs_add_to_cart_text( $text ) {
return __( 'Orçar' );
}
// Loop.
add_filter( 'woocommerce_product_add_to_cart_text', 'cs_add_to_cart_text' );
// Single.
add_filter( 'woocommerce_product_single_add_to_cart_text', 'cs_add_to_cart_text' );