is_main_query() ) {
// Hook to change the standard buttons' priority number in content
// Example: add_filter( 'addtoany_content_priority', 20 );
$priority = apply_filters( 'alert_me_content_priority', 98 );
add_filter( 'the_content', 'alert_me_add_to_content', $priority );
}
}
add_action( 'pre_get_posts', 'alert_me_pre_get_posts' );
function alert_me_add_to_content( $content ) {
global $wp_current_filter;
$options = get_option( 'alertme_options', array() );
$post_type = get_post_type( get_the_ID() );
$alertme_enable_post_alertme = get_post_meta( get_the_ID(), 'alertme_enable_post_alertme', true );
// Don't add to get_the_excerpt because it's too early and strips tags (adding to the_excerpt is allowed)
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) || is_home() || is_search() || is_archive() || !array_key_exists($post_type , $options['display_alert_me_post_type']) || get_post_status( get_the_ID() ) == 'private') {
// Return early
return $content;
}
if ($options['alert_me_post_type_visibility_setting'][$post_type] == 'manual') {
if ($alertme_enable_post_alertme == 1):
$options['alert_me_position'] = isset( $options['alert_me_position'] ) ? $options['alert_me_position'] : 'bottom';
if ($options['alert_me_position'] == 'both' || $options['alert_me_position'] == 'top') {
// Prepend to content
$content = alert_me_loadAlertMeBox($options) . '
' . $content;
}
if ( $options['alert_me_position'] == 'bottom' || $options['alert_me_position'] == 'both') {
// Append to content
$content .= alert_me_loadAlertMeBox($options);
}
endif;
} else {
$options['alert_me_position'] = isset( $options['alert_me_position'] ) ? $options['alert_me_position'] : 'bottom';
if ($options['alert_me_position'] == 'both' || $options['alert_me_position'] == 'top') {
// Prepend to content
$content = alert_me_loadAlertMeBox($options) . '
' . $content;
}
if ( $options['alert_me_position'] == 'bottom' || $options['alert_me_position'] == 'both') {
// Append to content
$content .= alert_me_loadAlertMeBox($options);
}
}
return $content;
}
function alert_me_loadAlertMeBox( $options, $print = false ) {
global $alert_me_form_heading_text, $alert_me_form_success_message,$options, $wpdb, $alertme_table;
$table_name = $wpdb->prefix . $alertme_table;
if (isset($options['alert_me_my_subscription_page']) && $options['alert_me_my_subscription_page'] != 0 ) {
$alert_me_my_subscription_page = get_the_permalink($options['alert_me_my_subscription_page']);
} else {
$alert_me_my_subscription_page = get_site_url();
}
ob_start();
?>
ID . " AND email_confirm = 1";
$alreadyCount = $wpdb->get_var($count_query);
if ($alreadyCount > 0): ?>