Only a few week age, I established a simple plugin for myself to showing the social share button in menu. Referred to Building Your Own Social Sharing Plugin for WordPress.

Then, the plugin was successful created. But I have a question of the syntax why If I added the below syntax in the program the checked=”checked” will showing twice.

echo "<input type='checkbox' name='social-share' value='1' " . checked(1, get_option('social-share'), true) ." /> "; 

After that, I found another code to prevent this happen.

?>
  <input type="checkbox" name="social-share" value="1" <?php checked(1, get_option('social-share-wechat'), true); ?> /> Check for Yes
<?php

and Function Reference/checked displaying checked=’checked’

checked( '1', get_option( 'wwo_enable_'.$lrole ), false )

I wondered if anyone can tell me why using HTML format to show the syntax will not show twice?

Read more here: WordPress checked="checked" syntax


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: