Plugin Directory

Changeset 3474983


Ignore:
Timestamp:
03/04/2026 10:03:34 PM (3 weeks ago)
Author:
butterflymedia
Message:

Add PHP-only blocks (WordPress 7.0+)

Location:
mdl-shortcodes/trunk
Files:
7 added
2 edited

Legend:

Unmodified
Added
Removed
  • mdl-shortcodes/trunk/mdl-shortcodes.php

    r3433684 r3474983  
    33Plugin Name: Modern Design Library
    44Description: A modern design library toolkit for creating separators, lines, dividers, decorative elements and more.
    5 Version: 1.1.6
     5Version: 1.2.0
    66Author: Ciprian Popescu
    77Author URI: https://getbutterfly.com
     
    3434}
    3535
    36 define( 'MDLUI_VERSION', '1.1.6' );
     36define( 'MDLUI_VERSION', '1.2.0' );
     37
     38/**
     39 * Register plugin settings.
     40 */
     41function mdlui_register_settings() {
     42    register_setting(
     43        'mdlui_settings',
     44        'mdlui_enable_cta_block',
     45        array(
     46            'type'              => 'integer',
     47            'sanitize_callback' => 'absint',
     48            'default'           => 0,
     49        )
     50    );
     51    register_setting(
     52        'mdlui_settings',
     53        'mdlui_enable_author_box_block',
     54        array(
     55            'type'              => 'integer',
     56            'sanitize_callback' => 'absint',
     57            'default'           => 0,
     58        )
     59    );
     60    register_setting(
     61        'mdlui_settings',
     62        'mdlui_enable_advanced_heading_block',
     63        array(
     64            'type'              => 'integer',
     65            'sanitize_callback' => 'absint',
     66            'default'           => 0,
     67        )
     68    );
     69    register_setting(
     70        'mdlui_settings',
     71        'mdlui_enable_marquee_block',
     72        array(
     73            'type'              => 'integer',
     74            'sanitize_callback' => 'absint',
     75            'default'           => 0,
     76        )
     77    );
     78    register_setting(
     79        'mdlui_settings',
     80        'mdlui_enable_advanced_separator_block',
     81        array(
     82            'type'              => 'integer',
     83            'sanitize_callback' => 'absint',
     84            'default'           => 0,
     85        )
     86    );
     87}
     88add_action( 'admin_init', 'mdlui_register_settings' );
     89
     90/**
     91 * Conditionally load optional blocks based on enabled modules.
     92 */
     93if ( get_option( 'mdlui_enable_cta_block', 0 ) ) {
     94    require_once plugin_dir_path( __FILE__ ) . 'blocks/block-cta.php';
     95}
     96if ( get_option( 'mdlui_enable_author_box_block', 0 ) ) {
     97    require_once plugin_dir_path( __FILE__ ) . 'blocks/block-author-box.php';
     98}
     99if ( get_option( 'mdlui_enable_advanced_heading_block', 0 ) ) {
     100    require_once plugin_dir_path( __FILE__ ) . 'blocks/block-advanced-heading.php';
     101}
     102if ( get_option( 'mdlui_enable_marquee_block', 0 ) ) {
     103    require_once plugin_dir_path( __FILE__ ) . 'blocks/block-marquee.php';
     104}
     105if ( get_option( 'mdlui_enable_advanced_separator_block', 0 ) ) {
     106    require_once plugin_dir_path( __FILE__ ) . 'blocks/block-advanced-separator.php';
     107}
    37108
    38109// Hook: Editor assets.
     
    124195        <?php if ( $tab === 'dashboard' ) { ?>
    125196            <h3>Modules</h3>
    126             <ul>
    127                 <li>Coloured Dividers</li>
    128             </ul>
     197            <form method="post" action="options.php">
     198                <?php settings_fields( 'mdlui_settings' ); ?>
     199                <table class="widefat striped" style="max-width:680px">
     200                    <thead>
     201                        <tr>
     202                            <th style="width:40px"><?php esc_html_e( 'Active', 'mdl-shortcodes' ); ?></th>
     203                            <th><?php esc_html_e( 'Module', 'mdl-shortcodes' ); ?></th>
     204                            <th><?php esc_html_e( 'Description', 'mdl-shortcodes' ); ?></th>
     205                        </tr>
     206                    </thead>
     207                    <tbody>
     208                        <tr>
     209                            <td><span class="dashicons dashicons-yes-alt" style="color:#46b450" title="<?php esc_attr_e( 'Always active', 'mdl-shortcodes' ); ?>"></span></td>
     210                            <td><strong><?php esc_html_e( 'Coloured Dividers', 'mdl-shortcodes' ); ?></strong></td>
     211                            <td><?php esc_html_e( 'Coloured horizontal line / divider block with style variants (striped, shade, dotted).', 'mdl-shortcodes' ); ?></td>
     212                        </tr>
     213                        <tr>
     214                            <td>
     215                                <input type="hidden" name="mdlui_enable_cta_block" value="0">
     216                                <input
     217                                    type="checkbox"
     218                                    id="mdlui_enable_cta_block"
     219                                    name="mdlui_enable_cta_block"
     220                                    value="1"
     221                                    <?php checked( 1, get_option( 'mdlui_enable_cta_block', 0 ) ); ?>
     222                                >
     223                            </td>
     224                            <td>
     225                                <label for="mdlui_enable_cta_block">
     226                                    <strong><?php esc_html_e( 'Call to Action Block', 'mdl-shortcodes' ); ?></strong>
     227                                </label>
     228                                &nbsp;<span style="display:inline-block;padding:1px 7px;border-radius:3px;font-size:11px;font-weight:600;background:#f0c33c;color:#3d2b00"><?php esc_html_e( 'Experimental', 'mdl-shortcodes' ); ?></span>
     229                            </td>
     230                            <td><?php esc_html_e( 'PHP-only CTA block using the autoRegister flag. Provides primary, secondary, and dark style variants.', 'mdl-shortcodes' ); ?></td>
     231                        </tr>
     232                        <tr>
     233                            <td>
     234                                <input type="hidden" name="mdlui_enable_author_box_block" value="0">
     235                                <input
     236                                    type="checkbox"
     237                                    id="mdlui_enable_author_box_block"
     238                                    name="mdlui_enable_author_box_block"
     239                                    value="1"
     240                                    <?php checked( 1, get_option( 'mdlui_enable_author_box_block', 0 ) ); ?>
     241                                >
     242                            </td>
     243                            <td>
     244                                <label for="mdlui_enable_author_box_block">
     245                                    <strong><?php esc_html_e( 'Author Box Block', 'mdl-shortcodes' ); ?></strong>
     246                                </label>
     247                                &nbsp;<span style="display:inline-block;padding:1px 7px;border-radius:3px;font-size:11px;font-weight:600;background:#f0c33c;color:#3d2b00"><?php esc_html_e( 'Experimental', 'mdl-shortcodes' ); ?></span>
     248                            </td>
     249                            <td><?php esc_html_e( 'PHP-only author box block using the autoRegister flag. Displays avatar, bio, email, and LinkedIn for any user on the site. Also adds a LinkedIn URL field to user profiles.', 'mdl-shortcodes' ); ?></td>
     250                        </tr>
     251                        <tr>
     252                            <td>
     253                                <input type="hidden" name="mdlui_enable_advanced_heading_block" value="0">
     254                                <input
     255                                    type="checkbox"
     256                                    id="mdlui_enable_advanced_heading_block"
     257                                    name="mdlui_enable_advanced_heading_block"
     258                                    value="1"
     259                                    <?php checked( 1, get_option( 'mdlui_enable_advanced_heading_block', 0 ) ); ?>
     260                                >
     261                            </td>
     262                            <td>
     263                                <label for="mdlui_enable_advanced_heading_block">
     264                                    <strong><?php esc_html_e( 'Advanced Heading Block', 'mdl-shortcodes' ); ?></strong>
     265                                </label>
     266                                &nbsp;<span style="display:inline-block;padding:1px 7px;border-radius:3px;font-size:11px;font-weight:600;background:#f0c33c;color:#3d2b00"><?php esc_html_e( 'Experimental', 'mdl-shortcodes' ); ?></span>
     267                            </td>
     268                            <td><?php esc_html_e( 'PHP-only block with 13 decorative heading styles. Choose the heading level (H1–H6), an accent colour for decorative elements, and an optional tagline.', 'mdl-shortcodes' ); ?></td>
     269                        </tr>
     270                        <tr>
     271                            <td>
     272                                <input type="hidden" name="mdlui_enable_marquee_block" value="0">
     273                                <input
     274                                    type="checkbox"
     275                                    id="mdlui_enable_marquee_block"
     276                                    name="mdlui_enable_marquee_block"
     277                                    value="1"
     278                                    <?php checked( 1, get_option( 'mdlui_enable_marquee_block', 0 ) ); ?>
     279                                >
     280                            </td>
     281                            <td>
     282                                <label for="mdlui_enable_marquee_block">
     283                                    <strong><?php esc_html_e( 'Marquee Block', 'mdl-shortcodes' ); ?></strong>
     284                                </label>
     285                                &nbsp;<span style="display:inline-block;padding:1px 7px;border-radius:3px;font-size:11px;font-weight:600;background:#f0c33c;color:#3d2b00"><?php esc_html_e( 'Experimental', 'mdl-shortcodes' ); ?></span>
     286                            </td>
     287                            <td><?php esc_html_e( 'PHP-only scrolling marquee block. Add multiple blocks for multi-row layouts — each with its own text, colour, and speed. Animation uses requestAnimationFrame; script only loads on pages containing the block.', 'mdl-shortcodes' ); ?></td>
     288                        </tr>
     289                        <tr>
     290                            <td>
     291                                <input type="hidden" name="mdlui_enable_advanced_separator_block" value="0">
     292                                <input
     293                                    type="checkbox"
     294                                    id="mdlui_enable_advanced_separator_block"
     295                                    name="mdlui_enable_advanced_separator_block"
     296                                    value="1"
     297                                    <?php checked( 1, get_option( 'mdlui_enable_advanced_separator_block', 0 ) ); ?>
     298                                >
     299                            </td>
     300                            <td>
     301                                <label for="mdlui_enable_advanced_separator_block">
     302                                    <strong><?php esc_html_e( 'Advanced Separator Block', 'mdl-shortcodes' ); ?></strong>
     303                                </label>
     304                                &nbsp;<span style="display:inline-block;padding:1px 7px;border-radius:3px;font-size:11px;font-weight:600;background:#f0c33c;color:#3d2b00"><?php esc_html_e( 'Experimental', 'mdl-shortcodes' ); ?></span>
     305                            </td>
     306                            <td><?php esc_html_e( 'PHP-only styled horizontal separator with configurable width, height, padding, alignment, and three decorative variants (Striped, Shade, Dotted).', 'mdl-shortcodes' ); ?></td>
     307                        </tr>
     308                    </tbody>
     309                </table>
     310                <?php submit_button( __( 'Save Modules', 'mdl-shortcodes' ) ); ?>
     311            </form>
     312
     313            <hr style="margin:2rem 0">
     314
     315            <h3><?php esc_html_e( 'How to use the blocks', 'mdl-shortcodes' ); ?></h3>
     316            <p><?php esc_html_e( 'After enabling a module above and saving, open any post or page in the block editor. Use the block inserter (the + button in the top toolbar or between blocks) and search for the block by name.', 'mdl-shortcodes' ); ?></p>
     317
     318            <table class="widefat striped" style="max-width:680px">
     319                <thead>
     320                    <tr>
     321                        <th><?php esc_html_e( 'Block', 'mdl-shortcodes' ); ?></th>
     322                        <th><?php esc_html_e( 'Search for', 'mdl-shortcodes' ); ?></th>
     323                        <th><?php esc_html_e( 'Notes', 'mdl-shortcodes' ); ?></th>
     324                    </tr>
     325                </thead>
     326                <tbody>
     327                    <tr>
     328                        <td><strong><?php esc_html_e( 'Call to Action', 'mdl-shortcodes' ); ?></strong></td>
     329                        <td><code>Call to Action</code></td>
     330                        <td><?php esc_html_e( 'Edit heading, subheading, button text/URL, and variant in the sidebar. Use the native Color panel to override background and text colour.', 'mdl-shortcodes' ); ?></td>
     331                    </tr>
     332                    <tr>
     333                        <td><strong><?php esc_html_e( 'Author Box', 'mdl-shortcodes' ); ?></strong></td>
     334                        <td><code>Author Box</code></td>
     335                        <td><?php esc_html_e( 'Select a user from the dropdown. LinkedIn URL is set on the user\'s profile page (Users → Profile → Professional Links).', 'mdl-shortcodes' ); ?></td>
     336                    </tr>
     337                    <tr>
     338                        <td><strong><?php esc_html_e( 'Advanced Heading', 'mdl-shortcodes' ); ?></strong></td>
     339                        <td><code>Advanced Heading</code></td>
     340                        <td><?php esc_html_e( 'Choose a heading level (H1–H6) and one of 13 decorative styles. Set an optional tagline. Use the Color panel to change the accent decoration colour.', 'mdl-shortcodes' ); ?></td>
     341                    </tr>
     342                    <tr>
     343                        <td><strong><?php esc_html_e( 'Marquee', 'mdl-shortcodes' ); ?></strong></td>
     344                        <td><code>Marquee</code></td>
     345                        <td><?php esc_html_e( 'One block = one scrolling row. Add two blocks for a dual-row layout. Set text, speed, and direction in the sidebar. The animation script only loads on pages containing the block.', 'mdl-shortcodes' ); ?></td>
     346                    </tr>
     347                    <tr>
     348                        <td><strong><?php esc_html_e( 'Advanced Separator', 'mdl-shortcodes' ); ?></strong></td>
     349                        <td><code>Advanced Separator</code></td>
     350                        <td><?php esc_html_e( 'Set width, height, padding, and alignment in the sidebar. Pick a style variant (Striped, Shade, Dotted) from the Styles panel. Use Text Color to colour the line.', 'mdl-shortcodes' ); ?></td>
     351                    </tr>
     352                </tbody>
     353            </table>
     354
    129355        <?php } ?>
    130356    </div>
  • mdl-shortcodes/trunk/readme.txt

    r3433684 r3474983  
    33Tags: ui, ux, line, separator, divider
    44Requires at least: 5.4
    5 Requires PHP: 7.0
    6 Tested up to: 6.9
    7 Stable tag: 1.1.6
     5Requires PHP: 8.0
     6Tested up to: 7.0
     7Stable tag: 1.2.0
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl.html
    1010
    11 A Modern Design Library toolkit for creating separators, lines, dividers, decorative elements and more.
     11A Modern Design Library toolkit for blocks: separators, headings, marquees, call-to-action banners, and author boxes.
    1212
    1313== Description ==
    1414
    15 **Note:** The plugin has been adopted and is under development. A lighter version is now available and more releases will be pushed in the near future. Stay tuned and report bugs or code inconsistencies.
     15Modern Design Library is a toolkit of opinionated Gutenberg blocks for WordPress. All optional blocks are registered using PHP-only block registration (`autoRegister`) — no JavaScript build step or Node.js tooling required.
    1616
    17 *Note:** A new version is coming with fully compatible editor blocks, design patterns, a reusable block library and a UI kit.
     17The plugin ships with:
    1818
    19 A Modern Design Library toolkit for creating separators, lines, dividers, decorative elements and more.
     19* **Colored Line** — a fully customisable horizontal separator block with striped, shade, and dotted style variants (classic JS-registered block).
     20* **Advanced Separator** *(experimental)* — a PHP-only separator with configurable width, height, padding, alignment, and three decorative variants.
     21* **Advanced Heading** *(experimental)* — 13 decorative heading styles, heading level selector (H1–H6), optional tagline, and full typography/spacing/border block support controls. Accent decorations automatically follow the text colour.
     22* **Marquee** *(experimental)* — a single infinitely scrolling text row. Stack multiple blocks for multi-row layouts. Speed (Slow/Medium/Fast) and direction (Left/Right) are configurable. Animation script is loaded lazily — only on pages containing the block.
     23* **Call to Action** *(experimental)* — a CTA banner with heading, subheading, button label/URL, three visual variants (Primary/Secondary/Dark), and native colour overrides.
     24* **Author Box** *(experimental)* — displays a user card with avatar, bio, email, and LinkedIn link. User is selected from a dropdown. LinkedIn URL is stored as user meta (set on the user's profile page).
    2025
    21 The library currently includes a colored line block.
     26Optional blocks are enabled from **Settings → Modern Design Library → Modules**.
     27
     28The optional blocks require the **Gutenberg plugin** or **WordPress 7.0+** for the `autoRegister` block support.
    2229
    2330Read more on [getButterfly](https://getbutterfly.com/wordpress-plugins/modern-design-library-ui/).
     31
     32For a deep dive into how the PHP-only blocks work, read [PHP-Only Block Registration in WordPress 7.0](https://getbutterfly.com/php-only-block-registration-in-wordpress/).
    2433
    2534== Installation ==
     
    3039
    3140== Changelog ==
     41
     42= 1.2.0 =
     43* NEW: Advanced Separator block — PHP-only horizontal separator with width, height, padding, alignment, and Striped/Shade/Dotted style variants
     44* NEW: Advanced Heading block — PHP-only heading with 13 decorative styles, H1–H6 level selector, optional tagline, and full typography/spacing/border support; accent decorations inherit text colour via currentColor
     45* NEW: Marquee block — PHP-only infinitely scrolling text row with speed, direction, colour, and typography controls; animation script loaded lazily via render callback
     46* NEW: Call to Action block — PHP-only CTA banner with heading, subheading, button, three visual variants, and native colour overrides
     47* NEW: Author Box block — PHP-only author card with avatar, bio, email, and LinkedIn; user selected from a live dropdown; LinkedIn URL stored as user meta
     48* NEW: Modules admin panel — optional blocks are individually enabled/disabled from Settings → Modern Design Library → Modules
     49* NEW: Consolidated blocks.css — all PHP-only block styles share a single stylesheet loaded once per page regardless of how many MDL blocks are present
    3250
    3351= 1.1.6 =
Note: See TracChangeset for help on using the changeset viewer.