Skip to content

Instantly share code, notes, and snippets.

@danielpataki
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpataki/f895f91763e6ad55ca1e to your computer and use it in GitHub Desktop.
Save danielpataki/f895f91763e6ad55ca1e to your computer and use it in GitHub Desktop.
Hooks
<p><?php apply_filters( 'product_display_footer', 'Thanks for using our product display plugin' ) ?></p>
<h1><?php the_title() ?></h1>
<div class="description"><?php the_content() ?></div>
<?php do_action( 'below_product_description', $post ) ?>
add_filter( 'login_errors', 'modify_login_errors' );
function modify_login_errors() {
return 'Login unsuccessful, try again';
}
add_action( 'wp_insert_post', 'email_post_author', 10, 3 );
function email_post_author( $post_id, $post, $update ) {
$email = 'mymail@mail.com';
$subject = 'New Post Published';
$message = 'A new post was published, use this link to view it: ' . get_permalink( $post->ID );
wp_mail( $email, $subject, $message );
}
add_action( 'save_post', 'send_admin_email', 10, 3 );
add_action( 'save_post', 'update_post_stats', 5, 3 );
add_action( 'wp_insert_post', 'send_author_email', 10, 3 );
add_action( 'wp_insert_post', 'send_admin_email', 10, 3 );
<?php
/**
* Plugin Name: Hook Test
* Description: A simple plugin to test hooks
*/
function wp_publish_post( $post ) {
// Stuff that actually published the post
do_action( 'wp_insert_post', $post->ID, $post, true );
}
if ( ! empty( $errors ) ) {
/**
* Filter the error messages displayed above the login form.
*
* @since 2.1.0
*
* @param string $errors Login error message.
*/
echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment