Skip to content

Instantly share code, notes, and snippets.

View pedrohenriqueromio's full-sized avatar

pedro-romio pedrohenriqueromio

View GitHub Profile
@pedrohenriqueromio
pedrohenriqueromio / WP-plugin-settings-sample.php
Created April 30, 2023 23:15 — forked from adnan360/WP-plugin-settings-sample.php
Wordpress plugin with settings options sample code
<?php
// Example # 2 from
// https://codex.wordpress.org/Creating_Options_Pages
class MySettingsPage
{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;
@pedrohenriqueromio
pedrohenriqueromio / phpdocs examples
Created February 27, 2023 23:14
simple phpdocs examples
// Doc File example
/**
* Recipe class file
*
* PHP Version 8.1
*
* @category Recipe
* @package Recipe
* @author pedro henrique romio dos santos <pedrohenriqueromio@gmail.com>
<?php
$post_type = 'my_cpt';
// Register the columns.
add_filter( "manage_{$post_type}_posts_columns", function ( $defaults ) {
$defaults['custom-one'] = 'Custom One';
$defaults['custom-two'] = 'Custom Two';
.env usando php 7.4
cd {devilbox dir}/cfg/php-ini-7.4
criar arquivo xdebug.ini
"""
; Defaults
zend_extension=xdebug.so
xdebug.mode=profile
@pedrohenriqueromio
pedrohenriqueromio / yoast-seo-sitemap.php
Created November 14, 2022 19:23 — forked from mohandere/yoast-seo-sitemap.php
Wordpress yoast seo plugin, generate custom sitemap for custom URLS
<?php
/**
* Create a new custom yoast seo sitemap
*/
add_filter( 'wpseo_sitemap_index', 'ex_add_sitemap_custom_items' );
add_action( 'init', 'init_wpseo_do_sitemap_actions' );
// Add custom index
@pedrohenriqueromio
pedrohenriqueromio / RegEx on Html
Created November 8, 2022 13:04
Common regex used to extract data from Html
Get Hexadecimal color code
\#([a-fA-F]|[0-9]){3, 6}
Validate email address
/[A-Z0-9._%+-]+@[A-Z0-9-]+.+.[A-Z]{2,4}/igm
IPv4 address
/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/
IPv6 address
@pedrohenriqueromio
pedrohenriqueromio / Extend Recent Posts
Created March 8, 2022 16:40 — forked from paulruescher/Extend Recent Posts
Used this to change the output of WordPress' Recent Posts Widget
/**
* Extend Recent Posts Widget
*
* Adds different formatting to the default WordPress Recent Posts Widget
*/
Class My_Recent_Posts_Widget extends WP_Widget_Recent_Posts {
function widget($args, $instance) {