This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add Blog related field to REST API /wp-json/wp/v2/blog | |
function blog_add_related_posts() | |
{ | |
register_rest_field('blog', 'related', [ | |
'get_callback' => function ($post) { | |
$categories = wp_get_post_categories($post['id']); | |
$related = get_posts([ | |
'post_type' => 'blog', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add Blog CPT to category archive | |
add_action('pre_get_posts', 'blog_set_category'); | |
function blog_set_category($query) | |
{ | |
if (is_category() && !is_admin() && $query->is_main_query()) { | |
$query->set('post_type', 'blog'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('admin_init', function () { | |
// Redirect any user trying to access comments page | |
global $pagenow; | |
if ($pagenow === 'edit-comments.php') { | |
wp_redirect(admin_url()); | |
exit; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /* EVENT SLUG FROM DATE*/ | |
function event_slug($post_id, $post, $update) | |
{ | |
if (get_field('date', $post_id)) { | |
$date = get_field('date', $post_id); | |
$slug = date('ymd', strtotime($date)); | |
if ($post->post_name != $slug) { | |
remove_action('save_post_event', 'event_slug', 10, 3); | |
wp_update_post([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script will browse a Slack export folder and download all files in a new /export folder | |
# | |
# HOW TO: | |
# 1. As a Workspace admin, download an export of your Slack history (https://www.slack.com/services/export) | |
# 2. Make sure you have jq installed (https://stedolan.github.io/jq/) | |
# 3. Place this file at the root of your Slack export folder, next to channels.json | |
# 4. Run `bash slack-files-downloader.sh` in your terminal | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('wp_unique_post_slug', 'seed_unique_slug', 10, 4); | |
function seed_unique_slug($slug, $post_id, $post_status, $post_type) | |
{ | |
if (in_array($post_type, ['post', 'product'])) { | |
$post = get_post($post_id); | |
if (empty($post->post_name) || $slug != $post->post_name) { | |
$slug = randomSlug(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: [push] | |
jobs: | |
deploy_job: | |
runs-on: ubuntu-latest | |
name: deploy | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Dependencies |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"zipCode": "10100", | |
"subDistrictList": [ | |
{ | |
"subDistrictId": "100801", | |
"districtId": "1008", | |
"provinceId": "10", | |
"subDistrictName": "ป้อมปราบ" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Running No. Slug | |
add_action('wp_insert_post', 'change_slug'); | |
function change_slug($post_id, $force = false) | |
{ | |
$post_types = ['news', 'faq']; | |
$post_type = $_POST['post_type']; | |
if (!in_array($post_type, $post_types) || get_field('no', $post_id)) { | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
._th:not(:lang(th)), | |
._en:not(:lang(en-US)) { | |
display: none !important; | |
} |
NewerOlder