Skip to content

Instantly share code, notes, and snippets.

View jordymeow's full-sized avatar
🏝️
Enjoying life, always!

Jordy Meow jordymeow

🏝️
Enjoying life, always!
View GitHub Profile
@jordymeow
jordymeow / logchats.php
Last active July 2, 2023 01:06
AI Engine: Log the conversations to local files
<?php
add_filter( 'mwai_chatbot_reply', function ( $reply, $query, $params ) {
try {
global $mwai_core;
$newMessage = !empty( $params['newMessage'] ) ? $params['newMessage'] : "";
// We need to identify the user or session
$id = $mwai_core->get_user_id();
if ( empty( $id ) ) {
@jordymeow
jordymeow / useImage.js
Last active May 17, 2025 22:26
Simple React Hook which handles the status (loading, loaded or failed) of your images. It does a bit of caching.
const { useState, useEffect, useRef } = require('react');
function useImage({ src }) {
let [ image, setImage ] = useState({ src: null, status: 'loading' });
let imageElement = useRef();
let loadedUrls = useRef(new Set());
useEffect(() => {
const onload = () => {
setImage(img => {
@jordymeow
jordymeow / wplr_update_media_custom_meta.php
Created July 26, 2018 06:01
WP/LR Sync: Synchronize a custom meta/field with EXIF/IPTC data
add_action( "wplr_add_media", 'myapp_update_media_meta', 10, 2 );
add_action( "wplr_update_media", 'myapp_update_media_meta', 10, 2 );
function myapp_update_media_meta( $mediaId, $galleryID ) {
global $wplr;
$image = wp_get_attachment_url( $mediaId );
$size = getimagesize($image, $info);
if ( isset( $info['APP13'] ) ) {
$iptc = iptcparse( $info['APP13'] );
if ( isset( $iptc["2#090"][0] ) )
@jordymeow
jordymeow / mfrh_replace_rules.php
Last active July 24, 2018 23:03
Media File Renamer: Replace characters or strings
add_filter( 'mfrh_replace_rules', 'mfrh_replace_rules', 10, 1 );
function replace_s_by_z( $rules ) {
$rules['s'] = 'z';
return $rules;
}