Plugin Directory

Changeset 3494970


Ignore:
Timestamp:
03/30/2026 09:30:44 PM (2 days ago)
Author:
rstake
Message:

Update to version 3.9.20 — Gutenberg block, bio/lightbox fixes, dark scheme polish, API logging

Location:
bluebook-feed-sync/trunk
Files:
8 added
6 edited

Legend:

Unmodified
Added
Removed
  • bluebook-feed-sync/trunk/assets/css/bbfsync-frontend.css

    r3494499 r3494970  
    20742074    background: #0a0a0a;
    20752075}
    2076 .bbfsync-feed.bbfsync-scheme-dark ~ .bbfsync-lightbox .bbfsync-lightbox-container {
     2076.bbfsync-lightbox.bbfsync-scheme-dark .bbfsync-lightbox-container {
    20772077    background: #121212;
    20782078}
    2079 .bbfsync-feed.bbfsync-scheme-dark ~ .bbfsync-lightbox .bbfsync-lightbox-sidebar {
     2079.bbfsync-lightbox.bbfsync-scheme-dark .bbfsync-lightbox-sidebar {
    20802080    background: #121212; color: #e4e6eb; border-color: #2a2a2a;
    20812081}
    2082 .bbfsync-feed.bbfsync-scheme-dark ~ .bbfsync-lightbox .bbfsync-lightbox-close {
     2082.bbfsync-lightbox.bbfsync-scheme-dark .bbfsync-lightbox-close {
    20832083    color: #e4e6eb;
    20842084}
    2085 .bbfsync-feed.bbfsync-scheme-dark ~ .bbfsync-lightbox .bbfsync-lightbox-nav {
     2085.bbfsync-lightbox.bbfsync-scheme-dark .bbfsync-lightbox-nav {
    20862086    color: #e4e6eb;
    20872087}
    2088 .bbfsync-feed.bbfsync-scheme-dark ~ .bbfsync-lightbox .bbfsync-yt-video-box,
    2089 .bbfsync-feed.bbfsync-scheme-dark ~ .bbfsync-lightbox .bbfsync-fb-video-box {
     2088.bbfsync-lightbox.bbfsync-scheme-dark .bbfsync-yt-video-box,
     2089.bbfsync-lightbox.bbfsync-scheme-dark .bbfsync-fb-video-box {
    20902090    background: #0a0a0a;
    20912091}
     
    20972097    background: #4A8AF0 !important;
    20982098    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
     2099}
     2100.bbfsync-feed.bbfsync-scheme-dark .bbfsync-error {
     2101    background: #2a1215;
     2102    border-color: #5c2b2e;
     2103    color: #f5a3a8;
    20992104}
    21002105
  • bluebook-feed-sync/trunk/assets/js/bbfsync-frontend.js

    r3494499 r3494970  
    4141jQuery(function($) {
    4242    'use strict';
     43
     44    /* ========================
     45       MOVE LIGHTBOXES TO BODY
     46       Ensures they escape any ancestor stacking context
     47       (e.g. page builders using transform/will-change).
     48       ======================== */
     49    $('.bbfsync-lightbox, .bbfsync-video-lightbox').appendTo('body');
    4350
    4451    /* ========================
     
    662669        var $media = $lb.find('.bbfsync-lightbox-media');
    663670
     671        /* Inherit color scheme from the feed that triggered the lightbox */
     672        var scheme = $post.closest('.bbfsync-feed').attr('class').match(/bbfsync-scheme-(\S+)/);
     673        $lb.removeClass('bbfsync-scheme-inherit bbfsync-scheme-light bbfsync-scheme-dark bbfsync-scheme-custom');
     674        if (scheme) { $lb.addClass('bbfsync-scheme-' + scheme[1]); }
     675
    664676        /* Clean up previous */
    665677        $media.find('.bbfsync-lightbox-yt-embed, .bbfsync-lightbox-fb-embed, .bbfsync-lightbox-play, .bbfsync-touch-overlay, .bbfsync-fb-video-box, .bbfsync-yt-video-box, .bbfsync-video-mute-btn, .bbfsync-lb-fs-toggle').remove();
  • bluebook-feed-sync/trunk/bluebook-feed-sync.php

    r3494833 r3494970  
    33 * Plugin Name: BlueBook Feed Sync
    44 * Description: Display a customizable social page feed on your WordPress site with multiple layouts, color schemes, header options, like box, lightbox, and more.
    5  * Version: 3.9.19
     5 * Version: 3.9.20
    66 * Author: SDAweb - Rune Stake Stavdal, Vinjar Romsvik, Christer Andvik
    77 * Author URI: https://sdaweb.no
     
    2020
    2121if ( ! defined( 'BBFSYNC_VERSION' ) ) {
    22     define( 'BBFSYNC_VERSION', '3.9.19' );
     22    define( 'BBFSYNC_VERSION', '3.9.20' );
    2323}
    2424if ( ! defined( 'BBFSYNC_PLUGIN_DIR' ) ) {
     
    5959
    6060    private function __construct() {
    61         $this->maybe_migrate_from_pfb();
    62 
    6361        add_action( 'init', array( $this, 'init' ) );
    6462        add_shortcode( 'bbfsync_feed', array( $this, 'render_shortcode' ) );
     
    7573
    7674    public function init() {
    77         // Translations auto-loaded by WordPress 4.6+ for .org hosted plugins.
     75        $this->register_block();
     76    }
     77
     78    /**
     79     * Register the Gutenberg block.
     80     */
     81    private function register_block() {
     82        $asset_file = BBFSYNC_PLUGIN_DIR . 'blocks/bbfsync-feed/index.asset.php';
     83        $asset      = file_exists( $asset_file ) ? require $asset_file : array( 'dependencies' => array(), 'version' => BBFSYNC_VERSION );
     84
     85        wp_register_script(
     86            'bbfsync-block-editor',
     87            BBFSYNC_PLUGIN_URL . 'blocks/bbfsync-feed/index.js',
     88            $asset['dependencies'],
     89            $asset['version'],
     90            true
     91        );
     92
     93        wp_localize_script( 'bbfsync-block-editor', 'bbfsyncBlockData', array(
     94            'feeds' => BBFSYNC_Settings::get_feeds(),
     95        ) );
     96
     97        wp_set_script_translations( 'bbfsync-block-editor', 'bluebook-feed-sync' );
     98
     99        register_block_type( BBFSYNC_PLUGIN_DIR . 'blocks/bbfsync-feed' );
    78100    }
    79101
     
    95117     * Migrate options from the old pfb_ prefix to bbfsync_.
    96118     */
    97     private function maybe_migrate_from_pfb() {
     119    public function maybe_migrate_from_pfb() {
    98120        if ( get_option( 'bbfsync_pfb_migrated' ) ) {
    99121            return;
     
    224246        $settings['_feed_id'] = $feed_id;
    225247        $renderer = new BBFSYNC_Renderer( $settings );
    226         return $renderer->render();
     248        return $renderer->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in render()
    227249    }
    228250}
    229251
    230252// Activation hook - must be registered BEFORE instantiation
    231 register_activation_hook( __FILE__, array( 'BBFSYNC_Settings', 'set_defaults' ) );
     253register_activation_hook( __FILE__, 'bbfsync_activate' );
     254function bbfsync_activate() {
     255    BBFSYNC_Settings::set_defaults();
     256    BBFSYNC_Plugin::get_instance()->maybe_migrate_from_pfb();
     257}
    232258
    233259// Deactivation hook — clean up scheduled events if any exist
  • bluebook-feed-sync/trunk/includes/class-bbfsync-api.php

    r3487333 r3494970  
    66class BBFSYNC_API {
    77
     8    const GRAPH_API_VERSION = 'v22.0';
     9
    810    private $settings;
    9     private $graph_url = 'https://graph.facebook.com/v22.0/';
     11    private $graph_url;
    1012
    1113    /**
     
    1618
    1719    public function __construct( $settings = null ) {
     20        $this->graph_url = 'https://graph.facebook.com/' . self::GRAPH_API_VERSION . '/';
    1821        if ( $settings ) {
    1922            $this->settings = $settings;
     
    6770        $last_error = '';
    6871        $attempts   = 0;
    69         $max_attempts = 4; // Hard cap on total HTTP requests
    7072
    7173        foreach ( $endpoints as $endpoint ) {
    72             foreach ( $field_sets as $fields ) {
    73                 if ( $attempts >= $max_attempts ) {
    74                     break 2;
    75                 }
    76 
     74            foreach ( $field_sets as $fi => $fields ) {
    7775                $params = array(
    7876                    'fields'       => $fields,
     
    9593                if ( is_wp_error( $response ) ) {
    9694                    $last_error = $response->get_error_message();
     95                    self::log( 'get_posts attempt %d failed (endpoint: %s, field_set: %d): %s', $attempts, $endpoint, $fi + 1, $last_error );
    9796                    continue;
    9897                }
     
    103102                    $last_error = isset( $body['error']['message'] ) ? $body['error']['message'] : __( 'Unknown Facebook API error.', 'bluebook-feed-sync' );
    104103                    $error_code = isset( $body['error']['code'] ) ? intval( $body['error']['code'] ) : 0;
     104
     105                    self::log( 'get_posts attempt %d error %d (endpoint: %s, field_set: %d): %s', $attempts, $error_code, $endpoint, $fi + 1, $last_error );
    105106
    106107                    // Auth errors (expired token, invalid token) — fail immediately
     
    129130                    'next_cursor' => $next_cursor,
    130131                );
     132
     133                if ( $attempts > 1 ) {
     134                    self::log( 'get_posts succeeded on attempt %d (endpoint: %s, field_set: %d)', $attempts, $endpoint, $fi + 1 );
     135                }
    131136
    132137                $cache_duration = max( 900, intval( $this->settings['cache_duration'] ) );
     
    172177        );
    173178
    174         foreach ( $field_sets as $fields ) {
     179        $attempts = 0;
     180        foreach ( $field_sets as $fi => $fields ) {
    175181            $url = $this->graph_url . $page_id . '?' . http_build_query( array(
    176182                'fields'       => $fields,
     
    178184            ) );
    179185
     186            $attempts++;
    180187            $response = wp_remote_get( $url, array(
    181188                'timeout' => 15,
     
    183190
    184191            if ( is_wp_error( $response ) ) {
     192                self::log( 'get_page_info attempt %d failed (field_set: %d): %s', $attempts, $fi + 1, $response->get_error_message() );
    185193                continue;
    186194            }
     
    190198            if ( isset( $body['error'] ) ) {
    191199                $error_code = isset( $body['error']['code'] ) ? intval( $body['error']['code'] ) : 0;
     200                $error_msg  = isset( $body['error']['message'] ) ? $body['error']['message'] : __( 'Authentication error.', 'bluebook-feed-sync' );
     201
     202                self::log( 'get_page_info attempt %d error %d (field_set: %d): %s', $attempts, $error_code, $fi + 1, $error_msg );
    192203
    193204                // Auth errors — fail immediately
    194205                if ( 190 === $error_code ) {
    195                     $msg = isset( $body['error']['message'] ) ? $body['error']['message'] : __( 'Authentication error.', 'bluebook-feed-sync' );
    196                     return new WP_Error( 'bbfsync_api_error', $msg );
     206                    return new WP_Error( 'bbfsync_api_error', $error_msg );
    197207                }
    198208
    199209                continue;
     210            }
     211
     212            if ( $attempts > 1 ) {
     213                self::log( 'get_page_info succeeded on attempt %d (field_set: %d)', $attempts, $fi + 1 );
    200214            }
    201215
     
    247261        return $body;
    248262    }
     263
     264    /**
     265     * Log a debug message when WP_DEBUG_LOG is enabled.
     266     *
     267     * @param string $format  sprintf-style format string.
     268     * @param mixed  ...$args Values to interpolate.
     269     */
     270    private static function log( $format, ...$args ) {
     271        if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
     272            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- intentional debug logging
     273            error_log( '[BlueBook Feed Sync] ' . vsprintf( $format, $args ) );
     274        }
     275    }
    249276}
  • bluebook-feed-sync/trunk/includes/class-bbfsync-renderer.php

    r3494499 r3494970  
    1919
    2020    /**
    21      * Main render method
     21     * Main render method.
     22     *
     23     * @return string Escaped HTML.
    2224     */
    2325    public function render() {
     
    176178
    177179    /**
    178      * Render individual posts (also used by AJAX)
     180     * Render individual posts (also used by AJAX).
     181     *
     182     * @param array $posts Array of post data from the API.
     183     * @return string Escaped HTML.
    179184     */
    180185    public function render_posts( $posts ) {
     
    485490
    486491            /* Optional page name + bio under text header */
     492            $page_info  = $api->get_page_info();
     493            $title_text = ! empty( $s['header_title'] ) ? $s['header_title'] : ( ! is_wp_error( $page_info ) && isset( $page_info['name'] ) ? $page_info['name'] : '' );
     494            $bio_text   = '';
    487495            if ( ! empty( $s['header_show_bio'] ) ) {
    488                 $page_info  = $api->get_page_info();
    489                 $title_text = ! empty( $s['header_title'] ) ? $s['header_title'] : ( ! is_wp_error( $page_info ) && isset( $page_info['name'] ) ? $page_info['name'] : '' );
    490                 $bio_text   = ! empty( $s['header_bio'] ) ? $s['header_bio'] : ( ! is_wp_error( $page_info ) && isset( $page_info['about'] ) ? $page_info['about'] : '' );
    491                 if ( $title_text || $bio_text ) {
    492                     $pad_class = empty( $s['header_text_bg'] ) ? ' bbfsync-header-text-info-flat' : '';
    493                     $html .= '<div class="bbfsync-header-text-info' . $pad_class . '">';
    494                     if ( $title_text ) {
    495                         $html .= '<h3 class="bbfsync-header-text-title">' . esc_html( $title_text ) . '</h3>';
    496                     }
    497                     if ( $bio_text ) {
    498                         $html .= '<p class="bbfsync-header-text-bio">' . esc_html( $bio_text ) . '</p>';
    499                     }
    500                     $html .= '</div>';
    501                 }
     496                $bio_text = ! empty( $s['header_bio'] ) ? $s['header_bio'] : ( ! is_wp_error( $page_info ) && isset( $page_info['about'] ) ? $page_info['about'] : '' );
     497            }
     498            if ( $title_text || $bio_text ) {
     499                $pad_class = empty( $s['header_text_bg'] ) ? ' bbfsync-header-text-info-flat' : '';
     500                $html .= '<div class="bbfsync-header-text-info' . $pad_class . '">';
     501                if ( $title_text ) {
     502                    $html .= '<h3 class="bbfsync-header-text-title">' . esc_html( $title_text ) . '</h3>';
     503                }
     504                if ( $bio_text ) {
     505                    $html .= '<p class="bbfsync-header-text-bio">' . esc_html( $bio_text ) . '</p>';
     506                }
     507                $html .= '</div>';
    502508            }
    503509        } else {
     
    510516                $cover_url  = isset( $page_info['cover']['source'] ) ? $page_info['cover']['source'] : '';
    511517                $title_text = ! empty( $s['header_title'] ) ? $s['header_title'] : ( isset( $page_info['name'] ) ? $page_info['name'] : '' );
    512                 $bio_text   = ! empty( $s['header_bio'] ) ? $s['header_bio'] : ( isset( $page_info['about'] ) ? $page_info['about'] : '' );
    513                 if ( empty( $s['header_show_bio'] ) ) { $bio_text = ''; }
     518                $bio_text   = '';
     519                if ( ! empty( $s['header_show_bio'] ) ) {
     520                    $bio_text = ! empty( $s['header_bio'] ) ? $s['header_bio'] : ( isset( $page_info['about'] ) ? $page_info['about'] : '' );
     521                }
    514522                $fan_count  = isset( $page_info['fan_count'] ) ? $page_info['fan_count'] : 0;
    515523
     
    654662        }
    655663        $init_js .= '    xfbml: true,';
    656         $init_js .= '    version: "v22.0"';
     664        $init_js .= '    version: "' . esc_js( BBFSYNC_API::GRAPH_API_VERSION ) . '"';
    657665        $init_js .= '  });';
    658666        $init_js .= '};';
  • bluebook-feed-sync/trunk/readme.txt

    r3494833 r3494970  
    44Requires at least: 5.8
    55Tested up to: 6.9
    6 Stable tag: 3.9.19
     6Stable tag: 3.9.20
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    125125
    126126== Changelog ==
     127
     128= 3.9.20 =
     129* Fixed: Page name now displays correctly when entered manually in text header mode
     130* Fixed: Bio display logic made consistent across all header styles
     131* Fixed: Lightbox now renders above sticky headers and page builder containers
     132* Improved: Facebook Graph API version centralised as a single constant for easier updates
     133* Improved: API retry logic now logs failures and successes when WP_DEBUG_LOG is enabled
     134* Improved: Dark color scheme error message styling
     135* Changed: Legacy migration now runs only on plugin activation instead of every page load
    127136
    128137= 3.9.18 =
Note: See TracChangeset for help on using the changeset viewer.