php - WordPress - overwrite core function even after theme or site update -
i have googled this, of course, require solution stays put after upgrade theme and/or upgrade entire wordpress site newer version.
basically, before post shown, want show specific html. , want absolutely foolproof because handing on site old guy. don't want plugins installed because quite sure clicking on stuff randomly. -it must seamless.
it must analog of this: (post-template.php)
function the_content( $more_link_text = null, $strip_teaser = false) { $content = get_the_content( $more_link_text, $strip_teaser ); /** * filter post content. * * @since 0.71 * * @param string $content content of current post. */ $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); $extra_html=''; if(is_single()){$extra_html='insert html here';} echo $extra_html.$content; } i cant head around it. should put , where? updates make go away.
to make sure solution make not overwritten on post , themes update, best way around creating child theme , adding piece of html want on proper place. on loop template or single.php depending on how base theme structured.
this way, if wordpress or core theme he's using updated, you'll have solution online child theme not replaced.
another solution using theme , make sure it's online making 2 simple adjustments on wp setup:
- on wp-content folder create new folder called mu-plugins , drop custom made plugin in there. mu-plugins stands must use plugins , plugins on folder enabled , can't turn off unless delete server folder.
- make sure user can't edit theme , plugin files dropping
define( 'disallow_file_mods', true );line on wp-config.php.
both solutions achieve customization without regular user being able break simple button clicking around. if can still issue, can hide admin settings can cause trouble in future. use adminimize quite solutions above make sure user not click , break stuff around.
Comments
Post a Comment