Remove Comment Author Link only for subscribers

This doesn’t feel very nice since it calls get_comment() and get_userdata(), but I’m not sure there’s an obvious better way since the code that calls this doesn’t pass in the records we need: function remove_comment_author_link( $return, $author, $comment_ID ) { $comment = get_comment( $comment_ID ); if ( $comment && $comment->user_id ) { $user = get_userdata( … Read more

Modify existing plugin function with add_filter

So you’re half way there with the code you have, you’re only missing a small part which is that your filter function takes information about what it’s filtering through function parameters, can then make changes to the thing that’s being filtered (or not) and then must pass that back out (return it). I.e. In this … Read more

How should I be using filters and is_single together?

You can do this in functions.php, but you have to make sure the function is hooked into wp. Any earlier than that and is_single is undefined. Try adding this to functions.php: /** * Unhooks sixtenpresssermons_get_meta from the_content if currently on single post. */ function sx_unhook_sixtenpresssermons_get_meta() { // Do nothing if this isn’t single post if … Read more

filter hook to load a different post/page on current post/page

You can use the request hook to change the loaded page for the same URL: add_filter( ‘request’, function( $request ){ //Replace this with custom logic to determine if the user should see the contact-team page $load_team_contact = true; if( $load_team_contact && isset( $request[‘pagename’] ) && ‘contact’ == $request[‘pagename’] ){ $request[‘pagename’] = ‘contact-team’; } return $request; … Read more

How to hide/remove GhostKit component panel in gutenberg block inspector

Ok, nevermind, I found solution I’ve tried removeFilter( ‘editor.BlockEdit’, ‘ghostkit/sr/additional-attributes’ ); but it was not working inside my plugin, but it worked in console, so then I found out, that I need to hook this to something, so this is working solution addAction( ‘plugins.pluginRegistered’, ‘kubiq/remove-ghostkit-animations’, function( settings, name ){ if( name == ‘ghostkit’ ){ removeFilter( … Read more

Using add_filter to modify a public function of a class

It means that the instance of the class is being passed to the filter callback. This might be useful if the class instance contains properties and methods that you might want to re-use in your filter. Take this example of a class: class MyClass { public function complicated_process( $value ) { // Do something complex … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)