Skip to content

Instantly share code, notes, and snippets.

View rilwis's full-sized avatar
🙂
Happy and peace when coding

Anh Tran rilwis

🙂
Happy and peace when coding
View GitHub Profile
@rilwis
rilwis / gist:a7ca4bc716c0036624d7068dd5742498
Created December 21, 2023 09:27
Set status 410 for deleted pages
<?php
add_action( 'template_redirect', function () {
if ( ! is_404() ) {
return;
}
$path = trim( $_SERVER['REQUEST_URI'] ?? '', '/' );
if ( $path === 'your-deleted-page' ) {
status_header( 410 );
@rilwis
rilwis / acf-block.php
Created December 7, 2023 05:01 — forked from razaanstha/acf-block.php
ContentEditable - ACF Block
<?php
/**
* Block: Hero
* --------------------------------
* The hero block for all pages.
*/
$block_data = get_fields();
?>
@rilwis
rilwis / simple-meta-box.php
Created September 19, 2023 15:11
Test WP update button always active
<?php
// This code shows a simple meta box with a simple text, no inputs.
// And the "Update" button in WordPress is always active, e.g. never disabled, even if there's no changes, no updates.
add_action( 'add_meta_boxes', function() {
add_meta_box( 'test', 'Test', 'my_callback_func', 'post' );
} );
function my_callback_func() {
echo 'Just a text, and the Update button is always active.';
}
@rilwis
rilwis / remove-article-keywords.php
Created September 8, 2023 09:22
Slim SEO: Remove keywords from Article schema
<?php
add_filter( "slim_seo_schema_article", function ( $schema ) {
unset( $schema['keywords'] );
return $schema;
} );
@rilwis
rilwis / code.php
Created September 6, 2023 08:30
Slim SEO Schema: Remove hash in @id property
<?php
add_filter( 'slim_seo_schema_graph', function( $graph ) {
foreach( $graph as &$schema ) {
list( $url ) = explode( '#', $schema['@id'] );
$schema['@id'] = $url;
}
return $graph;
}, 20 );
@rilwis
rilwis / register.php
Created September 6, 2023 07:31
MB Relationships: change field type
<?php
add_action( 'mb_relationships_init', function () {
MB_Relationships_API::register( [
'id' => 'users_to_posts',
'from' => [
'object_type' => 'user',
'field' => [
'field_type' => 'checkbox_list',
],
],
@rilwis
rilwis / function.php
Last active January 31, 2020 09:20 — forked from kutoi94/function.php
How to Build a Hotel Booking Website Using Meta Box (P3) - functions.php
if ( ! get_option( 'rwmb_bookings' ) ) {
add_option( 'rwmb_bookings', array() );
}
add_action( 'rwmb_booking-fields_after_save_post', 'update_bookings_date' );
function update_bookings_date( $post_id ) {
$bookings = get_post_meta( $post_id, 'group_booking', true );
@rilwis
rilwis / single-room.php
Last active September 24, 2023 15:05 — forked from kutoi94/single-room.php
How to Build a Hotel Booking Website Using Meta Box (P3) - Template
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', 'single' );
the_post_navigation();
echo do_shortcode("[mb_frontend_form id='booking-fields' post_fields='title,content']");
@rilwis
rilwis / custom.js
Last active January 31, 2020 09:11 — forked from kutoi94/custom.js
How to Build a Hotel Booking Website Using Meta Box (P3)
jQuery( function($) {
setTimeout(function(){
datepicker_reinstall();
console.log(disable_dates);
}, 1000);
function datepicker_reinstall(){
var dateFormat = "yy-mm-dd",
from = $( "#group_booking_check_in" ),
to = $( "#group_booking_check_out" );
<main id="Main">
<div class="page-wrapper">
<div class="container">
<div class="row">
<div id="menuBarleft" class="col-lg-3 col-sm-12">
<div id="navbarNav" class="nav nav-tabs">
<div id="v-pills-tab" class="nav flex-column nav-pills menu-left" role="tablist" aria-orientation="vertical">
<?php $group_values = rwmb_meta( 'faq_tab' );
$count = 0;
if ( ! empty( $group_values ) ) {