Skip to content

Instantly share code, notes, and snippets.

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

Noah U nucab

🏠
Working from home
  • Philippines
  • 13:39 (UTC +08:00)
  • LinkedIn in/nucab
View GitHub Profile
@nucab
nucab / available_font-awesome_icons.php
Created November 19, 2016 19:28 — forked from gubi/available_font-awesome_icons.php
Get all icons from a font-awesome.css file and list in json mode
<?php
/**
* Available Font Awesome icons
*
* Get all icons from a font-awesome.css file and list in json mode
*
* @author Alessandro Gubitosi <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3
*/
https://wordpress.org/support/topic/w3-total-cache-how-to-disable-minify-css-in-a-particular-template/
Well, just add this line at the top of the template page :
define('DONOTMINIFY', true);
@nucab
nucab / webpack.config.js
Created November 1, 2016 04:17 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@nucab
nucab / Google Docs Script
Created October 21, 2016 05:40 — forked from tomcritchlow/Google Docs Script
The Google Spreadsheets Script Used To Call Social Media APIs
function FBshares(url) {
var jsondata = UrlFetchApp.fetch("http://graph.facebook.com/"+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.shares;
}
function Tweets(url) {
var jsondata = UrlFetchApp.fetch("http://urls.api.twitter.com/1/urls/count.json?url="+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.count;
@nucab
nucab / gist:44cade068aaab17bb120e0b298c60814
Created September 17, 2016 08:59 — forked from frankiejarrett/gist:5544469
Return an attachment ID using a URL in WordPress
<?php
/**
* Return an ID of an attachment by searching the database with the file URL.
*
* First checks to see if the $url is pointing to a file that exists in
* the wp-content directory. If so, then we search the database for a
* partial match consisting of the remaining path AFTER the wp-content
* directory. Finally, if a match is found the attachment ID will be
* returned.
*
@nucab
nucab / facebook_like-box_responsive.css
Created September 6, 2016 15:31 — forked from smeranda/facebook_like-box_responsive.css
Flexible width layout for Facebook Like Box/Activity Stream to use in Responsive Designs
/*
Make the Facebook Like box responsive (fluid width)
https://developers.facebook.com/docs/reference/plugins/like-box/
*/
/* This element holds injected scripts inside iframes that in some cases may stretch layouts. So, we're just hiding it. */
#fb-root {
display: none;
}
// User defined code goes here
window.onload = function(e) {
console.log('window loaded!');
parent.API.toggleContinueButton();
};
@nucab
nucab / Mark parent navigation active when on custom post type single page Mark (highlight) custom post type parent as active item in Wordpress Navigation. When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
/**
* Custom PayPal button text
*
*/
add_filter( 'gettext', 'ld_custom_paypal_button_text', 20, 3 );
function ld_custom_paypal_button_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Proceed to PayPal' :
$translated_text = __( 'Buy Now', 'woocommerce' );
break;
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript