diff --git wordcamp.org/public_html/wp-content/plugins/wc-post-types/inc/widgets.php wordcamp.org/public_html/wp-content/plugins/wc-post-types/inc/widgets.php
index b6100cd0d..16ba7d396 100644
|
|
|
class WCB_Widget_Sponsors extends WP_Widget { |
| 86 | 86 | <?php |
| 87 | 87 | echo $after_widget; |
| 88 | 88 | wp_reset_postdata(); |
| | 89 | |
| | 90 | wp_enqueue_script( |
| | 91 | 'sponsors-widget', |
| | 92 | dirname( plugin_dir_url( __FILE__ ) ) . '/js/sponsors-widget.js', |
| | 93 | array( ), |
| | 94 | filemtime( dirname( plugin_dir_path( __FILE__ ) ) . '/js/sponsors-widget.js' ), |
| | 95 | true |
| | 96 | ); |
| | 97 | wp_localize_script( |
| | 98 | 'sponsors-widget', |
| | 99 | 'sponsorsWidgetPhpObject', |
| | 100 | array( |
| | 101 | 'message' => esc_html__( 'Our sponsors help us to finance most of our WordCamp costs, please allow their logo to appear within your Ad Blocker.', 'wordcamporg' ), |
| | 102 | ) |
| | 103 | ); |
| 89 | 104 | } |
| 90 | 105 | |
| 91 | 106 | function form( $instance ) { |
diff --git wordcamp.org/public_html/wp-content/plugins/wc-post-types/js/sponsors-widget.js wordcamp.org/public_html/wp-content/plugins/wc-post-types/js/sponsors-widget.js
new file mode 100644
index 000000000..be650a814
|
-
|
+
|
|
| | 1 | ( function( sponsorWidget ) { |
| | 2 | window.addEventListener( 'load', function() { |
| | 3 | var loaded = false, undisplayedLogos = [], sponsorLogos = window.document.querySelectorAll( '.sponsor-logo' ); |
| | 4 | |
| | 5 | if ( loaded || ! sponsorWidget || ! sponsorWidget.message ) { |
| | 6 | return; |
| | 7 | } |
| | 8 | |
| | 9 | sponsorLogos.forEach( function( a ) { |
| | 10 | var style = getComputedStyle( a ); |
| | 11 | |
| | 12 | if ( style.display && 'none' === style.display ) { |
| | 13 | undisplayedLogos.push( a ); |
| | 14 | } |
| | 15 | } ); |
| | 16 | |
| | 17 | if ( undisplayedLogos.length && sponsorLogos.length === undisplayedLogos.length ) { |
| | 18 | window.document.querySelectorAll( '.wcb_widget_sponsors' ).forEach( function( widget ) { |
| | 19 | widget.innerHTML = '<p class="message">' + sponsorWidget.message + '</p>' ; |
| | 20 | window.document.querySelector( '.widget p' ).setAttribute( 'style', 'padding: 1em; background: lightYellow; border: solid 1px #E6DB55;' ); |
| | 21 | } ); |
| | 22 | } |
| | 23 | } ); |
| | 24 | } )( window.sponsorsWidgetPhpObject ); |