Plugin Directory

Changeset 3477447


Ignore:
Timestamp:
03/08/2026 02:36:52 PM (40 hours ago)
Author:
daext
Message:

Committing and tagging 1.24

Location:
ultimate-markdown
Files:
8 added
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ultimate-markdown/tags/1.24/admin/class-daextulma-admin.php

    r3424623 r3477447  
    389389        // Remove the "attachment" post type.
    390390        $available_post_types_a = array_diff( $available_post_types_a, array( 'attachment' ) );
     391
     392        /**
     393         * Enqueue Marked and DOMPurify only for post types with a UI.
     394         *
     395         * These libraries are required by the three block editor sidebar sections and by the three classic editor meta
     396         * boxes.
     397         */
    391398        if ( in_array( $screen->id, $available_post_types_a, true ) ) {
    392 
    393             /**
    394              * When the editor file is loaded (only in the post editor) add the names and IDs of all the documents as
    395              * json data in a property of the window.DAEXTULMA_PARAMETERS object.
    396              *
    397              * These data are used to populate the "Select Document" selector available in the post sidebar.
    398              */
    399             global $wpdb;
    400 
    401             // phpcs:ignore WordPress.DB.DirectDatabaseQuery
    402             $document_a = $wpdb->get_results(
    403                 "SELECT document_id, title FROM {$wpdb->prefix}daextulma_document ORDER BY document_id DESC",
    404                 ARRAY_A
    405             );
    406 
    407             $document_a_alt   = array();
    408             $document_a_alt[] = array(
    409                 'value' => 0,
    410                 'label' => __( 'Not set', 'ultimate-markdown' ),
    411             );
    412             foreach ( $document_a as $value ) {
    413                 $document_a_alt[] = array(
    414                     'value' => intval( $value['document_id'], 10 ),
    415                     'label' => stripslashes( $value['title'] ),
    416                 );
    417             }
    418 
    419             // Store the JavaScript parameters in the window.DAEXTULMA_PARAMETERS object.
    420             $initialization_script  = 'window.DAEXTULMA_PARAMETERS = {';
    421             $initialization_script .= 'documents: ' . wp_json_encode( $document_a_alt ) . ',';
    422             $initialization_script .= 'ajaxUrl: "' . admin_url( 'admin-ajax.php' ) . '",';
    423             $initialization_script .= 'pluginDirectoryUrl: "' . $this->shared->get( 'url' ) . '",';
    424             $initialization_script .= 'editorMarkdownParser: "' . get_option('daextulma_editor_markdown_parser') . '",';
    425             $initialization_script .= 'nonce: "' . wp_create_nonce( 'daextulma' ) . '",';
    426             $initialization_script .= '};';
    427             wp_add_inline_script( $this->shared->get( 'slug' ) . '-editor-js', $initialization_script, 'before' );
    428399
    429400            // Marked.
  • ultimate-markdown/tags/1.24/blocks/build/index.js

    r3335244 r3477447  
    1 !function(){"use strict";var t=window.wp.element;function e(t,e){const{dispatch:a,select:o}=wp.data;wp.data.dispatch("core/block-editor").insertBlocks(t),wp.data.dispatch("core/block-editor").clearSelectedBlock(),wp.data.dispatch("core/edit-post").openGeneralSidebar("edit-post/document"),null!==e.title&&wp.data.dispatch("core/editor").editPost({title:e.title}),null!==e.excerpt&&wp.data.dispatch("core/editor").editPost({excerpt:e.excerpt}),null!==e.categories&&a("core/editor").editPost({categories:e.categories}),null!==e.tags&&a("core/editor").editPost({tags:e.tags}),null!==e.author&&wp.data.dispatch("core/editor").editPost({author:e.author}),null!==e.date&&wp.data.dispatch("core/editor").editPost({date:e.date}),null!==e.status&&wp.data.dispatch("core/editor").editPost({status:e.status})}const{PluginDocumentSettingPanel:a}=wp.editor,{Component:o}=wp.element,{__:__}=wp.i18n,{FormFileUpload:r}=wp.components,{registerPlugin:n}=wp.plugins;n("daextulma-import-document",{icon:!1,render:class extends o{render(){return(0,t.createElement)(a,{name:"daextulma-import-document",title:__("Import Markdown","ultimate-markdown")},(0,t.createElement)(r,{className:"block-library-gallery-add-item-button",onChange:()=>{const t=event.target.files[0],a=new FormData;a.append("action","daextulma_import_document"),a.append("security",window.DAEXTULMA_PARAMETERS.nonce),a.append("uploaded_file",t),fetch(window.DAEXTULMA_PARAMETERS.ajaxUrl,{method:"POST",body:a}).then((function(t){return t.json()})).then((function(t){const a={invalid_date_format:__("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:__("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},o=a[t.data.error]||a.generic_error;if(t.data.error)return void wp.data.dispatch("core/notices").createErrorNotice(o,{type:"snackbar",isDismissible:!0});let r="";r="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.data.content):t.data.html_content,r=DOMPurify.sanitize(r,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:r}),t.data),wp.data.dispatch("core/notices").createErrorNotice(__("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})}))},accept:".md,.markdown,.mdown,.mkdn,.mkd,.mdwn,.mdtxt,.mdtext,.text,.txt",icon:"insert",__next40pxDefaultSize:!0},__("Upload file and import","ultimate-markdown")))}}});const{dispatch:d,select:i}=wp.data,{PluginDocumentSettingPanel:s}=wp.editor,{Component:c}=wp.element,{__:l}=wp.i18n,{Button:m,SelectControl:u}=wp.components,{registerPlugin:p}=wp.plugins;p("daextulma-load-document",{icon:!1,render:class extends c{constructor(t){super(...arguments),this.state={documentIdSelectorValue:""}}render(){const a=i("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_load_document_selector;return(0,t.createElement)(s,{name:"daextulma-load-document",title:l("Load Markdown","ultimate-markdown"),className:"daextulma-load-document-panel"},(0,t.createElement)(u,{label:l("Markdown document","ultimate-markdown"),help:l("Select a Markdown document, then click the submit document button to generate the corresponding blocks.","ultimate-markdown"),value:a,onChange:t=>{d("core/editor").editPost({meta:{_import_markdown_pro_load_document_selector:t}}),this.setState({documentIdSelectorValue:t})},options:window.DAEXTULMA_PARAMETERS.documents,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,t.createElement)(m,{variant:"secondary",className:"editor-post-trash is-destructive",onClick:()=>{const t=i("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_load_document_selector;if(0===parseInt(t,10))return;const a=new FormData;a.append("action","daextulma_load_document"),a.append("security",window.DAEXTULMA_PARAMETERS.nonce),a.append("document_id",t),fetch(window.DAEXTULMA_PARAMETERS.ajaxUrl,{method:"POST",body:a}).then((t=>t.json())).then((t=>{const a={invalid_date_format:l("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:l("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},o=a[t.data.error]||a.generic_error;if(t.data.error)return void wp.data.dispatch("core/notices").createErrorNotice(o,{type:"snackbar",isDismissible:!0});let r="";r="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.data.content):t.data.html_content,r=DOMPurify.sanitize(r,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:r}),t.data),d("core/editor").editPost({meta:{_import_markdown_pro_load_document_selector:"0"}}),this.setState({documentIdSelectorValue:"0"}),wp.data.dispatch("core/notices").createErrorNotice(l("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})}))}},l("Submit document","ultimate-markdown")))}}});const{Button:w,TextareaControl:_}=wp.components,{dispatch:k,select:h}=wp.data,{PluginDocumentSettingPanel:g}=wp.editor,{Component:b}=wp.element,{__:E}=wp.i18n,{registerPlugin:P}=wp.plugins;P("submit-text",{icon:!1,render:class extends b{constructor(t){super(...arguments),this.state={textareaValue:""}}render(){const a=h("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_submit_text_textarea;return(0,t.createElement)(g,{name:"submit-text",title:E("Submit Markdown","ultimate-markdown"),className:"daextulma-submit-text-panel"},(0,t.createElement)(_,{label:E("Markdown text","ultimate-markdown"),help:E("Enter the Markdown text, then click the submit text button to generate the corresponding blocks.","ultimate-markdown"),value:a,onChange:t=>{k("core/editor").editPost({meta:{_import_markdown_pro_submit_text_textarea:t}}),this.setState({textareaValue:t})},__nextHasNoMarginBottom:!0}),(0,t.createElement)(w,{variant:"secondary",className:"editor-post-trash is-destructive",onClick:()=>{wp.ajax.post("daextulma_submit_markdown",{security:window.DAEXTULMA_PARAMETERS.nonce,markdowntext:this.state.textareaValue}).done((t=>{let a="";a="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.content):t.html_content,a=DOMPurify.sanitize(a,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:a}),t),k("core/editor").editPost({meta:{_import_markdown_pro_submit_text_textarea:""}}),this.setState({textareaValue:""}),wp.data.dispatch("core/notices").createErrorNotice(E("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})})).fail((t=>{const e={invalid_date_format:E("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:E("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},a=e[t.error]||e.generic_error;wp.data.dispatch("core/notices").createErrorNotice(a,{type:"snackbar",isDismissible:!0})}))}},E("Submit text","ultimate-markdown")))}}})}();
     1!function(){"use strict";var t=window.wp.element;function e(t,e){const{dispatch:a,select:o}=wp.data;wp.data.dispatch("core/block-editor").insertBlocks(t),wp.data.dispatch("core/block-editor").clearSelectedBlock(),wp.data.dispatch("core/edit-post").openGeneralSidebar("edit-post/document"),null!==e.title&&wp.data.dispatch("core/editor").editPost({title:e.title}),null!==e.excerpt&&wp.data.dispatch("core/editor").editPost({excerpt:e.excerpt}),null!==e.categories&&a("core/editor").editPost({categories:e.categories}),null!==e.tags&&a("core/editor").editPost({tags:e.tags}),null!==e.author&&wp.data.dispatch("core/editor").editPost({author:e.author}),null!==e.date&&wp.data.dispatch("core/editor").editPost({date:e.date}),null!==e.status&&void 0!==e.status&&["publish","draft","pending","private","future"].includes(e.status)&&wp.data.dispatch("core/editor").editPost({status:e.status})}const{PluginDocumentSettingPanel:a}=wp.editor,{Component:o}=wp.element,{__:__}=wp.i18n,{FormFileUpload:r,BaseControl:n}=wp.components,{registerPlugin:d}=wp.plugins;d("daextulma-import-document",{icon:!1,render:class extends o{render(){return(0,t.createElement)(a,{name:"daextulma-import-document",title:__("Import Markdown","ultimate-markdown")},(0,t.createElement)(n,{help:__("Uploads a Markdown file and imports its content into the editor.","ultimate-markdown"),__nextHasNoMarginBottom:!0},(0,t.createElement)(r,{className:"block-library-gallery-add-item-button",onChange:()=>{const t=event.target.files[0],a=new FormData;a.append("action","daextulma_import_document"),a.append("security",window.DAEXTULMA_PARAMETERS.nonce),a.append("uploaded_file",t),fetch(window.DAEXTULMA_PARAMETERS.ajaxUrl,{method:"POST",body:a}).then((function(t){return t.json()})).then((function(t){const a={invalid_date_format:__("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:__("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},o=a[t.data.error]||a.generic_error;if(t.data.error)return void wp.data.dispatch("core/notices").createErrorNotice(o,{type:"snackbar",isDismissible:!0});let r="";r="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.data.content):t.data.html_content,r=DOMPurify.sanitize(r,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:r}),t.data),wp.data.dispatch("core/notices").createErrorNotice(__("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})}))},accept:".md,.markdown,.mdown,.mkdn,.mkd,.mdwn,.mdtxt,.mdtext,.text,.txt",icon:"insert",__next40pxDefaultSize:!0},__("Upload file and import","ultimate-markdown"))))}}});const{dispatch:i,select:s}=wp.data,{PluginDocumentSettingPanel:c}=wp.editor,{Component:l}=wp.element,{__:m}=wp.i18n,{Button:u,SelectControl:p,BaseControl:w}=wp.components,{registerPlugin:_}=wp.plugins;_("daextulma-load-document",{icon:!1,render:class extends l{constructor(t){super(...arguments),this.state={documentIdSelectorValue:""}}render(){const a=s("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_load_document_selector;return(0,t.createElement)(c,{name:"daextulma-load-document",title:m("Load Markdown","ultimate-markdown"),className:"daextulma-load-document-panel"},(0,t.createElement)(w,{help:m("Loads the selected Markdown document into the editor.","ultimate-markdown"),__nextHasNoMarginBottom:!0},(0,t.createElement)(p,{label:m("Document","ultimate-markdown"),value:a,onChange:t=>{i("core/editor").editPost({meta:{_import_markdown_pro_load_document_selector:t}}),this.setState({documentIdSelectorValue:t})},options:window.DAEXTULMA_PARAMETERS.documents,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,t.createElement)(u,{variant:"secondary",className:"editor-post-trash is-destructive",onClick:()=>{const t=s("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_load_document_selector;if(0===parseInt(t,10))return;const a=new FormData;a.append("action","daextulma_load_document"),a.append("security",window.DAEXTULMA_PARAMETERS.nonce),a.append("document_id",t),fetch(window.DAEXTULMA_PARAMETERS.ajaxUrl,{method:"POST",body:a}).then((t=>t.json())).then((t=>{const a={invalid_date_format:m("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:m("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},o=a[t.data.error]||a.generic_error;if(t.data.error)return void wp.data.dispatch("core/notices").createErrorNotice(o,{type:"snackbar",isDismissible:!0});let r="";r="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.data.content):t.data.html_content,r=DOMPurify.sanitize(r,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:r}),t.data),i("core/editor").editPost({meta:{_import_markdown_pro_load_document_selector:"0"}}),this.setState({documentIdSelectorValue:"0"}),wp.data.dispatch("core/notices").createErrorNotice(m("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})}))}},m("Load","ultimate-markdown"))))}}});const{Button:k,TextareaControl:h,BaseControl:g}=wp.components,{dispatch:E,select:M}=wp.data,{PluginDocumentSettingPanel:P}=wp.editor,{Component:b}=wp.element,{__:x}=wp.i18n,{registerPlugin:f}=wp.plugins;f("submit-text",{icon:!1,render:class extends b{constructor(t){super(...arguments),this.state={textareaValue:""}}render(){const a=M("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_submit_text_textarea;return(0,t.createElement)(P,{name:"submit-text",title:x("Insert Markdown","ultimate-markdown"),className:"daextulma-submit-text-panel"},(0,t.createElement)(g,{help:x("Inserts the Markdown above into the editor.","ultimate-markdown"),__nextHasNoMarginBottom:!0},(0,t.createElement)(h,{label:x("Markdown","ultimate-markdown"),value:a,onChange:t=>{E("core/editor").editPost({meta:{_import_markdown_pro_submit_text_textarea:t}}),this.setState({textareaValue:t})},__nextHasNoMarginBottom:!0}),(0,t.createElement)(k,{variant:"secondary",className:"editor-post-trash is-destructive",onClick:()=>{wp.ajax.post("daextulma_submit_markdown",{security:window.DAEXTULMA_PARAMETERS.nonce,markdowntext:this.state.textareaValue}).done((t=>{let a="";a="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.content):t.html_content,a=DOMPurify.sanitize(a,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:a}),t),E("core/editor").editPost({meta:{_import_markdown_pro_submit_text_textarea:""}}),this.setState({textareaValue:""}),wp.data.dispatch("core/notices").createErrorNotice(x("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})})).fail((t=>{const e={invalid_date_format:x("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:x("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},a=e[t.error]||e.generic_error;wp.data.dispatch("core/notices").createErrorNotice(a,{type:"snackbar",isDismissible:!0})}))}},x("Insert","ultimate-markdown"))))}}})}();
  • ultimate-markdown/tags/1.24/blocks/css/editor.css

    r3424623 r3477447  
    1 .daextulma-load-document-panel .components-base-control__help,
    2 .daextulma-submit-text-panel .components-base-control__help{
     1.daextulma-load-document-panel .components-input-control__container,
     2.daextulma-submit-text-panel .components-textarea-control{
    33    margin-bottom: 12px !important;
    44}
  • ultimate-markdown/tags/1.24/blocks/src/import-document/components/Sidebar.js

    r3424623 r3477447  
    88const {Component} = wp.element;
    99const {__} = wp.i18n;
    10 const {FormFileUpload} = wp.components;
     10const {FormFileUpload, BaseControl} = wp.components;
    1111import {updateFields} from '../../utils';
    1212
     
    1919                title={__('Import Markdown', 'ultimate-markdown')}
    2020            >
     21                <BaseControl
     22                    help={__(
     23                        'Uploads a Markdown file and imports its content into the editor.',
     24                        'ultimate-markdown'
     25                    )}
     26                    __nextHasNoMarginBottom={ true }
     27                >
    2128                <FormFileUpload
    2229                    className="block-library-gallery-add-item-button"
     
    112119                    {__('Upload file and import', 'ultimate-markdown')}
    113120                </FormFileUpload>
     121                </BaseControl>
    114122            </PluginDocumentSettingPanel>
    115123        );
  • ultimate-markdown/tags/1.24/blocks/src/init.php

    r3424623 r3477447  
    1818 */
    1919function daextulma_editor_assets() {
     20
     21    // Check capability before loading block editor assets.
     22    if ( ! current_user_can( 'edit_posts' ) ) {
     23        return;
     24    }
    2025
    2126    // assign an instance of Daextulma_Shared.
     
    4146        true // Enqueue the script in the footer.
    4247    );
     48
     49    // Get the documents used to populate the selector in the "Load Document" block editor sidebar section.
     50    $document_a_alt = $shared->get_documents_for_selector();
     51
     52    // Store the JavaScript parameters in the window.DAEXTULMA_PARAMETERS object.
     53    $initialization_script  = 'window.DAEXTULMA_PARAMETERS = {';
     54    $initialization_script .= 'documents: ' . wp_json_encode( $document_a_alt ) . ',';
     55    $initialization_script .= 'ajaxUrl: "' . admin_url( 'admin-ajax.php' ) . '",';
     56    $initialization_script .= 'pluginDirectoryUrl: "' . $shared->get( 'url' ) . '",';
     57    $initialization_script .= 'editorMarkdownParser: "' . get_option('daextulma_editor_markdown_parser') . '",';
     58    $initialization_script .= 'nonce: "' . wp_create_nonce( 'daextulma' ) . '",';
     59    $initialization_script .= '};';
     60    wp_add_inline_script( $shared->get( 'slug' ) . '-editor-js', $initialization_script, 'before' );
     61
    4362}
    4463
  • ultimate-markdown/tags/1.24/blocks/src/load-document/components/Sidebar.js

    r3424623 r3477447  
    99const {Component} = wp.element;
    1010const {__} = wp.i18n;
    11 const {Button, SelectControl} = wp.components;
     11const {Button, SelectControl, BaseControl} = wp.components;
    1212import {updateFields} from '../../utils';
    1313
     
    3636                className="daextulma-load-document-panel"
    3737            >
     38                <BaseControl
     39                    help={__(
     40                        'Loads the selected Markdown document into the editor.',
     41                        'ultimate-markdown'
     42                    )}
     43                    __nextHasNoMarginBottom={ true }
     44                >
    3845                <SelectControl
    39                     label={__('Markdown document', 'ultimate-markdown')}
    40                     help={__(
    41                         'Select a Markdown document, then click the submit document button to generate the corresponding blocks.',
    42                         'ultimate-markdown')}
     46                    label={__('Document', 'ultimate-markdown')}
    4347                    value={documentIdSelectorMeta}
    4448                    onChange={(document_id) => {
     
    7276                        const document_id = meta['_import_markdown_pro_load_document_selector'];
    7377
    74                         // Do not proceed if the selected option is "Not set".
     78                        // Do not proceed if the selected option is "Select a document…".
    7579                        if (parseInt(document_id, 10) === 0) {
    7680                            return;
     
    143147                            updateFields(blocks, response.data);
    144148
    145                             // Reset the document selector to "Not set" (0) in meta.
     149                            // Reset the document selector to "Select a document…" (0) in meta.
    146150                            dispatch('core/editor').editPost({
    147151                                meta: {
     
    150154                            });
    151155
    152                             // Reset the document selector to "Not set" (0) in local state.
     156                            // Reset the document selector to "Select a document…" (0) in local state.
    153157                            this.setState({
    154158                                documentIdSelectorValue: '0',
     
    166170
    167171                    }}
    168                 >{__('Submit document', 'ultimate-markdown')}</Button>
    169 
     172                >{__('Load', 'ultimate-markdown')}</Button>
     173                </BaseControl>
    170174            </PluginDocumentSettingPanel>
    171175        );
  • ultimate-markdown/tags/1.24/blocks/src/submit-text/components/Sidebar.js

    r3424623 r3477447  
    55 */
    66
    7 const {Button, TextareaControl} = wp.components;
     7const {Button, TextareaControl, BaseControl} = wp.components;
    88const {dispatch, select} = wp.data;
    99const {PluginDocumentSettingPanel} = wp.editor;
     
    3333            <PluginDocumentSettingPanel
    3434                name="submit-text"
    35                 title={__('Submit Markdown', 'ultimate-markdown')}
     35                title={__('Insert Markdown', 'ultimate-markdown')}
    3636                className="daextulma-submit-text-panel"
    3737            >
    38 
    39 
     38                <BaseControl
     39                    help={__(
     40                        'Inserts the Markdown above into the editor.',
     41                        'ultimate-markdown'
     42                    )}
     43                    __nextHasNoMarginBottom={ true }
     44                >
    4045                <TextareaControl
    41                     label={__('Markdown text', 'ultimate-markdown')}
    42                     help={__(
    43                         'Enter the Markdown text, then click the submit text button to generate the corresponding blocks.',
    44                         'ultimate-markdown')}
     46                    label={__('Markdown', 'ultimate-markdown')}
    4547                    value={markdownText}
    4648                    onChange={(value) => {
     
    123125
    124126                    }}
    125                 >{__('Submit text', 'ultimate-markdown')}</Button>
    126 
     127                >{__('Insert', 'ultimate-markdown')}</Button>
     128                </BaseControl>
    127129            </PluginDocumentSettingPanel>
    128130        );
  • ultimate-markdown/tags/1.24/blocks/src/utils.js

    r3424623 r3477447  
    9494    }
    9595
    96     // Update the status.
    97     if (data['status'] !== null) {
     96    /**
     97     *
     98     * Update the post status.
     99     *
     100     * WordPress internally supports several statuses (publish, draft, pending,
     101     * future, private, trash, auto-draft, inherit, etc.). However, only a limited subset of these statuses can be
     102     * safely using the provided front matter value.
     103     *
     104     *  - publish  → Published
     105     *  - draft    → Draft
     106     *  - pending  → Pending Review
     107     *  - private  → Private
     108     *  - future   → Scheduled
     109     *
     110     * Other statuses such as "trash", "auto-draft", or "inherit" are controlled by other mechanisms (e.g. trash
     111     * actions, internal WordPress logic) and should not be set.
     112     *
     113     * Note that the 'future' status (scheduled) doesn't actually need a publishing date, because if the date is not
     114     * set in the future, WordPress will automatically change the status to 'publish' when the post is saved. If instead
     115     * a future date is set, WordPress will keep the 'future' status and publish the post at the scheduled date.
     116     *
     117     * @type {string[]}
     118     */
     119    const allowedStatuses = ['publish', 'draft', 'pending', 'private', 'future'];
     120    if (data['status'] !== null && data.status !== undefined && allowedStatuses.includes(data.status)) {
    98121        wp.data.dispatch('core/editor').editPost({status: data['status']});
    99122    }
  • ultimate-markdown/tags/1.24/init.php

    r3424623 r3477447  
    33 * Plugin Name: Ultimate Markdown
    44 * Description: A set of tools that helps you work with the Markdown language.
    5  * Version: 1.23
     5 * Version: 1.24
    66 * Author: DAEXT
    77 * Author URI: https://daext.com
     
    4848    }
    4949
     50    // Load meta boxes.
     51    require_once plugin_dir_path( __FILE__ ) . 'admin/inc/class-daextulma-meta-boxes.php';
     52    add_action( 'plugins_loaded', array( 'Daextulma_Meta_Boxes', 'get_instance' ) );
     53
    5054    // Activate the plugin using only the class static methods.
    5155    register_activation_hook( __FILE__, array( 'Daextulma_Admin', 'ac_activate' ) );
  • ultimate-markdown/tags/1.24/readme.txt

    r3424623 r3477447  
    44Donate link: https://daext.com
    55Requires at least: 5.0
    6 Tested up to: 6.9
     6Tested up to: 6.9.1
    77Requires PHP: 5.3
    8 Stable tag: 1.23
     8Stable tag: 1.24
    99License: GPLv3
    1010
     
    1616Specifically, after installing the plugin, you will be able to:
    1717
    18 * Create posts with perfectly formatted blocks from existing Markdown files or Markdown documents created with the plugin.
    19 * Instantly generate blocks from Markdown text.
    20 * Create and manage an unlimited number of Markdown documents in a dedicated plugin menu.
    21 * Import Markdown file in WordPress.
     18* Create posts from Markdown files or Markdown documents created with the plugin.
     19* Convert Markdown text to blocks directly in the post editor.
     20* Create and manage Markdown documents in a dedicated plugin menu.
     21* Import Markdown files into WordPress.
    2222* Create archives of Markdown files from the Markdown documents created with the plugin.
    2323
    24 Please note that this plugin requires the use of the default [WordPress Blocks Editor](https://wordpress.org/support/article/blocks/). With third-party visual editors or with the [Classic Editor](https://wordpress.org/plugins/classic-editor/), you will not be able to use most of the plugin functionalities.
     24The plugin integrates with both the Block Editor and the Classic Editor. The Markdown tools are available in the post editor sidebar when using the Block Editor and as meta boxes when using the Classic Editor.
    2525
    2626### Pro Version
     
    4040Use this feature to create the blocks of a post from a Markdown document previously created with the plugin.
    4141
    42 #### Submit Markdown
     42#### Insert Markdown
    4343
    4444With this section, you can instantly transform Markdown text to blocks.
     
    5252#### Import
    5353
    54 Import one or more Markdown files in the plugin with the upload form provided in this menu.
     54Import one or more Markdown files into the plugin with the upload form provided in this menu.
    5555
    5656#### Export
     
    6060### Supported Markdown syntax
    6161
    62 The conversion from Markdown text to HTML is performed with [Marked](https://github.com/markedjs/marked), a high-performance Markdown parser that supports documents written in the following [Markdown flavors](https://github.com/commonmark/commonmark-spec/wiki/Markdown-Flavors).
     62The plugin can convert Markdown text to HTML using the following parsers:
     63
     64* [Marked](https://github.com/markedjs/marked), a high-performance JavaScript Markdown parser and compiler.
     65* [League\CommonMark](https://github.com/thephpleague/commonmark), a PHP Markdown parser that supports both the CommonMark and GitHub Flavored Markdown variants.
    6366
    6467### Front Matter
     
    7073### Credits
    7174
    72 This plugin makes use of the following resources:
     75This plugin includes the following third-party libraries:
    7376
    7477* [DOMPurify](https://github.com/cure53/DOMPurify) licensed under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
     
    7679* [League\CommonMark](https://github.com/thephpleague/commonmark) licensed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
    7780* [Composer](https://getcomposer.org/) licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
    78 * [HTML To Markdown for PHP](https://github.com/thephpleague/html-to-markdown) licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
    7981* [FrontYAML](https://github.com/mnapoli/FrontYAML) licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
    8082
     
    107109
    108110== Changelog ==
     111
     112= 1.24 =
     113
     114*March 8, 2026*
     115
     116* The post editor tools added by the plugin are now also available as meta boxes in the Classic Editor.
     117* Improved the UI of the Block Editor tools.
     118* Updating the post status via front matter is now restricted to valid statuses.
     119* The plugin now checks if the user has the "edit_posts" capability before showing the block editor tools or meta boxes.
    109120
    110121= 1.23 =
     
    2382491. Import Markdown section in the post sidebar.
    2392502. Load Markdown section in the post sidebar.
    240 3. Submit Markdown section in the post sidebar.
     2513. Insert Markdown section in the post sidebar.
    2412524. A single document.
    2422535. List of documents.
  • ultimate-markdown/tags/1.24/shared/class-daextulma-shared.php

    r3424623 r3477447  
    3333
    3434        $this->data['slug'] = 'daextulma';
    35         $this->data['ver']  = '1.23';
     35        $this->data['ver']  = '1.24';
    3636        $this->data['dir']  = substr( plugin_dir_path( __FILE__ ), 0, - 7 );
    3737        $this->data['url']  = substr( plugin_dir_url( __FILE__ ), 0, - 7 );
     
    11721172    }
    11731173
     1174    /**
     1175     * Get the list of documents formatted for the selector used in the "Load Document" block editor sidebar section and
     1176     * in the "Load Document" meta box.
     1177     *
     1178     * @return array
     1179     */
     1180    public function get_documents_for_selector() {
     1181
     1182        global $wpdb;
     1183
     1184        // phpcs:ignore WordPress.DB.DirectDatabaseQuery
     1185        $document_a = $wpdb->get_results(
     1186                "SELECT document_id, title FROM {$wpdb->prefix}daextulma_document ORDER BY document_id DESC",
     1187                ARRAY_A
     1188        );
     1189
     1190        $document_a_alt   = array();
     1191        $document_a_alt[] = array(
     1192                'value' => 0,
     1193                'label' => __( 'Select a document…', 'ultimate-markdown' ),
     1194        );
     1195
     1196        foreach ( $document_a as $value ) {
     1197            $document_a_alt[] = array(
     1198                    'value' => intval( $value['document_id'], 10 ),
     1199                    'label' => stripslashes( $value['title'] ),
     1200            );
     1201        }
     1202
     1203        return $document_a_alt;
     1204    }
     1205
    11741206}
  • ultimate-markdown/trunk/admin/class-daextulma-admin.php

    r3424623 r3477447  
    389389        // Remove the "attachment" post type.
    390390        $available_post_types_a = array_diff( $available_post_types_a, array( 'attachment' ) );
     391
     392        /**
     393         * Enqueue Marked and DOMPurify only for post types with a UI.
     394         *
     395         * These libraries are required by the three block editor sidebar sections and by the three classic editor meta
     396         * boxes.
     397         */
    391398        if ( in_array( $screen->id, $available_post_types_a, true ) ) {
    392 
    393             /**
    394              * When the editor file is loaded (only in the post editor) add the names and IDs of all the documents as
    395              * json data in a property of the window.DAEXTULMA_PARAMETERS object.
    396              *
    397              * These data are used to populate the "Select Document" selector available in the post sidebar.
    398              */
    399             global $wpdb;
    400 
    401             // phpcs:ignore WordPress.DB.DirectDatabaseQuery
    402             $document_a = $wpdb->get_results(
    403                 "SELECT document_id, title FROM {$wpdb->prefix}daextulma_document ORDER BY document_id DESC",
    404                 ARRAY_A
    405             );
    406 
    407             $document_a_alt   = array();
    408             $document_a_alt[] = array(
    409                 'value' => 0,
    410                 'label' => __( 'Not set', 'ultimate-markdown' ),
    411             );
    412             foreach ( $document_a as $value ) {
    413                 $document_a_alt[] = array(
    414                     'value' => intval( $value['document_id'], 10 ),
    415                     'label' => stripslashes( $value['title'] ),
    416                 );
    417             }
    418 
    419             // Store the JavaScript parameters in the window.DAEXTULMA_PARAMETERS object.
    420             $initialization_script  = 'window.DAEXTULMA_PARAMETERS = {';
    421             $initialization_script .= 'documents: ' . wp_json_encode( $document_a_alt ) . ',';
    422             $initialization_script .= 'ajaxUrl: "' . admin_url( 'admin-ajax.php' ) . '",';
    423             $initialization_script .= 'pluginDirectoryUrl: "' . $this->shared->get( 'url' ) . '",';
    424             $initialization_script .= 'editorMarkdownParser: "' . get_option('daextulma_editor_markdown_parser') . '",';
    425             $initialization_script .= 'nonce: "' . wp_create_nonce( 'daextulma' ) . '",';
    426             $initialization_script .= '};';
    427             wp_add_inline_script( $this->shared->get( 'slug' ) . '-editor-js', $initialization_script, 'before' );
    428399
    429400            // Marked.
  • ultimate-markdown/trunk/blocks/build/index.js

    r3335244 r3477447  
    1 !function(){"use strict";var t=window.wp.element;function e(t,e){const{dispatch:a,select:o}=wp.data;wp.data.dispatch("core/block-editor").insertBlocks(t),wp.data.dispatch("core/block-editor").clearSelectedBlock(),wp.data.dispatch("core/edit-post").openGeneralSidebar("edit-post/document"),null!==e.title&&wp.data.dispatch("core/editor").editPost({title:e.title}),null!==e.excerpt&&wp.data.dispatch("core/editor").editPost({excerpt:e.excerpt}),null!==e.categories&&a("core/editor").editPost({categories:e.categories}),null!==e.tags&&a("core/editor").editPost({tags:e.tags}),null!==e.author&&wp.data.dispatch("core/editor").editPost({author:e.author}),null!==e.date&&wp.data.dispatch("core/editor").editPost({date:e.date}),null!==e.status&&wp.data.dispatch("core/editor").editPost({status:e.status})}const{PluginDocumentSettingPanel:a}=wp.editor,{Component:o}=wp.element,{__:__}=wp.i18n,{FormFileUpload:r}=wp.components,{registerPlugin:n}=wp.plugins;n("daextulma-import-document",{icon:!1,render:class extends o{render(){return(0,t.createElement)(a,{name:"daextulma-import-document",title:__("Import Markdown","ultimate-markdown")},(0,t.createElement)(r,{className:"block-library-gallery-add-item-button",onChange:()=>{const t=event.target.files[0],a=new FormData;a.append("action","daextulma_import_document"),a.append("security",window.DAEXTULMA_PARAMETERS.nonce),a.append("uploaded_file",t),fetch(window.DAEXTULMA_PARAMETERS.ajaxUrl,{method:"POST",body:a}).then((function(t){return t.json()})).then((function(t){const a={invalid_date_format:__("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:__("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},o=a[t.data.error]||a.generic_error;if(t.data.error)return void wp.data.dispatch("core/notices").createErrorNotice(o,{type:"snackbar",isDismissible:!0});let r="";r="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.data.content):t.data.html_content,r=DOMPurify.sanitize(r,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:r}),t.data),wp.data.dispatch("core/notices").createErrorNotice(__("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})}))},accept:".md,.markdown,.mdown,.mkdn,.mkd,.mdwn,.mdtxt,.mdtext,.text,.txt",icon:"insert",__next40pxDefaultSize:!0},__("Upload file and import","ultimate-markdown")))}}});const{dispatch:d,select:i}=wp.data,{PluginDocumentSettingPanel:s}=wp.editor,{Component:c}=wp.element,{__:l}=wp.i18n,{Button:m,SelectControl:u}=wp.components,{registerPlugin:p}=wp.plugins;p("daextulma-load-document",{icon:!1,render:class extends c{constructor(t){super(...arguments),this.state={documentIdSelectorValue:""}}render(){const a=i("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_load_document_selector;return(0,t.createElement)(s,{name:"daextulma-load-document",title:l("Load Markdown","ultimate-markdown"),className:"daextulma-load-document-panel"},(0,t.createElement)(u,{label:l("Markdown document","ultimate-markdown"),help:l("Select a Markdown document, then click the submit document button to generate the corresponding blocks.","ultimate-markdown"),value:a,onChange:t=>{d("core/editor").editPost({meta:{_import_markdown_pro_load_document_selector:t}}),this.setState({documentIdSelectorValue:t})},options:window.DAEXTULMA_PARAMETERS.documents,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,t.createElement)(m,{variant:"secondary",className:"editor-post-trash is-destructive",onClick:()=>{const t=i("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_load_document_selector;if(0===parseInt(t,10))return;const a=new FormData;a.append("action","daextulma_load_document"),a.append("security",window.DAEXTULMA_PARAMETERS.nonce),a.append("document_id",t),fetch(window.DAEXTULMA_PARAMETERS.ajaxUrl,{method:"POST",body:a}).then((t=>t.json())).then((t=>{const a={invalid_date_format:l("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:l("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},o=a[t.data.error]||a.generic_error;if(t.data.error)return void wp.data.dispatch("core/notices").createErrorNotice(o,{type:"snackbar",isDismissible:!0});let r="";r="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.data.content):t.data.html_content,r=DOMPurify.sanitize(r,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:r}),t.data),d("core/editor").editPost({meta:{_import_markdown_pro_load_document_selector:"0"}}),this.setState({documentIdSelectorValue:"0"}),wp.data.dispatch("core/notices").createErrorNotice(l("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})}))}},l("Submit document","ultimate-markdown")))}}});const{Button:w,TextareaControl:_}=wp.components,{dispatch:k,select:h}=wp.data,{PluginDocumentSettingPanel:g}=wp.editor,{Component:b}=wp.element,{__:E}=wp.i18n,{registerPlugin:P}=wp.plugins;P("submit-text",{icon:!1,render:class extends b{constructor(t){super(...arguments),this.state={textareaValue:""}}render(){const a=h("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_submit_text_textarea;return(0,t.createElement)(g,{name:"submit-text",title:E("Submit Markdown","ultimate-markdown"),className:"daextulma-submit-text-panel"},(0,t.createElement)(_,{label:E("Markdown text","ultimate-markdown"),help:E("Enter the Markdown text, then click the submit text button to generate the corresponding blocks.","ultimate-markdown"),value:a,onChange:t=>{k("core/editor").editPost({meta:{_import_markdown_pro_submit_text_textarea:t}}),this.setState({textareaValue:t})},__nextHasNoMarginBottom:!0}),(0,t.createElement)(w,{variant:"secondary",className:"editor-post-trash is-destructive",onClick:()=>{wp.ajax.post("daextulma_submit_markdown",{security:window.DAEXTULMA_PARAMETERS.nonce,markdowntext:this.state.textareaValue}).done((t=>{let a="";a="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.content):t.html_content,a=DOMPurify.sanitize(a,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:a}),t),k("core/editor").editPost({meta:{_import_markdown_pro_submit_text_textarea:""}}),this.setState({textareaValue:""}),wp.data.dispatch("core/notices").createErrorNotice(E("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})})).fail((t=>{const e={invalid_date_format:E("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:E("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},a=e[t.error]||e.generic_error;wp.data.dispatch("core/notices").createErrorNotice(a,{type:"snackbar",isDismissible:!0})}))}},E("Submit text","ultimate-markdown")))}}})}();
     1!function(){"use strict";var t=window.wp.element;function e(t,e){const{dispatch:a,select:o}=wp.data;wp.data.dispatch("core/block-editor").insertBlocks(t),wp.data.dispatch("core/block-editor").clearSelectedBlock(),wp.data.dispatch("core/edit-post").openGeneralSidebar("edit-post/document"),null!==e.title&&wp.data.dispatch("core/editor").editPost({title:e.title}),null!==e.excerpt&&wp.data.dispatch("core/editor").editPost({excerpt:e.excerpt}),null!==e.categories&&a("core/editor").editPost({categories:e.categories}),null!==e.tags&&a("core/editor").editPost({tags:e.tags}),null!==e.author&&wp.data.dispatch("core/editor").editPost({author:e.author}),null!==e.date&&wp.data.dispatch("core/editor").editPost({date:e.date}),null!==e.status&&void 0!==e.status&&["publish","draft","pending","private","future"].includes(e.status)&&wp.data.dispatch("core/editor").editPost({status:e.status})}const{PluginDocumentSettingPanel:a}=wp.editor,{Component:o}=wp.element,{__:__}=wp.i18n,{FormFileUpload:r,BaseControl:n}=wp.components,{registerPlugin:d}=wp.plugins;d("daextulma-import-document",{icon:!1,render:class extends o{render(){return(0,t.createElement)(a,{name:"daextulma-import-document",title:__("Import Markdown","ultimate-markdown")},(0,t.createElement)(n,{help:__("Uploads a Markdown file and imports its content into the editor.","ultimate-markdown"),__nextHasNoMarginBottom:!0},(0,t.createElement)(r,{className:"block-library-gallery-add-item-button",onChange:()=>{const t=event.target.files[0],a=new FormData;a.append("action","daextulma_import_document"),a.append("security",window.DAEXTULMA_PARAMETERS.nonce),a.append("uploaded_file",t),fetch(window.DAEXTULMA_PARAMETERS.ajaxUrl,{method:"POST",body:a}).then((function(t){return t.json()})).then((function(t){const a={invalid_date_format:__("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:__("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},o=a[t.data.error]||a.generic_error;if(t.data.error)return void wp.data.dispatch("core/notices").createErrorNotice(o,{type:"snackbar",isDismissible:!0});let r="";r="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.data.content):t.data.html_content,r=DOMPurify.sanitize(r,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:r}),t.data),wp.data.dispatch("core/notices").createErrorNotice(__("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})}))},accept:".md,.markdown,.mdown,.mkdn,.mkd,.mdwn,.mdtxt,.mdtext,.text,.txt",icon:"insert",__next40pxDefaultSize:!0},__("Upload file and import","ultimate-markdown"))))}}});const{dispatch:i,select:s}=wp.data,{PluginDocumentSettingPanel:c}=wp.editor,{Component:l}=wp.element,{__:m}=wp.i18n,{Button:u,SelectControl:p,BaseControl:w}=wp.components,{registerPlugin:_}=wp.plugins;_("daextulma-load-document",{icon:!1,render:class extends l{constructor(t){super(...arguments),this.state={documentIdSelectorValue:""}}render(){const a=s("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_load_document_selector;return(0,t.createElement)(c,{name:"daextulma-load-document",title:m("Load Markdown","ultimate-markdown"),className:"daextulma-load-document-panel"},(0,t.createElement)(w,{help:m("Loads the selected Markdown document into the editor.","ultimate-markdown"),__nextHasNoMarginBottom:!0},(0,t.createElement)(p,{label:m("Document","ultimate-markdown"),value:a,onChange:t=>{i("core/editor").editPost({meta:{_import_markdown_pro_load_document_selector:t}}),this.setState({documentIdSelectorValue:t})},options:window.DAEXTULMA_PARAMETERS.documents,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,t.createElement)(u,{variant:"secondary",className:"editor-post-trash is-destructive",onClick:()=>{const t=s("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_load_document_selector;if(0===parseInt(t,10))return;const a=new FormData;a.append("action","daextulma_load_document"),a.append("security",window.DAEXTULMA_PARAMETERS.nonce),a.append("document_id",t),fetch(window.DAEXTULMA_PARAMETERS.ajaxUrl,{method:"POST",body:a}).then((t=>t.json())).then((t=>{const a={invalid_date_format:m("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:m("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},o=a[t.data.error]||a.generic_error;if(t.data.error)return void wp.data.dispatch("core/notices").createErrorNotice(o,{type:"snackbar",isDismissible:!0});let r="";r="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.data.content):t.data.html_content,r=DOMPurify.sanitize(r,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:r}),t.data),i("core/editor").editPost({meta:{_import_markdown_pro_load_document_selector:"0"}}),this.setState({documentIdSelectorValue:"0"}),wp.data.dispatch("core/notices").createErrorNotice(m("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})}))}},m("Load","ultimate-markdown"))))}}});const{Button:k,TextareaControl:h,BaseControl:g}=wp.components,{dispatch:E,select:M}=wp.data,{PluginDocumentSettingPanel:P}=wp.editor,{Component:b}=wp.element,{__:x}=wp.i18n,{registerPlugin:f}=wp.plugins;f("submit-text",{icon:!1,render:class extends b{constructor(t){super(...arguments),this.state={textareaValue:""}}render(){const a=M("core/editor").getEditedPostAttribute("meta")._import_markdown_pro_submit_text_textarea;return(0,t.createElement)(P,{name:"submit-text",title:x("Insert Markdown","ultimate-markdown"),className:"daextulma-submit-text-panel"},(0,t.createElement)(g,{help:x("Inserts the Markdown above into the editor.","ultimate-markdown"),__nextHasNoMarginBottom:!0},(0,t.createElement)(h,{label:x("Markdown","ultimate-markdown"),value:a,onChange:t=>{E("core/editor").editPost({meta:{_import_markdown_pro_submit_text_textarea:t}}),this.setState({textareaValue:t})},__nextHasNoMarginBottom:!0}),(0,t.createElement)(k,{variant:"secondary",className:"editor-post-trash is-destructive",onClick:()=>{wp.ajax.post("daextulma_submit_markdown",{security:window.DAEXTULMA_PARAMETERS.nonce,markdowntext:this.state.textareaValue}).done((t=>{let a="";a="marked"===window.DAEXTULMA_PARAMETERS.editorMarkdownParser?marked(t.content):t.html_content,a=DOMPurify.sanitize(a,{USE_PROFILES:{html:!0}}),wp.data.dispatch("core/block-editor").resetBlocks([]),e(wp.blocks.rawHandler({HTML:a}),t),E("core/editor").editPost({meta:{_import_markdown_pro_submit_text_textarea:""}}),this.setState({textareaValue:""}),wp.data.dispatch("core/notices").createErrorNotice(x("Markdown content successfully processed and blocks created.","ultimate-markdown"),{type:"snackbar",isDismissible:!0})})).fail((t=>{const e={invalid_date_format:x("Invalid date format in Front Matter. Please enter a valid date, e.g. 2025-07-16, or a date and time, e.g. 2025-07-16 10:30:42.","ultimate-markdown"),generic_error:x("Please review your document for any formatting issues in the Front Matter or Markdown content, then try again. The content could not be processed. For more details on supported fields and formatting, please refer to the plugin documentation.","ultimate-markdown")},a=e[t.error]||e.generic_error;wp.data.dispatch("core/notices").createErrorNotice(a,{type:"snackbar",isDismissible:!0})}))}},x("Insert","ultimate-markdown"))))}}})}();
  • ultimate-markdown/trunk/blocks/css/editor.css

    r3424623 r3477447  
    1 .daextulma-load-document-panel .components-base-control__help,
    2 .daextulma-submit-text-panel .components-base-control__help{
     1.daextulma-load-document-panel .components-input-control__container,
     2.daextulma-submit-text-panel .components-textarea-control{
    33    margin-bottom: 12px !important;
    44}
  • ultimate-markdown/trunk/blocks/src/import-document/components/Sidebar.js

    r3424623 r3477447  
    88const {Component} = wp.element;
    99const {__} = wp.i18n;
    10 const {FormFileUpload} = wp.components;
     10const {FormFileUpload, BaseControl} = wp.components;
    1111import {updateFields} from '../../utils';
    1212
     
    1919                title={__('Import Markdown', 'ultimate-markdown')}
    2020            >
     21                <BaseControl
     22                    help={__(
     23                        'Uploads a Markdown file and imports its content into the editor.',
     24                        'ultimate-markdown'
     25                    )}
     26                    __nextHasNoMarginBottom={ true }
     27                >
    2128                <FormFileUpload
    2229                    className="block-library-gallery-add-item-button"
     
    112119                    {__('Upload file and import', 'ultimate-markdown')}
    113120                </FormFileUpload>
     121                </BaseControl>
    114122            </PluginDocumentSettingPanel>
    115123        );
  • ultimate-markdown/trunk/blocks/src/init.php

    r3424623 r3477447  
    1818 */
    1919function daextulma_editor_assets() {
     20
     21    // Check capability before loading block editor assets.
     22    if ( ! current_user_can( 'edit_posts' ) ) {
     23        return;
     24    }
    2025
    2126    // assign an instance of Daextulma_Shared.
     
    4146        true // Enqueue the script in the footer.
    4247    );
     48
     49    // Get the documents used to populate the selector in the "Load Document" block editor sidebar section.
     50    $document_a_alt = $shared->get_documents_for_selector();
     51
     52    // Store the JavaScript parameters in the window.DAEXTULMA_PARAMETERS object.
     53    $initialization_script  = 'window.DAEXTULMA_PARAMETERS = {';
     54    $initialization_script .= 'documents: ' . wp_json_encode( $document_a_alt ) . ',';
     55    $initialization_script .= 'ajaxUrl: "' . admin_url( 'admin-ajax.php' ) . '",';
     56    $initialization_script .= 'pluginDirectoryUrl: "' . $shared->get( 'url' ) . '",';
     57    $initialization_script .= 'editorMarkdownParser: "' . get_option('daextulma_editor_markdown_parser') . '",';
     58    $initialization_script .= 'nonce: "' . wp_create_nonce( 'daextulma' ) . '",';
     59    $initialization_script .= '};';
     60    wp_add_inline_script( $shared->get( 'slug' ) . '-editor-js', $initialization_script, 'before' );
     61
    4362}
    4463
  • ultimate-markdown/trunk/blocks/src/load-document/components/Sidebar.js

    r3424623 r3477447  
    99const {Component} = wp.element;
    1010const {__} = wp.i18n;
    11 const {Button, SelectControl} = wp.components;
     11const {Button, SelectControl, BaseControl} = wp.components;
    1212import {updateFields} from '../../utils';
    1313
     
    3636                className="daextulma-load-document-panel"
    3737            >
     38                <BaseControl
     39                    help={__(
     40                        'Loads the selected Markdown document into the editor.',
     41                        'ultimate-markdown'
     42                    )}
     43                    __nextHasNoMarginBottom={ true }
     44                >
    3845                <SelectControl
    39                     label={__('Markdown document', 'ultimate-markdown')}
    40                     help={__(
    41                         'Select a Markdown document, then click the submit document button to generate the corresponding blocks.',
    42                         'ultimate-markdown')}
     46                    label={__('Document', 'ultimate-markdown')}
    4347                    value={documentIdSelectorMeta}
    4448                    onChange={(document_id) => {
     
    7276                        const document_id = meta['_import_markdown_pro_load_document_selector'];
    7377
    74                         // Do not proceed if the selected option is "Not set".
     78                        // Do not proceed if the selected option is "Select a document…".
    7579                        if (parseInt(document_id, 10) === 0) {
    7680                            return;
     
    143147                            updateFields(blocks, response.data);
    144148
    145                             // Reset the document selector to "Not set" (0) in meta.
     149                            // Reset the document selector to "Select a document…" (0) in meta.
    146150                            dispatch('core/editor').editPost({
    147151                                meta: {
     
    150154                            });
    151155
    152                             // Reset the document selector to "Not set" (0) in local state.
     156                            // Reset the document selector to "Select a document…" (0) in local state.
    153157                            this.setState({
    154158                                documentIdSelectorValue: '0',
     
    166170
    167171                    }}
    168                 >{__('Submit document', 'ultimate-markdown')}</Button>
    169 
     172                >{__('Load', 'ultimate-markdown')}</Button>
     173                </BaseControl>
    170174            </PluginDocumentSettingPanel>
    171175        );
  • ultimate-markdown/trunk/blocks/src/submit-text/components/Sidebar.js

    r3424623 r3477447  
    55 */
    66
    7 const {Button, TextareaControl} = wp.components;
     7const {Button, TextareaControl, BaseControl} = wp.components;
    88const {dispatch, select} = wp.data;
    99const {PluginDocumentSettingPanel} = wp.editor;
     
    3333            <PluginDocumentSettingPanel
    3434                name="submit-text"
    35                 title={__('Submit Markdown', 'ultimate-markdown')}
     35                title={__('Insert Markdown', 'ultimate-markdown')}
    3636                className="daextulma-submit-text-panel"
    3737            >
    38 
    39 
     38                <BaseControl
     39                    help={__(
     40                        'Inserts the Markdown above into the editor.',
     41                        'ultimate-markdown'
     42                    )}
     43                    __nextHasNoMarginBottom={ true }
     44                >
    4045                <TextareaControl
    41                     label={__('Markdown text', 'ultimate-markdown')}
    42                     help={__(
    43                         'Enter the Markdown text, then click the submit text button to generate the corresponding blocks.',
    44                         'ultimate-markdown')}
     46                    label={__('Markdown', 'ultimate-markdown')}
    4547                    value={markdownText}
    4648                    onChange={(value) => {
     
    123125
    124126                    }}
    125                 >{__('Submit text', 'ultimate-markdown')}</Button>
    126 
     127                >{__('Insert', 'ultimate-markdown')}</Button>
     128                </BaseControl>
    127129            </PluginDocumentSettingPanel>
    128130        );
  • ultimate-markdown/trunk/blocks/src/utils.js

    r3424623 r3477447  
    9494    }
    9595
    96     // Update the status.
    97     if (data['status'] !== null) {
     96    /**
     97     *
     98     * Update the post status.
     99     *
     100     * WordPress internally supports several statuses (publish, draft, pending,
     101     * future, private, trash, auto-draft, inherit, etc.). However, only a limited subset of these statuses can be
     102     * safely using the provided front matter value.
     103     *
     104     *  - publish  → Published
     105     *  - draft    → Draft
     106     *  - pending  → Pending Review
     107     *  - private  → Private
     108     *  - future   → Scheduled
     109     *
     110     * Other statuses such as "trash", "auto-draft", or "inherit" are controlled by other mechanisms (e.g. trash
     111     * actions, internal WordPress logic) and should not be set.
     112     *
     113     * Note that the 'future' status (scheduled) doesn't actually need a publishing date, because if the date is not
     114     * set in the future, WordPress will automatically change the status to 'publish' when the post is saved. If instead
     115     * a future date is set, WordPress will keep the 'future' status and publish the post at the scheduled date.
     116     *
     117     * @type {string[]}
     118     */
     119    const allowedStatuses = ['publish', 'draft', 'pending', 'private', 'future'];
     120    if (data['status'] !== null && data.status !== undefined && allowedStatuses.includes(data.status)) {
    98121        wp.data.dispatch('core/editor').editPost({status: data['status']});
    99122    }
  • ultimate-markdown/trunk/init.php

    r3424623 r3477447  
    33 * Plugin Name: Ultimate Markdown
    44 * Description: A set of tools that helps you work with the Markdown language.
    5  * Version: 1.23
     5 * Version: 1.24
    66 * Author: DAEXT
    77 * Author URI: https://daext.com
     
    4848    }
    4949
     50    // Load meta boxes.
     51    require_once plugin_dir_path( __FILE__ ) . 'admin/inc/class-daextulma-meta-boxes.php';
     52    add_action( 'plugins_loaded', array( 'Daextulma_Meta_Boxes', 'get_instance' ) );
     53
    5054    // Activate the plugin using only the class static methods.
    5155    register_activation_hook( __FILE__, array( 'Daextulma_Admin', 'ac_activate' ) );
  • ultimate-markdown/trunk/readme.txt

    r3424623 r3477447  
    44Donate link: https://daext.com
    55Requires at least: 5.0
    6 Tested up to: 6.9
     6Tested up to: 6.9.1
    77Requires PHP: 5.3
    8 Stable tag: 1.23
     8Stable tag: 1.24
    99License: GPLv3
    1010
     
    1616Specifically, after installing the plugin, you will be able to:
    1717
    18 * Create posts with perfectly formatted blocks from existing Markdown files or Markdown documents created with the plugin.
    19 * Instantly generate blocks from Markdown text.
    20 * Create and manage an unlimited number of Markdown documents in a dedicated plugin menu.
    21 * Import Markdown file in WordPress.
     18* Create posts from Markdown files or Markdown documents created with the plugin.
     19* Convert Markdown text to blocks directly in the post editor.
     20* Create and manage Markdown documents in a dedicated plugin menu.
     21* Import Markdown files into WordPress.
    2222* Create archives of Markdown files from the Markdown documents created with the plugin.
    2323
    24 Please note that this plugin requires the use of the default [WordPress Blocks Editor](https://wordpress.org/support/article/blocks/). With third-party visual editors or with the [Classic Editor](https://wordpress.org/plugins/classic-editor/), you will not be able to use most of the plugin functionalities.
     24The plugin integrates with both the Block Editor and the Classic Editor. The Markdown tools are available in the post editor sidebar when using the Block Editor and as meta boxes when using the Classic Editor.
    2525
    2626### Pro Version
     
    4040Use this feature to create the blocks of a post from a Markdown document previously created with the plugin.
    4141
    42 #### Submit Markdown
     42#### Insert Markdown
    4343
    4444With this section, you can instantly transform Markdown text to blocks.
     
    5252#### Import
    5353
    54 Import one or more Markdown files in the plugin with the upload form provided in this menu.
     54Import one or more Markdown files into the plugin with the upload form provided in this menu.
    5555
    5656#### Export
     
    6060### Supported Markdown syntax
    6161
    62 The conversion from Markdown text to HTML is performed with [Marked](https://github.com/markedjs/marked), a high-performance Markdown parser that supports documents written in the following [Markdown flavors](https://github.com/commonmark/commonmark-spec/wiki/Markdown-Flavors).
     62The plugin can convert Markdown text to HTML using the following parsers:
     63
     64* [Marked](https://github.com/markedjs/marked), a high-performance JavaScript Markdown parser and compiler.
     65* [League\CommonMark](https://github.com/thephpleague/commonmark), a PHP Markdown parser that supports both the CommonMark and GitHub Flavored Markdown variants.
    6366
    6467### Front Matter
     
    7073### Credits
    7174
    72 This plugin makes use of the following resources:
     75This plugin includes the following third-party libraries:
    7376
    7477* [DOMPurify](https://github.com/cure53/DOMPurify) licensed under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
     
    7679* [League\CommonMark](https://github.com/thephpleague/commonmark) licensed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
    7780* [Composer](https://getcomposer.org/) licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
    78 * [HTML To Markdown for PHP](https://github.com/thephpleague/html-to-markdown) licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
    7981* [FrontYAML](https://github.com/mnapoli/FrontYAML) licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
    8082
     
    107109
    108110== Changelog ==
     111
     112= 1.24 =
     113
     114*March 8, 2026*
     115
     116* The post editor tools added by the plugin are now also available as meta boxes in the Classic Editor.
     117* Improved the UI of the Block Editor tools.
     118* Updating the post status via front matter is now restricted to valid statuses.
     119* The plugin now checks if the user has the "edit_posts" capability before showing the block editor tools or meta boxes.
    109120
    110121= 1.23 =
     
    2382491. Import Markdown section in the post sidebar.
    2392502. Load Markdown section in the post sidebar.
    240 3. Submit Markdown section in the post sidebar.
     2513. Insert Markdown section in the post sidebar.
    2412524. A single document.
    2422535. List of documents.
  • ultimate-markdown/trunk/shared/class-daextulma-shared.php

    r3424623 r3477447  
    3333
    3434        $this->data['slug'] = 'daextulma';
    35         $this->data['ver']  = '1.23';
     35        $this->data['ver']  = '1.24';
    3636        $this->data['dir']  = substr( plugin_dir_path( __FILE__ ), 0, - 7 );
    3737        $this->data['url']  = substr( plugin_dir_url( __FILE__ ), 0, - 7 );
     
    11721172    }
    11731173
     1174    /**
     1175     * Get the list of documents formatted for the selector used in the "Load Document" block editor sidebar section and
     1176     * in the "Load Document" meta box.
     1177     *
     1178     * @return array
     1179     */
     1180    public function get_documents_for_selector() {
     1181
     1182        global $wpdb;
     1183
     1184        // phpcs:ignore WordPress.DB.DirectDatabaseQuery
     1185        $document_a = $wpdb->get_results(
     1186                "SELECT document_id, title FROM {$wpdb->prefix}daextulma_document ORDER BY document_id DESC",
     1187                ARRAY_A
     1188        );
     1189
     1190        $document_a_alt   = array();
     1191        $document_a_alt[] = array(
     1192                'value' => 0,
     1193                'label' => __( 'Select a document…', 'ultimate-markdown' ),
     1194        );
     1195
     1196        foreach ( $document_a as $value ) {
     1197            $document_a_alt[] = array(
     1198                    'value' => intval( $value['document_id'], 10 ),
     1199                    'label' => stripslashes( $value['title'] ),
     1200            );
     1201        }
     1202
     1203        return $document_a_alt;
     1204    }
     1205
    11741206}
Note: See TracChangeset for help on using the changeset viewer.