Plugin Directory

Changeset 3446880


Ignore:
Timestamp:
01/26/2026 07:19:17 AM (2 months ago)
Author:
timhodson
Message:

Version 2.0.0 - WordPress 6.x and PHP 8.x compatibility

Major update for modern WordPress and PHP:

  • Added Gutenberg block editor support
  • Added PHP 8.0, 8.1, 8.2, 8.3 compatibility
  • Added WordPress 6.x compatibility
  • Added activation and deactivation hooks
  • Fixed deprecated split(), ngettext(), wp_get_single_post(), utf8_encode()
  • Replaced old PHP Markdown with Parsedown
  • Added $wpdb->prepare() to all dynamic SQL queries
  • Added input sanitization to all shortcode attributes
  • Added sanitization callbacks to all settings
  • Added output escaping throughout
  • Added capability checks for admin pages
  • Removed legacy pre-WordPress 2.6 compatibility code
  • Removed deprecated extract() usage
  • Updated translation POT file
Location:
blog-in-blog/trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • blog-in-blog/trunk

    • Property svn:ignore
      •  

        old new  
        1212.dockerignore
        1313.vscode
         14.claude
  • blog-in-blog/trunk/blog-in-blog.php

    r3446690 r3446880  
    55  Plugin URI: http://informationtakesover.co.uk/blog-in-blog-wordpress-plugin/
    66  Description: Create a blog within a blog using a category, post_type or tag. This plugin basically shows selected posts on a page using shortcodes.
    7   Version: 1.1.1
     7  Version: 2.0.0
    88  Author: Tim Hodson
    99  Author URI: http://timhodson.com
     
    3333
    3434if (!defined('BIB_VERSION'))
    35     define('BIB_VERSION', '1.1.1');
     35    define('BIB_VERSION', '2.0.0');
    3636
    3737if (!defined('BIB_WP_UPLOADS_DIR')) {
     
    4242include_once( WP_PLUGIN_DIR . "/blog-in-blog/options.php" );
    4343
     44// Include Gutenberg block
     45include_once( WP_PLUGIN_DIR . "/blog-in-blog/blocks/blog-in-blog-block.php" );
     46
    4447$plugin_dir = basename(dirname(__FILE__));
     48
     49/**
     50 * Plugin activation hook.
     51 * Sets up default options when the plugin is first activated.
     52 */
     53function blog_in_blog_activate() {
     54    // Initialize default options
     55    bib_init_opts();
     56    // Store the plugin version
     57    update_option('bib_version', BIB_VERSION);
     58}
     59register_activation_hook(__FILE__, 'blog_in_blog_activate');
     60
     61/**
     62 * Plugin deactivation hook.
     63 * Performs cleanup when the plugin is deactivated.
     64 * Note: Options are preserved - they are only deleted on uninstall.
     65 */
     66function blog_in_blog_deactivate() {
     67    // Nothing to do on deactivation - options preserved for reactivation
     68    // Uninstall.php handles full cleanup when plugin is deleted
     69}
     70register_deactivation_hook(__FILE__, 'blog_in_blog_deactivate');
    4571
    4672global $blog_in_blog_opts;
     
    5379    bib_write_debug(__FUNCTION__,  print_r($atts, TRUE));
    5480
    55     if(! is_page()){
     81    // Allow rendering on pages, in REST API (for Gutenberg), and in admin (for previews)
     82    $is_rest_request = defined('REST_REQUEST') && REST_REQUEST;
     83    $is_admin_request = is_admin();
     84    if (!is_page() && !$is_rest_request && !$is_admin_request) {
    5685        return wpautop(wptexturize("<strong>ERROR:</strong> Blog-in-Blog shortcodes can only be used in pages, not posts."));
    5786    }
     
    107136    }
    108137
     138    // Initialize template comment (will be prepended to output, but not during REST requests)
     139    $template_comment = '';
     140
    109141    // set the template if set in shortcode, look in uploads, then plugin dir, then use default.
    110142    if ($template != '') {
     
    121153            }
    122154            // currently no default applied here...
    123         }
     155        }
     156
    124157        if (file_exists(BIB_WP_UPLOADS_DIR . "/" . $template)) {
    125158            $blog_in_blog_opts['bib_post_template'] = BIB_WP_UPLOADS_DIR . "/" . $template;
    126             echo "<!-- BIB: using template: " . esc_html($blog_in_blog_opts['bib_post_template']) . " -->" ;
     159            $template_comment = "<!-- BIB: using template: " . esc_html($blog_in_blog_opts['bib_post_template']) . " -->" ;
    127160            bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']);
    128161
    129162        } else if (file_exists(WP_CONTENT_DIR . '/uploads/' . $template)) {
    130163            $blog_in_blog_opts['bib_post_template'] = WP_CONTENT_DIR . '/uploads/' . $template;
    131             echo "<!-- BIB: using template: " . esc_html($blog_in_blog_opts['bib_post_template']) . " -->" ;
     164            $template_comment = "<!-- BIB: using template: " . esc_html($blog_in_blog_opts['bib_post_template']) . " -->" ;
    132165            bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']);
    133166
    134167        } else if (file_exists(WP_PLUGIN_DIR . "/blog-in-blog/" . $template)) {
    135168            $blog_in_blog_opts['bib_post_template'] = WP_PLUGIN_DIR . "/blog-in-blog/" . $template;
    136             echo "<!-- BIB: using template: " . esc_html($blog_in_blog_opts['bib_post_template']) . " -->" ;
     169            $template_comment = "<!-- BIB: using template: " . esc_html($blog_in_blog_opts['bib_post_template']) . " -->" ;
    137170            bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']);
    138            
     171
    139172        }else{
    140173            $blog_in_blog_opts['bib_post_template'] = ''; // this will force using of bib_html option
    141             //echo "Cannot find template file <b>$template</b> in either <code>".BIB_WP_UPLOADS_DIR."/</code> or <code>".WP_PLUGIN_DIR."/blog-in-blog/</code>" ;
    142174            bib_write_debug(__FUNCTION__, "template not found ".$blog_in_blog_opts['bib_post_template']);
    143175        }
    144176    } else {
    145177        $blog_in_blog_opts['bib_post_template'] = ''; // this will force using bib_html from database.
    146         echo "<!-- BIB: using default template from database -->" ;
     178        $template_comment = "<!-- BIB: using default template from database -->" ;
    147179        bib_write_debug(__FUNCTION__, "defaulting to database template.");
    148180    }
     
    256288
    257289    // return the posts data.
     290    // Include template comment only for non-REST requests (front-end display)
     291    if (!$is_rest_request && !empty($template_comment)) {
     292        $out = $template_comment . $out;
     293    }
    258294    return bib_do_shortcode($out);
    259295}
     
    623659    global $post ;
    624660    global $blog_in_blog_opts ;
     661
     662    // Only apply our custom excerpt_more when Blog in Blog is rendering
     663    if (!isset($blog_in_blog_opts['current_post_id']) || empty($blog_in_blog_opts['current_post_id'])) {
     664        return $more;
     665    }
     666
    625667    bib_write_debug(__FUNCTION__, "Using excerpt more filter");
    626668
     
    670712    // This especially problematic when bib is included in a page which is then included in another page!
    671713    // however big problem is identifying if this is the home page. if it is then we need to do something clever.
    672     bib_write_debug( __FUNCTION__,"Host Page ID: ".$blog_in_blog_opts['host_page']);
     714    $host_page = isset($blog_in_blog_opts['host_page']) ? $blog_in_blog_opts['host_page'] : 'unknown';
     715    bib_write_debug( __FUNCTION__,"Host Page ID: ".$host_page);
    673716
    674717    //if ($wp_query->is_home()){
  • blog-in-blog/trunk/blog-in-blog.pot

    r347739 r3446880  
    1 # Copyright (C) 2010 Blog in Blog
    2 # This file is distributed under the same license as the Blog in Blog package.
     1# Copyright (C) 2026 Tim Hodson
     2# This file is distributed under the same license as the Blog in Blog plugin.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Blog in Blog 1.0.3\n"
    6 "Report-Msgid-Bugs-To: http://wordpress.org/tag/blog-in-blog\n"
    7 "POT-Creation-Date: 2011-02-19 15:42:22+00:00\n"
     5"Project-Id-Version: Blog in Blog 1.1.1\n"
     6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/blog-in-blog\n"
     7"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     8"Language-Team: LANGUAGE <LL@li.org>\n"
    89"MIME-Version: 1.0\n"
    910"Content-Type: text/plain; charset=UTF-8\n"
    1011"Content-Transfer-Encoding: 8bit\n"
    11 "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
    12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    13 "Language-Team: LANGUAGE <LL@li.org>\n"
    14 
    15 #: blog-in-blog.php:395
     12"POT-Creation-Date: 2026-01-25T21:58:38+00:00\n"
     13"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     14"X-Generator: WP-CLI 2.12.0\n"
     15"X-Domain: blog-in-blog\n"
     16
     17#. Plugin Name of the plugin
     18#: blog-in-blog.php
     19msgid "Blog in Blog"
     20msgstr ""
     21
     22#. Plugin URI of the plugin
     23#: blog-in-blog.php
     24msgid "http://informationtakesover.co.uk/blog-in-blog-wordpress-plugin/"
     25msgstr ""
     26
     27#. Description of the plugin
     28#: blog-in-blog.php
     29msgid "Create a blog within a blog using a category, post_type or tag. This plugin basically shows selected posts on a page using shortcodes."
     30msgstr ""
     31
     32#. Author of the plugin
     33#: blog-in-blog.php
     34msgid "Tim Hodson"
     35msgstr ""
     36
     37#. Author URI of the plugin
     38#: blog-in-blog.php
     39msgid "http://timhodson.com"
     40msgstr ""
     41
     42#: blog-in-blog.php:551
    1643msgid "Comments"
    1744msgstr ""
    1845
    19 #: blog-in-blog.php:396
     46#: blog-in-blog.php:552
     47#, php-format
    2048msgid "%d Comment"
    2149msgid_plural "%d Comments"
     
    2351msgstr[1] ""
    2452
    25 #: blog-in-blog.php:401
     53#: blog-in-blog.php:555
    2654msgid "Respond"
    2755msgstr ""
    2856
    29 #: blog-in-blog.php:402
     57#: blog-in-blog.php:556
    3058msgid "Leave a response "
    3159msgstr ""
    3260
    33 #: blog-in-blog.php:407
     61#: blog-in-blog.php:559
    3462msgid "Comments are closed"
    3563msgstr ""
    3664
    37 #: blog-in-blog.php:481
    38 msgid "There is no excerpt because this is a protected post."
    39 msgstr ""
    40 
    41 #: options.php:30
     65#: options.php:32
    4266msgid "Page"
    4367msgstr ""
    4468
    45 #: options.php:36
     69#: options.php:39
    4670msgid "more"
    4771msgstr ""
    4872
    49 #: options.php:125
     73#: options.php:142
    5074msgid "Category(ies) to hide from homepage."
    5175msgstr ""
    5276
    53 #: options.php:128
     77#: options.php:145
    5478msgid "Hide categories from feed?"
    5579msgstr ""
    5680
    57 #: options.php:139
     81#: options.php:156
    5882msgid "Text to show as \"previous page\" link"
    5983msgstr ""
    6084
    61 #: options.php:142
     85#: options.php:159
    6286msgid "Text to show as \"next page\" link"
    6387msgstr ""
    6488
    65 #: options.php:145
    66 msgid ""
    67 "Text to show preceeding page 1. e.g. Post (Post 1, 2, 3) or Page (Page 1, 2, "
    68 "3) etc"
    69 msgstr ""
    70 
    71 #: options.php:148
     89#: options.php:162
     90msgid "Text to show preceeding page 1. e.g. Post (Post 1, 2, 3) or Page (Page 1, 2, 3) etc"
     91msgstr ""
     92
     93#: options.php:165
    7294msgid "The characters to show between page links, e.g. \",\" or \"|\""
    7395msgstr ""
    7496
    75 #: options.php:151
     97#: options.php:168
    7698msgid "Show dots (elipsis ... ) after n pages"
    7799msgstr ""
    78100
    79 #: options.php:154
     101#: options.php:171
    80102msgid "Style for current page e.g. font-weight:bold;"
    81103msgstr ""
    82104
    83 #: options.php:157
     105#: options.php:174
    84106msgid "Style for non current page e.g. color:grey;"
    85107msgstr ""
    86108
    87 #: options.php:179
    88 msgid "The html for the post template."
    89 msgstr ""
    90 
    91 #: options.php:182
    92 msgid ""
    93 "Text for the more link if you use the &lt;!--more--&gt; tag in your posts."
    94 msgstr ""
    95 
    96109#: options.php:185
     110msgid "The html for the default post template."
     111msgstr ""
     112
     113#: options.php:189
     114msgid "User templates"
     115msgstr ""
     116
     117#: options.php:192
     118msgid "Text for the more link if you use the &lt;!--more--&gt; tag in your posts."
     119msgstr ""
     120
     121#: options.php:195
    97122msgid "Size of the author avatar image (pixels)"
    98123msgstr ""
    99124
    100 #: options.php:189
     125#: options.php:199
    101126msgid "Custom Fields"
    102127msgstr ""
    103128
    104 #: options.php:192
    105 msgid ""
    106 "Custom fields that should be formatted as dates in the template tags (uses "
    107 "default wordpress date format). "
    108 msgstr ""
    109 
    110129#: options.php:202
     130msgid "Custom fields that should be formatted as dates in the template tags (uses default wordpress date format). "
     131msgstr ""
     132
     133#: options.php:212
     134msgid "Disable use of javascript on the admin page. This will show all settings in one go."
     135msgstr ""
     136
     137#: options.php:215
    111138msgid "Show some ugly debugging info"
    112139msgstr ""
    113140
    114 #: options.php:216
    115 msgid ""
    116 "Define which categories should be hidden from the home page and optionally "
    117 "exclude them from the feeds. Choose more than one category if required. Only "
    118 "categories with posts will appear for selection."
    119 msgstr ""
    120 
    121 #: options.php:251
     141#: options.php:225
     142msgid "Define which categories should be hidden from the home page and optionally exclude them from the feeds. Choose more than one category if required. Only categories with posts will appear for selection."
     143msgstr ""
     144
     145#: options.php:261
    122146msgid "Show all categories"
    123147msgstr ""
    124148
    125 #: options.php:275
    126 msgid ""
    127 "The pagination menu is shown by default when there are more posts than will "
    128 "fit on a page (as controlled by the 'num' shortcode parameter). These "
    129 "settings will allow you to change the pagination menu styling. See the help "
    130 "for turning pagination on and off"
    131 msgstr ""
    132 
    133 #: options.php:321
    134 msgid ""
    135 "The template is used to format each post displayed by a Blog-in-Blog "
    136 "shortcode. Edit the HTML below to update your current default template (this "
    137 "was copied from your existing default template file on upgade to this "
    138 "version). If you want to have more than one template in use for different "
    139 "instances of the shortcode, you can specify a template file using a "
    140 "shortcode paramater. We always look in `wp-content/uploads/` for your "
    141 "template file first (your template will be safe under uploads/) before "
    142 "looking in `wp-content/plugins/blog-in-blog` (your template will probably be "
    143 "lost when the plugin is upgraded). For more template tags see the help tab."
    144 msgstr ""
    145 
    146 #: options.php:350
    147 msgid ""
    148 "It is possible to display your custom fields in your post using template "
    149 "tags. The template tag will be the name of your custom field surrounded by a "
    150 "percent symbol (%). For example %my_field% . When you use date values in "
    151 "your custom fields, they should be entered using the format YYYY-MM-DD if "
    152 "you require sorting on a custom field in date order to work as expected. You "
    153 "can define which custom fields should be reformatted as a 'pretty' date in "
    154 "your locale specific format. "
    155 msgstr ""
    156 
    157 #: options.php:386
     149#: options.php:325
     150msgid "The template is used to format each post displayed by a Blog-in-Blog shortcode. Edit the HTML below to update your current default template (this was copied from your existing default template file on upgade to this version). If you want to have more than one template in use for different instances of the shortcode, you can specify a template file using a shortcode paramater. We always look in `wp-content/uploads/` for your template file first (your template will be safe under uploads/) before looking in `wp-content/plugins/blog-in-blog` (your template will probably be lost when the plugin is upgraded). For more template tags see the help tab."
     151msgstr ""
     152
     153#: options.php:467
     154msgid "It is possible to display your custom fields in your post using template tags. The template tag will be the name of your custom field surrounded by a percent symbol (%). For example %my_field% . When you use date values in your custom fields, they should be entered using the format YYYY-MM-DD if you require sorting on a custom field in date order to work as expected. You can define which custom fields should be reformatted as a 'pretty' date in your locale specific format. "
     155msgstr ""
     156
     157#: options.php:503
    158158msgid "Select none"
    159159msgstr ""
    160160
    161 #: options.php:400
     161#: options.php:517
    162162msgid "Some extra settings."
    163163msgstr ""
    164164
    165 #: options.php:537
     165#: options.php:546
     166msgid "You do not have sufficient permissions to access this page."
     167msgstr ""
     168
     169#: options.php:697
    166170msgid "Category"
    167171msgstr ""
    168172
    169 #: options.php:538
     173#: options.php:698
    170174msgid "Pagination"
    171175msgstr ""
    172176
    173 #: options.php:539
     177#: options.php:699
    174178msgid "Template"
    175179msgstr ""
    176180
    177 #: options.php:540
    178 msgid "Debug"
    179 msgstr ""
    180 
    181 #: options.php:541
     181#: options.php:700
     182msgid "Misc"
     183msgstr ""
     184
     185#: options.php:701
    182186msgid "Help"
    183187msgstr ""
    184188
    185 #: options.php:552 options.php:560 options.php:568 options.php:577
    186 #: options.php:589
    187 msgid "Save All Changes"
    188 msgstr ""
    189 
    190 #: options.php:594
     189#: options.php:702
     190msgid "Donate"
     191msgstr ""
     192
     193#: options.php:756
     194msgid "Support Blog-in-Blog Development"
     195msgstr ""
     196
     197#: options.php:758
     198msgid "Hi! I'm Tim, the developer of Blog-in-Blog. I created this plugin and maintain it in my free time, alongside my day job and family life."
     199msgstr ""
     200
     201#: options.php:759
     202msgid "If you find this plugin useful for your website, please consider buying me a coffee! Your support helps me dedicate time to:"
     203msgstr ""
     204
     205#: options.php:761
     206msgid "Keeping the plugin updated and compatible with the latest WordPress versions"
     207msgstr ""
     208
     209#: options.php:762
     210msgid "Fixing bugs and improving performance"
     211msgstr ""
     212
     213#: options.php:763
     214msgid "Adding new features based on user feedback"
     215msgstr ""
     216
     217#: options.php:764
     218msgid "Providing support to users"
     219msgstr ""
     220
     221#: options.php:766
     222msgid "Every donation, no matter how small, is greatly appreciated and motivates me to keep improving this plugin. Thank you! 🙏"
     223msgstr ""
     224
     225#: options.php:780
    191226msgid "See full notes at"
    192227msgstr ""
    193 
    194 #. Plugin Name of the plugin/theme
    195 msgid "Blog in Blog"
    196 msgstr ""
    197 
    198 #. Plugin URI of the plugin/theme
    199 msgid "http://informationtakesover.co.uk/blog-in-blog-wordpress-plugin/"
    200 msgstr ""
    201 
    202 #. Description of the plugin/theme
    203 msgid ""
    204 "Create a blog within a blog using a category. This plugin basically shows "
    205 "posts in a category on a page using shortcodes."
    206 msgstr ""
    207 
    208 #. Author of the plugin/theme
    209 msgid "Tim Hodson"
    210 msgstr ""
    211 
    212 #. Author URI of the plugin/theme
    213 msgid "http://timhodson.com"
    214 msgstr ""
  • blog-in-blog/trunk/readme.txt

    r514003 r3446880  
    22Contributors: timhodson
    33Donate link: http://informationtakesover.co.uk/blog-in-blog-wordpress-plugin/
    4 Tags: categories, blog, hide, cms
    5 Requires at least: 3.0
    6 Tested up to: 3.3.1
    7 Stable tag: 1.1.1
     4Tags: categories, blog, hide, cms, shortcode, posts, gutenberg, block
     5Requires at least: 5.0
     6Tested up to: 6.7
     7Stable tag: 2.0.0
     8Requires PHP: 8.0
    89
    910This plugin shows posts from a category on any page you like using shortcodes. Create multiple blogs within a blog using a category. Hode posts in a specific category from your homepage.
     
    193194== Changelog ==
    194195
    195 = 1.1.1 =
     196= 2.0.0 =
     197
     198Major update for modern WordPress and PHP compatibility.
     199
     200* Added: Gutenberg block editor support - use Blog in Blog visually in the block editor
     201* Added: PHP 8.0, 8.1, 8.2, 8.3 compatibility
     202* Added: WordPress 6.x compatibility
     203* Added: Activation and deactivation hooks for proper plugin lifecycle
     204* Fixed: Replaced deprecated `split()` with `explode()`
     205* Fixed: Replaced deprecated `__ngettext()` with `_n()`
     206* Fixed: Replaced deprecated `wp_get_single_post()` with `get_post()`
     207* Fixed: Replaced deprecated `utf8_encode()` with `mb_convert_encoding()`
     208* Fixed: Replaced old PHP Markdown library with modern Parsedown
     209* Security: Added `$wpdb->prepare()` to all dynamic SQL queries
     210* Security: Added proper input sanitization to all shortcode attributes
     211* Security: Added sanitization callbacks to all settings
     212* Security: Added output escaping throughout the plugin
     213* Security: Added capability checks for admin pages
     214* Removed: Legacy pre-WordPress 2.6 compatibility code
     215* Removed: Deprecated `extract()` usage
     216* Updated: Translation POT file
     217
     218= 1.1.1 =
    196219
    197220* Fixed: Read more links for post excerpts are now fixed.
  • blog-in-blog/trunk/uninstall.php

    r347736 r3446880  
    2222
    2323if(defined('ABSPATH') && defined('WP_UNINSTALL_PLUGIN')){
     24    // Pagination options
    2425    delete_option('bib_show_dots_after');
    2526    delete_option('bib_text_delim');
    26     delete_option('bib_text_page' );
    27     delete_option('bib_text_previous' );
    28     delete_option('bib_text_next' );
    29     delete_option('bib_style_selected' );
    30     delete_option('bib_style_not_selected' );
     27    delete_option('bib_text_page');
     28    delete_option('bib_text_previous');
     29    delete_option('bib_text_next');
     30    delete_option('bib_style_selected');
     31    delete_option('bib_style_not_selected');
     32
     33    // Template options
    3134    delete_option('bib_post_template');
     35    delete_option('bib_html');
     36    delete_option('bib_templates');
    3237    delete_option('bib_more_link_text');
    3338    delete_option('bib_avatar_size');
     39
     40    // Category options
    3441    delete_option('bib_hide_category_from_rss');
    3542    delete_option('bib_hide_category');
    36     delete_option('bib_hide_category[]');
     43
     44    // Meta/debug options
    3745    delete_option('bib_meta_keys');
    3846    delete_option('bib_debug');
    39     delete_option('bib_html');
    40     delete_option('bib_single');
     47    delete_option('bib_no_collapse');
     48    delete_option('bib_last_tab');
     49
     50    // Version tracking
     51    delete_option('bib_version');
    4152}
    4253
Note: See TracChangeset for help on using the changeset viewer.