Changeset 3477447
- Timestamp:
- 03/08/2026 02:36:52 PM (40 hours ago)
- Location:
- ultimate-markdown
- Files:
-
- 8 added
- 22 edited
- 1 copied
-
tags/1.24 (copied) (copied from ultimate-markdown/trunk)
-
tags/1.24/admin/assets/css/meta-boxes.css (added)
-
tags/1.24/admin/assets/js/meta-boxes-utilities.js (added)
-
tags/1.24/admin/assets/js/meta-boxes.js (added)
-
tags/1.24/admin/class-daextulma-admin.php (modified) (1 diff)
-
tags/1.24/admin/inc/class-daextulma-meta-boxes.php (added)
-
tags/1.24/blocks/build/index.js (modified) (1 diff)
-
tags/1.24/blocks/css/editor.css (modified) (1 diff)
-
tags/1.24/blocks/src/import-document/components/Sidebar.js (modified) (3 diffs)
-
tags/1.24/blocks/src/init.php (modified) (2 diffs)
-
tags/1.24/blocks/src/load-document/components/Sidebar.js (modified) (6 diffs)
-
tags/1.24/blocks/src/submit-text/components/Sidebar.js (modified) (3 diffs)
-
tags/1.24/blocks/src/utils.js (modified) (1 diff)
-
tags/1.24/init.php (modified) (2 diffs)
-
tags/1.24/readme.txt (modified) (9 diffs)
-
tags/1.24/shared/class-daextulma-shared.php (modified) (2 diffs)
-
trunk/admin/assets/css/meta-boxes.css (added)
-
trunk/admin/assets/js/meta-boxes-utilities.js (added)
-
trunk/admin/assets/js/meta-boxes.js (added)
-
trunk/admin/class-daextulma-admin.php (modified) (1 diff)
-
trunk/admin/inc/class-daextulma-meta-boxes.php (added)
-
trunk/blocks/build/index.js (modified) (1 diff)
-
trunk/blocks/css/editor.css (modified) (1 diff)
-
trunk/blocks/src/import-document/components/Sidebar.js (modified) (3 diffs)
-
trunk/blocks/src/init.php (modified) (2 diffs)
-
trunk/blocks/src/load-document/components/Sidebar.js (modified) (6 diffs)
-
trunk/blocks/src/submit-text/components/Sidebar.js (modified) (3 diffs)
-
trunk/blocks/src/utils.js (modified) (1 diff)
-
trunk/init.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (9 diffs)
-
trunk/shared/class-daextulma-shared.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ultimate-markdown/tags/1.24/admin/class-daextulma-admin.php
r3424623 r3477447 389 389 // Remove the "attachment" post type. 390 390 $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 */ 391 398 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 as395 * 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.DirectDatabaseQuery402 $document_a = $wpdb->get_results(403 "SELECT document_id, title FROM {$wpdb->prefix}daextulma_document ORDER BY document_id DESC",404 ARRAY_A405 );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' );428 399 429 400 // 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{ 3 3 margin-bottom: 12px !important; 4 4 } -
ultimate-markdown/tags/1.24/blocks/src/import-document/components/Sidebar.js
r3424623 r3477447 8 8 const {Component} = wp.element; 9 9 const {__} = wp.i18n; 10 const {FormFileUpload } = wp.components;10 const {FormFileUpload, BaseControl} = wp.components; 11 11 import {updateFields} from '../../utils'; 12 12 … … 19 19 title={__('Import Markdown', 'ultimate-markdown')} 20 20 > 21 <BaseControl 22 help={__( 23 'Uploads a Markdown file and imports its content into the editor.', 24 'ultimate-markdown' 25 )} 26 __nextHasNoMarginBottom={ true } 27 > 21 28 <FormFileUpload 22 29 className="block-library-gallery-add-item-button" … … 112 119 {__('Upload file and import', 'ultimate-markdown')} 113 120 </FormFileUpload> 121 </BaseControl> 114 122 </PluginDocumentSettingPanel> 115 123 ); -
ultimate-markdown/tags/1.24/blocks/src/init.php
r3424623 r3477447 18 18 */ 19 19 function daextulma_editor_assets() { 20 21 // Check capability before loading block editor assets. 22 if ( ! current_user_can( 'edit_posts' ) ) { 23 return; 24 } 20 25 21 26 // assign an instance of Daextulma_Shared. … … 41 46 true // Enqueue the script in the footer. 42 47 ); 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 43 62 } 44 63 -
ultimate-markdown/tags/1.24/blocks/src/load-document/components/Sidebar.js
r3424623 r3477447 9 9 const {Component} = wp.element; 10 10 const {__} = wp.i18n; 11 const {Button, SelectControl } = wp.components;11 const {Button, SelectControl, BaseControl} = wp.components; 12 12 import {updateFields} from '../../utils'; 13 13 … … 36 36 className="daextulma-load-document-panel" 37 37 > 38 <BaseControl 39 help={__( 40 'Loads the selected Markdown document into the editor.', 41 'ultimate-markdown' 42 )} 43 __nextHasNoMarginBottom={ true } 44 > 38 45 <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')} 43 47 value={documentIdSelectorMeta} 44 48 onChange={(document_id) => { … … 72 76 const document_id = meta['_import_markdown_pro_load_document_selector']; 73 77 74 // Do not proceed if the selected option is " Not set".78 // Do not proceed if the selected option is "Select a document…". 75 79 if (parseInt(document_id, 10) === 0) { 76 80 return; … … 143 147 updateFields(blocks, response.data); 144 148 145 // Reset the document selector to " Not set" (0) in meta.149 // Reset the document selector to "Select a document…" (0) in meta. 146 150 dispatch('core/editor').editPost({ 147 151 meta: { … … 150 154 }); 151 155 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. 153 157 this.setState({ 154 158 documentIdSelectorValue: '0', … … 166 170 167 171 }} 168 >{__(' Submit document', 'ultimate-markdown')}</Button>169 172 >{__('Load', 'ultimate-markdown')}</Button> 173 </BaseControl> 170 174 </PluginDocumentSettingPanel> 171 175 ); -
ultimate-markdown/tags/1.24/blocks/src/submit-text/components/Sidebar.js
r3424623 r3477447 5 5 */ 6 6 7 const {Button, TextareaControl } = wp.components;7 const {Button, TextareaControl, BaseControl} = wp.components; 8 8 const {dispatch, select} = wp.data; 9 9 const {PluginDocumentSettingPanel} = wp.editor; … … 33 33 <PluginDocumentSettingPanel 34 34 name="submit-text" 35 title={__(' Submit Markdown', 'ultimate-markdown')}35 title={__('Insert Markdown', 'ultimate-markdown')} 36 36 className="daextulma-submit-text-panel" 37 37 > 38 39 38 <BaseControl 39 help={__( 40 'Inserts the Markdown above into the editor.', 41 'ultimate-markdown' 42 )} 43 __nextHasNoMarginBottom={ true } 44 > 40 45 <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')} 45 47 value={markdownText} 46 48 onChange={(value) => { … … 123 125 124 126 }} 125 >{__(' Submit text', 'ultimate-markdown')}</Button>126 127 >{__('Insert', 'ultimate-markdown')}</Button> 128 </BaseControl> 127 129 </PluginDocumentSettingPanel> 128 130 ); -
ultimate-markdown/tags/1.24/blocks/src/utils.js
r3424623 r3477447 94 94 } 95 95 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)) { 98 121 wp.data.dispatch('core/editor').editPost({status: data['status']}); 99 122 } -
ultimate-markdown/tags/1.24/init.php
r3424623 r3477447 3 3 * Plugin Name: Ultimate Markdown 4 4 * Description: A set of tools that helps you work with the Markdown language. 5 * Version: 1.2 35 * Version: 1.24 6 6 * Author: DAEXT 7 7 * Author URI: https://daext.com … … 48 48 } 49 49 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 50 54 // Activate the plugin using only the class static methods. 51 55 register_activation_hook( __FILE__, array( 'Daextulma_Admin', 'ac_activate' ) ); -
ultimate-markdown/tags/1.24/readme.txt
r3424623 r3477447 4 4 Donate link: https://daext.com 5 5 Requires at least: 5.0 6 Tested up to: 6.9 6 Tested up to: 6.9.1 7 7 Requires PHP: 5.3 8 Stable tag: 1.2 38 Stable tag: 1.24 9 9 License: GPLv3 10 10 … … 16 16 Specifically, after installing the plugin, you will be able to: 17 17 18 * Create posts with perfectly formatted blocks from existingMarkdown files or Markdown documents created with the plugin.19 * Instantly generate blocks from Markdown text.20 * Create and manage an unlimited number ofMarkdown documents in a dedicated plugin menu.21 * Import Markdown file inWordPress.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. 22 22 * Create archives of Markdown files from the Markdown documents created with the plugin. 23 23 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.24 The 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. 25 25 26 26 ### Pro Version … … 40 40 Use this feature to create the blocks of a post from a Markdown document previously created with the plugin. 41 41 42 #### Submit Markdown42 #### Insert Markdown 43 43 44 44 With this section, you can instantly transform Markdown text to blocks. … … 52 52 #### Import 53 53 54 Import one or more Markdown files in the plugin with the upload form provided in this menu.54 Import one or more Markdown files into the plugin with the upload form provided in this menu. 55 55 56 56 #### Export … … 60 60 ### Supported Markdown syntax 61 61 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). 62 The 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. 63 66 64 67 ### Front Matter … … 70 73 ### Credits 71 74 72 This plugin makes use of the following resources:75 This plugin includes the following third-party libraries: 73 76 74 77 * [DOMPurify](https://github.com/cure53/DOMPurify) licensed under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) … … 76 79 * [League\CommonMark](https://github.com/thephpleague/commonmark) licensed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause) 77 80 * [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)79 81 * [FrontYAML](https://github.com/mnapoli/FrontYAML) licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php) 80 82 … … 107 109 108 110 == 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. 109 120 110 121 = 1.23 = … … 238 249 1. Import Markdown section in the post sidebar. 239 250 2. Load Markdown section in the post sidebar. 240 3. Submit Markdown section in the post sidebar.251 3. Insert Markdown section in the post sidebar. 241 252 4. A single document. 242 253 5. List of documents. -
ultimate-markdown/tags/1.24/shared/class-daextulma-shared.php
r3424623 r3477447 33 33 34 34 $this->data['slug'] = 'daextulma'; 35 $this->data['ver'] = '1.2 3';35 $this->data['ver'] = '1.24'; 36 36 $this->data['dir'] = substr( plugin_dir_path( __FILE__ ), 0, - 7 ); 37 37 $this->data['url'] = substr( plugin_dir_url( __FILE__ ), 0, - 7 ); … … 1172 1172 } 1173 1173 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 1174 1206 } -
ultimate-markdown/trunk/admin/class-daextulma-admin.php
r3424623 r3477447 389 389 // Remove the "attachment" post type. 390 390 $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 */ 391 398 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 as395 * 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.DirectDatabaseQuery402 $document_a = $wpdb->get_results(403 "SELECT document_id, title FROM {$wpdb->prefix}daextulma_document ORDER BY document_id DESC",404 ARRAY_A405 );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' );428 399 429 400 // 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{ 3 3 margin-bottom: 12px !important; 4 4 } -
ultimate-markdown/trunk/blocks/src/import-document/components/Sidebar.js
r3424623 r3477447 8 8 const {Component} = wp.element; 9 9 const {__} = wp.i18n; 10 const {FormFileUpload } = wp.components;10 const {FormFileUpload, BaseControl} = wp.components; 11 11 import {updateFields} from '../../utils'; 12 12 … … 19 19 title={__('Import Markdown', 'ultimate-markdown')} 20 20 > 21 <BaseControl 22 help={__( 23 'Uploads a Markdown file and imports its content into the editor.', 24 'ultimate-markdown' 25 )} 26 __nextHasNoMarginBottom={ true } 27 > 21 28 <FormFileUpload 22 29 className="block-library-gallery-add-item-button" … … 112 119 {__('Upload file and import', 'ultimate-markdown')} 113 120 </FormFileUpload> 121 </BaseControl> 114 122 </PluginDocumentSettingPanel> 115 123 ); -
ultimate-markdown/trunk/blocks/src/init.php
r3424623 r3477447 18 18 */ 19 19 function daextulma_editor_assets() { 20 21 // Check capability before loading block editor assets. 22 if ( ! current_user_can( 'edit_posts' ) ) { 23 return; 24 } 20 25 21 26 // assign an instance of Daextulma_Shared. … … 41 46 true // Enqueue the script in the footer. 42 47 ); 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 43 62 } 44 63 -
ultimate-markdown/trunk/blocks/src/load-document/components/Sidebar.js
r3424623 r3477447 9 9 const {Component} = wp.element; 10 10 const {__} = wp.i18n; 11 const {Button, SelectControl } = wp.components;11 const {Button, SelectControl, BaseControl} = wp.components; 12 12 import {updateFields} from '../../utils'; 13 13 … … 36 36 className="daextulma-load-document-panel" 37 37 > 38 <BaseControl 39 help={__( 40 'Loads the selected Markdown document into the editor.', 41 'ultimate-markdown' 42 )} 43 __nextHasNoMarginBottom={ true } 44 > 38 45 <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')} 43 47 value={documentIdSelectorMeta} 44 48 onChange={(document_id) => { … … 72 76 const document_id = meta['_import_markdown_pro_load_document_selector']; 73 77 74 // Do not proceed if the selected option is " Not set".78 // Do not proceed if the selected option is "Select a document…". 75 79 if (parseInt(document_id, 10) === 0) { 76 80 return; … … 143 147 updateFields(blocks, response.data); 144 148 145 // Reset the document selector to " Not set" (0) in meta.149 // Reset the document selector to "Select a document…" (0) in meta. 146 150 dispatch('core/editor').editPost({ 147 151 meta: { … … 150 154 }); 151 155 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. 153 157 this.setState({ 154 158 documentIdSelectorValue: '0', … … 166 170 167 171 }} 168 >{__(' Submit document', 'ultimate-markdown')}</Button>169 172 >{__('Load', 'ultimate-markdown')}</Button> 173 </BaseControl> 170 174 </PluginDocumentSettingPanel> 171 175 ); -
ultimate-markdown/trunk/blocks/src/submit-text/components/Sidebar.js
r3424623 r3477447 5 5 */ 6 6 7 const {Button, TextareaControl } = wp.components;7 const {Button, TextareaControl, BaseControl} = wp.components; 8 8 const {dispatch, select} = wp.data; 9 9 const {PluginDocumentSettingPanel} = wp.editor; … … 33 33 <PluginDocumentSettingPanel 34 34 name="submit-text" 35 title={__(' Submit Markdown', 'ultimate-markdown')}35 title={__('Insert Markdown', 'ultimate-markdown')} 36 36 className="daextulma-submit-text-panel" 37 37 > 38 39 38 <BaseControl 39 help={__( 40 'Inserts the Markdown above into the editor.', 41 'ultimate-markdown' 42 )} 43 __nextHasNoMarginBottom={ true } 44 > 40 45 <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')} 45 47 value={markdownText} 46 48 onChange={(value) => { … … 123 125 124 126 }} 125 >{__(' Submit text', 'ultimate-markdown')}</Button>126 127 >{__('Insert', 'ultimate-markdown')}</Button> 128 </BaseControl> 127 129 </PluginDocumentSettingPanel> 128 130 ); -
ultimate-markdown/trunk/blocks/src/utils.js
r3424623 r3477447 94 94 } 95 95 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)) { 98 121 wp.data.dispatch('core/editor').editPost({status: data['status']}); 99 122 } -
ultimate-markdown/trunk/init.php
r3424623 r3477447 3 3 * Plugin Name: Ultimate Markdown 4 4 * Description: A set of tools that helps you work with the Markdown language. 5 * Version: 1.2 35 * Version: 1.24 6 6 * Author: DAEXT 7 7 * Author URI: https://daext.com … … 48 48 } 49 49 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 50 54 // Activate the plugin using only the class static methods. 51 55 register_activation_hook( __FILE__, array( 'Daextulma_Admin', 'ac_activate' ) ); -
ultimate-markdown/trunk/readme.txt
r3424623 r3477447 4 4 Donate link: https://daext.com 5 5 Requires at least: 5.0 6 Tested up to: 6.9 6 Tested up to: 6.9.1 7 7 Requires PHP: 5.3 8 Stable tag: 1.2 38 Stable tag: 1.24 9 9 License: GPLv3 10 10 … … 16 16 Specifically, after installing the plugin, you will be able to: 17 17 18 * Create posts with perfectly formatted blocks from existingMarkdown files or Markdown documents created with the plugin.19 * Instantly generate blocks from Markdown text.20 * Create and manage an unlimited number ofMarkdown documents in a dedicated plugin menu.21 * Import Markdown file inWordPress.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. 22 22 * Create archives of Markdown files from the Markdown documents created with the plugin. 23 23 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.24 The 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. 25 25 26 26 ### Pro Version … … 40 40 Use this feature to create the blocks of a post from a Markdown document previously created with the plugin. 41 41 42 #### Submit Markdown42 #### Insert Markdown 43 43 44 44 With this section, you can instantly transform Markdown text to blocks. … … 52 52 #### Import 53 53 54 Import one or more Markdown files in the plugin with the upload form provided in this menu.54 Import one or more Markdown files into the plugin with the upload form provided in this menu. 55 55 56 56 #### Export … … 60 60 ### Supported Markdown syntax 61 61 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). 62 The 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. 63 66 64 67 ### Front Matter … … 70 73 ### Credits 71 74 72 This plugin makes use of the following resources:75 This plugin includes the following third-party libraries: 73 76 74 77 * [DOMPurify](https://github.com/cure53/DOMPurify) licensed under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) … … 76 79 * [League\CommonMark](https://github.com/thephpleague/commonmark) licensed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause) 77 80 * [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)79 81 * [FrontYAML](https://github.com/mnapoli/FrontYAML) licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php) 80 82 … … 107 109 108 110 == 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. 109 120 110 121 = 1.23 = … … 238 249 1. Import Markdown section in the post sidebar. 239 250 2. Load Markdown section in the post sidebar. 240 3. Submit Markdown section in the post sidebar.251 3. Insert Markdown section in the post sidebar. 241 252 4. A single document. 242 253 5. List of documents. -
ultimate-markdown/trunk/shared/class-daextulma-shared.php
r3424623 r3477447 33 33 34 34 $this->data['slug'] = 'daextulma'; 35 $this->data['ver'] = '1.2 3';35 $this->data['ver'] = '1.24'; 36 36 $this->data['dir'] = substr( plugin_dir_path( __FILE__ ), 0, - 7 ); 37 37 $this->data['url'] = substr( plugin_dir_url( __FILE__ ), 0, - 7 ); … … 1172 1172 } 1173 1173 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 1174 1206 }
Note: See TracChangeset
for help on using the changeset viewer.