Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Latest commit

 

History

History
42 lines (34 loc) · 980 Bytes

theme-actions.md

File metadata and controls

42 lines (34 loc) · 980 Bytes
extends title group subgroup prev next order
docs
Theme actions
Basics
Setup
defining-ajax-responses
theme-filters
1

Actions allow you to trigger various logic at the specific moments and places when executing your application.

They should be registered inside app/Setup/actions.php file. As a simple example, let's output Hello World to the footer.

namespace Tonik\Theme\App\Setup;

function render_text()
{
  echo "Hello world!";
}
add_action('wp_footer', 'Tonik\Theme\App\Setup\render_text');

Examples

Using action to reconfigure PHPMailer to use SMTP

namespace Tonik\Theme\App\Setup;

function recofigure_phpmailer_to_smtp($phpmailer)
{
    $phpmailer->isSMTP();
    $phpmailer->Host = 'host';
    $phpmailer->SMTPAuth = true;
    $phpmailer->Port = 2525;
    $phpmailer->Username = 'username';
    $phpmailer->Password = 'password';
}
add_action('phpmailer_init', 'Tonik\Theme\App\Setup\swap_mail_to_use_mailtrap');