How to Create WordPress plugin

MUST READ:

https://www.wautom.com/files/Creating%20A%20WordPress%20Plugin%20Is%20Easier%20Than%20You%20Think%20%20%20Beaver%20Builder.htm


plugins literally ‘plug in’ to WordPress core. This is done using ‘hooks,’ which enable one piece of code to interact with another. As such, hooks determine when and where on your site a plugin is actually used.

add_action( 'the_content', 'my_thank_you_text' );

function my_thank_you_text ( $content ) {
    return $content .= '<p>Thank you for reading!</p>';
}

==>
add_action is ADDing the new function to the another one.

LINK:
Creating A WordPress Plugin Is Easier Than You Think

function dh_modify_read_more_link() {
return '<a class="more-link" href="' . get_permalink() . '">Click to Read!</a>';
}
add_filter( 'the_content_more_link', 'dh_modify_read_more_link' );

==> add_filter is telling WP to replace the old core function "the_content_more_link" by this new one "db_modify_read_more_link".

LINK:
https://www.dreamhost.com/blog/how-to-create-your-first-wordpress-plugin/


The final line in this code uses a filter to hook into a function called the_content_more_link, which represents the Read More link. The filter instructs WordPress to call our new function instead, so the standard link will be replaced with our new version.


5
Leave a Reply

Please Login to comment
5 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
HanTang Recent comment authors
  Subscribe  
Notify of