Skip to content

Instantly share code, notes, and snippets.

View melvinstanly's full-sized avatar
🌪️
Fast and Furious

Melvin Stanly melvinstanly

🌪️
Fast and Furious
View GitHub Profile
@melvinstanly
melvinstanly / css-select.html
Last active September 4, 2018 10:18
Css tricks
// Custom scrolling bar for select
// Solution for no scroll in MAC browsers
<html>
<head>
<style>
.frame::-webkit-scrollbar {
-webkit-appearance: none;
}
@melvinstanly
melvinstanly / custom-tinymce-script.js
Last active September 5, 2018 07:09
tinyMCE related codes
jQuery(document).ready(function($) {
var divBodyConfig = {
selector: '.tinymce-body',
menubar: false,
inline: true,
plugins: [
'link',
'textcolor',
'lists',
// 'powerpaste',
@melvinstanly
melvinstanly / get_text_filter.php
Created October 22, 2018 04:26
Functions using the get_text filter
function custom_wc_translations( $translated_text, $text, $domain ) {
if(is_checkout()){
switch ($translated_text) {
case 'Replaceble_text' :
$translated_text = __('String to Replace', 'Domain');
break;
}
}
return $translated_text;
@melvinstanly
melvinstanly / scroll.php
Created November 1, 2018 12:58
Common CSS issues
<?php
// Content jumping when scroll bar is introduced
<div class="outer-wrapper">
<div class="inner-wrapper">
<div>
// Contents that affects overflow here
</div>
</div>
</div>
@melvinstanly
melvinstanly / wp-upload-folder.php
Last active November 5, 2018 10:27
Wordpress commonly used functions
<?php
// Get wordpress upload folder directory
function get_upload_folder_path(){
$current_user = wp_get_current_user();
$upload_dir = wp_upload_dir();
$uploads_folder = $upload_dir['basedir']; // Path to wordpress uploads folder
return $uploads_folder;
}
?>
@melvinstanly
melvinstanly / php file upload.php
Created November 5, 2018 10:30
Php File Upload
<html>
<form id="sample_form" name="sample-form">
<p>
<label>Name</label><br>
<input value="Melvin Stanly" type="text">
</p>
<p>
<label>File</label><br>
<input id="example-file" type="file">
</p>
@melvinstanly
melvinstanly / spectrum-color-picker
Created December 3, 2018 05:44
Color picker not Displayed / mispositioned inside a scrollable div
Color picker won't appear when clicked, if it is inside a scrollable div.
Also when colorpicker is opened and scrolled, the colorpicker also get scrolled.
The solution to fix this is to add `position:relative` to the parent div in which input field, span(colorpicker preview) and
div(iris-picker iris-border).
@melvinstanly
melvinstanly / worpress-file-upload-error.php
Created December 3, 2018 07:54
wordpress file upload
//How to fix “this file type is not permitted for security reasons” in WordPress
function enable_extended_upload ( $mime_types =array() ) {
// The MIME types listed here will be allowed in the media library.
// You can add as many MIME types as you want.
$mime_types['gz'] = 'application/x-gzip';
$mime_types['zip'] = 'application/zip';
$mime_types['rtf'] = 'application/rtf';
$mime_types['ppt'] = 'application/mspowerpoint';
@melvinstanly
melvinstanly / regex.txt
Created December 28, 2018 11:03
Regular expression tricks
* To replace all runs of white spaces in a string with ( _ ) underscore => /\s+/g
-> Replace adjacent white spaces with a single underscore
* To replace whitespace in a string with underscore => / /g
-> Replace each white space with a single underscore. Each adjacent white spaces will be replaced
@melvinstanly
melvinstanly / html data attributes.js
Last active January 23, 2019 11:38
html data attribute manipulation function
// Remove all data attributes of an element
$.each( $("element-selected").data(), function(i){
$("div").removeAttr("data-" + i);
});