initial
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
/**
|
||||
* Permalink Manager CSS
|
||||
*/
|
||||
#permalink-manager #plugin-name-heading .author-link{color:#959595;font-size:60%;text-decoration:none}
|
||||
#permalink-manager #permalink-manager-tab-nav .section_upgrade,#permalink-manager #permalink-manager-tab-nav .section_support{background:#555;border-color:#555;color:#fff}
|
||||
#permalink-manager h4{font-size:18px;margin-bottom:10px}
|
||||
#permalink-manager h5{font-size:15px;margin-bottom:10px}
|
||||
#permalink-manager .small{display:block;font-weight:400;color:#888;font-size:80%}
|
||||
#permalink-manager .mute{color:#888}
|
||||
#permalink-manager .settings-select{min-width:200px}
|
||||
#permalink-manager .fixed-table{max-width:100%;table-layout:fixed}
|
||||
#permalink-manager .margin-top{margin-top:15px}
|
||||
#permalink-manager .help_tooltip{text-decoration:none;color:#959595}
|
||||
#permalink-manager .small-select{height:24px;line-height:22px;padding:0 8px 1px;font-size:11px}
|
||||
#permalink-manager .lead{font-size:125%}
|
||||
#permalink-manager .licence-info{font-weight:bold}
|
||||
#permalink-manager p label{font-size:13px;color:#555d66;font-weight:bold}
|
||||
#permalink-manager a:focus{box-shadow:none}
|
||||
|
||||
#permalink-manager .woocommerce-icon:before{font-family:"WooCommerce";font-style:normal}
|
||||
#permalink-manager .woocommerce-cart:before{content:"\e01d"}
|
||||
#permalink-manager .woocommerce-logo:before{content:"\e03d"}
|
||||
|
||||
#permalink-manager .subsubsub{display:block;width:100%;overflow:hidden;margin-bottom:25px}
|
||||
#permalink-manager .subsubsub li:before{content:" | "}
|
||||
#permalink-manager .subsubsub li:first-child:before{content:"";color:#aaa}
|
||||
#permalink-manager .subsubsub li .dashicons,#permalink-manager .subsubsub li .woocommerce-logo{font-size:100%;line-height:200%;height:auto;width:auto}
|
||||
#permalink-manager .single-section{clear:both}
|
||||
#permalink-manager .tablenav{margin:15px 0;height:auto}
|
||||
#permalink-manager .tablenav.top{margin-top:0}
|
||||
#permalink-manager .tablenav .actions{padding:0;overflow:visible}
|
||||
#permalink-manager .tablenav #months-filter{margin-left:10px}
|
||||
#permalink-manager .search-box{margin:0 0 0 1em}
|
||||
#permalink-manager th#count a{display:inline-block}
|
||||
#permalink-manager .post_permalink{margin-top:5px;display:block}
|
||||
#permalink-manager .post_permalink a,#permalink-manager .post_permalink .dashicons,#permalink-manager .uri_locked .dashicons{font-size:13px;color:#aaa;line-height:1.5em;height:auto;width:auto}
|
||||
#permalink-manager .post_permalink .dashicons,#permalink-manager .uri_locked .dashicons{font-size:1em}
|
||||
#permalink-manager .column-count,#permalink-manager .column-post_lang{width:1%}
|
||||
#permalink-manager .column-count,#permalink-manager .column-post_lang,#permalink-manager th#count{text-align:right}
|
||||
#permalink-manager .column-item_uri .uri_locked,#permalink-manager .column-item_uri .duplicated_uri_alert{font-weight:bold;margin-top:5px;font-size:80%}
|
||||
#permalink-manager .extra-info span{white-space:nowrap}
|
||||
|
||||
#permalink-manager .info{box-shadow:0 1px 1px 0 rgba(0,0,0,.1);display:block;overflow:hidden;clear:both;border-left:4px solid #dc3232;}
|
||||
#permalink-manager .alert,#permalink-manager .info{line-height:19px;padding:11px 15px;margin:15px 0}
|
||||
#permalink-manager .alert p,#permalink-manager .info p{margin-top:0;line-height:200%}
|
||||
#permalink-manager .alert ul,#permalink-manager .alert ol{margin-top:0;margin-bottom:0}
|
||||
#permalink-manager .alert p:last-of-type,#permalink-manager .alert li:last-of-type,#permalink-manager .info p:last-of-type{margin-bottom:0}
|
||||
#permalink-manager .warning{background:#dc3232}
|
||||
#permalink-manager .warning,#permalink-manager .warning a{color:#fff}
|
||||
#permalink-manager .info{background:#f9f9f9}
|
||||
/*#permalink-manager .section-notes,#permalink-manager .short-pre,#permalink-manager .short-textarea{padding:15px;font-size:13px;margin-top:15px;line-height:20px;background:#e5e5e5;border:1px solid #ccc;color:#555}
|
||||
#permalink-manager .section-notes a,#permalink-manager .section-notes h3{color:#111}
|
||||
#permalink-manager .section-notes h3,#permalink-manager .section-notes h4{margin-top:0}*/
|
||||
#permalink-manager .section-notes h4{font-size:14px}
|
||||
#permalink-manager .section-notes code{font-size:11px}
|
||||
#permalink-manager .section-notes ol{margin-top:0;margin-bottom:0}
|
||||
#permalink-manager .section-notes ol li:last-of-type{margin-bottom:0}
|
||||
#permalink-manager .short-pre,#permalink-manager .short-textarea{height:150px;overflow:auto;max-width:100%;display:block}
|
||||
#permalink-manager .structure-tags-list{margin-top:15px}
|
||||
#permalink-manager .duplicated_uri_alert,.permalink-manager .duplicated_uri_alert{display:block;font-weight:bold;font-size:90%;margin-top:8px;color:#dc3232}
|
||||
|
||||
#permalink-manager .settings-tabs,#permalink-manager .settings-tabs form,#permalink-manager .settings-tabs form > div{clear:both;overflow:hidden}
|
||||
#permalink-manager .settings-tabs .subsubsub{margin-bottom:0}
|
||||
#permalink-manager .settings-tabs form > div{display:none}
|
||||
#permalink-manager .settings-tabs form > div.active-tab{display:block}
|
||||
|
||||
#permalink-manager .checkbox_actions{padding-top:10px;border-top:1px solid #ddd}
|
||||
#permalink-manager .extra-links,.permalink-manager-screen-options .extra-links{margin-top:5px;font-size:12px}
|
||||
#permalink-manager .extra-links a,.permalink-manager-screen-options .extra-links a{color:#666;display:inline-block;text-decoration:none}
|
||||
#permalink-manager .extra-links a:before,.permalink-manager-screen-options .extra-links a:before{content:" | "}
|
||||
#permalink-manager .extra-links a:first-child:before,.permalink-manager-screen-options .extra-links a:first-child:before{content:""}
|
||||
.permalink-manager-screen-options{margin-bottom:15px}
|
||||
#permalink-manager .checkboxes{margin-left:-15px;margin-right:15px;overflow:hidden;display:block}
|
||||
#permalink-manager .checkboxes > label{display:inline-block;width:33%;float:left;padding:0 15px 5px;box-sizing:border-box;overflow:hidden}
|
||||
#permalink-manager .checkboxes > label:nth-of-type(3n+1){clear:both}
|
||||
#permalink-manager .checkboxes > p{font-weight:bold;margin-left:15px;display:block;clear:both;margin-bottom:5px}
|
||||
#permalink-manager .checkboxes > label + p{padding-top:15px}
|
||||
#permalink-manager .field-description{font-size:12px}
|
||||
#permalink-manager .appended-row td{padding-left:0;padding-right:0}
|
||||
#permalink-manager #tools{margin:0 -15px;padding:0 15px 15px}
|
||||
#permalink-manager #tools select{min-width:60%}
|
||||
#permalink-manager fieldset label{margin-bottom:0 !important}
|
||||
|
||||
.structure-tags-list{display:block;line-height:175%}
|
||||
.structure-tags-list pre{white-space:normal;line-height:2em;word-break:keep-all;margin:0}
|
||||
.structure-tags-list .notice{padding:6px 12px;margin:1em 0;display:block}
|
||||
.structure-tags-list .permastruct-tag-container{display:flex;flex-direction:row;gap:20px}
|
||||
.structure-tags-list .permastruct-tag-container > *{flex-basis:400px}
|
||||
.structure-tags-list .permastruct-tag-container .permastruct-tag-buttons{display:inline-flex;flex-wrap:wrap;gap:10px}
|
||||
.structure-tags-list .permastruct-tag-container p:first-of-type{margin-top:0;padding-top:0!important}
|
||||
|
||||
#permalink-manager .updated-slugs-table .row-title{max-width:400px}
|
||||
|
||||
/**
|
||||
* Columns
|
||||
*/
|
||||
#permalink-manager .columns-container{overflow:hidden;margin-left:-15px;margin-right:-15px;clear:both;display:block}
|
||||
#permalink-manager .columns-container > *{float:left;padding-left:15px;padding-right:15px;box-sizing:border-box;-webkit-box-sizing:border-box;overflow:hidden;display:block}
|
||||
#permalink-manager .columns-container span a{color:#aaa}
|
||||
#permalink-manager .columns-container .column-1_2,#permalink-manager .columns-container .column-2_4{width:50%}
|
||||
#permalink-manager .columns-container .column-1_3{width:33.33%}
|
||||
#permalink-manager .columns-container .column-1_3:nth-of-type(3n+1){clear:left}
|
||||
#permalink-manager .columns-container .column-2_3{width:66.67%}
|
||||
#permalink-manager .columns-container .column-1_4{width:25%}
|
||||
#permalink-manager .columns-container .column-3_4{width:75%}
|
||||
|
||||
#slugdiv #post_name{width:100%}
|
||||
|
||||
/**
|
||||
* Edit URI & Duplicate box
|
||||
*/
|
||||
.permalink-manager-edit-uri-box{margin:10px -10px}
|
||||
.permalink-manager-edit-uri-box h2{border-bottom:1px solid #eee}
|
||||
.permalink-manager-edit-uri-box .inside{padding:0 10px 10px 10px;margin-bottom:0}
|
||||
.permalink-manager-edit-uri-box .inside > div{font-size:13px;line-height:1.5;margin:1em 0}
|
||||
.permalink-manager-edit-uri-box .inside > div:last-child,.permalink-manager-edit-uri-box .inside p:last-child{margin-bottom:0}
|
||||
.permalink-manager-edit-uri-box .strong{display:block;font-weight:bold;margin-bottom:5px}
|
||||
.permalink-manager-edit-uri-box .toggle-indicator:before{content:"\f142";display:inline-block;font:400 20px/1 dashicons}
|
||||
.permalink-manager-edit-uri-box .columns-container{margin-left:-10px!important;margin-right:-10px!important}
|
||||
.permalink-manager-edit-uri-box .columns-container > *{padding-left:10px;padding-right:10px}
|
||||
.permalink-manager-edit-uri-box .close-button{float:right;width:36px;height:36px;padding:0;cursor:pointer;display:block}
|
||||
.permalink-manager-edit-uri-box .close-icon{margin-top:4px;-webkit-border-radius:50%;border-radius:50%;text-indent:-1px;color:#72777c;line-height:36px;display:block;text-align:center}
|
||||
.permalink-manager-edit-uri-box .close-icon:before{content:"\f158";display:inline-block;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}
|
||||
.permalink-manager-edit-uri-box .uri_locked{color:#aaa;margin-top:8px;font-size:80%}
|
||||
.permalink-manager-edit-uri-box > .uri_locked{font-size:1em;padding:0 10px;color:inherit}
|
||||
.permalink-manager-edit-uri-box .default-permalink-row,.permalink-manager-edit-uri-box .redirects-row{border-top:1px solid #eee;padding-top:15px}
|
||||
.permalink-manager-edit-uri-box .default-permalink-row,.permalink-manager-edit-uri-box .default-permastruct-row,.permalink-manager-edit-uri-box .redirects-row{color:#aaa;font-size:90%}
|
||||
.permalink-manager-edit-uri-box .notice{margin-left:0;margin-right:0}
|
||||
.permalink-manager-edit-uri-box .notice p{margin:0!important}
|
||||
|
||||
#permalink-manager .restore-default{display:inline-block;border-radius:0;color:#959595;text-decoration:none}
|
||||
#permalink-manager .restore-default{text-align:right;width:100%}
|
||||
#permalink-manager .widefat,#permalink-manager #redirect-panel-inside,#permalink-manager #redirect-panel-inside table{width:100%!important;max-width:none;box-sizing:border-box}
|
||||
#permalink-manager textarea.widefat,#permalink-manager #redirect-panel-inside table{height:auto}
|
||||
#permalink-manager .heading,#permalink-manager .heading a{margin:0;line-height:1.4;font-weight:600;text-decoration:none;color:#777}
|
||||
#permalink-manager.permalink-manager-edit-term .permalink-manager-edit-uri-box{display:block!important;margin:0}
|
||||
#permalink-manager.permalink-manager-edit-term .permalink-manager-edit-uri-box h2,.permalink-manager.postbox .heading{font-size:14px!important;padding:8px 12px;margin:0;line-height:1.4}
|
||||
#permalink-manager.permalink-manager-edit-term .permalink-manager-edit-uri-box .close-button,#permalink-manager.permalink-manager-edit-term #permalink-manager-toggle{display:none}
|
||||
|
||||
#permalink-manager .permalink-manager-duplicate-box table{width:100%;color:#aaa}
|
||||
#permalink-manager .permalink-manager-duplicate-box table tr td{border-top:1px solid #eee}
|
||||
#permalink-manager .permalink-manager-duplicate-box table tr:first-child td{border-top:0}
|
||||
#permalink-manager .permalink-manager-duplicate-box table td{font-size:12px;line-height:1.5em;padding:8px 12px}
|
||||
#permalink-manager .permalink-manager-duplicate-box table tr td:first-child{width:60%}
|
||||
#permalink-manager .permalink-manager-duplicate-box table tr td:last-child{text-align:right}
|
||||
#permalink-manager .permalink-manager-duplicate-box .actions a{text-decoration:none}
|
||||
#permalink-manager .permalink-manager-duplicate-box .remove-duplicate-link{color:#a00}
|
||||
|
||||
.permalink-manager.postbox .heading{border-bottom:3px double #eee}
|
||||
.permalink-manager.postbox a{color:#444;text-decoration:none;white-space:nowrap}
|
||||
|
||||
.edit-post-meta-boxes-area #permalink-manager.postbox .inside{padding:0 24px 24px;background:none}
|
||||
#permalink-manager .permalink-manager-gutenberg .uri_locked{margin-top:1em}
|
||||
#permalink-manager .permalink-manager-gutenberg > div{margin-top:15px}
|
||||
#permalink-manager .permalink-manager-gutenberg .default-permalink-row > *{width:100%;float:none}
|
||||
#permalink-manager .permalink-manager-gutenberg .restore-default{text-align:left;margin-top:15px}
|
||||
#permalink-manager .permalink-manager-gutenberg .redirects-row{padding-top:15px}
|
||||
#permalink-manager .permalink-manager-gutenberg .redirects-panel .heading{background:#eee;padding:15px 10px;margin-bottom:-15px;width:100%;display:block;font-size:110%}
|
||||
#permalink-manager #redirect-panel-inside, #permalink-manager #redirect-panel-inside p{margin-top:15px}
|
||||
#permalink-manager .redirects-panel-description *{font-size:11px}
|
||||
|
||||
/**
|
||||
* Redirect panel
|
||||
*/
|
||||
#permalink-manager #redirect-panel-inside{display:none}
|
||||
#permalink-manager #redirect-panel-inside,#permalink-manager #redirect-panel-inside p{margin-top:15px;height:auto}
|
||||
#permalink-manager #redirect-panel-inside table{margin-bottom:10px;margin-top:-5px}
|
||||
#permalink-manager #redirect-panel-inside table td{padding:5px 0;width:100%}
|
||||
#permalink-manager #redirect-panel-inside table td a{text-decoration:none;text-align:right}
|
||||
#permalink-manager #redirect-panel-inside .single-section{margin-left:-10px;margin-right:-10px;padding:10px;border-top:1px dashed #eee}
|
||||
#permalink-manager #redirect-panel-inside .single-section:last-of-type{padding-bottom:0}
|
||||
#permalink-manager #redirect-panel-inside .single-section:first-of-type{padding-top:0;border:0}
|
||||
#permalink-manager #redirect-panel-inside .single-section > p:first-of-type{margin-top:0}
|
||||
.permalink-manager .sample-row{display:none}
|
||||
.permalink-manager .redirects-panel-description{margin-bottom:10px}
|
||||
.permalink-manager .redirects-panel-description *{font-size:12px}
|
||||
|
||||
/**
|
||||
* Coupon panel
|
||||
*/
|
||||
#permalink-manager-coupon-url > p:last-of-type{font-size:13px}
|
||||
|
||||
/**
|
||||
* Tippy.js custom theme
|
||||
*/
|
||||
.tippy-tooltip.tippy-pm-theme{text-align:left;font-size:13px}
|
||||
|
||||
/**
|
||||
* Permastructures
|
||||
*/
|
||||
#permalink-manager #permastructs{margin-top:1em}
|
||||
#permalink-manager .permastruct-row .permastruct-settings{display:none}
|
||||
#permalink-manager .permastruct-row .permastruct-settings .default-permastruct-row{margin-top:15px}
|
||||
#permalink-manager .permastruct-row .permastruct-settings .single_checkbox label{font-weight:400}
|
||||
#permalink-manager .permastruct-row h4{font-size:14px}
|
||||
#permalink-manager .permastruct-row p{font-size:13px}
|
||||
#permalink-manager .permastruct-row td label{font-weight:600;margin-top:15px!important;font-size:13px;margin-bottom:5px!important;display:block;clear:both}
|
||||
|
||||
#permalink-manager .permastruct-row .permastruct-container{display:flex;flex-direction:row;justify-content:flex-start;gap:15px;flex-wrap:wrap}
|
||||
#permalink-manager .permastruct-row .permastruct-field-container{display:flex;align-items:center;gap:5px;flex-wrap:wrap;flex-grow:1}
|
||||
#permalink-manager .permastruct-row .permastruct-field-container span:last-child{flex:1 0 auto;min-width:35%}
|
||||
#permalink-manager .permastruct-row .permastruct-field-container span:last-child input{width:100%}
|
||||
#permalink-manager .permastruct-row .permastruct-field:disabled{cursor:not-allowed}
|
||||
#permalink-manager .permastruct-row .permastruct-buttons{margin:0;font-size:13px;min-width:fit-content;display:flex;gap:10px}
|
||||
#permalink-manager .permastruct-row .permastruct-buttons > span{height:100%;display:flex}
|
||||
#permalink-manager .permastruct-row .permastruct-buttons a{border-color:#ddd;padding:0 8px;font-size:inherit;align-content:center}
|
||||
#permalink-manager .permastruct-row .permastruct-buttons a .dashicons{font-size:initial;line-height:1em;height:1em;vertical-align:middle}
|
||||
|
||||
/**
|
||||
* TagEditor custom theme & "Stop Words"
|
||||
*/
|
||||
#permalink-manager .words-editor{font-size:90%;height:400px;overflow-y:auto;border:1px solid #ddd;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.07);box-shadow:inset 0 1px 2px rgba(0,0,0,.07);background-color:#fff;color:#32373c;outline:0;-webkit-transition:50ms border-color ease-in-out;transition:50ms border-color ease-in-out;}
|
||||
#permalink-manager .words-editor .tag{background:#eee}
|
||||
#permalink-manager .words-editor .tag a{color:#000}
|
||||
#permalink-manager .stop-words-buttons{width:100%}
|
||||
#permalink-manager .stop-words-buttons tr > td:first-child{padding-left:0;width:50%}
|
||||
#permalink-manager .stop-words-buttons tr > td:last-child{padding-right:0}
|
||||
|
||||
/**
|
||||
* Breakpoints
|
||||
*/
|
||||
@media only screen and (min-width: 992px) {
|
||||
#permalink-manager #permalink-manager-tab-nav .section_debug,#permalink-manager #permalink-manager-tab-nav .section_support{float:right}
|
||||
#permalink-manager #permalink-manager-tab-nav .section_upgrade{margin-left:50px}
|
||||
|
||||
#permalink-manager .column-item_uri{width:600px;max-width:100%}
|
||||
#permalink-manager .column-item_uri input{width:100%}
|
||||
}
|
||||
@media only screen and (max-width: 782px) {
|
||||
#permalink-manager .columns-container .column-1_2,#permalink-manager .columns-container .column-1_3,#permalink-manager .columns-container .column-2_3{width:100%}
|
||||
#permalink-manager .permalink-manager-duplicate-box table tr td:first-child{width:40%}
|
||||
}
|
||||
@@ -0,0 +1,694 @@
|
||||
jQuery(document).ready(function () {
|
||||
|
||||
/**
|
||||
* "(Un)select all" checkboxes
|
||||
*/
|
||||
var checkbox_actions = ['select_all', 'unselect_all'];
|
||||
checkbox_actions.forEach(function (element) {
|
||||
jQuery(document).on('click', '#permalink-manager .' + element, function () {
|
||||
jQuery(this).parents('.field-container').find('.checkboxes input[type="checkbox"]').each(function () {
|
||||
var action = (element === 'select_all');
|
||||
jQuery(this).prop('checked', action);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
jQuery('#permalink-manager .checkboxes label, #permalink-manager .single_checkbox label').not('input').on('click', function (ev) {
|
||||
var input = jQuery(this).find("input");
|
||||
if (!jQuery(ev.target).is("input")) {
|
||||
input.prop('checked', !(input.prop("checked")));
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Confirm action
|
||||
*/
|
||||
jQuery('.pm-confirm-action').on('click', function () {
|
||||
return confirm(permalink_manager.confirm);
|
||||
});
|
||||
|
||||
jQuery('#permalink-manager #uri_editor form input[name="s"]').on('keydown keypress keyup', function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
jQuery('#permalink-manager #search-submit').trigger('click');
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Filter by content types in "Tools"
|
||||
*/
|
||||
jQuery('#permalink-manager *[data-field="content_type"] select').on('change', function () {
|
||||
var content_type = jQuery(this).val();
|
||||
if (content_type == 'post_types') {
|
||||
jQuery(this).parents('.form-table').find('*[data-field="post_types"],*[data-field="post_statuses"]').removeClass('hidden');
|
||||
jQuery(this).parents('.form-table').find('*[data-field="taxonomies"]').addClass('hidden');
|
||||
} else {
|
||||
jQuery(this).parents('.form-table').find('*[data-field="post_types"],*[data-field="post_statuses"]').addClass('hidden');
|
||||
jQuery(this).parents('.form-table').find('*[data-field="taxonomies"]').removeClass('hidden');
|
||||
}
|
||||
}).trigger("change");
|
||||
|
||||
/**
|
||||
* Toggle "Edit URI" box
|
||||
*/
|
||||
jQuery('#wpwrap').on('click', '#permalink-manager-toggle, .permalink-manager-edit-uri-box .close-button', function () {
|
||||
jQuery('.permalink-manager-edit-uri-box').slideToggle();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Toggle "Edit Redirects" box
|
||||
*/
|
||||
jQuery('#permalink-manager').on('click', '#toggle-redirect-panel', function () {
|
||||
jQuery('#redirect-panel-inside').slideToggle();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('#permalink-manager').on('click', '.permalink-manager.redirects-panel #permalink-manager-new-redirect', function () {
|
||||
// Find the table
|
||||
var table = jQuery(this).parents('.redirects-panel').find('table');
|
||||
|
||||
// Copy the row from the sample
|
||||
var new_row = jQuery(this).parents('.redirects-panel').find('.sample-row').clone().removeClass('sample-row');
|
||||
|
||||
// Adjust the array key
|
||||
var last_key = jQuery(table).find("tr:last-of-type input[data-index]").data("index") + 1;
|
||||
jQuery("input[data-index]", new_row).attr("data-index", last_key).attr("name", function () {
|
||||
return jQuery(this).attr("name") + "[" + last_key + "]"
|
||||
});
|
||||
|
||||
// Append the new row
|
||||
jQuery(table).append(new_row);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('#permalink-manager').on('click', '.remove-redirect', function () {
|
||||
jQuery(this).closest('tr').remove();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Synchronize "Edit URI" input field with the sample permalink
|
||||
*/
|
||||
var custom_uri_input = jQuery('.permalink-manager-edit-uri-box input[name="custom_uri"]');
|
||||
jQuery(custom_uri_input).on('keyup change', function () {
|
||||
jQuery('.sample-permalink-span .editable').text(jQuery(this).val());
|
||||
});
|
||||
|
||||
/**
|
||||
* Synchronize "Coupon URI" input field with the final permalink
|
||||
*/
|
||||
jQuery('#permalink-manager-coupon-url input[name="custom_uri"]').on('keyup change', function () {
|
||||
var uri = jQuery(this).val();
|
||||
jQuery('#permalink-manager-coupon-url code span').text(uri);
|
||||
|
||||
if (!uri) {
|
||||
jQuery('#permalink-manager-coupon-url .coupon-full-url').addClass("hidden");
|
||||
} else {
|
||||
jQuery('#permalink-manager-coupon-url .coupon-full-url').removeClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
function permalink_manager_duplicate_check(custom_uri_input, nonce) {
|
||||
// Set default values
|
||||
custom_uri_input = typeof custom_uri_input !== 'undefined' ? custom_uri_input : false;
|
||||
|
||||
var all_custom_uris_values = {};
|
||||
|
||||
if (custom_uri_input) {
|
||||
var custom_uri = jQuery(custom_uri_input).val();
|
||||
var element_id = jQuery(custom_uri_input).attr("data-element-id");
|
||||
|
||||
all_custom_uris_values[element_id] = custom_uri;
|
||||
} else {
|
||||
jQuery('.custom_uri').each(function (i, obj) {
|
||||
var field_name = jQuery(obj).attr('data-element-id');
|
||||
all_custom_uris_values[field_name] = jQuery(obj).val();
|
||||
});
|
||||
}
|
||||
|
||||
if (all_custom_uris_values) {
|
||||
jQuery.ajax(permalink_manager.ajax_url, {
|
||||
type: 'POST',
|
||||
async: true,
|
||||
data: {
|
||||
action: 'pm_detect_duplicates',
|
||||
nonce: nonce,
|
||||
custom_uris: all_custom_uris_values
|
||||
},
|
||||
success: function (data) {
|
||||
if (typeof data === 'object' && data !== null) {
|
||||
// Loop through results
|
||||
jQuery.each(data, function (key, is_duplicate) {
|
||||
var alert_container = jQuery('.custom_uri[data-element-id="' + key + '"]').parents('.custom_uri_container').find('.duplicated_uri_alert');
|
||||
|
||||
if (is_duplicate) {
|
||||
jQuery(alert_container).text(is_duplicate);
|
||||
} else {
|
||||
jQuery(alert_container).empty();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a single custom URI is not duplicated
|
||||
*/
|
||||
var custom_uri_check_timeout = null;
|
||||
jQuery('.custom_uri_container input[name="custom_uri"], .custom_uri_container input.custom_uri').each(function () {
|
||||
var input = this;
|
||||
|
||||
jQuery(this).on('keyup change', function () {
|
||||
clearTimeout(custom_uri_check_timeout);
|
||||
|
||||
// Wait until user finishes typing
|
||||
custom_uri_check_timeout = setTimeout(function () {
|
||||
permalink_manager_duplicate_check(input);
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if any of displayed custom URIs is not duplicated
|
||||
*/
|
||||
if (jQuery('#uri_editor .custom_uri').length > 0) {
|
||||
let uri_editor_nonce = jQuery('#uri_editor #uri_editor_nonce').val();
|
||||
permalink_manager_duplicate_check(false, uri_editor_nonce);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable "Edit URI" input if URI should be updated automatically
|
||||
*/
|
||||
jQuery('#permalink-manager').on('change', 'select[name="auto_update_uri"]', function () {
|
||||
var selected = jQuery(this).find('option:selected');
|
||||
var auto_update_status = jQuery(selected).data('readonly');
|
||||
var container = jQuery(this).parents('#permalink-manager');
|
||||
|
||||
if (auto_update_status == 1 || auto_update_status == 2) {
|
||||
jQuery(container).find('input[name="custom_uri"]').attr("readonly", true);
|
||||
jQuery(container).find('.uri_locked').removeClass("hidden");
|
||||
} else {
|
||||
jQuery(container).find('input[name="custom_uri"]').removeAttr("readonly", true);
|
||||
jQuery(container).find('.uri_locked').addClass("hidden");
|
||||
}
|
||||
});
|
||||
jQuery('select[name="auto_update_uri"]').trigger("change");
|
||||
|
||||
/**
|
||||
* Restore "Default URI"
|
||||
*/
|
||||
jQuery('#permalink-manager').on('click', '.restore-default', function () {
|
||||
// Find all input fields within the relevant container
|
||||
var inputs = jQuery(this).parents('.field-container, .permalink-manager-edit-uri-box, #permalink-manager .inside').find('input.custom_uri, .permastruct-field');
|
||||
|
||||
// Iterate over each input element
|
||||
inputs.each(function () {
|
||||
var input = jQuery(this);
|
||||
var default_uri = input.attr('data-default'); // Get the default value for this specific input
|
||||
|
||||
// Set the default value and trigger the 'keyup' event
|
||||
input.val(default_uri).trigger('keyup');
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Display additional permastructure settings
|
||||
*/
|
||||
jQuery('#permalink-manager').on('click', '.permastruct-buttons a.extra-settings', function () {
|
||||
jQuery(this).parents('.permastruct-row').find('.permastruct-settings').slideToggle();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Copy Permastructure tag to clipboard
|
||||
*/
|
||||
jQuery('.structure-tags-list .permastruct-tag-container .permastruct-tag-buttons button').on('click', async function () {
|
||||
const button = jQuery(this);
|
||||
const textToCopy = button.text().trim(); // Get button text
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(textToCopy); // Copy text to clipboard
|
||||
button.text('Copied!').prop('disabled', true); // Provide feedback
|
||||
|
||||
setTimeout(() => {
|
||||
button.text(button.data('original-text')).prop('disabled', false);
|
||||
}, 1000);
|
||||
} catch (err) {
|
||||
console.error('Clipboard copy failed:', err);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Control the settings tabs
|
||||
*/
|
||||
jQuery('#permalink-manager').on('click', '.settings-tabs .subsubsub a', function () {
|
||||
var tab_id = jQuery(this).attr('data-tab');
|
||||
|
||||
pm_load_settings_tab(tab_id);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (jQuery('#permalink-manager .settings-tabs').length > 0) {
|
||||
var tab_id = window.location.hash.substring(1);
|
||||
|
||||
if (tab_id) {
|
||||
pm_load_settings_tab(tab_id);
|
||||
}
|
||||
}
|
||||
|
||||
function pm_load_settings_tab(tab_id) {
|
||||
var settings_container = jQuery('#permalink-manager .settings-tabs');
|
||||
var new_tab = jQuery(settings_container).find('.subsubsub a[data-tab=' + tab_id + ']');
|
||||
|
||||
if (jQuery(new_tab).length > 0) {
|
||||
jQuery(settings_container).find('.subsubsub a').removeClass('current');
|
||||
jQuery(new_tab).addClass('current');
|
||||
|
||||
jQuery(settings_container).find('form > div').hide().removeClass('active-tab');
|
||||
jQuery(settings_container).find('form > div#pm_' + tab_id).show().addClass('active-tab');
|
||||
|
||||
jQuery(settings_container).find('form input[name="pm_active_tab"]').val(tab_id);
|
||||
|
||||
// Change the hash in the URL
|
||||
if (tab_id) {
|
||||
if (history.pushState) {
|
||||
history.pushState(null, null, "#" + tab_id);
|
||||
} else {
|
||||
window.location.hash = tab_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditional fields in Permalink Manager settings
|
||||
*/
|
||||
jQuery('#permalink-manager .settings-tabs #extra_redirects input[type="checkbox"]').on('change', function () {
|
||||
var is_checked = jQuery(this).is(':checked');
|
||||
var rel_field_container = jQuery('#permalink-manager .settings-tabs #setup_redirects');
|
||||
|
||||
if (is_checked == true) {
|
||||
rel_field_container.removeClass('hidden');
|
||||
} else {
|
||||
rel_field_container.addClass('hidden');
|
||||
}
|
||||
}).trigger("change");
|
||||
|
||||
/**
|
||||
* Hide global admin notices
|
||||
*/
|
||||
jQuery(document).on('click', '.permalink-manager-notice.is-dismissible .notice-dismiss', function () {
|
||||
var alert_id = jQuery(this).closest('.permalink-manager-notice').data('alert_id');
|
||||
|
||||
jQuery.ajax(permalink_manager.ajax_url, {
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'pm_dismissed_notice_handler',
|
||||
alert_id: alert_id,
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Save permalinks from Gutenberg with AJAX
|
||||
*/
|
||||
var pm_container = jQuery('#permalink-manager.postbox');
|
||||
var pm_container_disabled = false;
|
||||
var pm_container_reloading = false;
|
||||
jQuery('#permalink-manager .save-row.hidden').removeClass('hidden');
|
||||
jQuery('#permalink-manager').on('click', '#permalink-manager-save-button', pm_gutenberg_save_uri);
|
||||
|
||||
function pm_gutenberg_loading_overlay(show = true) {
|
||||
if (show && !pm_container_disabled) {
|
||||
pm_container_disabled = true;
|
||||
|
||||
jQuery(pm_container).LoadingOverlay('show', {
|
||||
background: 'rgba(0, 0, 0, 0.1)',
|
||||
});
|
||||
} else if (!show && pm_container_disabled) {
|
||||
pm_container_disabled = false;
|
||||
|
||||
jQuery(pm_container).LoadingOverlay('hide', true);
|
||||
}
|
||||
}
|
||||
|
||||
function pm_gutenberg_reload() {
|
||||
var pm_post_id = jQuery('input[name="permalink-manager-edit-uri-element-id"]').val();
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'GET',
|
||||
url: permalink_manager.ajax_url + '?action=pm_get_uri_editor',
|
||||
data: {
|
||||
'post_id': pm_post_id
|
||||
},
|
||||
beforeSend: pm_gutenberg_loading_overlay,
|
||||
success: function (html) {
|
||||
jQuery(pm_container).find('.permalink-manager-gutenberg').replaceWith(html);
|
||||
pm_gutenberg_loading_overlay(false);
|
||||
|
||||
jQuery(pm_container).find('select[name="auto_update_uri"]').trigger("change");
|
||||
pm_help_tooltips();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function pm_gutenberg_save_uri() {
|
||||
var pm_fields = jQuery(pm_container).find("input, select");
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: permalink_manager.ajax_url,
|
||||
async: true,
|
||||
data: jQuery(pm_fields).serialize() + '&action=pm_save_permalink',
|
||||
beforeSend: pm_gutenberg_loading_overlay,
|
||||
success: pm_gutenberg_reload
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the URI Editor in Gutenberg after the post is published or the title/slug is changed
|
||||
*/
|
||||
if (typeof wp !== 'undefined' && typeof wp.data !== 'undefined' && typeof wp.data.select !== 'undefined' && typeof wp.data.subscribe !== 'undefined' && wp.data.select('core/editor') != null && wp.data.select('core/edit-post') != null) {
|
||||
wp.data.subscribe(function () {
|
||||
try {
|
||||
var isSavingPost = wp.data.select('core/editor').isSavingPost();
|
||||
var isAutosavingPost = wp.data.select('core/editor').isAutosavingPost();
|
||||
var isSavingMetaBoxes = wp.data.select('core/edit-post').isSavingMetaBoxes();
|
||||
|
||||
// Disable URI Editor until it is reloaded
|
||||
if (isSavingPost && !isAutosavingPost) {
|
||||
pm_gutenberg_loading_overlay();
|
||||
}
|
||||
|
||||
// Reload URI Editor only after metaboxes are saved
|
||||
if (isSavingMetaBoxes) {
|
||||
pm_container_reloading = true;
|
||||
} else if (pm_container_reloading) {
|
||||
pm_container_reloading = false;
|
||||
|
||||
pm_gutenberg_reload();
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('Permalink Manager', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Help tooltips
|
||||
*/
|
||||
function pm_help_tooltips() {
|
||||
if (jQuery('#permalink-manager .help_tooltip').length > 0) {
|
||||
jQuery('#permalink-manager .help_tooltip').each(function () {
|
||||
var helpTooltip = this;
|
||||
|
||||
tippy(helpTooltip, {
|
||||
// placement: 'top-start',
|
||||
arrow: true,
|
||||
content: jQuery(helpTooltip).attr('title'),
|
||||
distance: 20
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pm_help_tooltips();
|
||||
|
||||
|
||||
/**
|
||||
* Check expiration date
|
||||
*/
|
||||
jQuery(document).on('click', '#pm_get_exp_date', function () {
|
||||
jQuery.ajax(permalink_manager.ajax_url, {
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'pm_get_exp_date',
|
||||
licence: {
|
||||
licence_key: jQuery('#permalink-manager #settings #licence_key input[type="text"]').val()
|
||||
}
|
||||
},
|
||||
beforeSend: function () {
|
||||
var spinner = '<img src="' + permalink_manager.spinners + '/wpspin_light-2x.gif" width="16" height="16">';
|
||||
jQuery('#permalink-manager .licence-info').html(spinner);
|
||||
},
|
||||
success: function (data) {
|
||||
jQuery('#permalink-manager .licence-info').html(data);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Bulk tools
|
||||
*/
|
||||
function pm_show_progress(elem, progress) {
|
||||
if (progress) {
|
||||
jQuery(elem).LoadingOverlay("text", progress + "%");
|
||||
} else {
|
||||
jQuery(elem).LoadingOverlay("show", {
|
||||
background: "rgba(0, 0, 0, 0.1)",
|
||||
text: '0%'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
jQuery('#permalink-manager #tools form.form-ajax').on('submit', function () {
|
||||
var total_iterations = updated_count = total = progress = 0;
|
||||
var iteration = 1;
|
||||
var data = jQuery(this).serialize() + '&action=pm_bulk_tools&iteration=' + iteration;
|
||||
|
||||
// Hide alert & results table
|
||||
jQuery('#permalink-manager .updated-slugs-table, .permalink-manager-notice.updated_slugs, #permalink-manager #updated-list').remove();
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: permalink_manager.ajax_url,
|
||||
data: data,
|
||||
beforeSend: function () {
|
||||
// Show progress overlay
|
||||
pm_show_progress("#permalink-manager #tools", progress);
|
||||
},
|
||||
success: function (data) {
|
||||
var table_dom = jQuery('#permalink-manager .updated-slugs-table');
|
||||
var ajax_request = this;
|
||||
|
||||
// The first AJAX request should return the total items & iterations count
|
||||
if (data.hasOwnProperty('total_iterations') && data.hasOwnProperty('total')) {
|
||||
total_iterations = parseInt(data.total_iterations);
|
||||
total = parseInt(data.total);
|
||||
|
||||
// If prior requests were handled with errors, remove those alerts
|
||||
jQuery('.permalink-manager-notice.updated_slugs.error').remove();
|
||||
|
||||
// Add the alert container with the status but do not display it yet
|
||||
if (data.hasOwnProperty('alert')) {
|
||||
jQuery('#plugin-name-heading').after(jQuery(data.alert).hide());
|
||||
}
|
||||
} // Check if the iteration and total count were correctly set in the first AJAX request
|
||||
else if (total_iterations === 0 || total === 0) {
|
||||
console.log('No items have been processed.');
|
||||
jQuery('#permalink-manager #tools').LoadingOverlay("hide", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Display the table
|
||||
if (data.hasOwnProperty('html')) {
|
||||
var table = jQuery(data.html);
|
||||
|
||||
if (table_dom.length == 0) {
|
||||
jQuery('#permalink-manager #tools').after(data.html);
|
||||
} else {
|
||||
jQuery(table_dom).append(jQuery(table).find('tbody').html());
|
||||
}
|
||||
}
|
||||
|
||||
// Increase updated count
|
||||
if (data.hasOwnProperty('updated_count')) {
|
||||
updated_count = updated_count + parseInt(data.updated_count);
|
||||
|
||||
jQuery('.permalink-manager-notice.updated_slugs .updated_count').text(updated_count);
|
||||
}
|
||||
|
||||
// Repeat the AJAX request for the next chunk of items
|
||||
if (iteration < total_iterations) {
|
||||
// Update the progress
|
||||
progress = Math.floor((iteration / total_iterations) * 100);
|
||||
console.log(iteration + "/" + total_iterations + " = " + progress + "%");
|
||||
|
||||
// Go to the next chunk
|
||||
iteration++;
|
||||
|
||||
// Change the iteration number in the AJAX data
|
||||
ajax_request.data = ajax_request.data.replace(/(&iteration=)([\d]+)/gm, "$1" + iteration);
|
||||
jQuery.ajax(ajax_request);
|
||||
} else {
|
||||
// Display the alert container and hide the loading overlay
|
||||
jQuery('.permalink-manager-notice.updated_slugs').fadeIn();
|
||||
jQuery('#permalink-manager #tools').LoadingOverlay("hide", true);
|
||||
|
||||
if (table_dom.length > 0) {
|
||||
jQuery('html, body').animate({
|
||||
scrollTop: table_dom.offset().top - 100
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// Reset progress & updated count
|
||||
progress = updated_count = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
error: function (xhr, status, error_data) {
|
||||
alert('There was a problem running this tool and the process could not be completed. You can find more details in browser\'s console log.');
|
||||
console.log('Status: ' + status);
|
||||
console.log('Please send the debug data to contact@permalinkmanager.pro:\n\n' + xhr.responseText);
|
||||
|
||||
jQuery('#permalink-manager #tools').LoadingOverlay("hide", true);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Stop-words
|
||||
*/
|
||||
var stop_words_input = '#permalink-manager .field-container textarea.stop_words';
|
||||
|
||||
if (jQuery(stop_words_input).length > 0) {
|
||||
var stop_words = new TIB(document.querySelector(stop_words_input), {
|
||||
alert: false,
|
||||
//escape: null,
|
||||
escape: [','],
|
||||
classes: ['tags words-editor', 'tag', 'tags-input', 'tags-output', 'tags-view'],
|
||||
});
|
||||
jQuery('.tags-output').hide();
|
||||
|
||||
// Force lowercase
|
||||
stop_words.filter = function (text) {
|
||||
return text.toLowerCase();
|
||||
};
|
||||
|
||||
// Remove all words
|
||||
jQuery('#permalink-manager .field-container .clear_all_words').on('click', function () {
|
||||
stop_words.reset();
|
||||
});
|
||||
|
||||
// Load stop-words list
|
||||
jQuery('#permalink-manager #load_stop_words_button').on('click', function () {
|
||||
var lang = jQuery(".load_stop_words option:selected").val();
|
||||
if (lang) {
|
||||
var json_url = permalink_manager.url + "/includes/vendor/stopwords-json/dist/" + lang + ".json";
|
||||
|
||||
// Load JSON with words list
|
||||
jQuery.getJSON(json_url, function (data) {
|
||||
var new_words = [];
|
||||
|
||||
jQuery.each(data, function (key, val) {
|
||||
new_words.push(val);
|
||||
});
|
||||
|
||||
stop_words.update(new_words);
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick Edit
|
||||
*/
|
||||
function pm_quick_edit(item, inlineEdit) {
|
||||
// Get the item ID and type
|
||||
let item_id = 0;
|
||||
let item_uri_id = '';
|
||||
let item_type = '';
|
||||
let item_row = '';
|
||||
|
||||
// Get the ID
|
||||
if (typeof (inlineEdit) == 'object') {
|
||||
item_id = parseInt(inlineEdit.getId(item));
|
||||
item_type = inlineEdit.type;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the edit row
|
||||
let edit_row = jQuery('#edit-' + item_id);
|
||||
|
||||
// Get the post/term row
|
||||
if (item_type === 'tag') {
|
||||
item_row = jQuery('#tag-' + item_id);
|
||||
item_uri_id = "tax-" + item_id;
|
||||
} else if (item_type === 'post' || item_type === 'page') {
|
||||
item_row = jQuery('#post-' + item_id);
|
||||
item_uri_id = item_id;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item_id !== 0) {
|
||||
// Get the row & "Custom URI" field
|
||||
let custom_uri_field = edit_row.find('.custom_uri');
|
||||
|
||||
// Prepare the Custom URI
|
||||
let custom_uri = item_row.find(".column-permalink-manager-col").text();
|
||||
|
||||
// Fill with the Custom URI
|
||||
custom_uri_field.val(custom_uri);
|
||||
|
||||
// Get auto-update settings
|
||||
let auto_update = item_row.find(".permalink-manager-col-uri").attr('data-disabled');
|
||||
|
||||
if (typeof auto_update !== "undefined" && (auto_update == 1 || auto_update == 2)) {
|
||||
if (auto_update == 1) {
|
||||
custom_uri_field.attr('readonly', 'readonly');
|
||||
} else if (auto_update == 2) {
|
||||
custom_uri_field.attr('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
|
||||
// Set the element ID
|
||||
edit_row.find('.permalink-manager-edit-uri-element-id').val(item_uri_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof inlineEditPost !== "undefined") {
|
||||
var inline_post_editor = inlineEditPost.edit;
|
||||
inlineEditPost.edit = function (id) {
|
||||
inline_post_editor.apply(this, arguments);
|
||||
|
||||
pm_quick_edit(id, this);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof inlineEditTax !== "undefined") {
|
||||
var inline_tax_editor = inlineEditTax.edit;
|
||||
inlineEditTax.edit = function (id) {
|
||||
inline_tax_editor.apply(this, arguments);
|
||||
|
||||
pm_quick_edit(id, this);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
/*var el = wp.element.createElement;
|
||||
var registerPlugin = wp.plugins.registerPlugin;
|
||||
var Text = wp.components.Text;
|
||||
var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
|
||||
|
||||
function PermalinkManagerURIEditor() {
|
||||
const post_ID = wp.data.select("core/editor").getCurrentPostId();
|
||||
|
||||
return el(
|
||||
PluginDocumentSettingPanel,
|
||||
{
|
||||
className: 'pm-urieditor',
|
||||
title: 'Permalink Manager',
|
||||
id: 'permalink-manager'
|
||||
},
|
||||
el( 'div',
|
||||
{ id: 'permalink-manager' },
|
||||
el( 'div',
|
||||
{ className: 'inside' },
|
||||
'-'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
registerPlugin( 'pm-urieditor', {
|
||||
icon: 'admin-links',
|
||||
render: PermalinkManagerURIEditor
|
||||
} );*/
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,144 @@
|
||||
(function(blocks, editor, element, components) {
|
||||
var el = element.createElement;
|
||||
var Button = components.Button;
|
||||
var ButtonGroup = components.ButtonGroup;
|
||||
var Modal = components.Modal;
|
||||
var withState = wp.compose.withState;
|
||||
|
||||
var ModalContent = function({ attributes, setAttributes }) {
|
||||
return (
|
||||
el(
|
||||
'div', {
|
||||
className: 'your-modal-class'
|
||||
},
|
||||
el('p', {}, 'Custom permalink:'),
|
||||
el('input', {
|
||||
type: 'text',
|
||||
value: attributes.customPermalink,
|
||||
onChange: function(event) {
|
||||
setAttributes({ customPermalink: event.target.value });
|
||||
}
|
||||
}),
|
||||
el('p', {}, 'Native slug:'),
|
||||
el('input', {
|
||||
type: 'text',
|
||||
value: attributes.nativeSlug,
|
||||
onChange: function(event) {
|
||||
setAttributes({ nativeSlug: event.target.value });
|
||||
}
|
||||
}),
|
||||
el(components.Button, {
|
||||
className: 'is-content-block',
|
||||
isDefault: true,
|
||||
onClick: function() { alert('Save'); }
|
||||
}, 'Save'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
var ModalButton = withState({
|
||||
isOpen: false
|
||||
})(function({ isOpen, setState, attributes, setAttributes }) {
|
||||
return (
|
||||
el('div', {
|
||||
className: 'block-editor-block-list__block wp-block is-content-block'
|
||||
},
|
||||
el(Button, {
|
||||
className: 'is-content-block',
|
||||
isDefault: true,
|
||||
onClick: function() {
|
||||
setState({
|
||||
isOpen: true
|
||||
});
|
||||
},
|
||||
}, 'Permalink Manager'),
|
||||
isOpen && el(Modal, {
|
||||
title: "Permalink Manager",
|
||||
onRequestClose: function() {
|
||||
setState({
|
||||
isOpen: false
|
||||
});
|
||||
},
|
||||
}, el(ModalContent, {
|
||||
attributes: attributes,
|
||||
setAttributes: setAttributes
|
||||
}))
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
blocks.registerBlockType('permalink-manager/woocommerce', {
|
||||
title: 'Permalink Manager',
|
||||
category: 'common',
|
||||
attributes: {
|
||||
customPermalink: {
|
||||
type: 'string',
|
||||
default: 'FGH'
|
||||
},
|
||||
nativeSlug: {
|
||||
type: 'string',
|
||||
default: 'IJK'
|
||||
}
|
||||
},
|
||||
edit: function(props) {
|
||||
return el(ModalButton, {
|
||||
isOpen: props.isOpen,
|
||||
setState: props.setState,
|
||||
attributes: props.attributes,
|
||||
setAttributes: props.setAttributes
|
||||
});
|
||||
},
|
||||
save: function() {
|
||||
// Trigger the function after the product is saved
|
||||
function triggerFunctionAfterSave() {
|
||||
// Your custom function logic here
|
||||
console.log('Product saved!');
|
||||
alert('Product saved!');
|
||||
}
|
||||
|
||||
// Add the event listener for 'save' event
|
||||
/*wp.data.dispatch('core/editor').addSaveHandler(function() {
|
||||
triggerFunctionAfterSave();
|
||||
});*/
|
||||
|
||||
return null;
|
||||
},
|
||||
});
|
||||
}(
|
||||
window.wp.blocks,
|
||||
window.wp.editor,
|
||||
window.wp.element,
|
||||
window.wp.components
|
||||
));
|
||||
|
||||
/*(function (hooks, metaBoxes) {
|
||||
var addFilter = hooks.addFilter;
|
||||
var applyFilters = hooks.applyFilters;
|
||||
var addAction = hooks.addAction;
|
||||
|
||||
// Hook into the wcSetPermalink action to update the permalink dynamically
|
||||
addAction('wcSetPermalink', 'myCustomAction', function (permalink, data) {
|
||||
// Get the updated permalink and modify it dynamically based on your requirements
|
||||
var updatedPermalink = applyFilters('myCustomPermalinkFilter', permalink, data);
|
||||
|
||||
return updatedPermalink;
|
||||
});
|
||||
|
||||
// Hook into the product title change event and update the permalink
|
||||
addFilter('woocommerce_product_title', 'myCustomProductTitleFilter', function (title, product) {
|
||||
// Update the permalink when the product title changes
|
||||
metaBoxes.updatePermalink(product);
|
||||
|
||||
return title;
|
||||
});
|
||||
|
||||
// Example: Modify the permalink based on the product title
|
||||
addFilter('myCustomPermalinkFilter', 'myCustomPermalinkFilter', function (permalink, data) {
|
||||
var productTitle = data.title;
|
||||
|
||||
// Modify the permalink dynamically based on the product title
|
||||
var modifiedPermalink = permalink + '-' + productTitle.toLowerCase().replace(/\s+/g, '-');
|
||||
|
||||
return modifiedPermalink;
|
||||
});
|
||||
})(wp.hooks, wc.metaBoxes);*/
|
||||
Reference in New Issue
Block a user