Last active
September 9, 2024 20:59
-
-
Save chrdesigner/39ee3b8cf83a5f93505337f4b3c7ab37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//add function inside functions.php | |
//add wordpress dashicons frontend | |
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' ); | |
function load_dashicons_front_end() { | |
wp_enqueue_style( 'dashicons' ); | |
} | |
//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() ) : ?> | |
<div id="chr-edit-post"> | |
<dl> | |
<dd><?php echo '<a href="' . esc_url( get_admin_url() ) . '" title="Acessar Backend" target="_blank"><span class="dashicons dashicons-wordpress"></span></a>'; ?></dd> | |
<dd><?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>'; ?></dd> | |
</dl> | |
<style type="text/css"> | |
#chr-edit-post{position: fixed; z-index: 9; right: 0; top: 50%; transform: translate(0, -50%);} | |
#chr-edit-post dl{flex-direction: column; display: flex; margin: 0; padding: 0;} | |
#chr-edit-post dl dd{margin: .1rem 0;} | |
#chr-edit-post dl dd a{ display: inline-block; text-decoration: none; color: #000; background-color: #29ce2b; padding: 1rem 1rem .5rem 1rem; transition: all .2s ease-in-out;} | |
#chr-edit-post dl dd a:hover{color: #FFF; background-color: #000;} | |
</style> | |
</div><?php | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment