Plugin Directory

Changeset 2587510


Ignore:
Timestamp:
08/24/2021 06:40:02 AM (5 years ago)
Author:
juvodesign
Message:

Update to version 2.0.4 from GitHub

Location:
juvo-mail-editor
Files:
10 added
6 deleted
28 edited
1 copied

Legend:

Unmodified
Added
Removed
  • juvo-mail-editor/tags/2.0.4/admin/Admin.php

    r2578743 r2587510  
    5454         */
    5555
    56         //wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mail-preview.css', array(), $this->version, 'all' );
     56        wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/options-page.css', array(), null, 'all' );
    5757
    5858    }
     
    7777         */
    7878
    79         //wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mail-preview.js', array( 'jquery' ), $this->version, true );
     79        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/ajax.js', array( 'jquery' ), null, true );
    8080
    8181    }
  • juvo-mail-editor/tags/2.0.4/juvo-mail-editor.php

    r2578743 r2587510  
    88 * Text Domain:     juvo-mail-editor
    99 * Domain Path:     /languages
    10  * Version:         2.0.3
     10 * Version:         2.0.4
    1111 */
    1212
  • juvo-mail-editor/tags/2.0.4/readme.txt

    r2578743 r2587510  
    44License: GPLv2 or later
    55Tested up to: 5.8
    6 Stable tag: 2.0.3
     6Stable tag: 2.0.4
    77
    88JUVO Mail Editor helps to modify the standard WordPress Mailings and allows adding dynamic mail triggers.
  • juvo-mail-editor/tags/2.0.4/src/Mail_Editor.php

    r2578743 r2587510  
    9696
    9797        /**
     98         * Options
     99         */
     100        $options = new Options_Page();
     101        $this->loader->add_action( 'cmb2_admin_init', $options, 'yourprefix_register_options_submenu_for_page_post_type' );
     102        $this->loader->add_action( 'wp_ajax_juvo-mail-editor-sync-triggers', $options, "ajax_sync_triggers" );
     103
     104        /**
    98105         * Post Type
    99106         */
     
    108115        $tax = new Mail_Trigger_TAX();
    109116        $this->loader->add_action( 'init', $tax, 'registerTaxonomy' );
    110         $this->loader->add_action( 'juvo_mail_editor_trigger_init', $tax, 'registerTrigger' );
    111         $this->loader->add_action( 'admin_init', $tax, 'registerTrigger' );
     117        $this->loader->add_action( 'juvo_mail_editor_trigger_init', $tax, 'registerTrigger' ); // Called by trigger
    112118        $this->loader->add_action( 'cmb2_admin_init', $tax, 'addMetaboxes' );
    113 
    114119
    115120        /**
  • juvo-mail-editor/tags/2.0.4/src/Mail_Trigger_TAX.php

    r2578743 r2587510  
    44namespace JUVO_MailEditor;
    55
     6
     7use WP_Error;
    68
    79class Mail_Trigger_TAX {
     
    8890    }
    8991
     92    /**
     93     * @return void|WP_Error
     94     */
    9095    public function registerTrigger() {
    9196
    9297        $triggers = [];
     98        $errors   = new WP_Error();
    9399
    94100        $triggers = apply_filters( "juvo_mail_editor_trigger", $triggers );
     
    97103
    98104            if ( ! $trigger instanceof Trigger ) {
    99                 error_log( "[juvo_mail_editor]: Provided trigger is no instance of JUVO_MailEditor\Trigger and therefore skipped" );
     105                $errors->add( "juvo_mail_editor_invalid_trigger", "Provided trigger is no instance of JUVO_MailEditor\Trigger and therefore skipped" );
    100106                continue;
    101107            }
    102108
     109            // Create or Update Term
    103110            $term = get_term_by( 'slug', $trigger->getSlug(), self::TAXONOMY_NAME );
    104 
    105             $term_id = null;
    106111            if ( ! $term ) {
    107                 $term_id = wp_insert_term( $trigger->getName(), self::TAXONOMY_NAME, [ "slug" => $trigger->getSlug() ] )["term_id"];
     112                $term = wp_insert_term(
     113                    $trigger->getName(),
     114                    self::TAXONOMY_NAME,
     115                    [ "slug" => $trigger->getSlug() ]
     116                );
    108117            } else {
    109                 $term_id = $term->term_id;
     118                $term = wp_update_term( $term->term_id, self::TAXONOMY_NAME, array(
     119                    'name' => $trigger->getName(),
     120                    'slug' => $trigger->getSlug()
     121                ) );
    110122            }
    111 
    112             // Verify Slug or mail
    113             if ( empty( $trigger->getName() ) || empty( $trigger->getSlug() ) ) {
    114                 error_log( "[juvo_mail_editor]: Slug or Name are empty" );
     123            if ( is_wp_error( $term ) ) {
     124                $errors->add( "juvo_mail_editor_term_error", $term->get_error_message() );
    115125                continue;
    116126            }
    117127
    118             $term_id = wp_update_term( $term_id, self::TAXONOMY_NAME, array(
    119                 'name' => $trigger->getName(),
    120                 'slug' => $trigger->getSlug()
    121             ) )["term_id"];
     128            // wp_insert_term returns an error while wp_update_term return an instance of WP_Term... thanks for nothing
     129            // normalize $term to be the term_id
     130            if ( is_array( $term ) ) {
     131                $term = $term["term_id"];
     132            } else { // @phpstan-ignore-line
     133                $term = $term->term_id;
     134            }
    122135
    123             update_term_meta( $term_id, self::TAXONOMY_NAME . "_always_send", $trigger->isAlwaysSent() );
    124             update_term_meta( $term_id, self::TAXONOMY_NAME . "_default_recipients", $trigger->getRecipients() );
    125             update_term_meta( $term_id, self::TAXONOMY_NAME . "_default_subject", $trigger->getSubject() );
    126             update_term_meta( $term_id, self::TAXONOMY_NAME . "_default_content", $trigger->getContent() );
    127             update_term_meta( $term_id, self::TAXONOMY_NAME . "_placeholders", $trigger->getPlaceholders() );
     136            // Update meta and log errors
     137            update_term_meta( $term, self::TAXONOMY_NAME . "_always_send", $trigger->isAlwaysSent() );
     138            update_term_meta( $term, self::TAXONOMY_NAME . "_default_recipients", $trigger->getRecipients() );
     139            update_term_meta( $term, self::TAXONOMY_NAME . "_default_subject", $trigger->getSubject() );
     140            update_term_meta( $term, self::TAXONOMY_NAME . "_default_content", $trigger->getContent() );
     141            update_term_meta( $term, self::TAXONOMY_NAME . "_placeholders", $trigger->getPlaceholders() );
     142        }
    128143
     144        foreach ( $errors->get_error_messages() as $error ) {
     145            error_log( "[juvo_mail_editor]: {$error}" );
    129146        }
     147
     148        return $errors;
    130149
    131150    }
  • juvo-mail-editor/tags/2.0.4/src/Mails/Password_Reset.php

    r2578743 r2587510  
    2020
    2121    function password_reset_email_message( string $message, string $key, string $user_login, WP_User $user ): string {
     22
     23        $this->setPlaceholderValues($user, ["key"=>$key]);
    2224
    2325        $relay    = new Relay( $this->getTrigger(), $this->placeholders, $user );
  • juvo-mail-editor/tags/2.0.4/src/Mails_PT.php

    r2578743 r2587510  
    4141            'hierarchical'    => false,
    4242            'menu_position'   => null,
    43             'supports'        => array( 'title', 'editor', 'author', 'revisions', 'custom-fields' ),
    44             'show_in_rest'    => true
     43            'supports'        => array( 'title', 'editor', 'author', 'revisions' ),
     44            'show_in_rest'    => true,
     45            'menu_icon'       => 'dashicons-email'
    4546        );
    4647
     
    7778        ) );
    7879
    79         // Same way the post_status works
    80 //      $cmb->add_field( array(
    81 //          'name'    => __( 'Active', 'juvo-mail-editor' ),
    82 //          'desc'    => __( 'Determines if this mail template should be used for the trigger', 'juvo-mail-editor' ),
    83 //          'id'      => self::POST_TYPE_NAME . '_active',
    84 //          'type'    => 'checkbox',
    85 //          'default' => true,
    86 //          'column'  => true,
    87 //      ) );
    88 
    8980        $cmb->add_field( array(
    90             'name'    => __( 'Recipients', 'juvo-mail-editor' ),
    91             'desc'    => __( 'Comma seperated list of mail addresses<br><code>{{CONTEXT}}</code><code>{{ADMIN_EMAIL}}</code>', 'juvo-mail-editor' ),
    92             'id'      => self::POST_TYPE_NAME . '_recipients',
    93             'type'    => 'text',
     81            'name'   => __( 'Recipients', 'juvo-mail-editor' ),
     82            'desc'   => __( 'Comma seperated list of mail addresses<br><code>{{CONTEXT}}</code><code>{{ADMIN_EMAIL}}</code>', 'juvo-mail-editor' ),
     83            'id'     => self::POST_TYPE_NAME . '_recipients',
     84            'type'   => 'text',
     85            'column' => true,
    9486        ) );
    9587
    9688        $cmb->add_field( array(
    97             'name' => __( 'Subject', 'juvo-mail-editor' ),
    98             'desc' => __( 'E-Mail subject', 'juvo-mail-editor' ),
    99             'id'   => self::POST_TYPE_NAME . '_subject',
    100             'type' => 'text',
     89            'name'   => __( 'Subject', 'juvo-mail-editor' ),
     90            'desc'   => __( 'E-Mail subject', 'juvo-mail-editor' ),
     91            'id'     => self::POST_TYPE_NAME . '_subject',
     92            'type'   => 'text',
     93            'column' => true,
    10194        ) );
    10295
  • juvo-mail-editor/tags/2.0.4/src/Relay.php

    r2578743 r2587510  
    3939     * @param string $trigger
    4040     * @param array $placeholders
     41     * @param mixed $context
    4142     */
    4243    public function __construct( string $trigger, array $placeholders, $context = null ) {
     
    178179        $subject = apply_filters( "juvo_mail_editor_before_subject_placeholder", $subject, $this->trigger, $this->context );
    179180        $subject = Placeholder::replacePlaceholder( $this->placeholders, $subject, $this->context );
    180         $subject = apply_filters( "juvo_mail_editor_after_subject_placeholder", $subject, $this->trigger, $this->context );
    181 
    182         return $subject;
     181
     182        return apply_filters( "juvo_mail_editor_after_subject_placeholder", $subject, $this->trigger, $this->context );
    183183    }
    184184
     
    200200        }
    201201        $recipients = Placeholder::replacePlaceholder( $placeholders, $recipients, $this->context );
    202         $recipients = apply_filters( "juvo_mail_editor_after_recipient_placeholder", $recipients, $this->trigger, $this->context );
    203 
    204         return $recipients;
     202
     203        return apply_filters( "juvo_mail_editor_after_recipient_placeholder", $recipients, $this->trigger, $this->context );
    205204    }
    206205
  • juvo-mail-editor/tags/2.0.4/vendor/autoload.php

    r2578760 r2587510  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInitd81e8c0431ed8f64bf4ad6a36464f4ef::getLoader();
     7return ComposerAutoloaderInitf63f9541b6a428f4859c2a7f96e49e21::getLoader();
  • juvo-mail-editor/tags/2.0.4/vendor/composer/autoload_psr4.php

    r2578760 r2587510  
    77
    88return array(
    9     'juvo\\WordPressAdminNotices\\' => array($vendorDir . '/juvo/wp-admin-notices/src'),
    10     'WPTRT\\AdminNotices\\' => array($vendorDir . '/wptrt/admin-notices/src'),
    119    'SzepeViktor\\PHPStan\\WordPress\\' => array($vendorDir . '/szepeviktor/phpstan-wordpress/src'),
    1210    'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'),
  • juvo-mail-editor/tags/2.0.4/vendor/composer/autoload_real.php

    r2578760 r2587510  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitd81e8c0431ed8f64bf4ad6a36464f4ef
     5class ComposerAutoloaderInitf63f9541b6a428f4859c2a7f96e49e21
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitd81e8c0431ed8f64bf4ad6a36464f4ef', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitf63f9541b6a428f4859c2a7f96e49e21', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitd81e8c0431ed8f64bf4ad6a36464f4ef', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitf63f9541b6a428f4859c2a7f96e49e21', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5454
    5555        if ($useStaticLoader) {
    56             $includeFiles = Composer\Autoload\ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::$files;
     56            $includeFiles = Composer\Autoload\ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::$files;
    5757        } else {
    5858            $includeFiles = require __DIR__ . '/autoload_files.php';
    5959        }
    6060        foreach ($includeFiles as $fileIdentifier => $file) {
    61             composerRequired81e8c0431ed8f64bf4ad6a36464f4ef($fileIdentifier, $file);
     61            composerRequiref63f9541b6a428f4859c2a7f96e49e21($fileIdentifier, $file);
    6262        }
    6363
     
    6666}
    6767
    68 function composerRequired81e8c0431ed8f64bf4ad6a36464f4ef($fileIdentifier, $file)
     68function composerRequiref63f9541b6a428f4859c2a7f96e49e21($fileIdentifier, $file)
    6969{
    7070    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • juvo-mail-editor/tags/2.0.4/vendor/composer/autoload_static.php

    r2578760 r2587510  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef
     7class ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21
    88{
    99    public static $files = array (
     
    1414
    1515    public static $prefixLengthsPsr4 = array (
    16         'j' =>
    17         array (
    18             'juvo\\WordPressAdminNotices\\' => 27,
    19         ),
    20         'W' =>
    21         array (
    22             'WPTRT\\AdminNotices\\' => 19,
    23         ),
    2416        'S' =>
    2517        array (
     
    4335
    4436    public static $prefixDirsPsr4 = array (
    45         'juvo\\WordPressAdminNotices\\' =>
    46         array (
    47             0 => __DIR__ . '/..' . '/juvo/wp-admin-notices/src',
    48         ),
    49         'WPTRT\\AdminNotices\\' =>
    50         array (
    51             0 => __DIR__ . '/..' . '/wptrt/admin-notices/src',
    52         ),
    5337        'SzepeViktor\\PHPStan\\WordPress\\' =>
    5438        array (
     
    8569    {
    8670        return \Closure::bind(function () use ($loader) {
    87             $loader->prefixLengthsPsr4 = ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::$prefixLengthsPsr4;
    88             $loader->prefixDirsPsr4 = ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::$prefixDirsPsr4;
    89             $loader->classMap = ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::$classMap;
     71            $loader->prefixLengthsPsr4 = ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::$prefixLengthsPsr4;
     72            $loader->prefixDirsPsr4 = ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::$prefixDirsPsr4;
     73            $loader->classMap = ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::$classMap;
    9074
    9175        }, null, ClassLoader::class);
  • juvo-mail-editor/tags/2.0.4/vendor/composer/installed.json

    r2578760 r2587510  
    6161            },
    6262            "install-path": "../cmb2/cmb2"
    63         },
    64         {
    65             "name": "juvo/wp-admin-notices",
    66             "version": "v1.0.2",
    67             "version_normalized": "1.0.2.0",
    68             "source": {
    69                 "type": "git",
    70                 "url": "https://github.com/JUVOJustin/wp-admin-notices.git",
    71                 "reference": "53129ec20d2bef9aac6291638d924a44fa7781c4"
    72             },
    73             "dist": {
    74                 "type": "zip",
    75                 "url": "https://api.github.com/repos/JUVOJustin/wp-admin-notices/zipball/53129ec20d2bef9aac6291638d924a44fa7781c4",
    76                 "reference": "53129ec20d2bef9aac6291638d924a44fa7781c4",
    77                 "shasum": ""
    78             },
    79             "require": {
    80                 "php": ">=7.0.0",
    81                 "wptrt/admin-notices": "^1.0"
    82             },
    83             "time": "2020-11-23T09:36:17+00:00",
    84             "type": "library",
    85             "installation-source": "dist",
    86             "autoload": {
    87                 "psr-4": {
    88                     "juvo\\WordPressAdminNotices\\": "src/"
    89                 }
    90             },
    91             "notification-url": "https://packagist.org/downloads/",
    92             "authors": [
    93                 {
    94                     "name": "Justin Vogt",
    95                     "email": "[email protected]",
    96                     "homepage": "https://juvo-design.de"
    97                 }
    98             ],
    99             "description": "Adds a wrapper layer to store notices for wptrt/admin-notices",
    100             "keywords": [
    101                 "notices",
    102                 "wordpress",
    103                 "wptrt"
    104             ],
    105             "support": {
    106                 "issues": "https://github.com/JUVOJustin/wp-admin-notices/issues",
    107                 "source": "https://github.com/JUVOJustin/wp-admin-notices/tree/v1.0.2"
    108             },
    109             "install-path": "../juvo/wp-admin-notices"
    11063        },
    11164        {
     
    573526            ],
    574527            "install-path": "../szepeviktor/phpstan-wordpress"
    575         },
    576         {
    577             "name": "wptrt/admin-notices",
    578             "version": "v1.0.3",
    579             "version_normalized": "1.0.3.0",
    580             "source": {
    581                 "type": "git",
    582                 "url": "https://github.com/WPTT/admin-notices.git",
    583                 "reference": "3904e0dc087b48289056a77eea3d1dab4ef0dde1"
    584             },
    585             "dist": {
    586                 "type": "zip",
    587                 "url": "https://api.github.com/repos/WPTT/admin-notices/zipball/3904e0dc087b48289056a77eea3d1dab4ef0dde1",
    588                 "reference": "3904e0dc087b48289056a77eea3d1dab4ef0dde1",
    589                 "shasum": ""
    590             },
    591             "require": {
    592                 "php": ">=5.6"
    593             },
    594             "time": "2020-02-15T10:34:51+00:00",
    595             "type": "library",
    596             "installation-source": "dist",
    597             "autoload": {
    598                 "psr-4": {
    599                     "WPTRT\\AdminNotices\\": "src/"
    600                 }
    601             },
    602             "notification-url": "https://packagist.org/downloads/",
    603             "license": [
    604                 "GPL-2.0-or-later"
    605             ],
    606             "authors": [
    607                 {
    608                     "name": "WordPress.org Theme Review Team",
    609                     "email": "[email protected]",
    610                     "homepage": "https://make.wordpress.org/themes",
    611                     "role": "Developer"
    612                 }
    613             ],
    614             "description": "A class to create admin-notices for the WordPress dashboard.",
    615             "homepage": "https://github.com/WPTRT/admin-notices",
    616             "keywords": [
    617                 "wordpress"
    618             ],
    619             "support": {
    620                 "issues": "https://github.com/WPTRT/admin-notices/issues",
    621                 "source": "https://github.com/WPTT/admin-notices/tree/v1.0.3"
    622             },
    623             "install-path": "../wptrt/admin-notices"
    624528        }
    625529    ],
  • juvo-mail-editor/tags/2.0.4/vendor/composer/installed.php

    r2578760 r2587510  
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => 'c80c30d81787c927c36cb4f6ef4e6cc1ead4587a',
     8        'reference' => 'ec729b7b920038180c08b479a32b1c43f785e26c',
    99        'name' => 'juvo/mail-editor',
    1010        'dev' => true,
     
    3232            'install_path' => __DIR__ . '/../../',
    3333            'aliases' => array(),
    34             'reference' => 'c80c30d81787c927c36cb4f6ef4e6cc1ead4587a',
    35             'dev_requirement' => false,
    36         ),
    37         'juvo/wp-admin-notices' => array(
    38             'pretty_version' => 'v1.0.2',
    39             'version' => '1.0.2.0',
    40             'type' => 'library',
    41             'install_path' => __DIR__ . '/../juvo/wp-admin-notices',
    42             'aliases' => array(),
    43             'reference' => '53129ec20d2bef9aac6291638d924a44fa7781c4',
     34            'reference' => 'ec729b7b920038180c08b479a32b1c43f785e26c',
    4435            'dev_requirement' => false,
    4536        ),
     
    116107            'dev_requirement' => true,
    117108        ),
    118         'wptrt/admin-notices' => array(
    119             'pretty_version' => 'v1.0.3',
    120             'version' => '1.0.3.0',
    121             'type' => 'library',
    122             'install_path' => __DIR__ . '/../wptrt/admin-notices',
    123             'aliases' => array(),
    124             'reference' => '3904e0dc087b48289056a77eea3d1dab4ef0dde1',
    125             'dev_requirement' => false,
    126         ),
    127109    ),
    128110);
  • juvo-mail-editor/trunk/admin/Admin.php

    r2578743 r2587510  
    5454         */
    5555
    56         //wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mail-preview.css', array(), $this->version, 'all' );
     56        wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/options-page.css', array(), null, 'all' );
    5757
    5858    }
     
    7777         */
    7878
    79         //wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mail-preview.js', array( 'jquery' ), $this->version, true );
     79        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/ajax.js', array( 'jquery' ), null, true );
    8080
    8181    }
  • juvo-mail-editor/trunk/juvo-mail-editor.php

    r2578743 r2587510  
    88 * Text Domain:     juvo-mail-editor
    99 * Domain Path:     /languages
    10  * Version:         2.0.3
     10 * Version:         2.0.4
    1111 */
    1212
  • juvo-mail-editor/trunk/readme.txt

    r2578743 r2587510  
    44License: GPLv2 or later
    55Tested up to: 5.8
    6 Stable tag: 2.0.3
     6Stable tag: 2.0.4
    77
    88JUVO Mail Editor helps to modify the standard WordPress Mailings and allows adding dynamic mail triggers.
  • juvo-mail-editor/trunk/src/Mail_Editor.php

    r2578743 r2587510  
    9696
    9797        /**
     98         * Options
     99         */
     100        $options = new Options_Page();
     101        $this->loader->add_action( 'cmb2_admin_init', $options, 'yourprefix_register_options_submenu_for_page_post_type' );
     102        $this->loader->add_action( 'wp_ajax_juvo-mail-editor-sync-triggers', $options, "ajax_sync_triggers" );
     103
     104        /**
    98105         * Post Type
    99106         */
     
    108115        $tax = new Mail_Trigger_TAX();
    109116        $this->loader->add_action( 'init', $tax, 'registerTaxonomy' );
    110         $this->loader->add_action( 'juvo_mail_editor_trigger_init', $tax, 'registerTrigger' );
    111         $this->loader->add_action( 'admin_init', $tax, 'registerTrigger' );
     117        $this->loader->add_action( 'juvo_mail_editor_trigger_init', $tax, 'registerTrigger' ); // Called by trigger
    112118        $this->loader->add_action( 'cmb2_admin_init', $tax, 'addMetaboxes' );
    113 
    114119
    115120        /**
  • juvo-mail-editor/trunk/src/Mail_Trigger_TAX.php

    r2578743 r2587510  
    44namespace JUVO_MailEditor;
    55
     6
     7use WP_Error;
    68
    79class Mail_Trigger_TAX {
     
    8890    }
    8991
     92    /**
     93     * @return void|WP_Error
     94     */
    9095    public function registerTrigger() {
    9196
    9297        $triggers = [];
     98        $errors   = new WP_Error();
    9399
    94100        $triggers = apply_filters( "juvo_mail_editor_trigger", $triggers );
     
    97103
    98104            if ( ! $trigger instanceof Trigger ) {
    99                 error_log( "[juvo_mail_editor]: Provided trigger is no instance of JUVO_MailEditor\Trigger and therefore skipped" );
     105                $errors->add( "juvo_mail_editor_invalid_trigger", "Provided trigger is no instance of JUVO_MailEditor\Trigger and therefore skipped" );
    100106                continue;
    101107            }
    102108
     109            // Create or Update Term
    103110            $term = get_term_by( 'slug', $trigger->getSlug(), self::TAXONOMY_NAME );
    104 
    105             $term_id = null;
    106111            if ( ! $term ) {
    107                 $term_id = wp_insert_term( $trigger->getName(), self::TAXONOMY_NAME, [ "slug" => $trigger->getSlug() ] )["term_id"];
     112                $term = wp_insert_term(
     113                    $trigger->getName(),
     114                    self::TAXONOMY_NAME,
     115                    [ "slug" => $trigger->getSlug() ]
     116                );
    108117            } else {
    109                 $term_id = $term->term_id;
     118                $term = wp_update_term( $term->term_id, self::TAXONOMY_NAME, array(
     119                    'name' => $trigger->getName(),
     120                    'slug' => $trigger->getSlug()
     121                ) );
    110122            }
    111 
    112             // Verify Slug or mail
    113             if ( empty( $trigger->getName() ) || empty( $trigger->getSlug() ) ) {
    114                 error_log( "[juvo_mail_editor]: Slug or Name are empty" );
     123            if ( is_wp_error( $term ) ) {
     124                $errors->add( "juvo_mail_editor_term_error", $term->get_error_message() );
    115125                continue;
    116126            }
    117127
    118             $term_id = wp_update_term( $term_id, self::TAXONOMY_NAME, array(
    119                 'name' => $trigger->getName(),
    120                 'slug' => $trigger->getSlug()
    121             ) )["term_id"];
     128            // wp_insert_term returns an error while wp_update_term return an instance of WP_Term... thanks for nothing
     129            // normalize $term to be the term_id
     130            if ( is_array( $term ) ) {
     131                $term = $term["term_id"];
     132            } else { // @phpstan-ignore-line
     133                $term = $term->term_id;
     134            }
    122135
    123             update_term_meta( $term_id, self::TAXONOMY_NAME . "_always_send", $trigger->isAlwaysSent() );
    124             update_term_meta( $term_id, self::TAXONOMY_NAME . "_default_recipients", $trigger->getRecipients() );
    125             update_term_meta( $term_id, self::TAXONOMY_NAME . "_default_subject", $trigger->getSubject() );
    126             update_term_meta( $term_id, self::TAXONOMY_NAME . "_default_content", $trigger->getContent() );
    127             update_term_meta( $term_id, self::TAXONOMY_NAME . "_placeholders", $trigger->getPlaceholders() );
     136            // Update meta and log errors
     137            update_term_meta( $term, self::TAXONOMY_NAME . "_always_send", $trigger->isAlwaysSent() );
     138            update_term_meta( $term, self::TAXONOMY_NAME . "_default_recipients", $trigger->getRecipients() );
     139            update_term_meta( $term, self::TAXONOMY_NAME . "_default_subject", $trigger->getSubject() );
     140            update_term_meta( $term, self::TAXONOMY_NAME . "_default_content", $trigger->getContent() );
     141            update_term_meta( $term, self::TAXONOMY_NAME . "_placeholders", $trigger->getPlaceholders() );
     142        }
    128143
     144        foreach ( $errors->get_error_messages() as $error ) {
     145            error_log( "[juvo_mail_editor]: {$error}" );
    129146        }
     147
     148        return $errors;
    130149
    131150    }
  • juvo-mail-editor/trunk/src/Mails/Password_Reset.php

    r2578743 r2587510  
    2020
    2121    function password_reset_email_message( string $message, string $key, string $user_login, WP_User $user ): string {
     22
     23        $this->setPlaceholderValues($user, ["key"=>$key]);
    2224
    2325        $relay    = new Relay( $this->getTrigger(), $this->placeholders, $user );
  • juvo-mail-editor/trunk/src/Mails_PT.php

    r2578743 r2587510  
    4141            'hierarchical'    => false,
    4242            'menu_position'   => null,
    43             'supports'        => array( 'title', 'editor', 'author', 'revisions', 'custom-fields' ),
    44             'show_in_rest'    => true
     43            'supports'        => array( 'title', 'editor', 'author', 'revisions' ),
     44            'show_in_rest'    => true,
     45            'menu_icon'       => 'dashicons-email'
    4546        );
    4647
     
    7778        ) );
    7879
    79         // Same way the post_status works
    80 //      $cmb->add_field( array(
    81 //          'name'    => __( 'Active', 'juvo-mail-editor' ),
    82 //          'desc'    => __( 'Determines if this mail template should be used for the trigger', 'juvo-mail-editor' ),
    83 //          'id'      => self::POST_TYPE_NAME . '_active',
    84 //          'type'    => 'checkbox',
    85 //          'default' => true,
    86 //          'column'  => true,
    87 //      ) );
    88 
    8980        $cmb->add_field( array(
    90             'name'    => __( 'Recipients', 'juvo-mail-editor' ),
    91             'desc'    => __( 'Comma seperated list of mail addresses<br><code>{{CONTEXT}}</code><code>{{ADMIN_EMAIL}}</code>', 'juvo-mail-editor' ),
    92             'id'      => self::POST_TYPE_NAME . '_recipients',
    93             'type'    => 'text',
     81            'name'   => __( 'Recipients', 'juvo-mail-editor' ),
     82            'desc'   => __( 'Comma seperated list of mail addresses<br><code>{{CONTEXT}}</code><code>{{ADMIN_EMAIL}}</code>', 'juvo-mail-editor' ),
     83            'id'     => self::POST_TYPE_NAME . '_recipients',
     84            'type'   => 'text',
     85            'column' => true,
    9486        ) );
    9587
    9688        $cmb->add_field( array(
    97             'name' => __( 'Subject', 'juvo-mail-editor' ),
    98             'desc' => __( 'E-Mail subject', 'juvo-mail-editor' ),
    99             'id'   => self::POST_TYPE_NAME . '_subject',
    100             'type' => 'text',
     89            'name'   => __( 'Subject', 'juvo-mail-editor' ),
     90            'desc'   => __( 'E-Mail subject', 'juvo-mail-editor' ),
     91            'id'     => self::POST_TYPE_NAME . '_subject',
     92            'type'   => 'text',
     93            'column' => true,
    10194        ) );
    10295
  • juvo-mail-editor/trunk/src/Relay.php

    r2578743 r2587510  
    3939     * @param string $trigger
    4040     * @param array $placeholders
     41     * @param mixed $context
    4142     */
    4243    public function __construct( string $trigger, array $placeholders, $context = null ) {
     
    178179        $subject = apply_filters( "juvo_mail_editor_before_subject_placeholder", $subject, $this->trigger, $this->context );
    179180        $subject = Placeholder::replacePlaceholder( $this->placeholders, $subject, $this->context );
    180         $subject = apply_filters( "juvo_mail_editor_after_subject_placeholder", $subject, $this->trigger, $this->context );
    181 
    182         return $subject;
     181
     182        return apply_filters( "juvo_mail_editor_after_subject_placeholder", $subject, $this->trigger, $this->context );
    183183    }
    184184
     
    200200        }
    201201        $recipients = Placeholder::replacePlaceholder( $placeholders, $recipients, $this->context );
    202         $recipients = apply_filters( "juvo_mail_editor_after_recipient_placeholder", $recipients, $this->trigger, $this->context );
    203 
    204         return $recipients;
     202
     203        return apply_filters( "juvo_mail_editor_after_recipient_placeholder", $recipients, $this->trigger, $this->context );
    205204    }
    206205
  • juvo-mail-editor/trunk/vendor/autoload.php

    r2578760 r2587510  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInitd81e8c0431ed8f64bf4ad6a36464f4ef::getLoader();
     7return ComposerAutoloaderInitf63f9541b6a428f4859c2a7f96e49e21::getLoader();
  • juvo-mail-editor/trunk/vendor/composer/autoload_psr4.php

    r2578760 r2587510  
    77
    88return array(
    9     'juvo\\WordPressAdminNotices\\' => array($vendorDir . '/juvo/wp-admin-notices/src'),
    10     'WPTRT\\AdminNotices\\' => array($vendorDir . '/wptrt/admin-notices/src'),
    119    'SzepeViktor\\PHPStan\\WordPress\\' => array($vendorDir . '/szepeviktor/phpstan-wordpress/src'),
    1210    'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'),
  • juvo-mail-editor/trunk/vendor/composer/autoload_real.php

    r2578760 r2587510  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitd81e8c0431ed8f64bf4ad6a36464f4ef
     5class ComposerAutoloaderInitf63f9541b6a428f4859c2a7f96e49e21
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitd81e8c0431ed8f64bf4ad6a36464f4ef', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitf63f9541b6a428f4859c2a7f96e49e21', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitd81e8c0431ed8f64bf4ad6a36464f4ef', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitf63f9541b6a428f4859c2a7f96e49e21', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5454
    5555        if ($useStaticLoader) {
    56             $includeFiles = Composer\Autoload\ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::$files;
     56            $includeFiles = Composer\Autoload\ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::$files;
    5757        } else {
    5858            $includeFiles = require __DIR__ . '/autoload_files.php';
    5959        }
    6060        foreach ($includeFiles as $fileIdentifier => $file) {
    61             composerRequired81e8c0431ed8f64bf4ad6a36464f4ef($fileIdentifier, $file);
     61            composerRequiref63f9541b6a428f4859c2a7f96e49e21($fileIdentifier, $file);
    6262        }
    6363
     
    6666}
    6767
    68 function composerRequired81e8c0431ed8f64bf4ad6a36464f4ef($fileIdentifier, $file)
     68function composerRequiref63f9541b6a428f4859c2a7f96e49e21($fileIdentifier, $file)
    6969{
    7070    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • juvo-mail-editor/trunk/vendor/composer/autoload_static.php

    r2578760 r2587510  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef
     7class ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21
    88{
    99    public static $files = array (
     
    1414
    1515    public static $prefixLengthsPsr4 = array (
    16         'j' =>
    17         array (
    18             'juvo\\WordPressAdminNotices\\' => 27,
    19         ),
    20         'W' =>
    21         array (
    22             'WPTRT\\AdminNotices\\' => 19,
    23         ),
    2416        'S' =>
    2517        array (
     
    4335
    4436    public static $prefixDirsPsr4 = array (
    45         'juvo\\WordPressAdminNotices\\' =>
    46         array (
    47             0 => __DIR__ . '/..' . '/juvo/wp-admin-notices/src',
    48         ),
    49         'WPTRT\\AdminNotices\\' =>
    50         array (
    51             0 => __DIR__ . '/..' . '/wptrt/admin-notices/src',
    52         ),
    5337        'SzepeViktor\\PHPStan\\WordPress\\' =>
    5438        array (
     
    8569    {
    8670        return \Closure::bind(function () use ($loader) {
    87             $loader->prefixLengthsPsr4 = ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::$prefixLengthsPsr4;
    88             $loader->prefixDirsPsr4 = ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::$prefixDirsPsr4;
    89             $loader->classMap = ComposerStaticInitd81e8c0431ed8f64bf4ad6a36464f4ef::$classMap;
     71            $loader->prefixLengthsPsr4 = ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::$prefixLengthsPsr4;
     72            $loader->prefixDirsPsr4 = ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::$prefixDirsPsr4;
     73            $loader->classMap = ComposerStaticInitf63f9541b6a428f4859c2a7f96e49e21::$classMap;
    9074
    9175        }, null, ClassLoader::class);
  • juvo-mail-editor/trunk/vendor/composer/installed.json

    r2578760 r2587510  
    6161            },
    6262            "install-path": "../cmb2/cmb2"
    63         },
    64         {
    65             "name": "juvo/wp-admin-notices",
    66             "version": "v1.0.2",
    67             "version_normalized": "1.0.2.0",
    68             "source": {
    69                 "type": "git",
    70                 "url": "https://github.com/JUVOJustin/wp-admin-notices.git",
    71                 "reference": "53129ec20d2bef9aac6291638d924a44fa7781c4"
    72             },
    73             "dist": {
    74                 "type": "zip",
    75                 "url": "https://api.github.com/repos/JUVOJustin/wp-admin-notices/zipball/53129ec20d2bef9aac6291638d924a44fa7781c4",
    76                 "reference": "53129ec20d2bef9aac6291638d924a44fa7781c4",
    77                 "shasum": ""
    78             },
    79             "require": {
    80                 "php": ">=7.0.0",
    81                 "wptrt/admin-notices": "^1.0"
    82             },
    83             "time": "2020-11-23T09:36:17+00:00",
    84             "type": "library",
    85             "installation-source": "dist",
    86             "autoload": {
    87                 "psr-4": {
    88                     "juvo\\WordPressAdminNotices\\": "src/"
    89                 }
    90             },
    91             "notification-url": "https://packagist.org/downloads/",
    92             "authors": [
    93                 {
    94                     "name": "Justin Vogt",
    95                     "email": "[email protected]",
    96                     "homepage": "https://juvo-design.de"
    97                 }
    98             ],
    99             "description": "Adds a wrapper layer to store notices for wptrt/admin-notices",
    100             "keywords": [
    101                 "notices",
    102                 "wordpress",
    103                 "wptrt"
    104             ],
    105             "support": {
    106                 "issues": "https://github.com/JUVOJustin/wp-admin-notices/issues",
    107                 "source": "https://github.com/JUVOJustin/wp-admin-notices/tree/v1.0.2"
    108             },
    109             "install-path": "../juvo/wp-admin-notices"
    11063        },
    11164        {
     
    573526            ],
    574527            "install-path": "../szepeviktor/phpstan-wordpress"
    575         },
    576         {
    577             "name": "wptrt/admin-notices",
    578             "version": "v1.0.3",
    579             "version_normalized": "1.0.3.0",
    580             "source": {
    581                 "type": "git",
    582                 "url": "https://github.com/WPTT/admin-notices.git",
    583                 "reference": "3904e0dc087b48289056a77eea3d1dab4ef0dde1"
    584             },
    585             "dist": {
    586                 "type": "zip",
    587                 "url": "https://api.github.com/repos/WPTT/admin-notices/zipball/3904e0dc087b48289056a77eea3d1dab4ef0dde1",
    588                 "reference": "3904e0dc087b48289056a77eea3d1dab4ef0dde1",
    589                 "shasum": ""
    590             },
    591             "require": {
    592                 "php": ">=5.6"
    593             },
    594             "time": "2020-02-15T10:34:51+00:00",
    595             "type": "library",
    596             "installation-source": "dist",
    597             "autoload": {
    598                 "psr-4": {
    599                     "WPTRT\\AdminNotices\\": "src/"
    600                 }
    601             },
    602             "notification-url": "https://packagist.org/downloads/",
    603             "license": [
    604                 "GPL-2.0-or-later"
    605             ],
    606             "authors": [
    607                 {
    608                     "name": "WordPress.org Theme Review Team",
    609                     "email": "[email protected]",
    610                     "homepage": "https://make.wordpress.org/themes",
    611                     "role": "Developer"
    612                 }
    613             ],
    614             "description": "A class to create admin-notices for the WordPress dashboard.",
    615             "homepage": "https://github.com/WPTRT/admin-notices",
    616             "keywords": [
    617                 "wordpress"
    618             ],
    619             "support": {
    620                 "issues": "https://github.com/WPTRT/admin-notices/issues",
    621                 "source": "https://github.com/WPTT/admin-notices/tree/v1.0.3"
    622             },
    623             "install-path": "../wptrt/admin-notices"
    624528        }
    625529    ],
  • juvo-mail-editor/trunk/vendor/composer/installed.php

    r2578760 r2587510  
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => 'c80c30d81787c927c36cb4f6ef4e6cc1ead4587a',
     8        'reference' => 'ec729b7b920038180c08b479a32b1c43f785e26c',
    99        'name' => 'juvo/mail-editor',
    1010        'dev' => true,
     
    3232            'install_path' => __DIR__ . '/../../',
    3333            'aliases' => array(),
    34             'reference' => 'c80c30d81787c927c36cb4f6ef4e6cc1ead4587a',
    35             'dev_requirement' => false,
    36         ),
    37         'juvo/wp-admin-notices' => array(
    38             'pretty_version' => 'v1.0.2',
    39             'version' => '1.0.2.0',
    40             'type' => 'library',
    41             'install_path' => __DIR__ . '/../juvo/wp-admin-notices',
    42             'aliases' => array(),
    43             'reference' => '53129ec20d2bef9aac6291638d924a44fa7781c4',
     34            'reference' => 'ec729b7b920038180c08b479a32b1c43f785e26c',
    4435            'dev_requirement' => false,
    4536        ),
     
    116107            'dev_requirement' => true,
    117108        ),
    118         'wptrt/admin-notices' => array(
    119             'pretty_version' => 'v1.0.3',
    120             'version' => '1.0.3.0',
    121             'type' => 'library',
    122             'install_path' => __DIR__ . '/../wptrt/admin-notices',
    123             'aliases' => array(),
    124             'reference' => '3904e0dc087b48289056a77eea3d1dab4ef0dde1',
    125             'dev_requirement' => false,
    126         ),
    127109    ),
    128110);
Note: See TracChangeset for help on using the changeset viewer.