Changeset 3814646
- Timestamp:
- 11/21/2026 12:18:35 AM (less than one hour ago)
- Location:
- del-embed-for-bandcamp
- Files:
-
- 10 edited
- 1 copied
-
tags/2.0.1 (copied) (copied from del-embed-for-bandcamp/trunk )
-
tags/2.0.1/assets/admin.css (modified) (1 diff)
-
tags/2.0.1/del-embed-for-bandcamp.php (modified) (3 diffs)
-
tags/2.0.1/includes/notice.php (modified) (2 diffs)
-
tags/2.0.1/includes/settings.php (modified) (1 diff)
-
tags/2.0.1/readme.txt (modified) (3 diffs)
-
trunk/assets/admin.css (modified) (1 diff)
-
trunk/del-embed-for-bandcamp.php (modified) (3 diffs)
-
trunk/includes/notice.php (modified) (2 diffs)
-
trunk/includes/settings.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
del-embed-for-bandcamp/tags/2.0.1/assets/admin.css
r3814642 r3814646 891 891 transition: opacity 0.15s; 892 892 } 893 894 /* Review request (2.0.1) */ 895 .bcwp-review { 896 border-left-color: #dba617; 897 } -
del-embed-for-bandcamp/tags/2.0.1/del-embed-for-bandcamp.php
r3814642 r3814646 3 3 * Plugin Name: DEL Embed for Bandcamp 4 4 * Description: Display your Bandcamp releases on WordPress with embedded players and customizable layouts. 5 * Version: 2.0. 05 * Version: 2.0.1 6 6 * Author: David Elfström Lilja 7 7 * Author URI: https://davidlilja.se/ … … 14 14 } 15 15 16 define( 'BCWP_VERSION', '2.0. 0' );16 define( 'BCWP_VERSION', '2.0.1' ); 17 17 define( 'BCWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 18 18 define( 'BCWP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); … … 66 66 require_once BCWP_PLUGIN_DIR . 'includes/stats.php'; 67 67 68 // On a new install or an update: remember when the plugin was installed. 69 if ( $bcwp_prev !== BCWP_VERSION ) { 70 bcwp_note_install( $bcwp_prev ); 71 } 72 68 73 // Stop the automatic import schedule when the plugin is deactivated. 69 74 register_deactivation_hook( __FILE__, function () { -
del-embed-for-bandcamp/tags/2.0.1/includes/notice.php
r3812128 r3814646 1 1 <?php 2 2 /** 3 * Thank-you notice. Shown once on the plugin's own admin pages after an 4 * install or update, until the user closes it. 3 * Notices on the plugin's own admin pages. 4 * 5 * Thank-you notice: shown once after an install or update, until the user 6 * closes it. 7 * 8 * Review request (2.0.1): asks for a review on WordPress.org once the plugin 9 * has been in use for a while. It can be closed for good or postponed, is 10 * never shown together with the thank-you notice, and offers nothing in 11 * return for a review. 5 12 */ 6 13 … … 85 92 <?php 86 93 } 94 95 define( 'BCWP_REVIEW_URL', 'https://wordpress.org/support/plugin/del-embed-for-bandcamp/reviews/#new-post' ); 96 97 add_action( 'admin_post_bcwp_review', 'bcwp_review_action' ); 98 add_action( 'wp_ajax_bcwp_review', 'bcwp_review_action' ); 99 100 /** 101 * Remember when the plugin was installed. Called when the version changes. 102 * 103 * A new install stores the time. A site that already had the plugin before 104 * this was tracked stores 0, which means "has used it for a while". 105 * 106 * @param string $previous_version Version before this one, or '' for a new install. 107 */ 108 function bcwp_note_install( $previous_version ) { 109 if ( false === get_option( 'bcwp_installed' ) ) { 110 add_option( 'bcwp_installed', '' === $previous_version ? time() : 0, '', false ); 111 } 112 } 113 114 /** 115 * Whether the current user should see the review request. 116 */ 117 function bcwp_show_review() { 118 if ( ! current_user_can( 'manage_options' ) || bcwp_show_thanks() ) { 119 return false; 120 } 121 122 // "done" = closed for good, a number = hidden until that time. 123 $state = get_user_meta( get_current_user_id(), 'bcwp_review', true ); 124 if ( 'done' === $state || ( is_numeric( $state ) && time() < (int) $state ) ) { 125 return false; 126 } 127 128 $installed = get_option( 'bcwp_installed' ); 129 if ( false === $installed ) { 130 return false; 131 } 132 $releases = count( bcwp_get_items() ); 133 134 // Sites that had the plugin before 2.0.1: ask as soon as it is in use. 135 if ( 0 === (int) $installed ) { 136 return $releases >= 1; 137 } 138 139 // New installs: after two weeks and a few releases. 140 return (int) $installed <= time() - 14 * DAY_IN_SECONDS && $releases >= 3; 141 } 142 143 /** 144 * Close or postpone the review request for the current user. Works with and 145 * without JavaScript. 146 */ 147 function bcwp_review_action() { 148 check_admin_referer( 'bcwp_review' ); 149 150 $do = isset( $_REQUEST['do'] ) ? sanitize_key( wp_unslash( $_REQUEST['do'] ) ) : ''; 151 152 if ( current_user_can( 'manage_options' ) ) { 153 if ( 'later' === $do ) { 154 update_user_meta( get_current_user_id(), 'bcwp_review', time() + 30 * DAY_IN_SECONDS ); 155 } elseif ( 'done' === $do ) { 156 update_user_meta( get_current_user_id(), 'bcwp_review', 'done' ); 157 } 158 } 159 160 if ( wp_doing_ajax() ) { 161 wp_send_json_success(); 162 } 163 164 wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'admin.php?page=bandcamp-releases' ) ); 165 exit; 166 } 167 168 /** 169 * Print the review request. Called from the shared page header. 170 */ 171 function bcwp_render_review() { 172 if ( ! bcwp_show_review() ) { 173 return; 174 } 175 176 $base = wp_nonce_url( admin_url( 'admin-post.php?action=bcwp_review' ), 'bcwp_review' ); 177 $done_url = add_query_arg( 'do', 'done', $base ); 178 $later_url = add_query_arg( 'do', 'later', $base ); 179 ?> 180 <div class="bcwp-thanks bcwp-review" id="bcwp-review" role="region" aria-label="<?php esc_attr_e( 'Review', 'del-embed-for-bandcamp' ); ?>"> 181 <a href="<?php echo esc_url( $done_url ); ?>" class="bcwp-thanks-close" data-do="done" aria-label="<?php esc_attr_e( 'Close', 'del-embed-for-bandcamp' ); ?>">×</a> 182 <p class="bcwp-thanks-title"><?php esc_html_e( 'Enjoying DEL Embed for Bandcamp?', 'del-embed-for-bandcamp' ); ?> ⭐</p> 183 <p><?php esc_html_e( 'You\'ve been using the plugin for a while now. If it\'s useful to you, a short review on WordPress.org would mean a lot. Reviews help other musicians and labels find the plugin, and they keep me going.', 'del-embed-for-bandcamp' ); ?></p> 184 <p class="bcwp-thanks-actions"> 185 <a href="<?php echo esc_url( BCWP_REVIEW_URL ); ?>" target="_blank" rel="noopener" class="button button-primary bcwp-review-go" data-do="done">⭐ <?php esc_html_e( 'Leave a review', 'del-embed-for-bandcamp' ); ?></a> 186 <a href="<?php echo esc_url( $later_url ); ?>" class="button" data-do="later"><?php esc_html_e( 'Maybe later', 'del-embed-for-bandcamp' ); ?></a> 187 <a href="<?php echo esc_url( $done_url ); ?>" class="bcwp-thanks-dismiss" data-do="done"><?php esc_html_e( 'No thanks', 'del-embed-for-bandcamp' ); ?></a> 188 </p> 189 </div> 190 <script> 191 ( function () { 192 var box = document.getElementById( 'bcwp-review' ); 193 if ( ! box || ! window.fetch ) { 194 return; 195 } 196 box.addEventListener( 'click', function ( e ) { 197 var link = e.target.closest( '[data-do]' ); 198 if ( ! link ) { 199 return; 200 } 201 // The review button opens WordPress.org in a new tab; the others stay here. 202 if ( ! link.classList.contains( 'bcwp-review-go' ) ) { 203 e.preventDefault(); 204 } 205 box.parentNode.removeChild( box ); 206 var body = new URLSearchParams( { 207 action: 'bcwp_review', 208 'do': link.getAttribute( 'data-do' ), 209 _wpnonce: <?php echo wp_json_encode( wp_create_nonce( 'bcwp_review' ) ); ?> 210 } ); 211 fetch( <?php echo wp_json_encode( admin_url( 'admin-ajax.php' ) ); ?>, { method: 'POST', credentials: 'same-origin', body: body, keepalive: true } ); 212 } ); 213 } )(); 214 </script> 215 <?php 216 } -
del-embed-for-bandcamp/tags/2.0.1/includes/settings.php
r3814642 r3814646 395 395 <?php 396 396 bcwp_render_thanks(); 397 bcwp_render_review(); 397 398 } 398 399 -
del-embed-for-bandcamp/tags/2.0.1/readme.txt
r3814642 r3814646 4 4 Requires at least: 5.0 5 5 Tested up to: 7.1 6 Stable tag: 2.0. 06 Stable tag: 2.0.1 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 162 162 == Changelog == 163 163 164 = 2.0.1 = 165 * New: A small note on the plugin's own pages asks for a review once you have used the plugin for a while. You can close it for good or postpone it. 166 164 167 = 2.0.0 = 165 168 Everything new is optional and off until you turn it on. Existing shortcodes and blocks work as before. … … 263 266 == Upgrade Notice == 264 267 268 = 2.0.1 = 269 Adds a small, dismissible review request on the plugin's own pages. No other changes. 270 265 271 = 2.0.0 = 266 272 Big update: vinyl record effect, latest release spotlight, player bar, format labels, filter buttons, shareable links and statistics. All optional. Existing shortcodes work as before. -
del-embed-for-bandcamp/trunk/assets/admin.css
r3814642 r3814646 891 891 transition: opacity 0.15s; 892 892 } 893 894 /* Review request (2.0.1) */ 895 .bcwp-review { 896 border-left-color: #dba617; 897 } -
del-embed-for-bandcamp/trunk/del-embed-for-bandcamp.php
r3814642 r3814646 3 3 * Plugin Name: DEL Embed for Bandcamp 4 4 * Description: Display your Bandcamp releases on WordPress with embedded players and customizable layouts. 5 * Version: 2.0. 05 * Version: 2.0.1 6 6 * Author: David Elfström Lilja 7 7 * Author URI: https://davidlilja.se/ … … 14 14 } 15 15 16 define( 'BCWP_VERSION', '2.0. 0' );16 define( 'BCWP_VERSION', '2.0.1' ); 17 17 define( 'BCWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 18 18 define( 'BCWP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); … … 66 66 require_once BCWP_PLUGIN_DIR . 'includes/stats.php'; 67 67 68 // On a new install or an update: remember when the plugin was installed. 69 if ( $bcwp_prev !== BCWP_VERSION ) { 70 bcwp_note_install( $bcwp_prev ); 71 } 72 68 73 // Stop the automatic import schedule when the plugin is deactivated. 69 74 register_deactivation_hook( __FILE__, function () { -
del-embed-for-bandcamp/trunk/includes/notice.php
r3812128 r3814646 1 1 <?php 2 2 /** 3 * Thank-you notice. Shown once on the plugin's own admin pages after an 4 * install or update, until the user closes it. 3 * Notices on the plugin's own admin pages. 4 * 5 * Thank-you notice: shown once after an install or update, until the user 6 * closes it. 7 * 8 * Review request (2.0.1): asks for a review on WordPress.org once the plugin 9 * has been in use for a while. It can be closed for good or postponed, is 10 * never shown together with the thank-you notice, and offers nothing in 11 * return for a review. 5 12 */ 6 13 … … 85 92 <?php 86 93 } 94 95 define( 'BCWP_REVIEW_URL', 'https://wordpress.org/support/plugin/del-embed-for-bandcamp/reviews/#new-post' ); 96 97 add_action( 'admin_post_bcwp_review', 'bcwp_review_action' ); 98 add_action( 'wp_ajax_bcwp_review', 'bcwp_review_action' ); 99 100 /** 101 * Remember when the plugin was installed. Called when the version changes. 102 * 103 * A new install stores the time. A site that already had the plugin before 104 * this was tracked stores 0, which means "has used it for a while". 105 * 106 * @param string $previous_version Version before this one, or '' for a new install. 107 */ 108 function bcwp_note_install( $previous_version ) { 109 if ( false === get_option( 'bcwp_installed' ) ) { 110 add_option( 'bcwp_installed', '' === $previous_version ? time() : 0, '', false ); 111 } 112 } 113 114 /** 115 * Whether the current user should see the review request. 116 */ 117 function bcwp_show_review() { 118 if ( ! current_user_can( 'manage_options' ) || bcwp_show_thanks() ) { 119 return false; 120 } 121 122 // "done" = closed for good, a number = hidden until that time. 123 $state = get_user_meta( get_current_user_id(), 'bcwp_review', true ); 124 if ( 'done' === $state || ( is_numeric( $state ) && time() < (int) $state ) ) { 125 return false; 126 } 127 128 $installed = get_option( 'bcwp_installed' ); 129 if ( false === $installed ) { 130 return false; 131 } 132 $releases = count( bcwp_get_items() ); 133 134 // Sites that had the plugin before 2.0.1: ask as soon as it is in use. 135 if ( 0 === (int) $installed ) { 136 return $releases >= 1; 137 } 138 139 // New installs: after two weeks and a few releases. 140 return (int) $installed <= time() - 14 * DAY_IN_SECONDS && $releases >= 3; 141 } 142 143 /** 144 * Close or postpone the review request for the current user. Works with and 145 * without JavaScript. 146 */ 147 function bcwp_review_action() { 148 check_admin_referer( 'bcwp_review' ); 149 150 $do = isset( $_REQUEST['do'] ) ? sanitize_key( wp_unslash( $_REQUEST['do'] ) ) : ''; 151 152 if ( current_user_can( 'manage_options' ) ) { 153 if ( 'later' === $do ) { 154 update_user_meta( get_current_user_id(), 'bcwp_review', time() + 30 * DAY_IN_SECONDS ); 155 } elseif ( 'done' === $do ) { 156 update_user_meta( get_current_user_id(), 'bcwp_review', 'done' ); 157 } 158 } 159 160 if ( wp_doing_ajax() ) { 161 wp_send_json_success(); 162 } 163 164 wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'admin.php?page=bandcamp-releases' ) ); 165 exit; 166 } 167 168 /** 169 * Print the review request. Called from the shared page header. 170 */ 171 function bcwp_render_review() { 172 if ( ! bcwp_show_review() ) { 173 return; 174 } 175 176 $base = wp_nonce_url( admin_url( 'admin-post.php?action=bcwp_review' ), 'bcwp_review' ); 177 $done_url = add_query_arg( 'do', 'done', $base ); 178 $later_url = add_query_arg( 'do', 'later', $base ); 179 ?> 180 <div class="bcwp-thanks bcwp-review" id="bcwp-review" role="region" aria-label="<?php esc_attr_e( 'Review', 'del-embed-for-bandcamp' ); ?>"> 181 <a href="<?php echo esc_url( $done_url ); ?>" class="bcwp-thanks-close" data-do="done" aria-label="<?php esc_attr_e( 'Close', 'del-embed-for-bandcamp' ); ?>">×</a> 182 <p class="bcwp-thanks-title"><?php esc_html_e( 'Enjoying DEL Embed for Bandcamp?', 'del-embed-for-bandcamp' ); ?> ⭐</p> 183 <p><?php esc_html_e( 'You\'ve been using the plugin for a while now. If it\'s useful to you, a short review on WordPress.org would mean a lot. Reviews help other musicians and labels find the plugin, and they keep me going.', 'del-embed-for-bandcamp' ); ?></p> 184 <p class="bcwp-thanks-actions"> 185 <a href="<?php echo esc_url( BCWP_REVIEW_URL ); ?>" target="_blank" rel="noopener" class="button button-primary bcwp-review-go" data-do="done">⭐ <?php esc_html_e( 'Leave a review', 'del-embed-for-bandcamp' ); ?></a> 186 <a href="<?php echo esc_url( $later_url ); ?>" class="button" data-do="later"><?php esc_html_e( 'Maybe later', 'del-embed-for-bandcamp' ); ?></a> 187 <a href="<?php echo esc_url( $done_url ); ?>" class="bcwp-thanks-dismiss" data-do="done"><?php esc_html_e( 'No thanks', 'del-embed-for-bandcamp' ); ?></a> 188 </p> 189 </div> 190 <script> 191 ( function () { 192 var box = document.getElementById( 'bcwp-review' ); 193 if ( ! box || ! window.fetch ) { 194 return; 195 } 196 box.addEventListener( 'click', function ( e ) { 197 var link = e.target.closest( '[data-do]' ); 198 if ( ! link ) { 199 return; 200 } 201 // The review button opens WordPress.org in a new tab; the others stay here. 202 if ( ! link.classList.contains( 'bcwp-review-go' ) ) { 203 e.preventDefault(); 204 } 205 box.parentNode.removeChild( box ); 206 var body = new URLSearchParams( { 207 action: 'bcwp_review', 208 'do': link.getAttribute( 'data-do' ), 209 _wpnonce: <?php echo wp_json_encode( wp_create_nonce( 'bcwp_review' ) ); ?> 210 } ); 211 fetch( <?php echo wp_json_encode( admin_url( 'admin-ajax.php' ) ); ?>, { method: 'POST', credentials: 'same-origin', body: body, keepalive: true } ); 212 } ); 213 } )(); 214 </script> 215 <?php 216 } -
del-embed-for-bandcamp/trunk/includes/settings.php
r3814642 r3814646 395 395 <?php 396 396 bcwp_render_thanks(); 397 bcwp_render_review(); 397 398 } 398 399 -
del-embed-for-bandcamp/trunk/readme.txt
r3814642 r3814646 4 4 Requires at least: 5.0 5 5 Tested up to: 7.1 6 Stable tag: 2.0. 06 Stable tag: 2.0.1 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 162 162 == Changelog == 163 163 164 = 2.0.1 = 165 * New: A small note on the plugin's own pages asks for a review once you have used the plugin for a while. You can close it for good or postpone it. 166 164 167 = 2.0.0 = 165 168 Everything new is optional and off until you turn it on. Existing shortcodes and blocks work as before. … … 263 266 == Upgrade Notice == 264 267 268 = 2.0.1 = 269 Adds a small, dismissible review request on the plugin's own pages. No other changes. 270 265 271 = 2.0.0 = 266 272 Big update: vinyl record effect, latest release spotlight, player bar, format labels, filter buttons, shareable links and statistics. All optional. Existing shortcodes work as before.
Note:
See TracChangeset
for help on using the changeset viewer.