Skip to content

Instantly share code, notes, and snippets.

@eduardozulian
eduardozulian / wp-unprotected-meta.php
Last active February 21, 2024 11:01
WordPress filter to replace the default "_" (underscore) with "-" (hyphen) in protected custom fields for debugging purposes
View wp-unprotected-meta.php
<?php
/**
* Replace the default "_" (underscore) with "-" (hyphen) in protected custom fields for debugging purposes
*
* @param bool $protected The default value
* @param string $meta_key The meta key
* @return bool True for meta keys starting with "-" (hyphen), false otherwise
*/
function unprotected_meta( $protected, $meta_key ) {
@eduardozulian
eduardozulian / featured-sticky-posts.php
Last active December 11, 2015 15:38
Uses sticky posts as featured posts in the front page.
View featured-sticky-posts.php
@eduardozulian
eduardozulian / wp-customize-image-reloaded.php
Last active November 16, 2023 02:50
Extend WP_Customize_Image_Control class allowing access to files uploaded within the same context.
View wp-customize-image-reloaded.php
<?php
/**
* Customize Image Reloaded Class
*
* Extend WP_Customize_Image_Control allowing access to uploads made within
* the same context
*/
class My_Customize_Image_Reloaded_Control extends WP_Customize_Image_Control {
/**
* Constructor.
@eduardozulian
eduardozulian / widget-posts-from-category.php
Last active December 14, 2015 06:19
Widget that displays the latest WordPress posts from a certain category / Widget que mostra os últimos posts de uma determinada categoria
View widget-posts-from-category.php
<?php
/**
* Cria o Widget que mostra os posts da categoria selecionada
*
*/
class Recent_Category_Posts extends WP_Widget {
/**
* Constructor
*
@eduardozulian
eduardozulian / wp-featured-video.php
Last active January 5, 2016 21:58
Create a custom field with the first embed URL found in a post format video. Can be used for featuring a video wherever is necessary.
View wp-featured-video.php
@eduardozulian
eduardozulian / wp-get-image-sizes.php
Created September 6, 2013 18:23
Get all the registered image sizes along with their dimensions
View wp-get-image-sizes.php
<?php
/**
* Get all the registered image sizes along with their dimensions
*
* @global array $_wp_additional_image_sizes
*
* @link http://core.trac.wordpress.org/ticket/18947 Reference ticket
* @return array $image_sizes The image sizes
*/
function _get_all_image_sizes() {
@eduardozulian
eduardozulian / wp-taxonomy-checkbox.php
Created September 24, 2013 13:31
Use checkbox term selection for non-hierarchical taxonomies.
View wp-taxonomy-checkbox.php
<?php
// Change this to your own taxonomy and post type
new Tag_Checklist( 'taxonomy_name', 'post_type' );
/**
* Use checkbox term selection for non-hierarchical taxonomies
*
* @author Hugh Lashbrooke
@eduardozulian
eduardozulian / wp-get-attachment-id.php
Created September 30, 2013 13:24
Retrieve the attachment ID from the file URL
View wp-get-attachment-id.php
<?php
/**
* Retrieve the attachment ID from the file URL
*
* @link http://pippinsplugins.com/retrieve-attachment-id-from-image-url/
*/
function horizonte_rural_get_attachment_id( $image_url ) {
global $wpdb;
$attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE guid='%s';", $image_url ) );
@eduardozulian
eduardozulian / readme.txt
Last active December 29, 2015 10:39
My WordPress plugins readme standard
View readme.txt
=== PLUGIN_NAME ===
Contributors: eduardozulian
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H28V8F5PHSZHA
Tags:
Requires at least: 3.0
Tested up to: 3.8
Stable tag: 1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@eduardozulian
eduardozulian / plugin-init.php
Created December 19, 2013 20:45
WordPress plugin initialization
View plugin-init.php
<?php
/*
Plugin Name:
Plugin URI:
Description:
Version: 0.1
Author: Eduardo Zulian
Author URI:
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html