Skip to content

Instantly share code, notes, and snippets.

View LukaszJaro's full-sized avatar

LukaszJaro

View GitHub Profile
@TylerB24890
TylerB24890 / media-versioned-cache.php
Last active January 7, 2022 16:52
Add timestamp to end of media assets replaced by Enable Media Replace
<?php
/**
* Automatic Media & Post Cache Purging
* when using the Enable Media Replace plugin.
*
* @package Tyme
*/
namespace Tyme\CacheManager;
@georgestephanis
georgestephanis / client.js
Last active March 1, 2024 09:12
This is an example client app to integrate with the WordPress 5.6 Application Passwords system. It walks the user through authenticating, and then queries and enumerates all users on the site.
(function($){
const $root = $( '#root' );
const $stage1 = $( '.stage-1', $root );
const $stage2 = $( '.stage-2', $root );
// If there's no GET string, then no credentials have been passed back. Let's get them.
if ( ! window.location.href.includes('?') ) {
// Stage 1: Get the WordPress Site URL, Validate the REST API, and Send to the Authentication Flow
const $urlInput = $( 'input[type=url]', $stage1 );
@maheshwaghmare
maheshwaghmare / debug-http-request.php
Last active March 26, 2024 21:15
Debug the HTTP requests in WordPress wp_remote_post() or wp_remote_get() with the help of `http_api_debug` hook.
<?php
/**
* Debug HTTP requests in WordPress
*
* Fires after an HTTP API response is received and before the response is returned.
*
* Output in `wp-content\debug.log` file:
*
* [24-Apr-2019 06:50:16 UTC] ------------------------------
* [24-Apr-2019 06:50:16 UTC] https://downloads.wordpress.org/plugin/elementor.2.5.14.zip
@chrismccoy
chrismccoy / gutenberg.txt
Last active April 4, 2024 20:34
Gutenberg Resources
How to parse Gutenberg content for headless WordPress
https://kinsta.com/blog/headless-wordpress-gutenberg/
Adding wrapper to Gutenberg’s Table block
https://helloadmin.com/adding-wrapper-to-gutenbergs-table-block/
Display specific Gutenberg blocks of a post outside of the post content in the theme
https://florianbrinkmann.com/en/display-specific-gutenberg-blocks-of-a-post-outside-of-the-post-content-in-the-theme-5620/
Modifying the Markup of a Core Block
@sirbrillig
sirbrillig / functions.php
Last active January 24, 2024 15:46 — forked from UmeshSingla/functions.php
Post file using wp_remote_post in WordPress
<?php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array(
'name' => 'value',
);
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,
);
<?php
/*
Plugin Name: UTF8mb4-convert
Version: 1.0
*/
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
return;
}
@subfuzion
subfuzion / curl.md
Last active May 6, 2024 09:53
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@taninbkk
taninbkk / functions.php
Last active November 1, 2023 07:55
Polylang Shortcode
// Polylang Shortcode - https://wordpress.org/plugins/polylang/
// Add this code in your functions.php
// Put shortcode [polylang] to post/page for display flags
function polylang_shortcode() {
ob_start();
pll_the_languages(array('show_flags'=>1,'show_names'=>0));
$flags = ob_get_clean();
return $flags;
}
@danielgreen
danielgreen / ValidateHiddenFields.js
Last active October 26, 2023 14:19
The jQuery Validation plugin does not validate hidden fields by default. Here is how to get around that.
// By default, the jQuery Validation plugin ignores hidden fields. You may want them to be validated however.
// The default 'ignore' setting is ':hidden'
// See https://github.com/jzaefferer/jquery-validation/issues/189
// Attach a validator to a particular form, with a blank 'ignore' setting.
// If you are using Unobtrusive Validation then you can't do this, as the Unobtrusive script initialises the plugin for you.
// Instead, you must either amend the setting on the validator once it's attached to the form,
// or amend the default setting before the validator is attached (read on to see how).
$("MyForm").validate({ ignore: "" });
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2019.03.03
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */