Gravity Forms PHP Helpers

const IC_REGEXP_KATAKANA = “/\A[ア-ンガ-ボァ-ョヮッーヴ]+\z/”; const IC_REGEXP_POST_CODE_JP = “/\A\d{3}-?\d{4}\z/”; const IC_REGEXP_PHONE = “/\A\+?[1-9]\d{1,14}\z/”; add_filter(‘gform_field_validation’, ‘icFormValidation’, 10, 4); function icFormValidation($result, $value, $form, $field) { // カタカナのみの入力 if(preg_match(‘/\bkatakana\b/’, $field->cssClass) && !empty($value) && !preg_match(IC_REGEXP_KATAKANA, $value)) { $result[‘is_valid’] = false; $result[‘message’] = implode(‘ ‘, array_filter([$result[‘message’],…Continue reading

CustomFonts

/* Plugin Name: MA Custom Fonts Description: Load custom fonts and inject to Gutenberg, Bricks, Oxygen Author: Matthias Altmann Project: Code Snippet MA Custom Fonts Version: 3.4.3 Plugin URI: https://www.altmann.de/en/blog-en/code-snippet-custom-fonts/ Description: en: https://www.altmann.de/en/blog-en/code-snippet-custom-fonts/ de: https://www.altmann.de/blog/code-snippet-eigene-schriftarten/ Copyright: © 2020-2025, Matthias Altmann…Continue reading

_MK – SECURITY – Disable XML-RPC-API

// Disable XML-RPC add_filter( ‘xmlrpc_enabled’, ‘__return_false’ ); // Block access to xmlrpc.php via .htaccess equivalent (Apache fallback) add_action( ‘init’, function () { if (strpos($_SERVER[‘REQUEST_URI’], ‘xmlrpc.php’) !== false) { wp_die( ‘Access denied.’ ); } }); // Remove pingback header add_filter( ‘wp_headers’,…Continue reading

_MK – Last connection

// Enregistre la date de connexion de l’utilisateur function enregistrer_derniere_connexion($user_login, $user) { // Met à jour la date de la dernière connexion $last_login = current_time(‘mysql’); update_user_meta($user->ID, ‘last_login’, $last_login); // Debug: Vérifie si la date est bien enregistrée if (false ===…Continue reading

_MK – SECURITY – Block Author Enumeration

// 🔒 Block ?author=1 user enumeration attempts add_action(‘init’, function () { if (!is_admin() && isset($_GET[‘author’])) { wp_redirect(home_url(), 301); exit; } }); // 🛡️ Disable REST API user exposure add_filter(‘rest_endpoints’, function ($endpoints) { if (isset($endpoints[‘/wp/v2/users’])) { unset($endpoints[‘/wp/v2/users’]); } return $endpoints; });Continue reading

Post Shortcodes

// Est. Reading Time $reading_speed = 200; // 200 words per minute $content = get_post_field( ‘post_content’, get_the_id() ); $word_count = str_word_count( strip_tags( $content ) ); $reading_time = ceil( $word_count / $reading_speed ); function post_read_time_shortcode($atts) { echo ‘ Estimated reading time:…Continue reading

NMDFX Admin bar, Dashboard, Edits & Custom CSS

/* HIDE Monster Icon */ .monsterinsights-quick-links, .monsterinsights-float-right { display: none!important; } #monsterinsights_reports_widget { padding: 50px 0; } #monsterinsights_reports_widget .ui-sortable-handle { display: none!important; } /* Replace plugin logo */ .monsterinsights-logo-area img { content: url(‘https://www.coverings.com/wp-content/uploads/2024/11/Nation-Media-Dashboard-FX.png’); /* Adjust size if needed */ width:…Continue reading

Typography Enqueue

function typography_enqueue_styles() { // Enqueue Typeboost.css from Cloudflare CDN wp_enqueue_style(‘typeboost-css’, ‘https://cdnjs.cloudflare.com/ajax/libs/typeboost/1.0.0/typeboost.css’, array(), ‘1.0.0’); // Enqueue webfontloader.js from Cloudflare CDN wp_enqueue_script(‘webfontloader’, ‘https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js’, array(), ‘1.6.28’, true); } add_action(‘wp_enqueue_scripts’, ‘typography_enqueue_styles’);Continue reading