Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: block emails #42

Merged
merged 6 commits into from
Jul 13, 2023
Merged

feat: block emails #42

merged 6 commits into from
Jul 13, 2023

Conversation

Xieyt
Copy link
Contributor

@Xieyt Xieyt commented Jun 3, 2023

This pull request implements a functionality that prevents the sending of emails when using the wp_mail function to send emails.

Why it’s required?

Blocking email functionality in the WordPress development environment is essential for testing, security, privacy, and efficiency purposes. It prevents unintended consequences, such as sending test emails to real users or exposing sensitive information. Additionally, it helps maintain a smooth development process by avoiding delays caused by email processing.

How it works?

This pull request introduces a plugin which override the wp-mail function, ensuring it is loaded at the start of the mu-plugins loading phase. This prevents other mu-plugins and plugins from overriding it. The default naming convention of this plugin is designed to ensure it is loaded early in the alphabetical loading order of mu-plugins, further enhancing its loading position within the mu-plugins loading phase.

Plugin Information

Plugin Name Block Emails
Plugin Type Must Use Plugin
Plugin Default File Name 000-block-emails.php

Usage

  • This pull request introduces the addition of three new variables to both the hosts.yml file and the GitHub Action workflow file.
  • Variables can be set in both the hosts.yml file and your deploy action workflow file.
  • Setting variables in hosts.yml file has more priority.

In hosts.yml

Variable Default Possible Values Purpose
block_emails null true If set to true, this will enable email blocking functionality.
block_emails_plugin_path null Accept relative path from wp-content directory, for example: custom-mu-plugins If you have set the MU_PLUGIN_DIR constant in your wp-config.php file to specify a custom path for mu-plugins, you can use this variable to install Block Emails into your custom mu-plugins directory.
block_emails_plugin_file_name 000-block-emails String without the .php extension. If you wish to modify the loading position of this plugin within the mu-plugins loading phase.

Example

Assuming you wish to block emails and have configured MU_PLUGIN_DIR to /var/www/htdocs/current/wp-content/custom-mu-plugins.

main:
  user: user
  hostname: example.com
  deploy_path: /opt/easyengine/sites/example.com/app/htdocs
  wp_version: 6.2
  block_emails: true
  block_emails_plugin_path: custom-mu-plugins

In workflow file

Environment Variables Default Possible Values Purpose
BLOCK_EMAILS null true If set to true, this will enable email blocking functionality.

Example

Assuming you wish to block emails and have configured MU_PLUGIN_DIR to /var/www/htdocs/current/wp-content/custom-mu-plugins.

on:
  push:
    branches:
      - main
      - develop

name: Deploy
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Deploy
      uses: rtcamp/action-deploy-wordpress@v3
      env:
        SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
        WP_VERSION: 6.2
        BLOCK_EMAILS: true
        BLOCK_EMAILS_PLUGIN_PATH: custom-mu-plugins

@Xieyt Xieyt requested a review from mrrobot47 June 3, 2023 10:16
Copy link
Member

@mrrobot47 mrrobot47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the requested changes are done, add documentation in main readme file about all the things as shared in PR description.

main.sh Outdated Show resolved Hide resolved
main.sh Outdated Show resolved Hide resolved
@Xieyt Xieyt requested a review from mrrobot47 June 20, 2023 12:06
@mrrobot47 mrrobot47 merged commit f831a9d into rtCamp:master Jul 13, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants