Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Making things. All the things. Ahh!

Macario James macariojames

💭
Making things. All the things. Ahh!
View GitHub Profile
@macariojames
macariojames / gist:6f28e4edb7f5dbb03515
Last active Aug 1, 2019 — forked from carolineschnapp/gist:9122054
Shopify/Liquid: Order form to use in a page or collection template.
View gist:6f28e4edb7f5dbb03515
{% comment %}
Source: https://gist.github.com/carolineschnapp/9122054
If you are not on a collection page, do define which collection to use in the order form.
Use the following assign statement, replace 'your-collection-handle-here' with your collection handle.
{% assign collection = collections.your-collection-handle-here %}
Use the assign statement outside of this comment block at the top of your template.
{% endcomment %}
{% paginate collection.products by 100 %}
@macariojames
macariojames / upload2facebook
Created Oct 11, 2016 — forked from nseo/upload2facebook
A sample code to upload an image file to facebook using Facebook javascript sdk
View upload2facebook
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Hello FB</title>
</head>
<body>
<div id="fb-root"></div>
<div id="fb-content"></div>
<div>
@macariojames
macariojames / remove-video.js
Created Nov 2, 2016 — forked from danro/remove-video.js
Remove HTML5 video and clear src attribute to prevent leaks.
View remove-video.js
// remove audio + video + stop all the downloadin’
// assumes $video and $audio are jQuery selectors for <video> and <audio> tags.
var removeMedia = function () {
_.each([$video, $audio], function ($media) {
if (!$media.length) return;
$media[0].pause();
$media[0].src = '';
$media.children('source').prop('src', '');
$media.remove().length = 0;
});
@macariojames
macariojames / strong-passwords.php
Created Apr 27, 2017 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
View strong-passwords.php
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by
@macariojames
macariojames / remove-password-protected-posts-from-the-loop.php
Last active Aug 31, 2018
Remove password protected posts from the Loop
View remove-password-protected-posts-from-the-loop.php
<?php // WordPress Stuffs!
// Add this to functions.php
// for removing password protected posts from the Loop
function wpb_password_post_filter( $where = '' ) {
if (!is_single() && !is_admin()) {
$where .= " AND post_password = ''";
}
return $where;
}
@macariojames
macariojames / wordpress-firebase.php
Created Mar 14, 2018 — forked from derekconjar/wordpress-firebase.php
An example of using Firebase and WordPress together. The idea is to use WP's custom post types and metaboxes to make content management easy, and sync with Firebase so that your websites have access to a real-time JSON feed of your custom data.
View wordpress-firebase.php
<?php
/**
* All custom functions should be defined in this class
* and tied to WP hooks/filters w/in the constructor method
*/
class Custom_Functions {
// Custom metaboxes and fields configuration
@macariojames
macariojames / remove-article-tag-yoast-wpseo-wordpress.php
Last active Sep 1, 2019
Remove article:tag meta from Yoast WordPress SEO plugin
View remove-article-tag-yoast-wpseo-wordpress.php
<?php
// Put in functions.php or custom functionality plugin.
// Remove article:tag meta that Yoast's WordPress SEO outputs ~mj
function remove_wpseo_fb_tags_categories() {
global $wpseo_og;
remove_action('wpseo_opengraph', array($wpseo_og, 'tags'), 16);
remove_action('wpseo_opengraph', array($wpseo_og, 'category'), 17);
}
add_action('wpseo_opengraph', 'remove_wpseo_fb_tags_categories');
@macariojames
macariojames / .htaccess
Created Apr 1, 2018 — forked from ryansechrest/.htaccess
Sample configuration files for WordPress as Git submodule.
View .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Prevent requests to index.php from being rewritten
RewriteRule ^index\.php$ - [L]
# Prefix specified PHP files with 'wordpress'
RewriteRule ^((wp-login|xmlrpc)\.php) wordpress/$1 [R=301,L]
@macariojames
macariojames / hide-wp-upcoming-events.php
Created Apr 19, 2018
Hide Upcoming Events from the WordPress Events and News Dashboard Widget
View hide-wp-upcoming-events.php
// Hide Upcoming Events from Dashboard Widget
// Basically just CSS; a display: none and then some personal choice
// formatting for the news items ~mj
function hide_wp_upcoming_events() {
?>
<style>
#community-events {
display: none;
}
@macariojames
macariojames / add-img-responsive-class-images-wordpress.php
Last active Sep 1, 2019
Add .img-responsive class to all images uploaded/added in WordPress
View add-img-responsive-class-images-wordpress.php
<?php
/**
* @desc Add .img-responsive to all post images ~mj
*/
function add_post_img_responsive_class($attr) {
$attr['class'] .= ' img-responsive'; // note the leading space
return $attr;
}
add_filter('wp_get_attachment_image_attributes', 'add_post_img_responsive_class');
You can’t perform that action at this time.