Plugin Directory

Changeset 3347823


Ignore:
Timestamp:
08/21/2025 02:12:33 AM (7 months ago)
Author:
peter202202
Message:

Releasing bug fix 3.20.8

Location:
markup-markdown
Files:
1144 added
4 edited

Legend:

Unmodified
Added
Removed
  • markup-markdown/trunk/MarkupMarkdown/Addons/Released/Layout.php

    r3345401 r3347823  
    4242            add_filter( 'addon_markdown2html', array( $this, 'render_lightbox_masonry' ) );
    4343            if ( defined( 'MMD_USE_BLOCKSTYLES' ) && MMD_USE_BLOCKSTYLES ) :
     44                # New theme using Gutenberg blocks need the hooks to be triggered earlier
    4445                add_filter( 'addon_markdown2html', array( $this, 'render_gutenberg_basics' ), 12, 1 );
     46                add_filter( 'gallery_style', array( $this, 'gallery_style_filter' ), 11, 1 );
     47                add_filter( 'wp_get_attachment_link_attributes', array( $this, 'attachment_link_attributes_filter' ), 11, 2 );
    4548            endif;
    4649            add_action( 'wp_enqueue_scripts', array( $this, 'my_plugin_assets' ), 11 );
     
    6972     * @return Void
    7073     */
    71     public function update_config( $my_cnf ) {
     74    final public function update_config( $my_cnf ) {
    7275        $my_cnf[ 'goodvibes' ] = filter_input( INPUT_POST, 'mmd_goodvibes', FILTER_VALIDATE_INT );
    7376        $my_cnf[ 'lightbox' ] = filter_input( INPUT_POST, 'mmd_lightbox', FILTER_VALIDATE_INT );
     
    9093        return $my_cnf;
    9194    }
    92     public function create_const( $my_cnf ) {
     95    final public function create_const( $my_cnf ) {
    9396        $my_cnf[ 'MMD_USE_LIGHTBOX' ] = isset( $my_cnf[ 'lightbox' ] ) ? $my_cnf[ 'lightbox' ] : 0;
    9497        unset( $my_cnf[ 'lightbox' ] );
     
    113116
    114117
    115     public function load_layout_assets( $hook ) {
     118    final public function load_layout_assets( $hook ) {
    116119        if ( 'settings_page_markup-markdown-admin' === $hook ) :
    117120            add_action( 'mmd_tabmenu_options', array( $this, 'add_tabmenu' ) );
     
    129132     * @return Void
    130133     */
    131     public function add_tabmenu() {
     134    final public function add_tabmenu() {
    132135        echo "\t\t\t\t\t\t<li><a href=\"#tab-layout\" class=\"mmd-ico ico-layout\">" . esc_html__( 'Layout', 'markup-markdown' ) . "</a></li>\n";
    133136    }
     
    142145     * @return Void
    143146     */
    144     public function add_tabcontent() {
     147    final public function add_tabcontent() {
    145148        $conf_file = mmd()->conf_blog_prefix . 'conf.php';
    146149        if ( mmd()->exists( $conf_file ) ) :
     
    166169     * @return \HTML_node The updated html code
    167170     */
    168     public function gallery_style_filter( $gallery_style ) {
     171    final public function gallery_style_filter( $gallery_style ) {
    169172        $this->gal++;
    170173        return $gallery_style;
     
    183186     * @return Array The updated link attributes
    184187     */
    185     public function attachment_link_attributes_filter( $attributes, $post_ID ) {
     188    final public function attachment_link_attributes_filter( $attributes, $post_ID ) {
    186189        if ( isset( $attributes[ 'href' ] ) && strpos( $attributes[ 'href' ], 'attachment' ) === FALSE ) :
    187190            $attributes[ 'data-lightbox' ] = 'gallery' . $post_ID . '-' . $this->gal;
     
    206209            wp_enqueue_style( 'lightbox', $plugin_uri . 'assets/lightbox2/css/lightbox.min.css', [], '2.11.4' );
    207210            wp_enqueue_script( 'lightbox', $plugin_uri . 'assets/lightbox2/js/lightbox.min.js', [ 'jquery' ], '2.11.4', true );
     211            # Old themes
    208212            add_filter( 'gallery_style', array( $this, 'gallery_style_filter' ), 11, 1 );
    209213            add_filter( 'wp_get_attachment_link_attributes', array( $this, 'attachment_link_attributes_filter' ), 11, 2 );
     
    259263        wp_enqueue_script( 'masonry' );
    260264        wp_enqueue_script( 'jquery-masonry' );
    261         if ( $lightbox_used > 0 ) :
    262             wp_add_inline_style( 'lightbox', '.lightbox-set { margin: 0 -8px } .grid-sizer, .grid-item { margin: 0 8px 16px 8px; width: calc(50% - 16px) } .grid-item a, .grid-item a img { display: block }' );
    263         endif;
     265        wp_add_inline_style( $lightbox_used > 0 ? 'lightbox' : 'mansory', '.lightbox-set { margin: 0 -8px } .grid-sizer, .grid-item { margin: 0 8px 16px 8px; width: calc(50% - 16px) } .grid-item a, .grid-item a img { display: block }' );
    264266        wp_add_inline_script( 'masonry', 'jQuery( document ).ready(function() { jQuery( \'.grid\' ).each(function() { var $grid = jQuery( this ); $grid.imagesLoaded().progress(function() { $grid.masonry( \'layout\' ); }); }); });' );
    265267        return TRUE;
     
    275277     * @return Void
    276278     */
    277     public function my_plugin_assets() {
     279    final public function my_plugin_assets() {
    278280        $config = mmd()->conf_blog_prefix . 'conf.php';
    279281        if ( ! mmd()->exists( $config ) ) :
     
    298300     * @return Void
    299301     */
    300     public function render_lightbox_masonry( $content = '' ) {
     302    final public function render_lightbox_masonry( $content = '' ) {
    301303        $allowed_medias = "jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG|apng|APNG|webp|WEBP|tiff|TIFF|avif|AVIF";
    302304        $replacers = array(
     
    304306            # Old versions with no *figure* and *figcaption* tags
    305307            [ "#<li><a href=\"(/wp-content/.*?\.(" . $allowed_medias . "))\" title=\"(myset[0-9_]+)\s(.*?)</li>#u", "<div class=\"grid-item\"><a data-lightbox=\"$3\" href=\"$1\" title=\"$4</div>" ],
    306             [ "#<ul>\n<div class=\"grid-item\"><a data-lightbox=\"(.*?)\" href=\"(.*?)\"#u", "<div id=\"$1\" class=\"grid lightbox-set\" data-masonry='{ \"itemSelector\": \".grid-item\", \"columnWidth\": \".grid-sizer\", \"percentPosition\": true }'>\n<div class=\"grid-sizer\"></div>\n<div class=\"grid-item\"><a data-lightbox=\"$1\" href=\"$2\"" ],
     308            [ "#<ul>\n*<div class=\"grid-item\"><a data-lightbox=\"(.*?)\" href=\"(.*?)\"#u", "<div id=\"$1\" class=\"grid lightbox-set\" data-masonry='{ \"itemSelector\": \".grid-item\", \"columnWidth\": \".grid-sizer\", \"percentPosition\": true }'>\n<div class=\"grid-sizer\"></div>\n<div class=\"grid-item\"><a data-lightbox=\"$1\" href=\"$2\"" ],
    307309            # New version with *figure* and *figcaption*
    308             [ "#<li><figure([^>]+)><a href=\"(/wp-content/.*?\.(" . $allowed_medias . "))\" title=\"(myset[0-9_]+)\s(.*?)</li>#u", "<div class=\"grid-item\"><figure$1><a data-lightbox=\"$4\" href=\"$2\" title=\"$5</div>" ],
    309             [ "#<ul>\n<div class=\"grid-item\"><figure id\=\"(.*?)\"([^>]+)><a data-lightbox=\"(.*?)\" href=\"(.*?)\"#u", "<div id=\"$1\" class=\"grid lightbox-set\" data-masonry='{ \"itemSelector\": \".grid-item\", \"columnWidth\": \".grid-sizer\", \"percentPosition\": true }'>\n<div class=\"grid-sizer\"></div>\n<div class=\"grid-item\"><figure id=\"$1\"$2><a data-lightbox=\"$3\" href=\"$4\"" ],
     310            [ "#<li>\n*<figure([^>]+)><a href=\"(/wp-content/.*?\.(" . $allowed_medias . "))\" title=\"(myset[0-9_]+)\s(.*?)\n*</li>#u", "<div class=\"grid-item\"><figure$1><a data-lightbox=\"$4\" href=\"$2\" title=\"$5</div>" ],
     311            [ "#<ul>\n*<div class=\"grid-item\"><figure id\=\"(.*?)\"([^>]+)><a data-lightbox=\"(.*?)\" href=\"(.*?)\"#u", "<div id=\"$1\" class=\"grid lightbox-set\" data-masonry='{ \"itemSelector\": \".grid-item\", \"columnWidth\": \".grid-sizer\", \"percentPosition\": true }'>\n<div class=\"grid-sizer\"></div>\n<div class=\"grid-item\"><figure id=\"$1\"$2><a data-lightbox=\"$3\" href=\"$4\"" ],
    310312            # Safety clean
    311             [ "#</div>\n</ul>#u", "</div>\n</div>" ],
     313            [ "#</div>\n*</ul>#u", "</div>\n</div>" ],
    312314            # Adjust lightbox for single images
    313315            [ "#<a href=\"(/wp-content/.*?\.(" . $allowed_medias . "))\"#u", "<a href=\"$1\" data-lightbox=\"mygallery\"" ],
     
    327329     * @return Void
    328330     */
    329     public function render_gutenberg_basics( $content ) {
     331    final public function render_gutenberg_basics( $content ) {
    330332        # <h2 class="has-text-align-center"> => <h2 class="wp-block-heading has-text-align-center">
    331333        # <h2 id="peter" class="has-text-align-center"> => <h2 d="peter" class="wp-block-heading has-text-align-center">
  • markup-markdown/trunk/MarkupMarkdown/Addons/Released/Media/Image.php

    r3327869 r3347823  
    5454
    5555
    56     public function load_image_block_assets() {
     56    final public function load_image_block_assets() {
    5757        if ( $this->gutenberg > 0 ) : # Already loaded
    5858            return FALSE;
    5959        endif;
    6060        $this->gutenberg = 1;
    61         wp_enqueue_style( 'wp-block-image', '/wp-includes/blocks/image/style.min.css', array(), get_bloginfo( 'version' ) );
    62         wp_enqueue_style( 'wp-block-embed', '/wp-includes/blocks/embed/style.min.css', array(), get_bloginfo( 'version' ) );
     61        $blog_version = get_bloginfo( 'version' );
     62        wp_enqueue_style( 'wp-block-image', '/wp-includes/blocks/image/style.min.css', array(), $blog_version );
     63        wp_enqueue_style( 'wp-block-embed', '/wp-includes/blocks/embed/style.min.css', array(), $blog_version );
     64        wp_enqueue_style( 'wp-block-gallery', '/wp-includes/blocks/gallery/style.min.css', array(), $blog_version );
     65        wp_enqueue_style( 'mmd-block-gallery', mmd()->plugin_uri . '/assets/markup-markdown/css/gallery-compatibility.min.css', array(), $blog_version );
     66        add_filter( 'the_content', array( $this, 'render_gutenberg_html4_galleries' ), 19, 1 );
    6367        return TRUE;
    6468    }
     
    106110     * @return string $content The modified html code
    107111     */
    108     public function render_responsive_images( $content = '' ) {
     112    final public function render_responsive_images( $content = '' ) {
    109113        if ( defined( 'MMD_USE_BLOCKSTYLES' ) && MMD_USE_BLOCKSTYLES ) :
    110114            $this->load_image_block_assets();
     
    127131
    128132
     133    /**
     134     * Format the gallery classnames generated from the shortcode
     135     *
     136     * @access public
     137     * @since 3.20.7
     138     *
     139     * @param String $content The html generated
     140     * @return String $content The modified html code
     141     */
     142    final public function render_gutenberg_html4_galleries( $content = '' ) {
     143        preg_match_all( '#<' . 'div id\=[\"|\']{1}gallery-\d*[\"|\']{1} class\=[\"|\']{1}(gallery galleryid-\d* gallery-columns-\d* gallery-size-[a-z]+)' . '[\"|\']{1}>#', $content, $html4_galleries );
     144        if ( ! isset( $html4_galleries ) || ! isset( $html4_galleries[ 0 ] ) || ! is_array( $html4_galleries[ 0 ] ) ) :
     145            return $content;
     146        endif;
     147        foreach( $html4_galleries[ 0 ] as $idx => $gal_opener ) :
     148                $content = str_replace( $html4_galleries[ 0 ][ $idx ], str_replace( $html4_galleries[ 1 ][ $idx ], $html4_galleries[ 1 ][ $idx ] . ' ' . str_replace( 'gallery', 'wp-block-gallery', $html4_galleries[ 1 ][ $idx ] ) . ' has-nested-images columns-default is-cropped is-layout-flex wp-block-gallery-is-layout-flex', $html4_galleries[ 0 ][ $idx ] ), $content );
     149        endforeach;
     150        $content = preg_replace( '#figure class\=[\"|\']{1}gallery-item[\"|\']{1}#', 'figure class="gallery-item wp-block-image"', $content );
     151        return $content;
     152    }
     153
     154
    129155}
  • markup-markdown/trunk/markup-markdown.php

    r3345401 r3347823  
    66 * Plugin URI:  https://www.markup-markdown.com
    77 * Description: Replaces the Gutenberg Block Editor in favor of pure markdown based markups
    8  * Version:     3.20.7
     8 * Version:     3.20.8
    99 * Author:      Pierre-Henri Lavigne
    1010 * Author URI:  https://www.markup-markdown.com
     
    3434
    3535        protected $settings = array(
    36             'version' => '3.20.7',
     36            'version' => '3.20.8',
    3737            'plugin_uri' => '',
    3838            'plugin_dir' => '',
  • markup-markdown/trunk/readme.txt

    r3345401 r3347823  
    11=== Markup Markdown ===
    22Tags: Editor, Markdown
    3 Stable Tag: 3.20.7
    4 Version: 3.20.7
     3Stable Tag: 3.20.8
     4Version: 3.20.8
    55Requires at least: 4.9
    66Tested up to: 6.8
     
    6969
    7070== Changelog ==
     71
     72= 3.20.8 =
     73
     74Bug fix:
     75- Image media filters patched for themes built for blocks editor
     76
     77All _gallery shortcodes_ `[gallery ...]` with classic or block editor themes should trigger properly the _lightbox_ option if enabled. 
     78Any list of images will be converted to a 2 columns layout if the _masonry_ option is enabled AND the post format is set to _gallery_.
    7179
    7280= 3.20.7 =
Note: See TracChangeset for help on using the changeset viewer.