Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/email-encoder-bundle/assets/index.php
+++ b/email-encoder-bundle/assets/index.php
@@ -0,0 +1 @@
+<?php //Silence is golden
No newline at end of file
--- a/email-encoder-bundle/config/SafeHtmlConfig.php
+++ b/email-encoder-bundle/config/SafeHtmlConfig.php
@@ -0,0 +1,73 @@
+<?php
+
+return [
+ 'p' => [
+ 'id' => [],
+ 'class' => [],
+ 'style' => [],
+ 'align' => [],
+ 'lang' => [],
+ 'dir' => [],
+ ],
+ 'div' => [
+ 'id' => [],
+ 'class' => [],
+ 'style' => [],
+ 'align' => [],
+ 'lang' => [],
+ 'dir' => [],
+ ],
+ 'span' => [
+ 'id' => [],
+ 'class' => [],
+ 'style' => [],
+ 'lang' => [],
+ 'dir' => [],
+ ],
+ 'br' => [],
+ 'strong' => [],
+ 'center' => [],
+ 'ul' => [
+ 'id' => [],
+ 'class' => [],
+ 'style' => [],
+ 'lang' => [],
+ 'dir' => [],
+ ],
+ 'ol' => [
+ 'id' => [],
+ 'class' => [],
+ 'style' => [],
+ 'lang' => [],
+ 'dir' => [],
+ ],
+ 'li' => [
+ 'id' => [],
+ 'class' => [],
+ 'style' => [],
+ 'lang' => [],
+ 'dir' => [],
+ ],
+ 'a' => [
+ 'id' => [],
+ 'class' => [],
+ 'style' => [],
+ 'href' => [],
+ 'title' => [],
+ 'rel' => [],
+ 'target' => [],
+ 'lang' => [],
+ 'dir' => [],
+ ],
+ 'img' => [
+ 'id' => [],
+ 'class' => [],
+ 'style' => [],
+ 'src' => [],
+ 'alt' => [],
+ 'width' => [],
+ 'height' => [],
+ 'align' => [],
+ 'title' => [],
+ ],
+];
No newline at end of file
--- a/email-encoder-bundle/config/SettingsConfig.php
+++ b/email-encoder-bundle/config/SettingsConfig.php
@@ -0,0 +1,292 @@
+<?php
+
+return [
+
+ 'protect' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'protect',
+ 'type' => 'multi-input',
+ 'input-type' => 'radio',
+ 'title' => __( 'Protect emails', 'email-encoder-bundle' ),
+ 'inputs' => [
+ 1 => [
+ 'label' => __( 'Full-page scan', 'email-encoder-bundle' ),
+ 'description' => __('This will check the whole page against any mails and secures them.', 'email-encoder-bundle' )
+ ],
+ 2 => [
+ 'label' => __( 'Wordpress filters', 'email-encoder-bundle' ),
+ 'description' => __('Secure only mails that occur within WordPress filters. (Not recommended)', 'email-encoder-bundle' ),
+ 'advanced' => true,
+ ],
+ 3 => [
+ 'label' => __( 'Don't do anything.', 'email-encoder-bundle' ),
+ 'description' => __('This turns off the protection for emails. (Not recommended)', 'email-encoder-bundle')
+ ],
+ ],
+ 'required' => false
+ ],
+
+ 'protect_using' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'protect_using',
+ 'type' => 'multi-input',
+ 'input-type' => 'radio',
+ 'title' => __( 'Protect emails using', 'email-encoder-bundle' ),
+ 'inputs' => [
+ 'with_javascript' => [
+ 'label' => __( 'automatically the best method (including javascript)', 'email-encoder-bundle' )
+ ],
+ 'without_javascript' => [
+ 'label' => __( 'automatically the best method (excluding javascript)', 'email-encoder-bundle' ),
+ ],
+ 'strong_method' => [
+ 'label' => __( 'a strong method that replaces all emails with a "*protection text*".', 'email-encoder-bundle' ),
+ 'description' => __('You can configure the protection text within the advanced settings.', 'email-encoder-bundle')
+ ],
+ 'char_encode' => [
+ 'label' => __( 'simple HTML character encoding.', 'email-encoder-bundle' ),
+ 'description' => __('Offers good (but not the best) protection, which saves you in most scenarios.', 'email-encoder-bundle')
+ ],
+ ],
+ 'required' => false
+ ],
+
+ 'filter_body' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'filter_body',
+ 'type' => 'multi-input',
+ 'input-type' => 'checkbox',
+ 'advanced' => true,
+ 'title' => __( 'Protect...', 'email-encoder-bundle' ),
+ 'label' => __( 'Customize what this plugin protects.', 'email-encoder-bundle' ),
+ 'inputs' => [
+ 'filter_rss' => [
+ 'advanced' => true,
+ 'label' => __( 'RSS feed', 'email-encoder-bundle' ),
+ 'description' => __( 'Activating this option results in protecting the rss feed based on the given protection method.', 'email-encoder-bundle' )
+ ],
+ 'ajax_requests' => [
+ 'advanced' => true,
+ 'label' => __( 'Ajax requests', 'email-encoder-bundle' ),
+ 'description' => __( 'By default, ajax requests can send clear emails in some situations. Activating this settings will apply encoding to ajax-relate requests.', 'email-encoder-bundle' )
+ ],
+ 'admin_requests' => [
+ 'advanced' => true,
+ 'label' => __( 'Admin requests', 'email-encoder-bundle' ),
+ 'description' => __( 'By default, we only protect frontend requests (Everything people see on your website). Activating this setting will also protect the backend of your website (The admin area).', 'email-encoder-bundle' )
+ ],
+ 'remove_shortcodes_rss' => [
+ 'advanced' => true,
+ 'label' => __( 'Remove all shortcodes from the RSS feeds', 'email-encoder-bundle' ),
+ 'description' => __( 'Activating this option results in protecting the rss feed based on the given protection method.', 'email-encoder-bundle' )
+ ],
+ 'input_strong_protection' => [
+ 'advanced' => true,
+ 'label' => __( 'input form email fields using strong protection.', 'email-encoder-bundle' ),
+ 'description' => __( 'Warning: this option could conflict with certain form plugins. Test it first. (Requires javascript)', 'email-encoder-bundle' )
+ ],
+ 'encode_mailtos' => [
+ 'advanced' => true,
+ 'label' => __( 'plain emails by converting them to mailto links', 'email-encoder-bundle' ),
+ 'description' => __( 'Plain emails will be automatically converted to mailto links where possible.', 'email-encoder-bundle' )
+ ],
+ 'convert_plain_to_image' => [
+ 'advanced' => true,
+ 'label' => __( 'plain emails by converting them to png images', 'email-encoder-bundle' ),
+ 'description' => __( 'Plain emails will be automatically converted to png images where possible.', 'email-encoder-bundle' )
+ ],
+ 'protect_shortcode_tags' => [
+ 'advanced' => true,
+ 'label' => __( 'shortcode content', 'email-encoder-bundle' ),
+ 'description' => __( 'Protect every shortcode content separately. (This may slows down your site)', 'email-encoder-bundle' )
+ ],
+ 'filter_hook' => [
+ 'advanced' => true,
+ 'label' => __( 'emails from "init" hook', 'email-encoder-bundle' ),
+ 'description' => __( 'Check this option if you want to register the email filters on the "init" hook instead of the "wp" hook.', 'email-encoder-bundle' )
+ ],
+ 'deactivate_rtl' => [
+ 'advanced' => true,
+ 'label' => __( 'mailto links without CSS direction', 'email-encoder-bundle' ),
+ 'description' => __( 'Check this option if your site does not support CSS directions.', 'email-encoder-bundle' )
+ ],
+ 'no_script_tags' => [
+ 'advanced' => true,
+ 'label' => __( 'no script tags', 'email-encoder-bundle' ),
+ 'description' => __( 'Check this option if you face issues with encoded script tags. This will deactivate protection for script tags.', 'email-encoder-bundle' )
+ ],
+ 'no_attribute_validation' => [
+ 'advanced' => true,
+ 'label' => __( 'html attributes without soft encoding.', 'email-encoder-bundle' ),
+ 'description' => __( 'Do not soft-filter all html attributes. This might optimizes the performance, but can break the site if other plugins use your email in attribute tags.', 'email-encoder-bundle' )
+ ],
+ ],
+ 'required' => false,
+ ],
+
+ 'image_settings' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'image_settings',
+ 'type' => 'multi-input',
+ 'input-type' => 'text',
+ 'advanced' => true,
+ 'title' => __( 'Image settings', 'email-encoder-bundle' ),
+ 'label' => __( 'Customize the settings for dynamically created images.', 'email-encoder-bundle' ),
+ 'inputs' => [
+ 'image_color' => [
+ 'advanced' => true,
+ 'label' => __( 'Image Colors', 'email-encoder-bundle' ),
+ 'description' => __( 'Please include RGB colors, comme saparated. E.g.: 0,0,255', 'email-encoder-bundle' )
+ ],
+ 'image_background_color' => [
+ 'advanced' => true,
+ 'label' => __( 'Image Background Colors', 'email-encoder-bundle' ),
+ 'description' => __( 'Please include RGB colors, comme saparated. E.g.: 0,0,255', 'email-encoder-bundle' )
+ ],
+ 'image_text_opacity' => [
+ 'advanced' => true,
+ 'label' => __( 'Text Opacity', 'email-encoder-bundle' ),
+ 'description' => __( 'Change the text opacity for the created images. 0 = not transparent - 127 = completely transprent', 'email-encoder-bundle' )
+ ],
+ 'image_background_opacity' => [
+ 'advanced' => true,
+ 'label' => __( 'Background Opacity', 'email-encoder-bundle' ),
+ 'description' => __( 'Change the background opacity for the created images. 0 = not transparent - 127 = completely transprent', 'email-encoder-bundle' )
+ ],
+ 'image_font_size' => [
+ 'advanced' => true,
+ 'label' => __( 'Font Size', 'email-encoder-bundle' ),
+ 'description' => __( 'Change the font size of the image text. Default: 4 - You can choose from 1 - 5', 'email-encoder-bundle' )
+ ],
+ 'image_underline' => [
+ 'advanced' => true,
+ 'label' => __( 'Text Underline', 'email-encoder-bundle' ),
+ 'description' => __( 'Adds a line beneath the text to highlight it as a link. empty or 0 deactivates the border. 1 = 1px', 'email-encoder-bundle' )
+ ],
+ ],
+ 'required' => false,
+ ],
+
+ 'skip_posts' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'skip_posts',
+ 'type' => 'text',
+ 'advanced' => true,
+ 'title' => __('Exclude post id's from protection', 'email-encoder-bundle'),
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('By comma separating post id's ( e.g. 123,4535,643), you are able to exclude these posts from the logic protection.', 'email-encoder-bundle')
+ ],
+
+ 'skip_query_parameters' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'skip_query_parameters',
+ 'type' => 'text',
+ 'advanced' => true,
+ 'title' => __('Exclude URL parameters from protection', 'email-encoder-bundle'),
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('By comma separating URL (Query) parameters ( e.g. param1,param2), you are able to exclude URLs with these parameters from the protection. URL or Query parameters are found at the end of your URL (e.g. domain.com?param1=test)', 'email-encoder-bundle')
+ ],
+
+ 'protection_text' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'protection_text',
+ 'type' => 'text',
+ 'advanced' => true,
+ 'title' => __('Set protection text *', 'email-encoder-bundle'),
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('This text will be shown for protected email addresses and within noscript tags.', 'email-encoder-bundle')
+ ],
+
+ 'class_name' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'class_name',
+ 'type' => 'text',
+ 'advanced' => true,
+ 'title' => __('Additional classes', 'email-encoder-bundle'),
+ 'label' => __('Add extra classes to mailto links.', 'email-encoder-bundle'),
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('Leave blank for none', 'email-encoder-bundle')
+ ],
+
+ 'custom_href_attr' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'custom_href_attr',
+ 'type' => 'text',
+ 'advanced' => true,
+ 'title' => __('Protect custom href attributes', 'email-encoder-bundle'),
+ 'label' => __('Protect href atrributes such as tel:, ftp:, file:, etc.', 'email-encoder-bundle'),
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('Add the href attributes you want to protect as a comme-separated list. E.g. tel,file,ftp', 'email-encoder-bundle')
+ ],
+
+ 'footer_scripts' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'footer_scripts',
+ 'type' => 'checkbox',
+ 'advanced' => true,
+ 'title' => __('Load scripts in footer', 'email-encoder-bundle'),
+ 'label' => __('Check this button if you want to load all frontend scripts within the footer.', 'email-encoder-bundle'),
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('This forces every script to be enqueued within the footer.', 'email-encoder-bundle')
+ ],
+
+ 'show_encoded_check' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'show_encoded_check',
+ 'type' => 'checkbox',
+ 'title' => __('Security Check', 'email-encoder-bundle'),
+ 'label' => __('Mark emails on the site as successfully encoded', 'email-encoder-bundle') . '<i class="dashicons-before dashicons-lock" style="color:green;"></i>',
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('Only visible for admin users. If your emails look broken, simply deactivate this feature. This also loads the dashicons style.', 'email-encoder-bundle')
+ ],
+
+ 'own_admin_menu' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'own_admin_menu',
+ 'type' => 'checkbox',
+ 'advanced' => true,
+ 'title' => __('Admin Menu', 'email-encoder-bundle'),
+ 'label' => __('Show this page in the main menu item', 'email-encoder-bundle'),
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('Otherwise it will be shown in "Settings"-menu.', 'email-encoder-bundle')
+ ],
+
+ 'encoder_form' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'encoder_form',
+ 'type' => 'multi-input',
+ 'input-type' => 'checkbox',
+ 'advanced' => true,
+ 'title' => __( 'Encoder form settings', 'email-encoder-bundle' ),
+ 'inputs' => [
+ 'encoder_form_frontend' => [
+ 'label' => __( 'Encoder form frontend', 'email-encoder-bundle' ),
+ 'description' => __( 'Activate this to use the [eeb_form] shortcode or the PHP template function eeb_form() within the frontend.', 'email-encoder-bundle' )
+ ],
+ 'powered_by' => [
+ 'label' => __( 'Show a "powered by" link on bottom of the encoder form', 'email-encoder-bundle' ),
+ ],
+ ],
+ 'required' => false
+ ],
+
+ 'advanced_settings' => [
+ 'fieldset' => [ 'slug' => 'main', 'label' => 'Label' ],
+ 'id' => 'advanced_settings',
+ 'type' => 'checkbox',
+ 'title' => __('Advanced Settings', 'email-encoder-bundle'),
+ 'label' => __('Show advanced settings for more configuration possibilities.', 'email-encoder-bundle'),
+ 'placeholder' => '',
+ 'required' => false,
+ 'description' => __('Activate the advanced settings in case you want to customize the default logic or you want to troubleshoot the plugin.', 'email-encoder-bundle')
+ ],
+
+];
No newline at end of file
--- a/email-encoder-bundle/core/class-email-encoder-bundle.php
+++ b/email-encoder-bundle/core/class-email-encoder-bundle.php
@@ -1,150 +1,94 @@
<?php
-if ( ! class_exists( 'Email_Encoder' ) ) :
- /**
- * Main Email_Encoder Class.
- *
- * @since 2.0.0
- * @package EEB
- * @author Ironikus <info@ironikus.com>
- */
- final class Email_Encoder {
+namespace LegacyEmailEncoderBundle;
- /**
- * The real instance
- *
- * @var Email_Encoder
- * @since 2.0.0
- */
- private static $instance;
-
- /**
- * EEB settings Object.
- *
- * @var object|Email_Encoder_Settings
- * @since 2.0.0
- */
- public $settings;
-
- /**
- * EEB helpers Object.
- *
- * @var object|Email_Encoder_Helpers
- * @since 2.0.0
- */
- public $helpers;
-
- /**
- * EEB validate Object.
- *
- * @var object|Email_Encoder_Validate
- * @since 2.0.0
- */
- public $validate;
-
- /**
- * Throw error on object clone.
- *
- * Cloning instances of the class is forbidden.
- *
- * @since 2.0.0
- * @return void
- */
- public function __clone() {
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'email-encoder-bundle' ), '2.0.0' );
+use OnlineOptimisationEmailEncoderBundleAdminAdmin;
+use OnlineOptimisationEmailEncoderBundleFrontFront;
+use OnlineOptimisationEmailEncoderBundleValidateValidate;
+
+final class Email_Encoder {
+
+ private static ?Email_Encoder $instance = null;
+ public Email_Encoder_Settings $settings;
+ public Email_Encoder_Helpers $helpers;
+ // public Email_Encoder_Validate $validate;
+ public Validate $validate;
+ public Email_Encoder_Ajax $ajax;
+
+ /** @var Admin|Front */
+ public $context;
+
+ private array $integrations = [
+ 'avada_builder' => IntegrationAvadaBuilder::class,
+ 'bricks_builder' => IntegrationBricksBuilder::class,
+ 'maintenance' => IntegrationMaintenance::class,
+ 'divi_theme' => IntegrationDiviTheme::class,
+ 'google_site_kit' => IntegrationGoogleSiteKit::class,
+ 'oxygen_builder' => IntegrationOxygenBuilder::class,
+ 'the_events_calendar' => IntegrationEventsCalendar::class,
+ 'wpml' => IntegrationWpml::class,
+ 'hive_press' => IntegrationHivePress::class,
+ ];
+
+
+ public static function instance(): self {
+ if ( self::$instance === null ) {
+ self::$instance = new self();
+ self::$instance->boot();
}
- /**
- * Disable unserializing of the class.
- *
- * @since 2.0.0
- * @return void
- */
- public function __wakeup() {
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'email-encoder-bundle' ), '2.0.0' );
- }
+ return self::$instance;
+ }
- /**
- * Main Email_Encoder Instance.
- *
- * Insures that only one instance of Email_Encoder exists in memory at any one
- * time. Also prevents needing to define globals all over the place.
- *
- * @since 2.0.0
- * @static
- * @staticvar array $instance
- * @return object|Email_Encoder The one true Email_Encoder
- */
- public static function instance() {
- if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Email_Encoder ) ) {
- self::$instance = new Email_Encoder;
- self::$instance->base_hooks();
- self::$instance->includes();
- self::$instance->helpers = new Email_Encoder_Helpers();
- self::$instance->settings = new Email_Encoder_Settings();
- self::$instance->validate = new Email_Encoder_Validate();
-
- new Email_Encoder_Ajax();
- new EEB_Integrations_Loader();
- new Email_Encoder_Run();
-
- /**
- * Fire a custom action to allow extensions to register
- * after Email Encoder was successfully registered
- */
- do_action( 'eeb_plugin_loaded' );
- }
- return self::$instance;
- }
+ private function boot(): void {
- /**
- * Include required files.
- *
- * @access private
- * @since 2.0.0
- * @return void
- */
- private function includes() {
- require_once EEB_PLUGIN_DIR . 'core/includes/classes/class-email-encoder-bundle-helpers.php';
- require_once EEB_PLUGIN_DIR . 'core/includes/classes/class-email-encoder-bundle-settings.php';
- require_once EEB_PLUGIN_DIR . 'core/includes/classes/class-email-encoder-bundle-validate.php';
-
- require_once EEB_PLUGIN_DIR . 'core/includes/classes/class-email-encoder-bundle-ajax.php';
- require_once EEB_PLUGIN_DIR . 'core/includes/functions/template-tags.php';
-
- require_once EEB_PLUGIN_DIR . 'core/includes/integrations/loader.php';
-
- if( is_admin() ){
- require_once EEB_PLUGIN_DIR . 'core/includes/classes/class-email-encoder-bundle-run-admin.php';
- } else {
- require_once EEB_PLUGIN_DIR . 'core/includes/classes/class-email-encoder-bundle-run.php';
- }
+ $this->helpers = new Email_Encoder_Helpers();
+ $this->settings = new Email_Encoder_Settings();
+ // $this->validate = new Email_Encoder_Validate();
+ $this->validate = new Validate();
+ $this->validate->boot();
- }
+ ( new Email_Encoder_Ajax() )->boot();
- /**
- * Add base hooks for the core functionality
- *
- * @access private
- * @since 2.0.0
- * @return void
- */
- private function base_hooks() {
- add_action( 'init', array( self::$instance, 'load_textdomain' ) );
- }
+ $this->integrate3rdParty();
+
+ $this->context = is_admin() ? new Admin() : new Front();
+ $this->context->boot();
+
+ do_action( 'eeb_plugin_loaded', $this );
+ }
+
+
+ private function integrate3rdParty(): void {
+
+ foreach ( $this->integrations as $plugin_id => $class ) {
+
+ if ( true !== apply_filters( 'eeb/integrations/' . $plugin_id, true ) ) {
+ continue;
+ }
- /**
- * Loads the plugin language files.
- *
- * @access public
- * @since 2.0.0
- * @return void
- */
- public function load_textdomain() {
- load_plugin_textdomain( EEB_TEXTDOMAIN, FALSE, dirname( plugin_basename( EEB_PLUGIN_FILE ) ) . '/languages/' );
+ $instance = new $class();
+ $instance->boot();
}
+ }
+
+ /**
+ * Protection.
+ * Cloning instances and unserializing of the class is forbidden.
+ */
+ public function __clone() {
+ _doing_it_wrong( __FUNCTION__,
+ __( 'Cheatin’ huh?', 'email-encoder-bundle' ),
+ '2.0.0'
+ );
}
-endif; // End if class_exists check.
No newline at end of file
+ public function __wakeup() {
+ _doing_it_wrong( __FUNCTION__,
+ __( 'Cheatin’ huh?', 'email-encoder-bundle' ),
+ '2.0.0'
+ );
+ }
+}
--- a/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-ajax.php
+++ b/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-ajax.php
@@ -1,133 +1,92 @@
<?php
-/**
- * Class Email_Encoder_Ajax
- *
- * Thats where we bring the plugin to life
- *
- * @since 2.0.0
- * @package EEB
- * @author Ironikus <info@ironikus.com>
- */
+namespace LegacyEmailEncoderBundle;
+
+use OnlineOptimisationEmailEncoderBundleTraitsPluginHelper;
class Email_Encoder_Ajax{
- /**
- * The main page name for our admin page
- *
- * @var string
- * @since 2.0.0
- */
- private $page_name;
-
- /**
- * The main page title for our admin page
- *
- * @var string
- * @since 2.0.0
- */
- private $page_title;
-
- /**
- * Our Email_Encoder_Run constructor.
- */
- function __construct(){
- $this->page_name = EEB()->settings->get_page_name();
- $this->page_title = EEB()->settings->get_page_title();
-
- // $this->add_hooks();
- add_action( 'init', [ $this, 'add_hooks' ] );
- }
-
- /**
- * Define all of our necessary hooks
- */
- public function add_hooks(){
-
- if(
- EEB()->helpers->is_page( $this->page_name )
- || ( wp_doing_ajax() && isset( $_POST['action'] ) && $_POST['action'] === 'eeb_get_email_form_output' )
- ){
- add_action( 'admin_enqueue_scripts', array( $this, 'load_ajax_scripts_styles' ), EEB()->settings->get_hook_priorities( 'load_ajax_scripts_styles_admin' ) );
- add_action( 'wp_ajax_eeb_get_email_form_output', array( $this, 'eeb_ajax_email_encoder_response' ) );
- }
-
- $form_frontend = (bool) EEB()->settings->get_setting( 'encoder_form_frontend', true, 'encoder_form' );
-
- if( $form_frontend ){
- add_action( 'wp_enqueue_scripts', array( $this, 'load_ajax_scripts_styles' ), EEB()->settings->get_hook_priorities( 'load_ajax_scripts_styles' ) );
- add_action( 'wp_ajax_nopriv_eeb_get_email_form_output', array( $this, 'eeb_ajax_email_encoder_response' ) );
- }
-
- }
-
- /**
- * ######################
- * ###
- * #### SCRIPTS & STYLES
- * ###
- * ######################
- */
-
- /**
- * Register all necessary scripts and styles
- *
- * @since 2.0.0
- */
- public function load_ajax_scripts_styles() {
-
- $js_version_form = date( "ymd-Gis", filemtime( EEB_PLUGIN_DIR . 'core/includes/assets/js/encoder-form.js' ));
- wp_enqueue_script( 'eeb-js-ajax-ef', EEB_PLUGIN_URL . 'core/includes/assets/js/encoder-form.js', array('jquery'), $js_version_form, true );
- wp_localize_script( 'eeb-js-ajax-ef', 'eeb_ef', array(
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
- 'security' => wp_create_nonce( $this->page_name )
- ));
-
- }
-
- /**
- * ######################
- * ###
- * #### CORE LOGIC
- * ###
- * ######################
- */
-
- public function eeb_ajax_email_encoder_response(){
- check_ajax_referer( $this->page_name, 'eebsec' );
-
- $email = html_entity_decode( sanitize_email( $_POST['eebEmail'] ) );
- $method = sanitize_text_field( $_POST['eebMethod'] );
- $display = html_entity_decode( $_POST['eebDisplay'] );
- $custom_class = (string) EEB()->settings->get_setting( 'class_name', true );
- $protection_text = __( EEB()->settings->get_setting( 'protection_text', true ), 'email-encoder-bundle' );
-
- if( empty( $display ) ) {
- $display = $email;
- } else {
- $display = wp_kses_post( $display );
- }
-
- $display = sanitize_text_field( $display );
-
- $class_name = ' class="' . esc_attr( $custom_class ) . '"';
- $mailto = '<a href="mailto:' . $email . '"'. $class_name . '>' . $display . '</a>';
-
- switch( $method ){
- case 'rot13':
- $mailto = EEB()->validate->encode_ascii( $mailto, $protection_text );
- break;
- case 'escape':
- $mailto = EEB()->validate->encode_escape( $mailto, $protection_text );
- break;
- case 'encode':
- default:
- $mailto = '<a href="mailto:' . antispambot( $email ) . '"'. $class_name . '>' . antispambot( $display ) . '</a>';
- break;
- }
-
- echo apply_filters( 'eeb/ajax/encoder_form_response', $mailto );
- exit;
- }
+ use PluginHelper;
+
+ public function boot(): void {
+ add_action( 'init', [ $this, 'register_hooks' ] );
+ }
+
+ public function register_hooks(): void
+ {
+ $EEB = Email_Encoder::instance();
+ $page = $EEB->settings->get_page_name();
+
+ $is_target_admin_page = $EEB->helpers->is_page( $page )
+ || ( wp_doing_ajax() && ( $_POST['action'] ?? '' ) === 'eeb_get_email_form_output')
+ ;
+
+ if ( $is_target_admin_page ) {
+ add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
+ add_action( 'wp_ajax_eeb_get_email_form_output', [ $this, 'handle' ] );
+ }
+
+ if ( (bool) $EEB->settings->get_setting( 'encoder_form_frontend', true, 'encoder_form' ) ) {
+ add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
+ add_action( 'wp_ajax_nopriv_eeb_get_email_form_output', [ $this, 'handle' ] );
+ }
+ }
+
+
+ public function enqueue_scripts(): void
+ {
+ $file = EEB_PLUGIN_DIR . 'core/includes/assets/js/encoder-form.js';
+ $ver = file_exists( $file ) ? filemtime( $file ) : false;
+
+ wp_enqueue_script(
+ 'eeb-js-ajax-ef',
+ EEB_PLUGIN_URL . 'core/includes/assets/js/encoder-form.js',
+ [ 'jquery' ],
+ $ver,
+ true
+ );
+
+ wp_localize_script( 'eeb-js-ajax-ef', 'eeb_ef', [
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
+ 'security' => wp_create_nonce( 'eeb_form' )
+ ] );
+ }
+
+
+ public function handle(): void
+ {
+ check_ajax_referer( 'eeb_form', 'eebsec' );
+
+ $email = sanitize_email( $_POST['eebEmail'] ?? '' );
+ $method = sanitize_text_field( $_POST['eebMethod'] ?? '' );
+ $display = wp_kses_post( $_POST['eebDisplay'] ?? '' );
+ $display = $display ?: $email;
+
+ $EEB = Email_Encoder::instance();
+
+ $class = esc_attr( $this->getSetting( 'class_name', true ) );
+ $protect = __( $this->getSetting( 'protection_text', true ), 'email-encoder-bundle' );
+ $link = '<a href="mailto:' . $email . '" class="' . $class . '">' . $display . '</a>';
+
+ switch ( $method ) {
+ case 'rot13':
+ $link = $this->encodeAscii($link, $protect);
+ break;
+
+ case 'escape':
+ $link = $this->encodeEscape($link, $protect);
+ break;
+
+ default:
+ $link = '<a href="mailto:' . antispambot($email) . '" class="' . $class . '">' . antispambot($display) . '</a>';
+ }
+
+ # @TODO: Proper way to do this
+ // wp_send_json_success( apply_filters('eeb/ajax/encoder_form_response', $link) );
+
+ # @TODO: Old way
+ echo apply_filters('eeb/ajax/encoder_form_response', $link);
+ exit;
+ }
}
--- a/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-helpers.php
+++ b/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-helpers.php
@@ -1,20 +1,7 @@
<?php
-/**
- * Email_Encoder_Helpers Class
- *
- * This class contains all of the available helper functions
- *
- * @since 2.0.0
- */
+namespace LegacyEmailEncoderBundle;
-/**
- * The helpers of the plugin.
- *
- * @since 2.0.0
- * @package EEB
- * @author Ironikus <info@ironikus.com>
- */
class Email_Encoder_Helpers {
/**
@@ -23,7 +10,7 @@
* @param $param
* @return bool
*/
- public function is_page( $param ) {
+ public function is_page( ?string $param ): bool {
if( empty( $param ) ){
return false;
}
--- a/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-run-admin.php
+++ b/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-run-admin.php
@@ -1,282 +0,0 @@
-<?php
-
-/**
- * Class Email_Encoder_Run
- *
- * Thats where we bring the plugin to life
- *
- * @since 2.0.0
- * @package EEB
- * @author Ironikus <info@ironikus.com>
- */
-
-class Email_Encoder_Run{
-
- /**
- * The main page name for our admin page
- *
- * @var string
- * @since 2.0.0
- */
- private $page_name;
-
- /**
- * The main page title for our admin page
- *
- * @var string
- * @since 2.0.0
- */
- private $page_title;
-
- /**
- * The page hook itself for registering the meta boxes
- *
- * @var string
- * @since 2.0.0
- */
- private $pagehook;
-
- /**
- * The settings key
- *
- * @var string
- * @since 2.0.0
- */
- private $settings_key;
-
- /**
- * The display notices
- *
- * @var string
- * @since 2.0.0
- */
- private $display_notices;
-
- /**
- * Our Email_Encoder_Run constructor.
- */
- function __construct(){
- $this->page_name = EEB()->settings->get_page_name();
- $this->page_title = EEB()->settings->get_page_title();
- $this->settings_key = EEB()->settings->get_settings_key();
- $this->display_notices = array();
- $this->add_hooks();
- }
-
- /**
- * Define all of our necessary hooks
- */
- private function add_hooks(){
-
- add_action( 'plugin_action_links_' . EEB_PLUGIN_BASE, array($this, 'plugin_action_links') );
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ) );
- add_action( 'admin_menu', array( $this, 'add_user_submenu' ), 150 );
- add_action( 'admin_init', array( $this, 'save_settings' ), 10 );
- }
-
- /**
- * Plugin action links.
- *
- * Adds action links to the plugin list table
- *
- * Fired by `plugin_action_links` filter.
- *
- * @since 2.0.0
- * @access public
- *
- * @param array $links An array of plugin action links.
- *
- * @return array An array of plugin action links.
- */
- public function plugin_action_links( $links ) {
- $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=' . $this->page_name ), __( 'Settings', 'email-encoder-bundle' ) );
-
- array_unshift( $links, $settings_link );
-
- $links['visit_us'] = sprintf( '<a href="%s" target="_blank" style="font-weight:700;color:#f1592a;">%s</a>', 'https://wpemailencoder.com/?utm_source=email-encoder-bundle&utm_medium=plugin-overview-website-button&utm_campaign=WP%20Mailto%20Links', __('Visit us', 'email-encoder-bundle') );
-
- return $links;
- }
-
- /**
- * ######################
- * ###
- * #### SCRIPTS & STYLES
- * ###
- * ######################
- */
-
- /**
- * Register all necessary scripts and styles
- *
- * @since 2.0.0
- */
- public function enqueue_scripts_and_styles() {
- if( EEB()->helpers->is_page( $this->page_name ) ) {
- $js_version = date( "ymd-Gis", filemtime( EEB_PLUGIN_DIR . 'core/includes/assets/js/custom-admin.js' ));
- $css_version = date( "ymd-Gis", filemtime( EEB_PLUGIN_DIR . 'core/includes/assets/css/style-admin.css' ));
-
- wp_enqueue_script( 'eeb-admin-scripts', EEB_PLUGIN_URL . 'core/includes/assets/js/custom-admin.js', array( 'jquery' ), $js_version, true );
- wp_register_style( 'eeb-css-backend', EEB_PLUGIN_URL . 'core/includes/assets/css/style-admin.css', false, $css_version );
- wp_enqueue_style ( 'eeb-css-backend' );
- }
- }
-
- /**
- * ######################
- * ###
- * #### MENU TEMPLATE ITEMS
- * ###
- * ######################
- */
-
- /**
- * Add our custom admin user page
- */
- public function add_user_submenu(){
-
- if( (string) EEB()->settings->get_setting( 'own_admin_menu', true ) !== '1' ){
- $this->pagehook = add_submenu_page( 'options-general.php', __( $this->page_title, 'email-encoder-bundle' ), __( $this->page_title, 'email-encoder-bundle' ), EEB()->settings->get_admin_cap( 'admin-add-submenu-page-item' ), $this->page_name, array( $this, 'render_admin_menu_page' ) );
- } else {
- $this->pagehook = add_menu_page( __( $this->page_title, 'email-encoder-bundle' ), __( $this->page_title, 'email-encoder-bundle' ), EEB()->settings->get_admin_cap( 'admin-add-menu-page-item' ), $this->page_name, array( $this, 'render_admin_menu_page' ), plugins_url( 'core/includes/assets/img/icon-email-encoder-bundle.png', EEB_PLUGIN_FILE ) );
- }
-
- add_action( 'load-' . $this->pagehook, array( $this, 'add_help_tabs' ) );
- }
-
- /**
- * Render the admin submenu page
- *
- * You need the specified capability to edit it.
- */
- public function render_admin_menu_page(){
- if( ! current_user_can( EEB()->settings->get_admin_cap('admin-menu-page') ) ){
- wp_die( __( EEB()->settings->get_default_string( 'insufficient-permissions' ), 'email-encoder-bundle' ) );
- }
-
- include( EEB_PLUGIN_DIR . 'core/includes/partials/eeb-page-display.php' );
-
- }
-
- /**
- * ######################
- * ###
- * #### SETTINGS LOGIC
- * ###
- * ######################
- */
-
- public function save_settings(){
-
- if( isset( $_POST[ $this->page_name . '_nonce' ] ) ){
- if( ! wp_verify_nonce( $_POST[ $this->page_name . '_nonce' ], $this->page_name ) ){
- wp_die( __( 'You don't have permission to update these settings.', 'email-encoder-bundle' ) );
- }
-
- if( ! current_user_can( EEB()->settings->get_admin_cap( 'admin-update-settings' ) ) ){
- wp_die( __( 'You don't have permission to update these settings.', 'email-encoder-bundle' ) );
- }
-
- if( isset( $_POST[ $this->settings_key ] ) && is_array( $_POST[ $this->settings_key ] ) ){
-
- //Strip duplicate slashes before saving
- foreach( $_POST[ $this->settings_key ] as $k => $v ){
- if( is_string( $v ) ){
- $_POST[ $this->settings_key ][ $k ] = stripslashes( $v );
- }
- }
-
- $check = update_option( $this->settings_key, $_POST[ $this->settings_key ] );
- if( $check ){
- EEB()->settings->reload_settings();
- $update_notice = EEB()->helpers->create_admin_notice( 'Settings successfully saved.', 'success', true );
- $this->display_notices[] = $update_notice;
- } else {
- $update_notice = EEB()->helpers->create_admin_notice( 'No changes were made to your settings with your last save.', 'info', true );
- $this->display_notices[] = $update_notice;
- }
- }
-
- }
-
- }
-
- /**
- * ######################
- * ###
- * #### HELP TABS TEMPLATE ITEMS
- * ###
- * ######################
- */
- public function add_help_tabs(){
- $screen = get_current_screen();
-
- $defaults = array(
- 'content' => '',
- 'callback' => array( $this, 'load_help_tabs' ),
- );
-
- $screen->add_help_tab(wp_parse_args(array(
- 'id' => 'general',
- 'title' => __('General', 'email-encoder-bundle'),
- ), $defaults));
-
- $screen->add_help_tab(wp_parse_args(array(
- 'id' => 'shortcodes',
- 'title' => __('Shortcode', 'email-encoder-bundle'),
- ), $defaults));
-
- $screen->add_help_tab(wp_parse_args(array(
- 'id' => 'template-tags',
- 'title' => __('Template Tags', 'email-encoder-bundle'),
- ), $defaults));
-
- if( EEB()->helpers->is_page( $this->page_name ) ){
- add_meta_box( 'encode_form', __( $this->page_title, 'email-encoder-bundle' ), array( $this, 'show_meta_box_content' ), null, 'normal', 'core', array( 'encode_form' ) );
- }
-
- }
-
- public function load_help_tabs($screen, array $args){
-
- if( ! empty( $args['id'] ) ){
- include( EEB_PLUGIN_DIR . 'core/includes/partials/help-tabs/' . $args['id'] . '.php' );
- }
-
- }
-
- /**
- * Show content of metabox (callback)
- * @param array $post
- * @param array $meta_box
- */
- public function show_meta_box_content( $post, $meta_box ) {
- $key = $meta_box['args'][0];
-
- if ($key === 'encode_form') {
- ?>
- <p><?php _e('If you like you can also create you own secured emails manually with this form. Just copy/paste the generated code and put it in your post, page or template. We choose automatically the best method for you, based on your settings.', 'email-encoder-bundle') ?></p>
-
- <hr style="border:1px solid #FFF; border-top:1px solid #EEE;" />
-
- <?php echo EEB()->validate->get_encoder_form(); ?>
-
- <hr style="border:1px solid #FFF; border-top:1px solid #EEE;"/>
-
- <?php
-
- $form_frontend = (bool) EEB()->settings->get_setting( 'encoder_form_frontend', true, 'encoder_form' );
- if( $form_frontend ){
- ?>
- <p class="description"><?php _e('You can also put the encoder form on your site by using the shortcode <code>[eeb_form]</code> or the template function <code>eeb_form()</code>.', 'email-encoder-bundle') ?></p>
- <?php
- } else {
- ?>
- <p class="description"><?php _e('In case you want to display the Email Encoder form within the frontend, you can activate it inside of the Advanced settings.', 'email-encoder-bundle') ?></p>
- <?php
- }
- }
-
- }
-
-}
--- a/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-run.php
+++ b/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-run.php
@@ -1,713 +0,0 @@
-<?php
-
-/**
- * Class Email_Encoder_Run
- *
- * Thats where we bring the plugin to life
- *
- * @since 2.0.0
- * @package EEB
- * @author Ironikus <info@ironikus.com>
- */
-
-class Email_Encoder_Run{
-
- /**
- * The main page name for our admin page
- *
- * @var string
- * @since 2.0.0
- */
- private $page_name;
-
- /**
- * The main page title for our admin page
- *
- * @var string
- * @since 2.0.0
- */
- private $page_title;
-
- /**
- * The hook used for the final output buffer
- *
- * @var string
- * @since 2.0.0
- */
- private $final_outout_buffer_hook;
-
- /**
- * The hook used for the widget callbacks
- *
- * @var string
- * @since 2.0.0
- */
- private $widget_callback_hook;
-
- /**
- * Our Email_Encoder_Run constructor.
- */
- function __construct() {
- $this->page_name = EEB()->settings->get_page_name();
- $this->page_title = EEB()->settings->get_page_title();
- $this->final_outout_buffer_hook = EEB()->settings->get_final_outout_buffer_hook();
- $this->widget_callback_hook = EEB()->settings->get_widget_callback_hook();
- // $this->add_hooks();
- add_action( 'init', [ $this, 'add_hooks' ] );
- }
-
- /**
- * Define all of our necessary hooks
- */
- public function add_hooks() {
- $filter_hook = (bool) EEB()->settings->get_setting( 'filter_hook', true, 'filter_body' );
- if( $filter_hook ) {
- $hook_name = 'init';
- } else {
- $hook_name = 'wp';
- }
-
- add_action( 'wp', array( $this, 'display_email_image' ), EEB()->settings->get_hook_priorities( 'display_email_image' ) );
- add_action( 'init', array( $this, 'buffer_final_output' ), EEB()->settings->get_hook_priorities( 'buffer_final_output' ) );
- add_action( 'init', array( $this, 'add_custom_template_tags' ), EEB()->settings->get_hook_priorities( 'add_custom_template_tags' ) );
- add_action( $hook_name, array( $this, 'setup_single_filter_hooks' ), EEB()->settings->get_hook_priorities( 'setup_single_filter_hooks' ) );
- add_action( 'wp_enqueue_scripts', array( $this, 'load_frontend_header_styling' ), EEB()->settings->get_hook_priorities( 'load_frontend_header_styling' ) );
-
- //Add shortcodes
- add_shortcode( 'eeb_protect_emails', array( $this, 'protect_content_shortcode' ) );
- add_shortcode( 'eeb_protect_content', array( $this, 'shortcode_eeb_content' ) );
- add_shortcode( 'eeb_mailto', array( $this, 'shortcode_eeb_email' ) );
- add_shortcode( 'eeb_form', array( $this, 'shortcode_email_encoder_form' ) );
-
- //BAckwards compatibility
- add_shortcode( 'eeb_content', array( $this, 'shortcode_eeb_content' ) );
- add_shortcode( 'eeb_email', array( $this, 'shortcode_eeb_email' ) );
-
- do_action('eeb_ready', array($this, 'eeb_ready_callback_filter'), $this);
-
- add_action( 'init', array( $this, 'reload_settings_for_integrations' ), 5 );
- }
-
- /**
- * ######################
- * ###
- * #### CALLBACK FILTERS
- * ###
- * ######################
- */
-
- /**
- * WP filter callback
- * @param string $content
- * @return string
- */
- public function eeb_ready_callback_filter( $content ) {
-
- $apply_protection = true;
-
- if( EEB()->validate->is_query_parameter_excluded() ) {
- $apply_protection = false;
- }
-
- if( EEB()->validate->is_post_excluded() ) {
- $apply_protection = false;
- }
-
- $apply_protection = apply_filters( 'eeb/frontend/apply_protection', $apply_protection );
-
- if( ! $apply_protection ) {
- return $content;
- }
-
- $protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
-
- return EEB()->validate->filter_content( $content, $protect_using );
- }
-
- /**
- * Reload the settings to reflect
- * Third party and integration changes
- *
- * @since 2.1.6
- * @return void
- */
- public function reload_settings_for_integrations() {
- EEB()->settings->reload_settings();
- }
-
- /**
- * ######################
- * ###
- * #### PAGE BUFFERING & WIDGET FILTER
- * ###
- * ######################
- */
-
- /**
- * Buffer the final output on the init hook
- *
- * @return void
- */
- public function buffer_final_output() {
-
- if(
- defined( 'WP_CLI' ) //Bail if WP CLI command
- || defined( 'DOING_CRON' ) //Bail if it is a cron call
- ) {
- return;
- }
-
- if( wp_doing_ajax() ) {
-
- //Maybe allow filtering for ajax requests
- $filter_ajax_requests = (int) EEB()->settings->get_setting( 'ajax_requests', true, 'filter_body' );
- if( $filter_ajax_requests !== 1 ) {
- return;
- }
-
- }
-
- if( is_admin() ) {
-
- //Maybe allow filtering for admin requests
- $filter_admin_requests = (int) EEB()->settings->get_setting( 'admin_requests', true, 'filter_body' );
- if( $filter_admin_requests !== 1 ) {
- return;
- }
-
- }
-
- ob_start( array( $this, 'apply_content_filter' ) );
- }
-
- /**
- * Apply the callabla function for ob_start()
- *
- * @param string $content
- * @return string - the filtered content
- */
- public function apply_content_filter( $content ) {
- $filteredContent = apply_filters( $this->final_outout_buffer_hook, $content );
-
- // remove filters after applying to prevent multiple applies
- remove_all_filters( $this->final_outout_buffer_hook );
-
- return $filteredContent;
- }
-
- /**
- * Filter for "dynamic_sidebar_params" hook
- *
- * @deprecated 2.1.4
- * @global array $wp_registered_widgets
- * @param array $params
- * @return array
- */
- public function eeb_dynamic_sidebar_params( $params) {
- global $wp_registered_widgets;
-
- if ( is_admin() ) {
- return $params;
- }
-
- $widget_id = $params[0]['widget_id'];
-
- // prevent overwriting when already set by another version of the widget output class
- if ( isset( $wp_registered_widgets[ $widget_id ]['_wo_original_callback'] ) ) {
- return $params;
- }
-
- $wp_registered_widgets[ $widget_id ]['_wo_original_callback'] = $wp_registered_widgets[ $widget_id ]['callback'];
- $wp_registered_widgets[ $widget_id ]['callback'] = array( $this, 'call_widget_callback' );
-
- return $params;
- }
-
- /**
- * The Widget Callback
- *
- * @deprecated 2.1.4
- * @global array $wp_registered_widgets
- */
- public function call_widget_callback() {
- global $wp_registered_widgets;
-
- $original_callback_params = func_get_args();
- $original_callback = null;
-
- $widget_id = $original_callback_params[0]['widget_id'];
-
- $original_callback = $wp_registered_widgets[ $widget_id ]['_wo_original_callback'];
- $wp_registered_widgets[ $widget_id ]['callback'] = $original_callback;
-
- $widget_id_base = ( isset( $wp_registered_widgets[ $widget_id ]['callback'][0]->id_base ) ) ? $wp_registered_widgets[ $widget_id ]['callback'][0]->id_base : 0;
-
- if ( is_callable( $original_callback ) ) {
- ob_start();
- call_user_func_array( $original_callback, $original_callback_params );
- $widget_output = ob_get_clean();
-
- echo apply_filters( $this->widget_callback_hook, $widget_output, $widget_id_base, $widget_id );
-
- // remove filters after applying to prevent multiple applies
- remove_all_filters( $this->widget_callback_hook );
- }
- }
-
- /**
- * ######################
- * ###
- * #### SCRIPT ENQUEUEMENTS
- * ###
- * ######################
- */
-
- public function load_frontend_header_styling() {
-
- $js_version = date( "ymd-Gis", filemtime( EEB_PLUGIN_DIR . 'core/includes/assets/js/custom.js' ));
- $css_version = date( "ymd-Gis", filemtime( EEB_PLUGIN_DIR . 'core/includes/assets/css/style.css' ));
- $protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
- $footer_scripts = (bool) EEB()->settings->get_setting( 'footer_scripts', true );
-
- if( $protect_using === 'with_javascript' ) {
- wp_enqueue_script( 'eeb-js-frontend', EEB_PLUGIN_URL . 'core/includes/assets/js/custom.js', array( 'jquery' ), $js_version, $footer_scripts );
- }
-
- if(
- $protect_using === 'with_javascript'
- || $protect_using === 'without_javascript'
- ) {
- wp_register_style( 'eeb-css-frontend', EEB_PLUGIN_URL . 'core/includes/assets/css/style.css', false, $css_version );
- wp_enqueue_style ( 'eeb-css-frontend' );
- }
-
- if( (string) EEB()->settings->get_setting( 'show_encoded_check', true ) === '1' ) {
- wp_enqueue_style('dashicons');
- }
-
- }
-
- /**
- * ######################
- * ###
- * #### CORE LOGIC
- * ###
- * ######################
- */
-
- /**
- * Register all single filters to protect your content
- *
- * @return void
- */
- public function setup_single_filter_hooks() {
-
- if( EEB()->validate->is_query_parameter_excluded() ) {
- return;
- }
-
- if( EEB()->validate->is_post_excluded() ) {
- return;
- }
-
- $protection_method = (int) EEB()->settings->get_setting( 'protect', true );
- $filter_rss = (int) EEB()->settings->get_setting( 'filter_rss', true, 'filter_body' );
- $remove_shortcodes_rss = (int) EEB()->settings->get_setting( 'remove_shortcodes_rss', true, 'filter_body' );
- $protect_shortcode_tags = (bool) EEB()->settings->get_setting( 'protect_shortcode_tags', true, 'filter_body' );
- $protect_shortcode_tags_valid = false;
-
- if ( is_feed() ) {
-
- if( $filter_rss === 1 ) {
- add_filter( $this->final_outout_buffer_hook, array( $this, 'filter_rss' ), EEB()->settings->get_hook_priorities( 'filter_rss' ) );
- }
-
- if ( $remove_shortcodes_rss ) {
- add_filter( $this->final_outout_buffer_hook, array( $this, 'callback_rss_remove_shortcodes' ), EEB()->settings->get_hook_priorities( 'callback_rss_remove_shortcodes' ) );
- }
-
- }
-
- if ( $protection_method === 2 ) {
- $protect_shortcode_tags_valid = true;
-
- $filter_hooks = array(
- 'the_title',
- 'the_content',
- 'the_excerpt',
- 'get_the_excerpt',
-
- //Comment related
- 'comment_text',
- 'comment_excerpt',
- 'comment_url',
- 'get_comment_author_url',
- 'get_comment_author_url_link',
-
- //Widgets
- 'widget_title',
- 'widget_text',
- 'widget_content',
- 'widget_output',
- );
-
- $filter_hooks = apply_filters( 'eeb/frontend/wordpress_filters', $filter_hooks );
-
- foreach ( $filter_hooks as $hook ) {
- add_filter( $hook, array( $this, 'filter_content' ), EEB()->settings->get_hook_priorities( 'filter_content' ) );
- }
- } elseif ( $protection_method === 1 ) {
- $protect_shortcode_tags_valid = true;
-
- add_filter( $this->final_outout_buffer_hook, array( $this, 'filter_page' ), EEB()->settings->get_hook_priorities( 'filter_page' ) );
- }
-
- if ( $protect_shortcode_tags_valid ) {
- if ( $protect_shortcode_tags ) {
- add_filter( 'do_shortcode_tag', array( $this, 'filter_content' ), EEB()->settings->get_hook_priorities( 'do_shortcode_tag' ) );
- }
- }
-
- }
-
- /**
- * Filter the page itself
- *
- * @param string $content
- * @return string
- */
- public function filter_page( $content ) {
- $protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
-
- return EEB()->validate->filter_page( $content, $protect_using );
- }
-
- /**
- * Filter the whole content
- *
- * @param string $content
- * @return string
- */
- public function filter_content( $content ) {
- $protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
- return EEB()->validate->filter_content( $content, $protect_using );
- }
-
- /**
- * Filter the rss content
- *
- * @param string $content
- * @return string
- */
- public function filter_rss( $content ) {
- $protection_type = (string) EEB()->settings->get_setting( 'protect_using', true );
- return EEB()->validate->filter_rss( $content, $protection_type );
- }
-
- /**
- * RSS Callback Remove shortcodes
- * @param string $content
- * @return string
- */
- public function callback_rss_remove_shortcodes( $content ) {
- // strip shortcodes like [eeb_content], [eeb_form]
- $content = strip_shortcodes($content);
-
- return $content;
- }
-
- /**
- * ######################
- * ###
- * #### SHORTCODES
- * ###
- * ######################
- */
-
- /**
- * Handle content filter shortcode
- * @param array $atts
- * @param string $content
- */
- public function protect_content_shortcode( $atts, $content = null ) {
- $protect = (int) EEB()->settings->get_setting( 'protect', true );
- $allowed_attr_html = EEB()->settings->get_safe_html_attr();
- $protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
- $protection_activated = ( $protect === 1 || $protect === 2 ) ? true : false;
-
- if ( ! $protection_activated ) {
- return $content;
- }
-
- if( isset( $atts['protect_using'] ) ) {
- $protect_using = sanitize_title( $atts['protect_using'] );
- }
-
- //Filter content first
- $content = wp_kses( html_entity_decode( $content ), $allowed_attr_html );
-
- $content = EEB()->validate->filter_content( $content, $protect_using );
-
- return $content;
- }
-
- /**
- * Return the email encoder form
- * @param array $atts
- * @param string $content
- */
- public function shortcode_email_encoder_form( $atts = array(), $content = null ) {
-
- if(
- EEB()->helpers->is_page( $this->page_name )
- || (bool) EEB()->settings->get_setting( 'encoder_form_frontend', true, 'encoder_form' )
- ) {
- return EEB()->validate->get_encoder_form();
- }
-
- return '';
- }
-
- /**
- * Return the encoded content
- * @param array $atts
- * @param string $content
- */
- public function shortcode_eeb_content( $atts = array(), $content = null ) {
-
- $original_content = $content;
- $allowed_attr_html = EEB()->settings->get_safe_html_attr();
- $show_encoded_check = (string) EEB()->settings->get_setting( 'show_encoded_check', true );
-
- if( ! isset( $atts['protection_text'] ) ) {
- $protection_text = __( EEB()->settings->get_setting( 'protection_text', true ), 'email-protection-text-eeb-content' );
- } else {
- $protection_text = wp_kses_post( $atts['protection_text'] );
- }
-
- if( isset( $atts['method'] ) ) {
- $method = sanitize_title( $atts['method'] );
- } else {
- $method = 'rot13';
- }
-
- $content = wp_kses( html_entity_decode( $content ), $allowed_attr_html );
-
- if( isset( $atts['do_shortcode'] ) && $atts['do_shortcode'] === 'yes' ) {
- $content = do_shortcode( $content );
- }
-
- switch( $method ) {
- case 'enc_ascii':
- case 'rot13':
- $content = EEB()->validate->encode_ascii( $content, $protection_text );
- break;
- case 'enc_escape':
- case 'escape':
- $content = EEB()->validate->encode_escape( $content, $protection_text );
- break;
- case 'enc_html':
- case 'encode':
- default:
- $content = antispambot( $content );
- break;
- }
-
- // mark link as successfullly encoded (for admin users)
- if ( current_user_can( EEB()->settings->get_admin_cap( 'frontend-display-security-check' ) ) && $show_encoded_check ) {
- $content .= EEB()->validate->get_encoded_email_icon();
- }
-
- return apply_filters( 'eeb/frontend/shortcode/eeb_protect_content', $content, $atts, $original_content );
- }
-
- /**
- * Return the encoded email
- * @param array $atts
- * @param string $content
- */
- public function shortcode_eeb_email( $atts = array(), $content = null ) {
-
- $allowed_attr_html = EEB()->settings->get_safe_html_attr();
- $show_encoded_check = (bool) EEB()->settings->get_setting( 'show_encoded_check', true );
- $protection_text = __( EEB()->settings->get_setting( 'protection_text', true ), 'email-encoder-bundle' );
-
- if( empty( $atts['email'] ) ) {
- return '';
- } else {
- $email = sanitize_email( $atts['email'] );
- }
-
- if( empty( $atts['extra_attrs'] ) ) {
- $extra_attrs = '';
- } else {
- $extra_attrs = $atts['extra_attrs'];
- }
-
- if( ! isset( $atts['method'] ) || empty( $atts['method'] ) ) {
- $protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
- if( ! empty( $protect_using ) ) {
- $method = $protect_using;
- } else {
- $method = 'rot13'; //keep as fallback
- }
- } else {
- $method = sanitize_title( $atts['method'] );
- }
-
- $custom_class = (string) EEB()->settings->get_setting( 'class_name', true );
-
- if( empty( $atts['display'] ) ) {
- $display = $email;
- } else {
- $display = wp_kses( html_entity_decode( $atts['display'] ), $allowed_attr_html );
- $display = str_replace( '\', '', $display ); //Additionally sanitize unicode
- }
-
- if( empty( $atts['noscript'] ) ) {
- $noscript = $protection_text;
- } else {
- $noscript = wp_kses( html_entity_decode( $atts['noscript'] ), $allowed_attr_html );
- $noscript = str_replace( '\', '', $noscript ); //Additionally sanitize unicode
- }
-
- $class_name = ' ' . EEB()->helpers->sanitize_html_attributes( $extra_attrs );
- $class_name .= ' class="' . esc_attr( $custom_class ) . '"';
- $mailto = '<a href="mailto:' . $email . '"'. $class_name . '>' . $display . '</a>';
-
- switch( $method ) {
- case 'enc_ascii':
- case 'rot13':
- $mailto = EEB()->validate->encode_ascii( $mailto, $noscript );
- break;
- case 'enc_escape':
- case 'escape':
- $mailto = EEB()->validate->encode_escape( $mailto, $noscript );
- break;
- case 'with_javascript':
- $mailto = EEB()->validate->dynamic_js_email_encoding( $mailto, $noscript );
- break;
- case 'without_javascript':
- $mailto = EEB()->validate->encode_email_css( $mailto );
- break;
- case 'char_encode':
- $mailto = EEB()->validate->filter_plain_emails( $mailto, null, 'char_encode' );
- break;
- case 'strong_method':
- $mailto = EEB()->validate->filter_plain_emails( $mailto );
- break;
- case 'enc_html':
- case 'encode':
- default:
- $mailto = '<a href="mailto:' . antispambot( $email ) . '"'. $class_name . '>' . antispambot( $display ) . '</a>';
- break;
- }
-
- // mark link as successfullly encoded (for admin users)
- if ( current_user_can( EEB()->settings->get_admin_cap( 'frontend-display-security-check' ) ) && $show_encoded_check ) {
- $mailto .= EEB()->validate->get_encoded_email_icon();
- }
-
- return apply_filters( 'eeb/frontend/shortcode/eeb_mailto', $mailto );
- }
-
- /**
- * ######################
- * ###
- * #### EMAIL IMAGE
- * ###
- * ######################
- */
-
- public function display_email_image() {
-
- if( ! isset( $_GET['eeb_mail'] ) ) {
- return;
- }
-
- $email = sanitize_email( base64_decode( $_GET['eeb_mail'] ) );
-
- if( ! is_email( $email ) || ! isset( $_GET['eeb_hash'] ) ) {
- return;
- }
-
- $hash = (string) $_GET['eeb_hash'];
- $secret = EEB()->settings->get_email_image_secret();
-
- if( ! function_exists( 'imagefontwidth' ) ) {
- wp_die( __('GD Library Not Enabled. Please enable it first.', 'email-encoder-bundle') );
- }
-
- if( EEB()->validate->generate_email_signature( $email, $secret ) !== $hash ) {
- wp_die( __('Your signture is invalid.', 'email-encoder-bundle') );
- }
-
- $image = EEB()->validate->email_to_image( $email );
-
- if( empty( $image ) ) {
- wp_die( __('Your email could not be converted.', 'email-encoder-bundle') );
- }
-
- header('Content-type: image/png');
- echo $image;
- die();
-
- }
-
- /**
- * ######################
- * ###
- * #### TEMPLATE TAGS
- * ###
- * ######################
- */
-
- public function add_custom_template_tags() {
- $template_tags = EEB()->settings->get_template_tags();
-
- foreach( $template_tags as $hook => $callback ) {
-
- //Make sure we only call our own custom template tags
- if( is_callable( array( $this, $callback ) ) ) {
- apply_filters( $hook, array( $this, $callback ), 10 );
- }
-
- }
- }
-
- /**
- * Filter for the eeb_filter template tag
- *
- * This function is called dynamically by add_custom_template_tags
- * using the EEB()->settings->get_template_tags() callback.
- *
- * @param string $content - the default content
- * @return string - the filtered content
- */
- public function template_tag_eeb_filter( $content ) {
- $protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
- return EEB()->validate->filter_content( $content, $protect_using );
- }
-
- /**
- * Filter for the eeb_filter template tag
- *
- * This function is called dynamically by add_custom_template_tags
- * using the EEB()->settings->get_template_tags() callback.
- *
- * @param string $content - the default content
- * @return string - the filtered content
- */
- public function template_tag_eeb_mailto( $email, $display = null, $atts = array() ) {
- if ( is_array( $display ) ) {
- // backwards compatibility (old params: $display, $attrs = array())
- $atts = $display;
- $display = $email;
- } else {
- $atts['href'] = 'mailto:'.$email;
- }
-
- return EEB()->validate->create_protected_mailto( $display, $atts );
- }
-
-}
--- a/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-settings.php
+++ b/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-settings.php
@@ -1,160 +1,70 @@
<?php
-/**
- * Class Email_Encoder_Settings
- *
- * This class contains all of our important settings
- * Here you can configure the whole plugin behavior.
- *
- * @since 2.0.0
- * @package EEB
- * @author Ironikus <info@ironikus.com>
- */
-class Email_Encoder_Settings{
+namespace LegacyEmailEncoderBundle;
- /**
- * Our globally used capability
- *
- * @var string
- * @since 2.0.0
- */
- private $admin_cap;
-
- /**
- * The main page name
- *
- * @var string
- * @since 2.0.0
-