diff --git a/admin-customizations b/admin-customizations
new file mode 100644
index 0000000..04c097c
--- /dev/null
+++ b/admin-customizations
@@ -0,0 +1,482 @@
+';
+
+ //* Adds the admin.css file
+ echo '';
+
+}
+
+//* Adds the favicon to the login screen and the backend admin area
+add_action( 'login_head', 'wordimpress_custom_styles' );
+add_action( 'admin_head', 'wordimpress_custom_styles' );
+
+
+/***********************************************
+* Login with username or email address:
+* http://en.bainternet.info/2013/wordpress-allow-login-with-email
+*
+***********************************************/
+
+add_filter('authenticate', 'bainternet_allow_email_login', 20, 3);
+function bainternet_allow_email_login( $user, $username, $password ) {
+ if ( is_email( $username ) ) {
+ $user = get_user_by_email( $username );
+ if ( $user ) $username = $user->user_login;
+
+ }
+ return wp_authenticate_username_password( null, $username, $password );
+}
+
+add_filter( 'gettext', 'addEmailToLogin', 20, 3 );
+function addEmailToLogin( $translated_text, $text, $domain ) {
+ if ( "Username" == $translated_text )
+ $translated_text .= __( ' Or Email');
+ return $translated_text;
+}
+
+
+/*************************************************
+* domainname.com/login after the domain name redirects to the correct wp-login.php url.
+* http://en.bainternet.info/2012/wordpress-easy-login-url-with-no-htaccess
+*
+***************************************************/
+
+// Add rewrite rule and flush on plugin activation
+register_activation_hook( __FILE__, 'NLURL_activate' );
+function NLURL_activate() {
+ if (! get_option('permalink_structure') ){
+ add_action('admin_notices', 'permalink_structure_admin_notice');
+ }
+ NLURL_rewrite();
+ flush_rewrite_rules();
+}
+
+// Flush on plugin deactivation
+register_deactivation_hook( __FILE__, 'NLURL_deactivate' );
+function NLURL_deactivate() {
+ flush_rewrite_rules();
+}
+
+// Create new rewrite rule
+add_action( 'init', 'NLURL_rewrite' );
+function NLURL_rewrite() {
+ add_rewrite_rule( 'login/?$', 'wp-login.php', 'top' );
+ add_rewrite_rule( 'register/?$', 'wp-login.php?action=register', 'top' );
+ add_rewrite_rule( 'forgot/?$', 'wp-login.php?action=lostpassword', 'top' );
+}
+
+
+//register url fix
+add_filter('register','fix_register_url');
+function fix_register_url($link){
+ return str_replace(site_url('wp-login.php?action=register', 'login'),site_url('register', 'login'),$link);
+}
+
+
+/******************************
+login url fix
+add_filter('login_url','fix_login_url');
+function fix_login_url($link){
+ return str_replace(site_url('wp-login.php', 'login'),site_url('login', 'login'),$link);
+}
+*******************************/
+
+//forgot password url fix
+add_filter('lostpassword_url','fix_lostpass_url');
+function fix_lostpass_url($link){
+ return str_replace('?action=lostpassword','',str_replace(network_site_url('wp-login.php', 'login'),site_url('forgot', 'login'),$link));
+}
+
+//Site URL hack to overwrite register url
+add_filter('site_url','fix_urls',10,3);
+function fix_urls($url, $path, $orig_scheme){
+ if ($orig_scheme !== 'login')
+ return $url;
+ if ($path == 'wp-login.php?action=register')
+ return site_url('register', 'login');
+
+ return $url;
+}
+//notice if user needs to enable permalinks
+function permalink_structure_admin_notice(){
+ echo '
';
+}
+
+
+/********************************************************************
+* replace WordPress Howdy
+* http://www.trickspanda.com/2014/01/change-howdy-text-wordpress-admin-bar/
+*
+********************************************************************/
+function change_howdy($translated, $text, $domain) {
+
+ if (!is_admin() || 'default' != $domain)
+ return $translated;
+ if (false !== strpos($translated, 'Howdy'))
+ return str_replace('Howdy', 'Welcome', $translated);
+ return $translated;
+}
+add_filter('gettext', 'change_howdy', 10, 3);
+
+
+/***************************************
+* Change --Footer text-- in WordPress admin/backend
+* http://www.trickspanda.com/2014/01/change-footer-text-wordpress-admin-panel/
+*
+***************************************/
+function remove_footer_admin () {
+ echo 'Made with WordPress | Initial creation by WordImpress | WordPress Tutorials: Easy Web Design Tutorials';
+}
+add_filter('admin_footer_text', 'remove_footer_admin');
+
+
+/***************************************************
+* Reveal page IDs - Ads the Page ID on the Pages list screen
+*
+* http://markgoodyear.com/2013/07/display-page-id-wordpress-admin-area/
+* There is also a plugin: http://wordpress.org/plugins/reveal-ids-for-wp-admin-25/
+****************************************************/
+
+// Set columns to be used in the Pages section
+function custom_set_pages_columns($columns) {
+ return array(
+ 'cb' => '',
+ 'page_id' => __('ID'),
+ 'title' => __('Title'),
+ 'author' => __('Author'),
+ 'date' => __('Date'),
+ );
+}
+
+// Add the ID to the page ID column
+function custom_set_pages_columns_page_id( $column, $post_id ) {
+ if ($column == 'page_id'){
+ echo $post_id;
+ }
+}
+
+// Add custom styles to the page ID column
+function custom_admin_styling() {
+ echo '';
+}
+
+// Add filters and actions
+add_filter('manage_edit-page_columns' , 'custom_set_pages_columns');
+add_action( 'manage_pages_custom_column' , 'custom_set_pages_columns_page_id', 10, 2 );
+add_action('admin_head', 'custom_admin_styling');
+
+
+
+
+/************************ ---- CHECK THE CODE - It effects the visibility of Posts ----
+* Hide items from wp-admin menu for non admin users
+* http://www.1stwebdesigner.com/wordpress/12-wordpress-coding-snippets-hacks/
+*
+*************************
+
+
+ function remove_dashboard_widgets() {
+ global $menu,$submenu;
+
+ global $current_user;
+ get_currentuserinfo();
+
+ if ($current_user->ID != 1) { // only admin sees the whole thing
+ // $menu and $submenu will return fo all menu and submenu list in admin panel .
+ $menu[2] = ""; //Dashboard
+ $menu[5] = ""; // Posts
+ $menu[15] = ""; //Links
+ $menu[25] = ""; //Comments
+ $menu[65] = ""; //Plugins
+
+ unset($submenu['themes.php'][5]); //themes
+ unset($submenu['themes.php'][12]); //editor
+ }
+ }
+ add_action('admin_head', 'remove_dashboard_widgets');
+
+
+/********************************************
+*
+* Add TinyMCE Editor to Category Description -- Is not working correctly-
+*
+* http://www.paulund.co.uk/add-tinymce-editor-category-description
+*
+**********************************************/
+
+// remove the html filtering
+remove_filter( 'pre_term_description', 'wp_filter_kses' );
+remove_filter( 'term_description', 'wp_kses_data' );
+
+add_filter('edit_category_form_fields', 'cat_description');
+function cat_description($tag)
+{
+ ?>
+
+ id == 'edit-category' )
+ {
+ ?>
+
+
+ $(document).ready( function() {
+ $("#wpadminbar").fadeTo( "slow", 0 );
+ $("#wpadminbar").hover(function() {
+ $("#wpadminbar").fadeTo( "slow", 1 );
+ }, function() {
+ $("#wpadminbar").fadeTo( "slow", 0 );
+ });
+ });
+
+ ';
+ echo $hide_adminbar;
+}
+/* wp-admin area - Backend */
+/*if ( is_admin() ) {
+ add_action( 'admin_head', 'hide_adminbar' );
+}*/
+/* websites - Frontend */
+if ( !is_admin() ) {
+ add_action( 'wp_head', 'hide_adminbar' );
+}
+
+
+
+/*********************************
+* Add and remove dashboard widgets
+* - activity, right now (At a Glance) and quick press (Quick Draft), primary (WordPress News)
+************************************/
+function wordimpress_dashboard_cleanup() {
+
+ //* remove meta boxes to the left
+//* remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' );
+//* remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
+
+ //* remove meta boxes to the right
+//* remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
+//* remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
+
+}
+
+/*****************************
+*Add a custom Welcome Panel
+*****************************/
+function my_welcome_panel() {
+ ?>
+
+
+
+
+
+
+
Based on and inspired by
+
+
Made by
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - ' . __( 'Add a page' ) . '', admin_url( 'edit.php?post_type=page' ) ); ?>
+
+ - ' . __( 'Add a blog post (article)' ) . '', admin_url( 'edit.php' ) ); ?>
+
+ - ' . __( 'Add to the Media Library' ) . '', admin_url( 'upload.php' ) ); ?>
+
+
+
+
+
+
+
+
+
+
+ - ' . __( 'Check out the themes' ) . '', admin_url( 'themes.php' ) ); ?>
+
+ - ' . __( 'Customize the look of your site' ) . '', admin_url( 'customize.php' ) ); ?>
+
+ - ' . __( 'Manage widgets or menus' ) . '
', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); ?>
+
+
' . __( 'Add a plugin' ) . '', admin_url( 'upload.php' ) ); ?>
+
+
+
+
+
+
+
+
+ - ' . __( 'General' ) . '', admin_url( 'options-general.php' ) ); ?>
+
+ - ' . __( 'Reading' ) . '', admin_url( 'options-reading.php' ) ); ?>
+
+ - ' . __( 'Media' ) . '', admin_url( 'options-media.php' ) ); ?>
+
+ - ' . __( 'Permalink' ) . '', admin_url( 'options-permalink.php' ) ); ?>
+
+
+
+
+
+
+
+
+/i";
+ $replacement = '';
+ $content = preg_replace($pattern, $replacement, $content);
+ return $content;
+}
+
+/*******************
+*
+* Sharpen thumbnails
+* https://managewp.com/enhanced-performance-code-snippets
+*
+********************
+
+function ajx_sharpen_resized_files( $resized_file ) {
+
+ $image = wp_load_image( $resized_file );
+ if ( !is_resource( $image ) )
+ return new WP_Error( 'error_loading_image', $image, $file );
+
+ $size = @getimagesize( $resized_file );
+ if ( !$size )
+ return new WP_Error('invalid_image', __('Could not read image size'), $file);
+ list($orig_w, $orig_h, $orig_type) = $size;
+
+ switch ( $orig_type ) {
+ case IMAGETYPE_JPEG:
+ $matrix = array(
+ array(-1, -1, -1),
+ array(-1, 16, -1),
+ array(-1, -1, -1),
+ );
+
+ $divisor = array_sum(array_map('array_sum', $matrix));
+ $offset = 0;
+ imageconvolution($image, $matrix, $divisor, $offset);
+ imagejpeg($image, $resized_file,apply_filters( 'jpeg_quality', 90, 'edit_image' ));
+ break;
+ case IMAGETYPE_PNG:
+ return $resized_file;
+ case IMAGETYPE_GIF:
+ return $resized_file;
+ }
+
+ return $resized_file;
+}
+
+add_filter('image_make_intermediate_size', 'ajx_sharpen_resized_files',900);
+
+
+
+
+/*---------- Menu -------------*/
+
+
+
+
+
+
+/*----------- Media Library -----------*/
+
+
+
+/*---------- WIDGETS ---------*/
+
+/********************************************
+* Enable shortcodes in text widgets
+* http://stephanieleary.com/2010/02/using-shortcodes-everywhere/
+********************************************/
+
+add_filter( 'widget_text', 'shortcode_unautop');
+add_filter( 'widget_text', 'do_shortcode');
+
+
+/**********************
+* Enable PHP Scripts in text widgets
+* http://andornagy.com/enable-scripts-and-shortcodes-in-wordpress-text-widgets/
+***********************/
+
+add_filter('widget_text', 'php_text', 99);
+
+function php_text($text) {
+ if (strpos($text, '<' . '?') !== false) {
+ ob_start();
+ eval('?' . '>' . $text);
+ $text = ob_get_contents();
+ ob_end_clean();
+ }
+ return $text;
+}
+
+
+
+ /*------- Avatar --------*/
+
+
+/****************************************************************
+* Add a new custom Gravatar to the bottom of the Settings -> Discussion section
+* http://blogtimenow.com/wordpress/create-add-custom-default-avatar-wordpress-gravatar/
+*
+*********************************************************************/
+add_filter( 'avatar_defaults', 'new_custom_default_gravatar' );
+function new_custom_default_gravatar ($avatar_defaults) {
+$myavatar = 'http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/800px-Smiley.svg.png';
+$avatar_defaults[$myavatar] = "Custom Default Gravatar";
+return $avatar_defaults;
+}
+
+
+/**************************************************
+* Custom avatar link added to the profile page.
+* http://www.billerickson.net/wordpress-custom-avatar/
+*
+**************************************************
+/**
+ * Add Custom Avatar Field
+ * @author Bill Erickson
+ * @link http://www.billerickson.net/wordpress-custom-avatar/
+ *
+ * @param object $user
+ */
+function be_custom_avatar_field( $user ) { ?>
+ Custom Avatar
+
+ ';
+ elseif ($avatar)
+ $return = $avatar;
+ else
+ $return = '';
+
+ return $return;
+}
+add_filter('get_avatar', 'be_gravatar_filter', 10, 5);
+
+
+
+/***************************************
+*
+* Remove default author profile fields
+* http://www.wpbeginner.com/wp-tutorials/25-extremely-useful-tricks-for-the-wordpress-functions-file/
+*
+******************************************/
+
+add_filter('user_contactmethods','hide_profile_fields',10,1);
+
+function hide_profile_fields( $contactmethods ) {
+ unset($contactmethods['aim']);
+ unset($contactmethods['jabber']);
+ unset($contactmethods['yim']);
+ return $contactmethods;
+}
+
+
+/***********************************************************
+*
+* Adding additional social media fields in profile settings
+* http://andornagy.com/custom-profile-fields-wordpress/
+*
+*************************************************************/
+
+add_filter('user_contactmethods', 'my_user_contactmethods');
+
+function my_user_contactmethods($user_contactmethods){
+
+ $user_contactmethods['facebook'] = 'Facebook URL';
+ $user_contactmethods['twitter'] = 'Twitter Username';
+ $user_contactmethods['linked'] = 'Linkedin Username';
+ $user_contactmethods['google'] = 'Google Profile Link';
+ $user_contactmethods['youtube'] = 'Youtube Channel Name';
+ $user_contactmethods['pinterest'] = 'Printerest Username';
+
+
+ return $user_contactmethods;
+}
+
+if ( get_the_author_meta( 'twitter' ) ) {
+ the_author_meta( 'twitter' );
+
+}
+// End check for twitter
+
+
+if ( get_the_author_meta( 'facebook' ) ) {
+ the_author_meta( 'facebook' );
+
+}
+// End check for facebook
+
+
+/******************************
+*
+* Open Graph
+* http://www.paulund.co.uk/add-facebook-open-graph-tags-to-wordpress
+*
+* To get the correct title, description and image data to show when
+* pasting a link to facebook.
+*
+* Test to see that it is working:
+* http://coveloping.com/tools/open-graph-tag-tester
+*
+*******************************/
+
+// Facebook Open Graph
+add_action('wp_head', 'add_fb_open_graph_tags');
+function add_fb_open_graph_tags() {
+ if (is_single()) {
+ global $post;
+ if(get_the_post_thumbnail($post->ID, 'thumbnail')) {
+ $thumbnail_id = get_post_thumbnail_id($post->ID);
+ $thumbnail_object = get_post($thumbnail_id);
+ $image = $thumbnail_object->guid;
+ } else {
+ $image = ''; // Change this to the URL of the logo you want beside your links shown on Facebook
+ }
+ //$description = get_bloginfo('description');
+ $description = my_excerpt( $post->post_content, $post->post_excerpt );
+ $description = strip_tags($description);
+ $description = str_replace("\"", "'", $description);
+?>
+
+
+
+
+
+
+
+', ']]>', $text);
+ $text = strip_tags($text);
+ $excerpt_length = apply_filters('excerpt_length', 55);
+ $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
+ $words = preg_split("/[\n
+ ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
+ if ( count($words) > $excerpt_length ) {
+ array_pop($words);
+ $text = implode(' ', $words);
+ $text = $text . $excerpt_more;
+ } else {
+ $text = implode(' ', $words);
+ }
+
+ return apply_filters('wp_trim_excerpt', $text, $excerpt);
+}
+
+
+
+
+/***********
+*
+* Share on Facebook and Twitter not sure if it works or not.
+*
+*************
+
+function share_this($content){
+ if(!is_feed() && !is_home()) {
+ $content .= '';
+ }
+ return $content;
+}
+add_action('the_content', 'share_this');
+
+
+/**********
+*
+* Google Plus to bottom of page.
+*
+****************
+
+add_filter('the_content', 'google_plus');
+function google_plus($content) {
+ $content = $content.'';
+ return $content;
+}
+
+add_action ('wp_enqueue_scripts', 'google_plus_script');
+function google_plus_script () {
+ wp_enqueue_script('google-plus', 'http://apis.google.com/js/plusone.js', array(), null);
+}
+
diff --git a/posts-customizations b/posts-customizations
new file mode 100644
index 0000000..5dbc33a
--- /dev/null
+++ b/posts-customizations
@@ -0,0 +1,232 @@
+ 'Thumbnail' );
+ $column_wordcount = array( 'wordcount' => 'Word count' );
+ $columns = array_slice( $columns, 0, 1, true ) + $column_thumbnail + array_slice( $columns, 1, NULL, true );
+ $columns = array_slice( $columns, 0, 3, true ) + $column_wordcount + array_slice( $columns, 3, NULL, true );
+ return $columns;
+}
+
+add_action( 'manage_posts_custom_column', 'my_column_action', 10, 1 );
+function my_column_action( $column ) {
+ global $post;
+ switch ( $column ) {
+ case 'thumbnail':
+ echo get_the_post_thumbnail( $post->ID, 'edit-screen-thumbnail' );
+ break;
+ case 'wordcount':
+ echo str_word_count( $post->post_content );
+ break;
+ }
+}
+
+
+
+/**************
+* Number of media used in each post
+*
+* http://wpsnipp.com/index.php/functions-php/display-post-attachment-count-in-admin-column/
+*
+********************
+
+
+add_filter('manage_posts_columns', 'posts_columns_attachment_count', 5);
+add_action('manage_posts_custom_column', 'posts_custom_columns_attachment_count', 5, 2);
+function posts_columns_attachment_count($defaults){
+ $defaults['wps_post_attachments'] = __('Media');
+ return $defaults;
+}
+function posts_custom_columns_attachment_count($column_name, $id){
+ if($column_name === 'wps_post_attachments'){
+ $attachments = get_children(array('post_parent'=>$id));
+ $count = count($attachments);
+ if($count !=0){echo $count;}
+ }
+}
+
+
+
+
+/******************************
+*
+* -Post List- Add a color for draft, pending and published posts
+*
+* http://wpsnipp.com/index.php/functions-php/change-admin-postpage-color-by-status-draft-pending-published-future-private/
+*
+**********************/
+
+add_action('admin_footer','posts_status_color');
+ function posts_status_color(){
+?>
+
+ID);
+
+ wp_editor($excerpt, $id);
+}
+
+function cosmic_get_excerpt($id) {
+ global $wpdb;
+ $row = $wpdb->get_row("SELECT post_excerpt FROM $wpdb->posts WHERE id = $id");
+ return $row->post_excerpt;
+}
+
+
+/*********************************
+* Duplicate Post or page
+* http://www.1stwebdesigner.com/12-wordpress-coding-snippets-hacks/
+*
+***********************************/
+
+ function duplicate($post) {
+ $title = get_the_title($post);
+ $post = array(
+ 'post_title' => $title,
+ 'post_status' => 'publish',
+ 'post_type' => 'post',
+ 'post_author' => 1
+ );
+ $post_id = wp_insert_post( $post );
+
+ $data = get_post_custom($post);
+
+ foreach ( $data as $key => $values) {
+ foreach ($values as $value) {
+ add_post_meta( $post_id, $key, $value );
+ }
+ }
+
+ return $post_id;
+ }
+
+
+
+
+/*********************************************************
+* Change read more link in a post.
+* http://www.narga.net/customizing-wordpress-read-more/
+*
+**********************************************************/
+
+add_filter( 'the_content_more_link', 'read_more_link', 10, 2 );
+
+function read_more_link( $more_link, $more_link_text ) {
+ return str_replace( $more_link_text, 'Continue reading →', $more_link );
+}
+
+
+/*******************************************************
+* Prevent page scroll when clicking the More link
+* http://www.narga.net/customizing-wordpress-read-more/
+*
+********************************************************/
+
+function remove_more_link_scroll( $link ) {
+ $link = preg_replace( '|#more-[0-9]+|', '', $link );
+ return $link;
+}
+add_filter( 'the_content_more_link', 'remove_more_link_scroll' );
+
+
+/******************************************************
+*
+* Change Post label to Article/Posts
+* http://www.paulund.co.uk/change-posts-text-in-admin-menu
+*
+*******************************************************/
+
+/**
+ * Change the post menu to article
+ */
+function change_post_menu_text() {
+ global $menu;
+ global $submenu;
+
+ // Change menu item
+ $menu[5][0] = 'Article/Posts';
+
+ // Change post submenu
+ $submenu['edit.php'][5][0] = 'Articles';
+ $submenu['edit.php'][10][0] = 'Add Articles';
+ $submenu['edit.php'][16][0] = 'Articles Tags';
+}
+
+add_action( 'admin_menu', 'change_post_menu_text' );
+
+
+
+/**
+ * Change the post type labels
+ */
+function change_post_type_labels() {
+ global $wp_post_types;
+
+ // Get the post labels
+ $postLabels = $wp_post_types['post']->labels;
+ $postLabels->name = 'Articles/Posts';
+ $postLabels->singular_name = 'Articles';
+ $postLabels->add_new = 'Add Articles';
+ $postLabels->add_new_item = 'Add Articles';
+ $postLabels->edit_item = 'Edit Articles';
+ $postLabels->new_item = 'Articles';
+ $postLabels->view_item = 'View Articles';
+ $postLabels->search_items = 'Search Articles';
+ $postLabels->not_found = 'No Articles found';
+ $postLabels->not_found_in_trash = 'No Articles found in Trash';
+}
+add_action( 'init', 'change_post_type_labels' );
diff --git a/security-customizations b/security-customizations
new file mode 100644
index 0000000..5006b01
--- /dev/null
+++ b/security-customizations
@@ -0,0 +1,183 @@
+set_permalink_structure( '%postname%/' );
+} );
+
+
+
+/***********************
+*
+* Force all scripts into wp_footer
+* https://managewp.com/enhanced-performance-code-snippets
+*
+***********************/
+
+if(!is_admin()){
+ remove_action('wp_head', 'wp_print_scripts');
+ remove_action('wp_head', 'wp_print_head_scripts', 9);
+ remove_action('wp_head', 'wp_enqueue_scripts', 1);
+
+ add_action('wp_footer', 'wp_print_scripts', 5);
+ add_action('wp_footer', 'wp_enqueue_scripts', 5);
+ add_action('wp_footer', 'wp_print_head_scripts', 5);
+}
+
+
+/****************************
+*
+* Hide update warning for every user but admin
+* http://www.1stwebdesigner.com/wordpress/12-wordpress-coding-snippets-hacks/
+*****************************/
+
+function wp_hide_update() {
+ global $current_user;
+ get_currentuserinfo();
+
+ if ($current_user->ID != 1) { // only admin will see it
+ remove_action( 'admin_notices', 'update_nag', 3 );
+ }
+ }
+ add_action('admin_menu','wp_hide_update');
+
+/*************************
+*
+* Email Address Encoder plugin by Til Kruss
+* http://wordpress.org/support/plugin/email-address-encoder
+*
+**************************/
+
+
+/**
+ * Define plugin constants that can be overridden, generally in wp-config.php.
+ */
+if (!defined('EAE_FILTER_PRIORITY'))
+ define('EAE_FILTER_PRIORITY', 1000);
+
+/**
+ * Register filters to encode exposed email addresses in
+ * posts, pages, excerpts, comments and widgets.
+ */
+foreach (array('the_content', 'the_excerpt', 'widget_text', 'comment_text', 'comment_excerpt') as $filter) {
+ add_filter($filter, 'eae_encode_emails', EAE_FILTER_PRIORITY);
+}
+
+/**
+ * Searches for plain email addresses in given $string and
+ * encodes them (by default) with the help of eae_encode_str().
+ *
+ * Regular expression is based on based on John Gruber's Markdown.
+ * http://daringfireball.net/projects/markdown/
+ *
+ * @param string $string Text with email addresses to encode
+ * @return string $string Given text with encoded email addresses
+ */
+function eae_encode_emails($string) {
+
+ // abort if $string doesn't contain a @-sign
+ if (apply_filters('eae_at_sign_check', true)) {
+ if (strpos($string, '@') === false) return $string;
+ }
+
+ // override encoding function with the 'eae_method' filter
+ $method = apply_filters('eae_method', 'eae_encode_str');
+
+ // override regex pattern with the 'eae_regexp' filter
+ $regexp = apply_filters(
+ 'eae_regexp',
+ '{
+ (?:mailto:)?
+ (?:
+ [-!#$%&*+/=?^_`.{|}~\w\x80-\xFF]+
+ |
+ ".*?"
+ )
+ \@
+ (?:
+ [-a-z0-9\x80-\xFF]+(\.[-a-z0-9\x80-\xFF]+)*\.[a-z]+
+ |
+ \[[\d.a-fA-F:]+\]
+ )
+ }xi'
+ );
+
+ return preg_replace_callback(
+ $regexp,
+ create_function(
+ '$matches',
+ 'return '.$method.'($matches[0]);'
+ ),
+ $string
+ );
+
+}
+
+/**
+ * Encodes each character of the given string as either a decimal
+ * or hexadecimal entity, in the hopes of foiling most email address
+ * harvesting bots.
+ *
+ * Based on Michel Fortin's PHP Markdown:
+ * http://michelf.com/projects/php-markdown/
+ * Which is based on John Gruber's original Markdown:
+ * http://daringfireball.net/projects/markdown/
+ * Whose code is based on a filter by Matthew Wickline, posted to
+ * the BBEdit-Talk with some optimizations by Milian Wolff.
+ *
+ * @param string $string Text with email addresses to encode
+ * @return string $string Given text with encoded email addresses
+ */
+function eae_encode_str($string) {
+
+ $chars = str_split($string);
+ $seed = mt_rand(0, (int) abs(crc32($string) / strlen($string)));
+
+ foreach ($chars as $key => $char) {
+
+ $ord = ord($char);
+
+ if ($ord < 128) { // ignore non-ascii chars
+
+ $r = ($seed * (1 + $key)) % 100; // pseudo "random function"
+
+ if ($r > 60 && $char != '@') ; // plain character (not encoded), if not @-sign
+ else if ($r < 45) $chars[$key] = ''.dechex($ord).';'; // hexadecimal
+ else $chars[$key] = ''.$ord.';'; // decimal (ascii)
+
+ }
+
+ }
+
+ return implode('', $chars);
+
+}
+
+/**********************/