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 / wp-manuall-plugin-install
Last active October 5, 2022 11:47
manual plugin install
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=automatic-youtube-gallery' ), 'install-plugin_automatic-youtube-gallery' );
Below you’ll find a function that generates a plugin install link for WordPress. You can use this in the dashboard. This link acts the same way as the “Install plugin” buttons when searching for plugins within WordPress.
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin={plugin_slug}' ), 'install-plugin_{plugin_slug}' );
----------------- Second solution -------------------
$action = 'install-plugin';
@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]) {
/* remove version string from js and css */
function prefix_remove_wp_version_strings( $src ) {
global $wp_version;
parse_str( parse_url($src, PHP_URL_QUERY), $query );
if ( !empty( $query['ver'] ) && $query['ver'] === $wp_version ) {
$src = remove_query_arg( 'ver', $src );
}
return $src;
@rayhanuddin2019
rayhanuddin2019 / template.php
Created December 5, 2019 05:55
Override this file in digiqole->core->helpers->functions->template.php see https://prnt.sc/q6faui
<?php if (!defined('ABSPATH')) die('Direct access forbidden.');
/**
* dynamic css, generated by customizer options
*/
// display navigation to the next/previous set of posts
// ----------------------------------------------------------------------------------------
function digiqole_post_nav() {
if(digiqole_option('blog_navigation_show','yes')=='no'){
return;