Skip to content

Instantly share code, notes, and snippets.

View devuri's full-sized avatar
🏠
Working from home

Uriel devuri

🏠
Working from home
View GitHub Profile
@Shelob9
Shelob9 / 1.php
Last active December 4, 2020 09:48
These are step by step examples for converting a WordPress shortcode to a Gutenberg block. Read the tutorial here: https://calderaforms.com/2019/01/convert-shortcode-gutenberg-block/ Completed example here: https://github.com/caldera-learn/basic-blocks/tree/master/blocks/post-title
<?php
/**
* Handler for [cl_post_title] shortcode
*
* @param $atts
*
* @return string
*/
function caldera_learn_basic_blocks_post_title_shortcode_handler($atts)
{
@matzeeable
matzeeable / is_rest.php
Last active February 22, 2024 20:20
Checks if the current request is a WP REST API request.
<?php
if ( !function_exists( 'is_rest' ) ) {
/**
* Checks if the current request is a WP REST API request.
*
* Case #1: After WP_REST_Request initialisation
* Case #2: Support "plain" permalink settings and check if `rest_route` starts with `/`
* Case #3: It can happen that WP_Rewrite is not yet initialized,
* so do this (wp-settings.php)
@mailenkno
mailenkno / gutenberg-sample-content.html
Last active July 4, 2024 08:54
WordPress Gutenberg Sample Content
<!-- wp:paragraph {"align":"center","customTextColor":"#000000","backgroundColor":"very-light-gray","fontSize":"small"} -->
<p style="color:#000000;text-align:center" class="has-background has-small-font-size has-very-light-gray-background-color">Gutenberg Sample Content.<br/>Put together with ❤️ by <a href="https://artisanthemes.io/">Artisan Themes</a>.</p>
<!-- /wp:paragraph -->
<!-- wp:heading {"level":1} -->
<h1>This is a heading (H1)</h1>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>This is a heading (H2)</h2>
@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.
<?php
namespace App;
trait FullTextSearch
{
/**
* Replaces spaces with full text search wildcards
*
* @param string $term
@rachelmccollin
rachelmccollin / code_full.php
Last active May 21, 2018 21:27
WMPU DEV display a random post from each category
<section class="random>">
<?php
$terms = get_terms( array(
'taxonomy' => 'category',
'parent' => 0
) );
$do_not_duplicate = array();
@devuri
devuri / example.php
Last active February 14, 2018 23:54
WordPress Action Hook Example
<?php
// https://stackoverflow.com/questions/26781857/how-do-do-action-and-add-action-work
do_action( 'my_footer_hook' );
add_action( 'my_footer_hook', 'my_footer_echo' );
function my_footer_echo(){
echo 'hello world';
}
@devuri
devuri / wp-config.php
Created February 13, 2018 16:03 — forked from lukecav/wp-config.php
Enabling White Label in WP Rocket
define ('WP_RWL', true);
@devuri
devuri / Backup.php
Created January 28, 2018 04:13 — forked from SahilC/Backup.php
Php Mysql Database backup and restore
<?php
$dump_path = ""; //input location for the backup to be saved
$host = ""; //db host e.g.- localhost
$user = ""; //user e.g.-root
$pass = ""; //password
$command=$dump_path.'mysqldump -h '.$host.' -u '.$user.' bank > bank.sql';
system($command);
?>
<?php
/**
* WordPress Plugin Install Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Retrieves plugin installer pages from the WordPress.org Plugins API.