Skip to content

Instantly share code, notes, and snippets.

View rayhanuddin2019's full-sized avatar

Rayhan Uddin rayhanuddin2019

View GitHub Profile
@rayhanuddin2019
rayhanuddin2019 / upload-a-file.MD
Created October 31, 2022 10:31 — forked from ahmadawais/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

@rayhanuddin2019
rayhanuddin2019 / elementor-widget.php
Created August 3, 2022 06:39 — forked from igorbenic/elementor-widget.php
Ultimate Guide for JavaScript in Elementor Widgets
<?php
/**
* Plugin Name: Elementor Widget
* Text Domain: elementor-widget
* Domain Path: /languages
* Version: 0.1.0
*
* @package Elementor_Widget
*/
@rayhanuddin2019
rayhanuddin2019 / wpms-smtp-disable-ssl-verify.php
Created July 31, 2022 07:01 — forked from slaFFik/wpms-smtp-disable-ssl-verify.php
WP Mail SMTP: when using SMTP mailer - disable SSL verify on PHP 5.6+
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
@rayhanuddin2019
rayhanuddin2019 / functions.php
Created June 2, 2022 04:33 — forked from knuch/functions.php
Gutenberg override core block
<?php
// https://developer.wordpress.org/reference/hooks/render_block/
add_filter( 'render_block', 'foo_core_gallery_filter', 10, 3);
function foo_core_gallery_filter( $block_content, $block ) {
// use blockName to only affect the desired block
if( "core/calendar" !== $block['blockName'] ) {
@rayhanuddin2019
rayhanuddin2019 / pubsub.js
Created April 10, 2020 07:45 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {