Skip to content

Instantly share code, notes, and snippets.

View rhcarlosweb's full-sized avatar
🖖

Rhuan Carlos rhcarlosweb

🖖
View GitHub Profile
@rhcarlosweb
rhcarlosweb / post-type-taxonomy-same-slug-wordpress.php
Created May 2, 2024 15:10
Post type and taxonomy with same slug
/**
* Função que altera o título da página de taxonomia 'category_photos'.
*
* @param string $title O título atual da página.
* @return string O novo título da página.
*/
add_filter('pre_get_document_title', 'change_title_taxonomy_page', 10, 1);
function change_title_taxonomy_page($title) {
if (is_tax('category_photos')) {
@rhcarlosweb
rhcarlosweb / rh_get_crop_image.php
Created February 29, 2024 15:37
Crop image wordpress
<?php function rh_image_size($attachment_id, $width = null, $height = null, $crop = true, $force_crop = false) {
$path = get_attached_file($attachment_id);
if (!file_exists($path)) {
return false;
}
$upload = wp_upload_dir();
$path_info = pathinfo($path);
$base_url = $upload['baseurl'] . str_replace($upload['basedir'], '', $path_info['dirname']);
@rhcarlosweb
rhcarlosweb / symlink-create.py
Last active October 20, 2023 14:18
UI para crirar symlink em python | Symlink creator with UI
/**
* Code that will fit the text to the card of project-grid-item if is only one word vanillajs
*/
const fitText = () => {
const projectGridItems = document.querySelectorAll('.project-grid-item');
projectGridItems.forEach((item) => {
const text = item.querySelector('.title');
// get length of words
const textLength = text.innerText.split(' ').length;
@rhcarlosweb
rhcarlosweb / prompt2.md
Last active July 7, 2023 08:21
Prompts Code

Haja como um desenvolvedor python muito experiente e qualificado, você além de conhecer tudo sobre python, também faz um código super limpo e bem documentado, a documentação você gosta de explicar em português, falando o que cada parte do código e funções faz, você é como um professor avançado, não deixando de fazer o seu código ser complexo e simples ao mesmo tempo, e é claro, muito seguro, você chega a um nível que parece ser o criador da linguagem python. Você também tem grande conhecimento da api do youtube e google, as versão mais atualizada é claro, conhece toda a documentação, poderia ser um desenvolvedor senior do google, não deixa passar nada, e sempre tenta trazer soluções simples, mas muito funcionais. E você também tem um dom artístico, gosta de fazer seus códigos visualmente bonitos, criar UI inteligentes, onde o usuário possa interagir através de opções, sempre perguntando se deseja fazer tal tarefa antes de ser executada. Gosta de manter log de tudo, erros, sucesso, alertas. Lembrando, você não

@rhcarlosweb
rhcarlosweb / functions.php
Last active April 14, 2023 20:03
Cut image on the fly by image ID, WordPress
<?php
function get_thumbnail($attachment_id = null, $width = null, $height = null, $crop = true, $url = false, $alt = "") {
// global $post variable is used later in the function to check if the current post has a thumbnail image
global $post;
// if an attachment ID is provided
if ($attachment_id) {
// get the path to the file on the server
$path = get_attached_file($attachment_id);
// if the file does not exist, return false
@rhcarlosweb
rhcarlosweb / functions.php
Created December 20, 2022 19:41
remove gutenbrger by template
/**
* Templates and Page IDs without editor
*/
function ea_disable_editor( $id = false ) {
$excluded_templates = array(
'front-page.php',
);
<?php
/**
* Relacionados
*
* @version 1.0
* @author Rhuan <rhcarlosweb@gmail.com>
*/
function nexo_relatedposts() {
/**
<div class="clock"
data-finish-year="2021"
data-finish-month="07"
data-finish-day="12"
data-finish-hour="0"
data-finish-minutes="0"
data-finish-seconds="0"
>
<div class="num -d">
00
@rhcarlosweb
rhcarlosweb / function.js
Created January 3, 2021 17:11
Share links
/**
* Social open window
*/
const sharingLinks = document.querySelectorAll("[data-sharing]")
if (sharingLinks) {
sharingLinks.forEach(link => {
link.addEventListener("click", evt => {
evt.preventDefault()
!window.open(link.getAttribute("href"), "Sharer", "toolbar=0, status=0, width=900, height=500")