Plugin Directory

Changeset 3153946


Ignore:
Timestamp:
09/18/2024 12:34:12 PM (19 months ago)
Author:
soulseekah
Message:

0.1.1

Location:
mailbob/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • mailbob/trunk/languages/mailbob.pot

    r3153934 r3153946  
    1 # Copyright (C) 2024 Mailbob
    2 # This file is distributed under the same license as the Mailbob plugin.
     1# Copyright (C) 2024 Mailbob.io
     2# This file is distributed under the GPLv2 or later.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Mailbob 0.1.0\n"
     5"Project-Id-Version: Mailbob 0.1.1\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mailbob-wp\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-06-02T18:20:49+00:00\n"
     12"POT-Creation-Date: 2024-09-18T12:27:37+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.8.1\n"
     
    1616
    1717#. Plugin Name of the plugin
    18 #. Author of the plugin
    19 #: mailbob.php:44
    20 #: mailbob.php:45
     18#: mailbob.php:46
     19#: mailbob.php:47
    2120msgid "Mailbob"
    2221msgstr ""
     
    3029msgstr ""
    3130
     31#. Author of the plugin
     32msgid "Mailbob.io"
     33msgstr ""
     34
    3235#. Author URI of the plugin
    3336msgid "https://mailbob.io"
     
    9093msgstr ""
    9194
    92 #: mailbob.php:104
     95#: mailbob.php:147
    9396msgid "Settings"
    9497msgstr ""
    9598
    96 #: mailbob.php:160
     99#: mailbob.php:203
    97100msgid "Security check failed. Please try again."
    98101msgstr ""
    99102
    100 #: mailbob.php:164
     103#: mailbob.php:209
    101104msgid "Please enter a valid email address."
    102105msgstr ""
    103106
    104 #: mailbob.php:179
     107#: mailbob.php:224
    105108msgid "Subscription. Please try again."
    106109msgstr ""
    107110
    108 #: mailbob.php:201
     111#: mailbob.php:246
    109112msgid "You do not have permission to do this."
    110113msgstr ""
  • mailbob/trunk/mailbob.php

    r3153934 r3153946  
    11<?php
    22/**
    3  * Plugin Name:     Mailbob
    4  * Plugin URI:      https://github.com/mailbob-io/mailbob-wp
    5  * Description:     Elevate your personal brand with an email newsletter platform that makes sense. Connect your audience or start from scratch, and send your first campaign in seconds.
    6  * Version:         0.1.0
    7  * Author:          Mailbob
    8  * Author URI:      https://mailbob.io
    9  * Text Domain:     mailbob
    10  * Domain Path:     /languages
    11  * Requires PHP:    7.1
    12  * Requires WP:     5.5.0
    13  * Namespace:       Mailbob
     3 * Plugin Name:       Mailbob
     4 * Plugin URI:        https://github.com/mailbob-io/mailbob-wp
     5 * Description:       Elevate your personal brand with an email newsletter platform that makes sense. Connect your audience or start from scratch, and send your first campaign in seconds.
     6 * Version:           0.1.1
     7 * Author:            Mailbob.io
     8 * Author URI:        https://mailbob.io
     9 * Requires at least: 6.0
     10 * Requires PHP:      7.0
     11 * License:           GPLv2 or later
     12 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     13 * Text Domain:       mailbob
     14 * Domain Path:       /languages
    1415 */
    1516
     
    2122    const __DIR__ = __DIR__;
    2223    const __FILE__ = __FILE__;
     24    const __VERSION__ = '0.1.1';
    2325
    2426    const API_BASE = 'https://api.mailbob.io/';
     
    6466                    'type' => 'array',
    6567                    'sanitize_callback' => function( $input ) {
    66                         return $input; // @todo(major): add some sanitization here
     68                        $input = array_merge(
     69                            get_option( 'mailbob_settings' ),
     70                            $input
     71                        );
     72
     73                        // Defaults.
     74                        $sanitized_input = [
     75                            'floating_widget' => [
     76                                'enable' => false,
     77                                'primaryColor' => '#198754',
     78                                'primaryHoverColor' => '#229861',
     79                            ],
     80                            'user_id' => null,
     81                            'api_key' => null,
     82                        ];
     83
     84                        // Sanitize and validate.
     85                        if ( isset( $input['floating_widget']['enable'] ) ) {
     86                            $sanitized_input['floating_widget']['enable'] = ( bool )$input['floating_widget']['enable'];
     87                        }
     88
     89                        if ( isset( $input['floating_widget']['primaryColor'] ) ) {
     90                            if ( preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{8})$/i', sanitize_text_field( $input['floating_widget']['primaryColor'] ), $matches ) ) {
     91                                $sanitized_input['floating_widget']['primaryColor'] = strtolower($matches[0] );
     92                            }
     93                        }
     94
     95                        if ( isset( $input['floating_widget']['primaryHoverColor'] ) ) {
     96                            if ( preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{8})$/i', sanitize_text_field( $input['floating_widget']['primaryHoverColor'] ), $matches ) ) {
     97                                $sanitized_input['floating_widget']['primaryHoverColor'] = strtolower( $matches[0] );
     98                            }
     99                        }
     100
     101                        if ( isset( $input['user_id'] ) ) {
     102                            $sanitized_input['user_id'] = substr( sanitize_text_field( $input['user_id'] ), 0, 64 );
     103                        }
     104
     105                        if ( isset( $input['api_key'] ) ) {
     106                            $sanitized_input['api_key'] = substr( sanitize_text_field( $input['api_key'] ), 0, 64 );
     107                        }
     108
     109                        return $sanitized_input;
    67110                    },
    68111                ]
     
    85128            $options = get_option( 'mailbob_settings' );
    86129
    87             wp_add_inline_script( 'mailbob-block-subscription-editor-script', 'window.Mailbob = ' . json_encode( [
     130            wp_add_inline_script( 'mailbob-block-subscription-editor-script', 'window.Mailbob = ' . wp_json_encode( [
    88131                'rootUrl' => plugins_url( '/', __FILE__ ),
    89132                'settingsUrl' => admin_url( 'admin.php?page=mailbob' ),
     
    117160         */
    118161        add_action( 'wp_enqueue_scripts', function() {
    119             wp_register_script( 'mailbob-embed-js', 'https://mailbob.io/static/embed.js', [], 1, true );
     162            wp_register_script( 'mailbob-embed-js', 'https://mailbob.io/static/embed.js', [], self::__VERSION__, true );
    120163        } );
    121164
     
    136179            wp_enqueue_script( 'mailbob-embed-js' );
    137180
    138             ?>
    139             <script>
    140                 window.mbConfig = window.mbConfig || [];
    141 
    142                 function mailbob() {
    143                     mbConfig.push(arguments);
    144                 }
    145 
    146                 mailbob('colors', {
    147                     primary: '<?php echo esc_attr( $options['floating_widget']['primaryColor'] ?? '#198754' ); ?>',
    148                     primaryHover: '<?php echo esc_attr( $options['floating_widget']['primaryHoverColor'] ?? '#229861' ); ?>'
    149                 });
    150                 mailbob('uid', '<?php echo esc_attr( $options['user_id'] ); ?>');
    151             </script>
    152             <?php
     181            $mbConfigJsSafe = wp_json_encode( [
     182                'colors' => [
     183                    'primary' => $options['floating_widget']['primaryColor'] ?? '#198754',
     184                    'primaryHover' => $options['floating_widget']['primaryHoverColor'] ?? '#229861',
     185                ],
     186                'uid' => $options['user_id'],
     187            ] );
     188
     189            wp_add_inline_script(
     190                'mailbob-embed-js',
     191                "mbConfig.push(['colors', ($mbConfigJsSafe).colors]);" .
     192                "mbConfig.push(['uid', ($mbConfigJsSafe).uid]);"
     193            );
    153194        } );
    154195
     
    157198         */
    158199        add_action( 'wp_ajax_mailbob_block_subscribe', $callback = static function() {
    159             if ( ! wp_verify_nonce( $_REQUEST['nonce'] ?? '', 'mailbob_nonce' ) ) {
     200            $sanitized_nonce = sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ?? '' ) );
     201
     202            if ( ! wp_verify_nonce( $sanitized_nonce, 'mailbob_nonce' ) ) {
    160203                wp_send_json_error( [ 'message' => esc_html__( 'Security check failed. Please try again.', 'mailbob' ) ], 401 );
    161204            }
    162205
    163             if ( ! is_email( $_REQUEST['email'] ?? '' ) ) {
     206            $sanitized_email = sanitize_text_field( $_REQUEST['email'] ?? '' );
     207
     208            if ( ! is_email( $sanitized_email ) ) {
    164209                wp_send_json_error( [ 'message' => esc_html__( 'Please enter a valid email address.', 'mailbob' ) ], 400 );
    165210            }
     
    172217                        'Authorization' => sprintf( 'Bearer %s:%s', $options['user_id'] ?? '', $options['api_key'] ?? '' ),
    173218                    ),
    174                     'body' => wp_json_encode( [ 'email' => $_REQUEST['email'] ?? '' ] ),
     219                    'body' => wp_json_encode( [ 'email' => $sanitized_email ] ),
    175220                    'data_format' => 'body',
    176221            ] );
     
    202247        }
    203248
    204         switch ( $_REQUEST['action'] ?? '' ):
     249        switch ( sanitize_text_field( $_REQUEST['action'] ?? '' ) ):
    205250            case 'mailbob_connect':
    206                 $nonce = $_REQUEST['_wpnonce_mailbob_connect'] ?? '';
    207                 if ( ! wp_verify_nonce( $nonce, 'mailbob_connect' ) ) {
     251                $sanitized_nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce_mailbob_connect'] ?? '' ) );
     252
     253                if ( ! wp_verify_nonce( $sanitized_nonce, 'mailbob_connect' ) ) {
    208254                    wp_safe_redirect( admin_url( 'admin.php?page=mailbob&e=NONCE' ) );
    209255                    exit;
     
    246292
    247293            case 'mailbob_connect_return':
    248                 $nonce = $_REQUEST['_wpnonce_mailbob_connect_return'] ?? '';
    249                 if ( ! wp_verify_nonce( $nonce, 'mailbob_connect_return' ) ) {
     294                $sanitized_nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce_mailbob_connect_return'] ?? '' ) );
     295
     296                if ( ! wp_verify_nonce( $sanitized_nonce, 'mailbob_connect_return' ) ) {
    250297                    wp_safe_redirect( admin_url( 'admin.php?page=mailbob&e=NONCE' ) );
    251298                    exit;
    252299                }
    253300
    254                 $user_id = $_REQUEST['mailbob_user_id'] ?? null;
    255                 $api_key = $_REQUEST['mailbob_api_key'] ?? null;
    256 
    257                 if ( ! $user_id || ! $api_key ) {
     301                $sanitized_user_id = sanitize_text_field( $_REQUEST['mailbob_user_id'] ?? '' );
     302                $sanitized_api_key = sanitize_text_field( $_REQUEST['mailbob_api_key'] ?? '' );
     303
     304                if ( ! $sanitized_user_id || ! $sanitized_api_key ) {
    258305                    wp_safe_redirect( admin_url( 'admin.php?page=mailbob&e=MISSING' ) );
    259306                    exit;
    260307                }
    261308
    262                 // @todo(major): verify the keys, and not just here
     309                // @todo(major): verify the keys against the API, and not just here
    263310
    264311                $options = get_option( 'mailbob_settings' );
    265312
    266                 $options['user_id'] = $user_id;
    267                 $options['api_key'] = $api_key;
     313                $options['user_id'] = $sanitized_user_id;
     314                $options['api_key'] = $sanitized_api_key;
    268315
    269316                update_option( 'mailbob_settings', $options );
  • mailbob/trunk/readme.txt

    r3153934 r3153946  
    11=== Mailbob ===
     2
     3Stable tag:        0.1.1
    24Contributors:      Kafleg, soulseekah, kovshenin, mailbob
    35Tags:              blocks, editor, gutenberg, gutenberg blocks, Mailbob, subscription, newsletter
    4 Tested up to:      6.1
    5 Stable tag:        0.1.0
    6 Requires PHP: 7.0
    7 License:           GPL-2.0-or-later
     6Requires at least: 6.1
     7Tested up to:      6.6
     8Requires PHP:      7.0
     9License:           GPLv2 or later
    810License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     11
    912This plugin adds Block Editor blocks and a floating subscription widget for Mailbob.io
    1013
     
    1619
    1720The plugin source code is available at https://github.com/mailbob-io/mailbob-wp
     21
     22=== External service disclosure ===
     23
     24This official Mailbob.io integration plugin relies the following external URIs for proper operation:
     25
     26 - https://mailbob.io/connect/ to authenticate your Mailbob.io account, we store your WordPress website domain and your Mailbob.io account
     27 - https://api.mailbob.io/subscribe/ to initiate your users' subscribption to your newsletter (double opt-in is required), the email address and the API key is sent
     28 - https://mailbob.io/static/embed.js to embed the floating subscription widget on any website, be it WordPress or not
     29
     30When requesting these resources the following information will be logged: IP address, browser User-Agent, the time the request was made.
     31
     32API reference: https://mailbob-docs.notion.site/API-Reference-f647d36f0bc14d1cb07ab75dab50aa4d
     33Privacy policy: https://mailbob.io/privacy/
Note: See TracChangeset for help on using the changeset viewer.