Skip to content

Instantly share code, notes, and snippets.

View mennwebs's full-sized avatar

Menn mennwebs

View GitHub Profile
@mennwebs
mennwebs / 0_reuse_code.js
Last active August 29, 2015 14:23
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
@mennwebs
mennwebs / single.php
Last active July 24, 2017 03:56
แสดง custom field ทั้งหมดใน WordPress Loop
<pre>
<small>
<?php
$cf = get_post_custom($post->ID);
print_r($cf);
?>
</small>
</pre>
@mennwebs
mennwebs / functions.php
Created July 24, 2017 14:29
WordPress - Redirect Login to /account/ page
<?php
function seed_login_redirect(){
global $pagenow;
if('wp-login.php' == $pagenow) {
if(isset($_POST['wp-submit']) || // in case of LOGIN
(isset($_GET['action']) && $_GET['action']=='logout') || // in case of LOGOUT
(isset($_GET['checkemail']) && $_GET['checkemail']=='confirm') || // in case of LOST PASSWORD
(isset($_GET['checkemail']) && $_GET['checkemail']=='registered')) return; // in case of REGISTER
else wp_redirect(home_url('/account/')); // or wp_redirect(home_url('/login'));
@mennwebs
mennwebs / .htaccess
Last active January 1, 2018 05:17
force HTTPS - เพิ่มไว้บนสุดของไฟล์ได้เลย
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
@mennwebs
mennwebs / front-page.php
Created April 12, 2018 06:12
ACF - Show product by Brand and Product_cat Taxonomy
<?php
if( have_rows($brand_slug) ):
$i = 1;
while( have_rows($brand_slug) ):
the_row();
$cat = $brand_slug . '-cat';
$term = get_sub_field($cat);
?>
<div class="tab-products">
@mennwebs
mennwebs / functions.php
Last active July 24, 2019 14:08
Auto CSS version for child theme.
<?php
/**
* Enqueue scripts and styles.
*/
function fruit_scripts() {
wp_dequeue_style( 'seed-style');
wp_enqueue_style( 'fruit-css', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() . '/style.css' ) );
wp_enqueue_script( 'fruit-js', get_stylesheet_directory_uri() . '/js/main.js', array(), '2017-1', true );
@mennwebs
mennwebs / Seed Social SCSS - ปุ่มติดกัน
Created November 25, 2018 05:40
แบบเว็บ SeedThemes.com
body .seed-social {
> div {
margin-right: 0;
margin-bottom: 0;
&.line {
margin-right: 0;
a {
border-radius: 0 3px 3px 0;
}
}
@mennwebs
mennwebs / functions.php
Created January 9, 2019 06:30 — forked from jay7793/functions.php
Sample WooCommerce API Product Update (พี่เม่น)
<?php
ติดตั้ง Woocommerce php sdk โดยใช้คำสั่งด้านล่างนี้ (ใช้ Command ในการตัดตั้ง)
// composer require automattic/woocommerce
// Setup:
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
function wc_init() {
@mennwebs
mennwebs / functions.php
Last active July 24, 2019 14:08
WooCommerce เรียงลำดับจังหวัด เวลาแสดงผลภาษาไทย
<?php
/* Custom Thai Province Order */
if (get_locale() == 'th') {
add_filter( 'woocommerce_states', 'seed_woocommerce_states' );
}
function seed_woocommerce_states( $states ) {
$states['TH'] = array(
'TH-81' => 'กระบี่',
'TH-10' => 'กรุงเทพมหานคร',
'TH-71' => 'กาญจนบุรี',
@mennwebs
mennwebs / style.css
Created May 28, 2019 12:38
CSS สำหรับเปลี่ยนค่าตามขนาดหน้าจอต่างๆ โดยทำแบบ Mobile First คือเริ่มจากจอเล็กไปใหญ่
// ใส่ CSS สำหรับแสดงผล Mobile เช่น
.test {
font-size: 12px;
}
@media (min-width: 768px) {
// โค้ด CSS สำหรับจอ iPad แนวตั้ง เช่น
.test {
font-size: 14px;
}