Skip to content

Instantly share code, notes, and snippets.

View jemoreto's full-sized avatar
😀
Hello

John jemoreto

😀
Hello
View GitHub Profile
@jemoreto
jemoreto / yourls-custom-url-parameters.php
Last active August 20, 2024 11:22
YOURLS Custom URL Parameters - Manages long link exit URL parameters
<?php
/*
Plugin Name: WP Boss - YOURLS Custom URL Parameters
Plugin URI: https://www.wpboss.com.br/
Description: Manages long link exit URL parameters
Version: 1.0
Author: John (João Elton Moreto)
Author URI: https://www.wpboss.com.br/
This plugin is based on "Google Analytics" plugin, by Katz Web Services, Inc. Reference link: http://katz.co/yourls-analytics/
// Put this on your theme's functions.php
add_action( 'init', 'q11_remove_soliloquy_license_stuff', 999 );
function q11_remove_soliloquy_license_stuff() {
// Do nothing if Soliloquy is not active.
if ( !class_exists('Soliloquy') && !is_admin() ) {
return;
}
if (is_admin()) {
@jemoreto
jemoreto / wpboss-file-rename-upload.php
Last active May 15, 2018 20:19
Este plugin renomeia e limpa nomes de arquivos de mídia do WordPress durante o upload
<?php
/**
* Plugin Name: WP Boss // Sanitizar nome de arquivo no upload
* Plugin URI: https://www.wpboss.com.br/dicas-truques/renomear-limpar-nomes-arquivos-midia-fazer-upload-wordpress/
* Description: Este plugin renomeia e limpa nomes de arquivos de mídia do WordPress durante o upload.
* Version: 1.0
* Author: João Elton Moreto <[email protected]>
* Author URI: https://www.wpboss.com.br/
* License: GPL-2.0+
*/
@jemoreto
jemoreto / wp-404-redirect-valid-slug.php
Created September 1, 2017 21:54
WordPress redirect 404 with valid slug
function q11_redirect_uri_site_antigo() {
if ( is_404() ) {
$url = 'INSERT_YOUR_DOMAIN_HERE' . $_SERVER['REQUEST_URI'];
$end = end(explode('/', rtrim($url, '/')));
if ($end) {
if ( $post = get_page_by_path( $end, OBJECT, array('post', 'page'))) {
$id = $post->ID;
} else {
@jemoreto
jemoreto / post_id_body_class_wp_admin.txt
Last active December 3, 2015 16:48
Adds the current editing post's ID to body_class in WordPress admin
// Adds the current editing post's ID to body_class in WordPress admin
// Add this code in your theme's funtions.php
function post_id_to_body_admin($pid) {
$screen = get_current_screen();
if ( 'post' == $screen->base ) {
global $post;
$pid .= ' post-id-' . $post->ID;
return $pid;
}
}
@jemoreto
jemoreto / multiple-roles-per-user.php
Created May 15, 2015 19:45
Multiple roles per user WordPress plugin. Working when creating a new user and editing an user. Thanks to nikolov-tmw (https://goo.gl/Xv563d) and evankennedy (https://goo.gl/sh2sX6).
/**
* Plugin Name: Multiple Roles per User
* Description: Allows anyone who can edit users to set multiple roles per user. In a default WordPress environment that wouldn't have much of an effect, since the user would have the privileges of the top-privileged role that you assign to him. But if you have custom roles with custom privileges, this might be helpful.
* Version: 1
* Author: nikolov.tmw
* Author URI: http://paiyakdev.com/
* License: GPL2
*/
/*
Copyright 2013 Nikola Nikolov (email: [email protected])