Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.php]
indent_style = tab
indent_size = 4

[*.{markdown,md,mdown,txt}]
indent_size = 4
trim_trailing_whitespace = false
10 changes: 5 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Builds
/build
/docs

# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~
*.sass-cache

# OS or Editor folders
.DS_Store
Thumbs.db
.cache
.project
.settings
.tmproj
*.esproj
nbproject
*.sublime-project
*.sublime-workspace

# Dreamweaver added files
_notes
dwsync.xml

# Komodo
*.komodoproject
.komodotools

# Package management
node_modules/
vendor/

# Folders to ignore
.hg
.svn
.CVS
intermediate
.idea
cache
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "gforceweb/wp-email-debug",
"type": "wordpress-plugin",
"license": "GPL",
"description": "Never accidentally send users emails from your testing sites again!",
"homepage": "https://wordpress.org/plugins/wp-email-debug",
"authors": [
{
"name": "Grant Derepas",
"homepage": "https://www.g-force.net"
}
],
"keywords": [
"wordpress"
],
"support": {
"issues": "https://github.com/GForceWeb/WP-Email-Debug/issues"
},
"require-dev": {
"dangoodman/composer-for-wordpress": "^1.0"
}
}
48 changes: 48 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

170 changes: 90 additions & 80 deletions hooks.php
Original file line number Diff line number Diff line change
@@ -1,121 +1,131 @@
<?php

$WPMDBUGerror;
if (WPMailDebugger::doEnforce())
{
add_filter('wp_mail', array('WPMailDebugger', 'filterEmail'));

if ( WPMailDebugger::doEnforce() ) {
add_filter( 'wp_mail', array( 'WPMailDebugger', 'filterEmail' ) );
}

add_action('admin_menu', 'WPMDBUG_settings_menu');
add_action('admin_init', 'WPMDBUG_handle_settings');
add_action('admin_notices', 'WPMDBUG_admin_notices');
add_action('admin_bar_menu', 'WPMDBUG_toolbar_link', 999);
add_action('admin_print_scripts', 'WPMDBUG_css');
add_action( 'admin_menu', 'WPMDBUG_settings_menu' );
add_action( 'admin_init', 'WPMDBUG_handle_settings' );
add_action( 'admin_notices', 'WPMDBUG_admin_notices' );
add_action( 'admin_bar_menu', 'WPMDBUG_toolbar_link', 999 );
add_action( 'admin_print_scripts', 'WPMDBUG_css' );

/**
* Display CSS to make the toolbar notification text red.
*
* @since 1.0.0
* @return void
**/
function WPMDBUG_css()
{
?>
<style type="text/css">
#wp-admin-bar-WPMDBUG-toolbar .ab-item {color:red !important;}
</style>
<?php
*/
function WPMDBUG_css() {
?>
<style type="text/css">
#wp-admin-bar-WPMDBUG-toolbar .ab-item { color:red !important; }
</style>
<?php
}

/**
* Show a link to the WP Email Debug settings page in the toolbar indicating
* the debugging functionality is enabled.
*
* @since 1.0.0
* @return void
**/
function WPMDBUG_toolbar_link($wp_admin_bar)
{
if (WPMailDebugger::doEnforce()) {
$args = array(
'id' => 'WPMDBUG-toolbar',
'title' => 'Email Debug ON',
'href' => get_admin_url(NULL, 'options-general.php?page=wpmdbug')
);
$wp_admin_bar->add_node( $args );
}
*/
function WPMDBUG_toolbar_link( $wp_admin_bar ) {
if ( WPMailDebugger::doEnforce() ) {
$args = array(
'id' => 'WPMDBUG-toolbar',
'title' => 'Email Debug ON',
'href' => get_admin_url(NULL, 'options-general.php?page=wpmdbug' )
);
$wp_admin_bar->add_node( $args );
}
}

/**
* Add the WP Email Debug settings page to the options menu.
*
* @since 1.0.0
* @return void
**/
function WPMDBUG_settings_menu()
{
add_options_page('E-Mail Debugger', 'E-Mail Debugger', 'manage_options', 'wpmdbug', 'WPMDBUG_settings_page');
*/
function WPMDBUG_settings_menu() {
add_options_page(
'E-Mail Debugger',
'E-Mail Debugger',
'manage_options',
'wpmdbug',
'WPMDBUG_settings_page'
);
}

/**
* Show the settings page.
*
* @since 1.0.0
* @return void
**/
function WPMDBUG_settings_page()
{
require_once WPMDBUG_PATH . 'settings.php';
*/
function WPMDBUG_settings_page() {
require_once WPMDBUG_PATH . 'settings.php';
}

/**
* Process posted data from the settings page.
*
* @since 1.0.0
* @return void
**/
function WPMDBUG_handle_settings()
{
global $WPMDBUGerror;
if (isset($_POST['wpmdbug_submit'])) {

if (isset($_POST['wpmdbug_enabled'])) {
update_option('WPMDBUG_enabled', TRUE);
} else {
update_option('WPMDBUG_enabled', FALSE);
}

$newEmail = $_POST['wpmdbug_sendto'];
$newEmail = filter_var($newEmail, FILTER_VALIDATE_EMAIL);

if ($newEmail === FALSE) {
$WPMDBUGerror = "Invalid Email Address";
} else {
update_option('WPMDBUG_email', $newEmail);
}

$debug_scope = $_POST['wpmdbug_scope'];

if ($debug_scope == 2) {
if (isset($_POST['targetplugins']) && is_array($_POST['targetplugins']) && count($_POST['targetplugins']) > 0) {
update_option('WPMDBUG_plugins', $_POST['targetplugins']);
} else {
$WPMDBUGerror = 'You need to select at least one plugin for the plugin-specific redirect';
}
} else {
update_option('WPMDBUG_plugins', array());
}

}
*/
function WPMDBUG_handle_settings() {
global $WPMDBUGerror;

if ( ! isset( $_POST[ 'wpmdbug_submit' ] ) ) {
return;
}

if ( isset( $_POST[ 'wpmdbug_enabled' ] ) ) {
update_option( 'WPMDBUG_enabled', true );
} else {
update_option( 'WPMDBUG_enabled', false );
}

$newEmail = $_POST[ 'wpmdbug_sendto' ];
$newEmail = filter_var( $newEmail, FILTER_VALIDATE_EMAIL );

if ( $newEmail === false ) {
$WPMDBUGerror = 'Invalid Email Address';
} else {
update_option( 'WPMDBUG_email', $newEmail);
}

$debug_scope = $_POST[ 'wpmdbug_scope' ];

if ( $debug_scope === 2 ) {
if ( isset( $_POST[ 'targetplugins' ] ) && is_array( $_POST[ 'targetplugins' ] ) && count( $_POST[ 'targetplugins' ] ) > 0 ) {
update_option( 'WPMDBUG_plugins', $_POST[ 'targetplugins' ] );
} else {
$WPMDBUGerror = 'You need to select at least one plugin for the plugin-specific redirect';
}
} else {
update_option( 'WPMDBUG_plugins', array() );
}

}

/**
* Add error messages to admin notices.
*
* @since 1.0.0
* @return void
**/
function WPMDBUG_admin_notices()
{
global $WPMDBUGerror;
if (!empty($WPMDBUGerror)) {
?>
<div class="error">
<p><?php echo $WPMDBUGerror; ?></p>
</div>
<?php
}
*/
function WPMDBUG_admin_notices() {
global $WPMDBUGerror;

if ( ! empty( $WPMDBUGerror ) ) {
printf(
'<div class="error"><p>%s</p></div>',
$WPMDBUGerror
);
}

}
Loading