Skip to content

Instantly share code, notes, and snippets.

View harisrozak's full-sized avatar
Upgrading multi-lang module...

Haris Ainur Rozak harisrozak

Upgrading multi-lang module...
View GitHub Profile
@harisrozak
harisrozak / 0_reuse_code.js
Created June 17, 2017 07:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@harisrozak
harisrozak / wpdb-sample.php
Created June 13, 2017 11:20
WordPress :: Sample WPDB
<?php
global $wpdb;
$query = "SELECT $wpdb->posts.ID
FROM $wpdb->posts
WHERE $wpdb->posts.post_type = 'facility'
ORDER BY RAND()
LIMIT 8";
$results = $wpdb->get_col($wpdb->prepare( $query ));
$ar_posts = array();
@harisrozak
harisrozak / .gitignore
Created April 6, 2017 11:51 — forked from todiadiyatmo/.gitignore
Git Ignore WordPress
# ignore everything in the root except the "wp-content" directory.
/*
!wp-content/
# ignore all files starting with .
.*
# track this file .gitignore (i.e. do NOT ignore it)
!.gitignore
@harisrozak
harisrozak / wc_booking_unavailable_rentals_by_date.php
Last active October 30, 2018 17:07
WooCommerce Booking, get the unavailable rentals by date
<?php
$dateTimeStart = new DateTime($timestamp_start);
$dateTimeEnd = new DateTime($timestamp_end);
$unavailable_ids = wc_booking_unavailable_rentals_by_date($dateTimeStart, $dateTimeEnd);
// get all unavailable rentals by date
function wc_booking_unavailable_rentals_by_date($dateStart, $dateEnd) {
$filtered_rentals = array();
$unavailable_ids = array();
@harisrozak
harisrozak / fluid-youtube.html
Last active November 24, 2016 01:29
Fluid youtube or iframe videos
<style type="text/css">
.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.videoWrapper iframe {
position: absolute;
top: 0;
@harisrozak
harisrozak / input-array-ajax.js
Created November 17, 2016 12:50
Array input html from ajax to php
var user_name = [];
$bulk_row.find('input[name="user_name[]"]:checked').each(function(index, elem) {
user_name.push(elem.value);
});
var data = {
action: 'ajax_form',
user_name: user_name
}
@harisrozak
harisrozak / meta-query-array.php
Last active November 7, 2016 10:34
Meta query for meta value serialized array
<?php
$args['meta_query'] = array(
array(
'key' => 'array_terms_id',
'value' => sprintf(':"%s";', $term->term_id),
'compare' => 'LIKE'
)
);
@harisrozak
harisrozak / css_centering_overflow_image.css
Last active October 24, 2016 08:52
CSS centering overflow image
.parent {
position: relative;
overflow: hidden;
}
.child {
position: absolute;
top: -9999px;
bottom: -9999px;
left: -9999px;
@harisrozak
harisrozak / jquery-header-and-mobile.js
Last active October 14, 2016 04:33
jQuery detect header scroll, and close header dropdown by click outside
var $document = jQuery(document),
$window = jQuery(window),
$header = jQuery('header.header-hc2'),
$container = $header.children('.container'),
$secondNav = $header.children('.secondary-navigation'),
$secondContainer = $secondNav.children('.container'),
onMobile = false,
scrollTop = 0,
scrollTimeout = false,
headerStatus = false;
@harisrozak
harisrozak / break_or_continue.js
Created October 10, 2016 07:35
jQuery break or continue looping
var x = {
...
}
x.each(function(){
if(x == 'break') return false;
else if(x == 'continue') return true;
});