Skip to content

Instantly share code, notes, and snippets.

View samk-dev's full-sized avatar
🦉
¯\_(ツ)_/¯

Sam K samk-dev

🦉
¯\_(ツ)_/¯
View GitHub Profile
@samk-dev
samk-dev / detect-bg-color-and-set-color-text.ts
Created February 16, 2023 17:07
get current background contrast && set font color accordingly
const contrast: string = r * 0.299 + g * 0.587 + b * 0.114 > 186 ? 'black' : 'white'
<?php
// disallow users from accessing other users posts
function posts_for_current_author($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( 'manage_options' ) ) {
@samk-dev
samk-dev / load-admin-template-name.php
Last active February 16, 2023 17:08
Loads admin template name inside wp admin
<?php
function enqueue_debug_scripts ($hook) {
echo "<p style='text-align:center;'>" .$hook. "</p>";
}
add_action('admin_enqueue_scripts', 'enqueue_debug_scripts');
?>
@samk-dev
samk-dev / woo-order-status-hooks.php
Created January 3, 2022 15:09
WooCommerce Order && Subscription status hooks
<?php
function woo_order_status_changed_to_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function woo_order_status_changed_to_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function woo_order_status_changed_to_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
@samk-dev
samk-dev / commit-emoji-refrence.md
Created December 31, 2021 10:26
Commit emoji refrence
Emoji Commit Type
🎉 :tada: Initial Commit
:sparkles: New Feature
🔖 :bookmark: Version Tag
🐛 :bug: BugFix
💥 :boom: HotFix
💄 :lipstick: UIFix
📚 :books: Documentation
🧪 :test_tube: Test