diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9aa5f8d --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitattributes b/.gitattributes index 412eeda..0b6acf1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38f381e --- /dev/null +++ b/.gitignore @@ -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 diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1b9a1eb --- /dev/null +++ b/composer.json @@ -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" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..82a67d6 --- /dev/null +++ b/composer.lock @@ -0,0 +1,48 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "a1a311ed33bc88c0d1a42a7fd466fcda", + "content-hash": "21f0d421b8975c98c259c00548a0a290", + "packages": [], + "packages-dev": [ + { + "name": "dangoodman/composer-for-wordpress", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/dangoodman/composer-for-wordpress.git", + "reference": "f7137989fd4b1be4b004dfd7d7bdec8e8d4c6a79" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dangoodman/composer-for-wordpress/zipball/f7137989fd4b1be4b004dfd7d7bdec8e8d4c6a79", + "reference": "f7137989fd4b1be4b004dfd7d7bdec8e8d4c6a79", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dangoodman\\ComposerForWordpress\\ComposerForWordpress" + }, + "autoload": { + "psr-4": { + "Dangoodman\\ComposerForWordpress\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "time": "2016-01-20 15:04:55" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/hooks.php b/hooks.php index f0ebe60..18d7ada 100644 --- a/hooks.php +++ b/hooks.php @@ -1,121 +1,131 @@ - - + + '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)) { - ?> -
%s
', + $WPMDBUGerror + ); + } + } diff --git a/settings.php b/settings.php index b3704dc..cbe7c2c 100644 --- a/settings.php +++ b/settings.php @@ -1,85 +1,85 @@ 0); +$scopes = get_option( 'WPMDBUG_plugins', array() ); +$scope = ( is_array( $scopes ) && count( $scopes ) > 0 ); -if (!function_exists('get_plugins')) { +if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugins = get_plugins(); ?>