Skip to content

Instantly share code, notes, and snippets.

View chrdesigner's full-sized avatar

César Ribeiro chrdesigner

View GitHub Profile
<?php
//add function inside functions.php
//after create in your file single.php ou page.php add code echo <?php chr_edit_post(); ?:>
function chr_edit_post() {
global $post;
if ( is_user_logged_in() ) : ?>
<style>.edit-post{position: fixed; z-index: 9; right: 0; top: 50%; transform: translate(0, -50%);} .edit-post a{ display: inline-block; text-decoration: none; color: #000; background-color: #EED467; padding: 1rem 1rem .5rem 1rem; transition: all .2s ease-in-out;} .edit-post a:hover{color: #FFF; background-color: #000;}</style>
<div class="edit-post">
<?php echo '<a href="' . esc_url( get_edit_post_link( $post->ID ) ) . '" title="Editar Post - ' . get_the_title() . '" target="_blank"><span class="dashicons dashicons-edit-large"></span></a>'; ?>
</div><?php
@chrdesigner
chrdesigner / 00-README.md
Last active June 20, 2024 21:07
Configure manual SMTP

=== GMAIL ===

Password: You can generate an App password. Using this Google App Password Link or go to Google Account Settings>Security>App Password.

<?php if( have_rows('repeater_field') ): ?>
<ul>
<?php while ( have_rows('repeater_field') ) : the_row(); ?>
<li><?php the_sub_field('sub_field'); ?></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
@chrdesigner
chrdesigner / .htaccess
Created December 21, 2023 15:13
htaccess redirect www to non-www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
@chrdesigner
chrdesigner / functions.php
Created November 17, 2022 14:21
Use GD instead of Imagick.
<?php
/** * Use GD instead of Imagick.
*/
function chr_use_gd_editor($array) {
return array( 'WP_Image_Editor_GD' );
}
add_filter( 'wp_image_editors', 'chr_use_gd_editor' );
@chrdesigner
chrdesigner / filter-external.js
Created September 17, 2018 19:21
Sub Menu + Filter TAG ~ External
$('.filterBlog a').on('click', function(e) {
filterBlogHash(this.hash, e);
});
$(window).on('load',function() {
filterBlogHash(window.location.hash);
});
function filterBlogHash(hash, e) {
if(hash === '') {
@chrdesigner
chrdesigner / filter.js
Created September 17, 2018 19:20
Sub Menu + Filter TAG ~ Simple
$('.filterBlog').on('click', 'a', function(e){
e.preventDefault();
var hash = $(this).attr('href').replace(/^.*?(#|$)/,'');
$('.filter a.type').each(function (index, value) {
// console.log('filter' + index + ':' + $(this).attr('id'));
@chrdesigner
chrdesigner / functions.php
Last active November 9, 2017 12:08
Function to create a custom related post list by tag and category
<?php
/**
* Related Posts.
*
* Usage:
* To show related by categories:
* Add in single.php <?php chr_related_posts(); ?>
* To show related by tags:
* Add in single.php <?php chr_related_posts( 'tag' ); ?>
*
@chrdesigner
chrdesigner / 00-README.md
Last active June 14, 2017 16:46
Git List - Post views Count
@chrdesigner
chrdesigner / 00-README.md
Created February 16, 2017 17:04
Git List - Exibir ou Ocultar a sua senha com jQuery