Changeset 3153946
- Timestamp:
- 09/18/2024 12:34:12 PM (19 months ago)
- Location:
- mailbob/trunk
- Files:
-
- 3 edited
-
languages/mailbob.pot (modified) (5 diffs)
-
mailbob.php (modified) (10 diffs)
-
readme.txt (modified) (2 diffs)
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. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Mailbob 0.1. 0\n"5 "Project-Id-Version: Mailbob 0.1.1\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mailbob-wp\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2024-0 6-02T18:20:49+00:00\n"12 "POT-Creation-Date: 2024-09-18T12:27:37+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.8.1\n" … … 16 16 17 17 #. 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 21 20 msgid "Mailbob" 22 21 msgstr "" … … 30 29 msgstr "" 31 30 31 #. Author of the plugin 32 msgid "Mailbob.io" 33 msgstr "" 34 32 35 #. Author URI of the plugin 33 36 msgid "https://mailbob.io" … … 90 93 msgstr "" 91 94 92 #: mailbob.php:1 0495 #: mailbob.php:147 93 96 msgid "Settings" 94 97 msgstr "" 95 98 96 #: mailbob.php: 16099 #: mailbob.php:203 97 100 msgid "Security check failed. Please try again." 98 101 msgstr "" 99 102 100 #: mailbob.php: 164103 #: mailbob.php:209 101 104 msgid "Please enter a valid email address." 102 105 msgstr "" 103 106 104 #: mailbob.php: 179107 #: mailbob.php:224 105 108 msgid "Subscription. Please try again." 106 109 msgstr "" 107 110 108 #: mailbob.php:2 01111 #: mailbob.php:246 109 112 msgid "You do not have permission to do this." 110 113 msgstr "" -
mailbob/trunk/mailbob.php
r3153934 r3153946 1 1 <?php 2 2 /** 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 14 15 */ 15 16 … … 21 22 const __DIR__ = __DIR__; 22 23 const __FILE__ = __FILE__; 24 const __VERSION__ = '0.1.1'; 23 25 24 26 const API_BASE = 'https://api.mailbob.io/'; … … 64 66 'type' => 'array', 65 67 '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; 67 110 }, 68 111 ] … … 85 128 $options = get_option( 'mailbob_settings' ); 86 129 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( [ 88 131 'rootUrl' => plugins_url( '/', __FILE__ ), 89 132 'settingsUrl' => admin_url( 'admin.php?page=mailbob' ), … … 117 160 */ 118 161 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 ); 120 163 } ); 121 164 … … 136 179 wp_enqueue_script( 'mailbob-embed-js' ); 137 180 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 ); 153 194 } ); 154 195 … … 157 198 */ 158 199 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' ) ) { 160 203 wp_send_json_error( [ 'message' => esc_html__( 'Security check failed. Please try again.', 'mailbob' ) ], 401 ); 161 204 } 162 205 163 if ( ! is_email( $_REQUEST['email'] ?? '' ) ) { 206 $sanitized_email = sanitize_text_field( $_REQUEST['email'] ?? '' ); 207 208 if ( ! is_email( $sanitized_email ) ) { 164 209 wp_send_json_error( [ 'message' => esc_html__( 'Please enter a valid email address.', 'mailbob' ) ], 400 ); 165 210 } … … 172 217 'Authorization' => sprintf( 'Bearer %s:%s', $options['user_id'] ?? '', $options['api_key'] ?? '' ), 173 218 ), 174 'body' => wp_json_encode( [ 'email' => $ _REQUEST['email'] ?? ''] ),219 'body' => wp_json_encode( [ 'email' => $sanitized_email ] ), 175 220 'data_format' => 'body', 176 221 ] ); … … 202 247 } 203 248 204 switch ( $_REQUEST['action'] ?? ''):249 switch ( sanitize_text_field( $_REQUEST['action'] ?? '' ) ): 205 250 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' ) ) { 208 254 wp_safe_redirect( admin_url( 'admin.php?page=mailbob&e=NONCE' ) ); 209 255 exit; … … 246 292 247 293 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' ) ) { 250 297 wp_safe_redirect( admin_url( 'admin.php?page=mailbob&e=NONCE' ) ); 251 298 exit; 252 299 } 253 300 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 ) { 258 305 wp_safe_redirect( admin_url( 'admin.php?page=mailbob&e=MISSING' ) ); 259 306 exit; 260 307 } 261 308 262 // @todo(major): verify the keys , and not just here309 // @todo(major): verify the keys against the API, and not just here 263 310 264 311 $options = get_option( 'mailbob_settings' ); 265 312 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; 268 315 269 316 update_option( 'mailbob_settings', $options ); -
mailbob/trunk/readme.txt
r3153934 r3153946 1 1 === Mailbob === 2 3 Stable tag: 0.1.1 2 4 Contributors: Kafleg, soulseekah, kovshenin, mailbob 3 5 Tags: blocks, editor, gutenberg, gutenberg blocks, Mailbob, subscription, newsletter 4 Tested up to:6.15 Stable tag: 0.1.0 6 Requires PHP: 7.07 License: GPL -2.0-or-later6 Requires at least: 6.1 7 Tested up to: 6.6 8 Requires PHP: 7.0 9 License: GPLv2 or later 8 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 9 12 This plugin adds Block Editor blocks and a floating subscription widget for Mailbob.io 10 13 … … 16 19 17 20 The plugin source code is available at https://github.com/mailbob-io/mailbob-wp 21 22 === External service disclosure === 23 24 This 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 30 When requesting these resources the following information will be logged: IP address, browser User-Agent, the time the request was made. 31 32 API reference: https://mailbob-docs.notion.site/API-Reference-f647d36f0bc14d1cb07ab75dab50aa4d 33 Privacy policy: https://mailbob.io/privacy/
Note: See TracChangeset
for help on using the changeset viewer.