Skip to content

Instantly share code, notes, and snippets.

@thedapifer
thedapifer / ninja-image-upload.php
Created March 13, 2018 09:25 — forked from sudiptoChy/ninja-image-upload.php
Ninja Image Upload WordPress Plugin
<?php
/**
* @package ninja_image_upload
* @version 1.0
*/
/*
Plugin Name: Ninja Image Upload
Plugin URI: http://authlab.io/
Description: This plugin allow users to upload image via a form can be created by shortcode
Version: 1.0
@thedapifer
thedapifer / wp-upload.php
Created March 11, 2018 02:15
WP File Upload Functions
/**
* Save a file submitted from a POST request and create an attachment post for it.
*
* @since 2.5.0
*
* @param string $file_id Index of the `$_FILES` array that the file was sent. Required.
* @param int $post_id The post ID of a post to attach the media item to. Required, but can
* be set to 0, creating a media item that has no relationship to a post.
* @param array $post_data Overwrite some of the attachment. Optional.
* @param array $overrides Override the wp_handle_upload() behavior. Optional.
@thedapifer
thedapifer / jquery-module-pattern.md
Created March 6, 2018 03:57
JQuery Module Pattern
  1. Immediately-Invoked-Function-Expressions

(function () { // code })();

** What does it do? -- It declares a function which in turn calls itself immediately (invokes). -- The function creates a new "scope" and creates "privacy" within itself.

@thedapifer
thedapifer / bootstrap-4-tabs.js
Created February 21, 2018 18:52
Bootstrap 4 Tabs
// work around to fix navtabs issue https://github.com/twbs/bootstrap/issues/23667
$('a[data-toggle="tab"]').click(function(){
// todo remove snippet on bootstrap v4
$('a[data-toggle="tab"]').click(function() {
$($(this).attr('href')).show().addClass('show active').siblings().hide();
})
});
@thedapifer
thedapifer / bootstrap-4-beta-responsive.md
Created February 16, 2018 10:09
Bootstrap 4 Beta Responsive
  1. To make columns responsive, you must design "mobile first". In Bootstrap this means, the "sm-*" class identifier.

Example of columns that swap places on mobile/desktop:

With column ordering

Content
@thedapifer
thedapifer / text-image-overlay.css
Created February 14, 2018 11:49
text overlay for images
.text-overlay-center{
position:absolute;
top:50%;
left:50%;
text-align:center;
transform: translateX(-50%) translateY(-50%);
}
.text-overlay-left{
position: absolute;
top: 45%;
@thedapifer
thedapifer / wp-bs-modal.js
Last active February 11, 2018 06:58
WP BS Modal
/** Pop Post Modal **/
// Quick view ajax function on products page
$('body').on('click', '.modal-link', function (e) {
var post_id = $(this).data('id');
// prevent link from being followed
e.preventDefault();
@thedapifer
thedapifer / wp-comment-functions.php
Created February 5, 2018 05:36
Wordpress Comment Functions
Various functions for retrieving, formatting, and displaying native Wordpress comments.
1. Use the [ comment_form($args=array($fields=array(),...... ] function to display a default comment form inside the loop.
* To customize the display of a comment form you can use the function's (args).
** Default Args:
$defaults = array(
'fields' => $fields,
'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>',
/** This filter is documented in wp-includes/link-template.php */
@thedapifer
thedapifer / image-error.js
Created January 16, 2018 03:55
JQuery Image Error
$('img.avatar').error(function(){
$(this).addClass('is-broken');
});
@thedapifer
thedapifer / missing_images.js
Created January 16, 2018 03:53 — forked from johnbocook/missing_images.js
Use jQuery to deal with missing images
// Hide the image on error
$("img").error(function(){
$(this).hide();
});
// Change the missing image to a default image
$('img').error(function(){
$(this).attr('src', 'no-image.jpg');
});