Skip to content

Instantly share code, notes, and snippets.

View enqtran's full-sized avatar

enqtran enqtran

View GitHub Profile
1 - ESLint extention enable
2 - run cmd: npm install - g eslint
3 - run cmd: npm install --save-dev eslint-config-rallycoding
4 - create file .eslintrc in folder project
5 - content file
{
"extends": "rallycoding"
}
/**
* [force_post_title_init]
*/
function force_post_title_init() {
wp_enqueue_script('jquery');
}
function force_post_title() {
echo "<script>jQuery('#publish').click(function(){
var testervar = jQuery('[id^=titlediv]').find('#title');
if (testervar.val().length < 1)
<div id="map_canvas" style="width:100%;height:500px;"></div>
<script>
function initMap() {
api = 'https://maps.googleapis.com/maps/api/geocode/json?address={address}&region=jp&key={key}';
jQuery.getJSON(api, function(r){
var abc = $.parseJSON(JSON.stringify(r));
var lat = abc['results'][0].geometry.location.lat;
var lng = abc['results'][0].geometry.location.lng;
var uluru = {lat: lat, lng: lng };
$arr_name_kana = array(
'あ' => array('あ', 'い', 'う', 'え', 'お', 'ア', 'イ', 'ウ', 'エ', 'オ'),
'か' => array('か', 'き', 'く', 'け', 'こ', 'カ', 'キ', 'ク', 'ケ', 'コ'),
'さ' => array('さ', 'し', 'す', 'せ', 'そ', 'サ', 'シ', 'ス', 'セ', 'ソ'),
'た' => array('た', 'ち', 'つ', 'て', 'と', 'タ', 'チ', 'ツ', 'テ', 'ト'),
'な' => array('な', 'に', 'ぬ', 'ね', 'の', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ'),
'は' => array('は', 'ひ', 'ふ', 'へ', 'ほ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ'),
'ま' => array('ま', 'み', 'む', 'め', 'も', 'マ', 'ミ', 'ム', 'メ', 'モ'),
'や' => array('や', 'ゆ', 'よ', 'ヤ', 'ユ', 'ヨ'),
'ら' => array('ら', 'り', 'る', 'れ', 'ろ', 'ラ', 'リ', 'ル', 'レ', 'ロ'),
/**
* Show column name kana
*/
if ( ! function_exists( 'kana_cpt_columns' ) ) {
function kana_cpt_columns( $columns ) {
if ( !isset($_GET['taxonomy']) || $_GET['taxonomy'] != 'category' )
return $columns;
$columns["namekana"] = "Name Kana";
return $columns;
}
@enqtran
enqtran / [PHP] replace string
Last active May 5, 2017 04:11
replace string
function replace($str) {
if(!$str) return false;
$unicode = array(
'a'=>array('á','à','ả','ã','ạ','ă','ắ','ặ','ằ','ẳ','ẵ','â','ấ','ầ','ẩ','ẫ','ậ'),
'A'=>array('Á','À','Ả','Ã','Ạ','Ă','Ắ','Ặ','Ằ','Ẳ','Ẵ','Â','Ấ','Ầ','Ẩ','Ẫ','Ậ'),
'd'=>array('đ'),
'-'=>array('-'),
'D'=>array('Đ'),
'e'=>array('é','è','ẻ','ẽ','ẹ','ê','ế','ề','ể','ễ','ệ'),
'E'=>array('É','È','Ẻ','Ẽ','Ẹ','Ê','Ế','Ề','Ể','Ễ','Ệ'),
(function($){
$.fn.extend({
limit: function(limit,element) {
var interval, f;
var self = $(this);
$(this).focus(function(){
interval = window.setInterval(substring,100);
});
$(this).blur(function(){
clearInterval(interval);
@enqtran
enqtran / [JS] Controll FabricJS
Last active May 5, 2017 04:11
Controll FabricJS
/**
* Created by ENQ on 7/15/2015.
*/
/*---------------------------------------------------------------------------------*/
/* CONFIGS */
/*---------------------------------------------------------------------------------*/
var maxItemAdd = 3;
var temp = 0; // for text
var tempImg = 0; //for image
var count_click = 0; //click
//add back to top admin
if ( ! function_exists( 'enqtran_back_to_top' ) ) {
function enqtran_back_to_top() {
echo '<a id="backtotop" href="#" style="position: fixed;
color: rgb(255, 255, 255);
right: 0px;
bottom: 5px;
text-decoration: none;
font-weight: bold;
padding: 7px 5px;
/**
* Image size.
*/
function image_web_thumb()
{
// Image pickup slider
add_image_size('thumb-image-130-110',130,110, true);
// Image pickup slider