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 / position-absolute-center.css
Created October 24, 2017 06:22
CSS position absolute center
.container {
width: 25%;
height: 50px;
position: relative;
}
.container .popup {
position: absolute;
width: 300px;
margin-left: 50%;
@harisrozak
harisrozak / loop_wget.sh
Last active March 22, 2018 07:05
Loop command on linux with bash file
#! /bin/bash
while [ "true" ]; do
# Do looping.
echo "-----------------------------"
date -u
echo "doing wget.."
wget --no-check-certificate -q -O - http://example.com >/dev/null 2>&1
echo "done, sleeping for a minute"
sleep 60
@harisrozak
harisrozak / acf-option-with-wpml.php
Last active February 8, 2018 10:15
WordPress :: Get ACF option field on WPML multi languages
<?php
// display current language
if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
echo "<pre>Current language code: ";
print_r(ICL_LANGUAGE_CODE);
echo "</pre>";
}
// get all WPML languages
@harisrozak
harisrozak / datepicker-range.js
Last active September 6, 2018 01:42
Apply the right behavior of two datepicker.js fields that act as range of dates
jQuery(document).ready(function($) {
$("#date-start").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd/mm/yy',
altField: 'input[name="date-start"]',
altFormat: 'yymmdd',
minDate: new Date(),
maxDate: '+2y',
onSelect: function(date){
@harisrozak
harisrozak / init-custom-download-page.php
Last active October 26, 2018 04:23
WordPress::Create custom static page on custom url
<?php
add_action('init', 'create_download_page');
public function create_download_page() {
global $wp;
$home_url = network_home_url();
$download_url = trailingslashit(network_home_url('download'));
// current url path
$current_path = parse_url(add_query_arg(array()), PHP_URL_PATH);
@harisrozak
harisrozak / wp_query_fields_ids.php
Last active April 26, 2019 06:44
WordPress::Wp_Query with field ids
<?php
$args = array(
'post_type' => 'custom-post',
'posts_per_page' => 10,
'post_status' => 'publish',
'author' => 1,
'fields' => 'ids',
'tax_query' => array(
array(
@harisrozak
harisrozak / learn-namespace.php
Last active May 27, 2019 00:01
PHP :: Learn Namespace
<?php
// Main namespace
namespace Haris\Learn\OONamespace;
// Constant
const FILE = __FILE__;
// Require files
require_once dirname(FILE) . '/module-one.php';
@harisrozak
harisrozak / admin-enqueue-script.php
Last active September 3, 2019 04:21
WordPress :: Datepicker on admin
<?php
public function bid_tabulation_enqueue_script( $hook ) {
global $post;
if( $hook == 'post.php' && isset( $post->post_type ) && $post->post_type == 'bid-tabulation' ) {
// load script & style
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_style( 'jquery-ui-datepicker', $GLOBALS['mu_assets_url'] . 'jquery-ui.min.css' );
@harisrozak
harisrozak / slider-pro-image-sides-navigation.css
Last active February 3, 2020 02:17
Custom CSS for Slider Pro and Feslider WP Plugin
/**
* Custom CSS for Slider Pro and Feslider WP Plugin
* Make the slide navigation to become image-sides-clicking instead of arrows-clicking
* Tested on Slider Pro v1.3 and Feslider 1.2
*/
.slider-pro > .sp-slides-container > .sp-arrows.sp-arrows {
height: 100%;
top: 0;
margin: 0;
@harisrozak
harisrozak / acf.php
Created March 6, 2020 06:07
WordPress :: Save ACF settings to json
<?php
/**
* Save ACF settings to json
*/
add_filter( 'acf/settings/load_json', 'astahub_acf_json_load' );
add_filter( 'acf/settings/save_json', 'astahub_acf_json_save' );
function astahub_get_acf_path() {
return get_template_directory() . '/acf-json';