How To Hide Delete From Option?
Topics related to Realistic theme goes here.

TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

How To Hide Delete From Option?

linkPost by TahMiD » Mon Dec 11, 2017 12:52 pm

I need To Hide This Option For Logged in User, but How? Wanna Keep Edit, But Wanna Hide Delete. Plz Help mE!
Screenshot_9.png
Screenshot_9.png (143.6 KiB) Viewed 2014 times
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: How To Hide Delete From Option?

linkPost by TahMiD » Fri Dec 15, 2017 9:29 pm

Hi There, Plz Reply on this topic.
User avatar
Asmi Khalil

Site Admin Rank
Posts: 781
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: How To Hide Delete From Option?

linkPost by admin » Sun Dec 17, 2017 9:48 pm

Hi,
Sorry, my notification about the topic was hidden.

Open /template-parts/content-actions.php file and replace everything (leave the PHP comments) with this code:
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

if ( !current_user_can( 'editor' ) && !current_user_can( 'administrator' ) ) {
	return '';
} ?>

<button id="post-actions<?php the_ID(); ?>" class="post-actions mdl-button mdl-js-button mdl-button--icon">
	<i class="material-icons">more_vert</i>
</button>

<ul class="post-actions-menu mdl-menu mdl-menu--top-right mdl-js-menu mdl-js-ripple-effect" for="post-actions<?php the_ID(); ?>">

	<?php edit_post_link( esc_html__( 'Edit', 'realistic' ), '<li class="mdl-menu__item">', '</li>'); ?>

	<?php if ( current_user_can( 'administrator' ) ) {

		$delLink = wp_nonce_url( admin_url() . "post.php?post=" . get_the_ID() . "&action=delete", 'delete-' . get_post_type() . '_' . get_the_ID() ); ?>

		<li class="mdl-menu__item">
			<a href="<?php echo $delLink; ?>"><?php esc_html_e( 'Delete', 'realistic' ); ?></a>
		</li>

	<?php } ?>
</ul>
The 3dots buttons and menu will appear for editors and admins only but the delete link will appear for admins only.

I should be releasing a minor update with the new date code and this fix (maybe I will add the option to choose between theme Ago date format or WordPress default format. Expect version 1.3.2 to be rolling out in the coming few hours. Maybe you should start using a child theme or you will have to restore your modifications each time you update the theme.
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: How To Hide Delete From Option?

linkPost by TahMiD » Sun Dec 17, 2017 9:55 pm

But I already made lots of changes, all will be lost... :?
User avatar
Asmi Khalil

Site Admin Rank
Posts: 781
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: How To Hide Delete From Option?

linkPost by admin » Sun Dec 17, 2017 10:06 pm

The changes are not hard to export to a child theme.
I have created a blanc child theme for you. All you need to do is copy CSS code to your child theme style.css and functions.php custom code to your child theme functions.php file. Then copy every file you have modified to your child theme while keeping same folder hierarchy so for example, parent theme /template-parts/content.php file, if modified, must be copied to your child theme /template-parts/ folder.
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: How To Hide Delete From Option?

linkPost by TahMiD » Sun Dec 17, 2017 10:15 pm

Where is the child theme?
User avatar
Asmi Khalil

Site Admin Rank
Posts: 781
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: How To Hide Delete From Option?

linkPost by admin » Thu Dec 21, 2017 9:58 pm

TahMiD wrote:Where is the child theme?
Sorry :oops: I forgot to upload it. This happens to me a lot :D
realistic-child.21.12.2017.zip
(2.1 KiB) Downloaded 62 times
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: How To Hide Delete From Option?

linkPost by TahMiD » Thu Dec 21, 2017 10:27 pm

No problem, I am Downloading It Now. And Can't Wait For The Pro Version Of This Theme. Just Love Google material Design!
User avatar
Asmi Khalil

Site Admin Rank
Posts: 781
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: How To Hide Delete From Option?

linkPost by admin » Thu Dec 21, 2017 10:35 pm

Good! I am afraid it will take a while before I will be able to start working on the Material Design theme but I promise you it will worth the waiting.

Happy new year my friend :D
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: How To Hide Delete From Option?

linkPost by TahMiD » Thu Dec 21, 2017 10:39 pm

yep. Happy new year brother!

Who is online

Users browsing this forum: No registered users and 1 guest

It is currently Fri Apr 19, 2019 12:31 pm