Commit inicial, se subio el proyecto

This commit is contained in:
Gabriel
2026-09-23 17:20:43 -06:00
commit 943dc06127
7470 changed files with 2641057 additions and 0 deletions
@@ -0,0 +1,67 @@
<template>
<div class="disable-media-pages">
<div class="disable-media-pages-toolbar">
<div class="disable-media-pages-toolbar__plugin-title">
<h1>{{ i18n.plugin_title }}</h1>
</div>
<div class="disable-media-pages-toolbar__tabs">
<button class="disable-media-pages-toolbar__tabs-tab"
v-on:click="currentTab = 'status'"
v-bind:class="{'disable-media-pages-toolbar__tabs-tab--active': currentTab === 'status'}"
>
{{ i18n.tab_status }}
</button>
<button class="disable-media-pages-toolbar__tabs-tab"
v-on:click="currentTab = 'mangle'"
v-bind:class="{'disable-media-pages-toolbar__tabs-tab--active': currentTab === 'mangle'}"
>
{{ i18n.tab_mangle }}
</button>
<button class="disable-media-pages-toolbar__tabs-tab"
v-on:click="currentTab = 'restore'"
v-bind:class="{'disable-media-pages-toolbar__tabs-tab--active': currentTab === 'restore'}"
>
{{ i18n.tab_restore }}
</button>
</div>
</div>
<div class="disable-media-pages-content">
<Status v-if="currentTab === 'status'" />
<Mangle v-if="currentTab === 'mangle'" />
<Restore v-if="currentTab === 'restore'" />
</div>
</div>
</template>
<script>
import { sprintf } from 'sprintf-js';
import Mangle from "./Mangle";
import Restore from "./Restore";
import Status from "./Status";
export default {
components: {Restore, Mangle, Status},
data: function () {
return {
i18n: window.disable_media_pages.i18n,
currentTab: 'status',
}
},
computed: {
},
methods: {
sprintf(...args) {
return sprintf(...args)
},
goToMangle() {
this.currentTab = 'mangle';
}
},
mounted() {
this.$root.$on('go-to-mangle', this.goToMangle);
},
beforeDestroy() {
// https://readybytes.in/blog/how-to-fix-duplicate-event-listeners-in-vuejs
this.$root.$off('go-to-mangle', this.goToMangle);
},
}
</script>
@@ -0,0 +1,130 @@
<template>
<div>
<ToolStart v-if="!fetchingAllPosts && !manglingPosts && !complete"
v-bind:title="i18n.mangle_title"
v-bind:subtitle="i18n.mangle_subtitle"
v-bind:description="i18n.mangle_description"
v-bind:button-text="i18n.mangle_button"
v-bind:event-name="'fetch-all-posts'"
/>
<ToolFetch v-if="fetchingAllPosts"
v-bind:title="i18n.mangle_title"
v-bind:subtitle="i18n.mangle_progress_title"
v-bind:description="i18n.mangle_progress_description"
/>
<ToolProcess v-if="manglingPosts"
v-bind:title="i18n.mangle_title"
v-bind:subtitle="i18n.mangle_progress_title"
v-bind:description="i18n.mangle_progress_description"
v-bind:progress="progress"
v-bind:total="total"
v-bind:processed="processed"
/>
<ToolResult
v-if="complete"
v-bind:title="i18n.mangle_title"
v-bind:subtitle="i18n.mangle_success_title"
v-bind:description="i18n.mangle_progress_description"
v-bind:button-text="i18n.mangle_success_button"
v-bind:total="total"
v-bind:processed="processed"
/>
</div>
</template>
<script>
import axios from 'axios';
import {sprintf} from 'sprintf-js';
import ToolStart from "./ToolStart";
import ToolFetch from "./ToolFetch";
import ToolProcess from "./ToolProcess";
import ToolResult from "./ToolResult";
export default {
components: {ToolResult, ToolProcess, ToolFetch, ToolStart},
data: function () {
return {
fetchingAllPosts: false,
manglingPosts: false,
posts: [],
total: 0,
processed: 0,
currentIndex: 0,
complete: false,
i18n: window.disable_media_pages.i18n,
}
},
computed: {
progress: function () {
return Math.round(this.processed / this.total * 100)
}
},
mounted() {
this.$root.$on('fetch-all-posts', this.fetchAllPosts);
this.$root.$on('start-over', this.startOver);
},
beforeDestroy() {
// https://readybytes.in/blog/how-to-fix-duplicate-event-listeners-in-vuejs
this.$root.$off('fetch-all-posts', this.fetchAllPosts);
this.$root.$off('start-over', this.startOver);
},
methods: {
sprintf(...args) {
return sprintf(...args)
},
fetchAllPosts() {
this.fetchingAllPosts = true;
const options = {
headers: {
'X-WP-Nonce': window.disable_media_pages.token,
}
}
axios.get(`${window.disable_media_pages.root}disable-media-pages/v1/get_all_attachments`, options).then(response => {
console.log(response)
this.posts = response.data.posts;
this.total = response.data.total;
this.fetchingAllPosts = false;
this.manglingPosts = true;
if (this.total > 0) {
this.processImage(this.posts[0])
} else {
// Nothing to process
this.manglingPosts = false;
this.complete = true;
}
})
},
processImage(id) {
const options = {
headers: {
'X-WP-Nonce': window.disable_media_pages.token,
}
}
axios.post(`${window.disable_media_pages.root}disable-media-pages/v1/process/${id}`, null, options).then(response => {
}).catch(response => {
// TODO: handle error?
}).finally(() => {
this.processed = this.processed + 1;
let newIndex = this.currentIndex + 1;
if (this.posts[newIndex]) {
this.currentIndex = newIndex;
this.processImage(this.posts[newIndex]);
} else {
this.manglingPosts = false;
this.complete = true;
}
});
},
startOver() {
this.complete = false;
this.posts = [];
this.currentIndex = 0;
this.total = 0;
this.processed = 0;
this.currentIndex = 0;
}
}
}
</script>
@@ -0,0 +1,131 @@
<template>
<div>
<ToolStart v-if="!fetchingAllPosts && !manglingPosts && !complete"
v-bind:title="i18n.restore_title"
v-bind:subtitle="i18n.restore_subtitle"
v-bind:description="i18n.restore_description"
v-bind:button-text="i18n.restore_button"
v-bind:event-name="'fetch-all-posts-to-restore'"
/>
<ToolFetch v-if="fetchingAllPosts"
v-bind:description="i18n.restore_progress_description"
v-bind:title="i18n.restore_title"
v-bind:subtitle="i18n.restore_progress_title"
/>
<ToolProcess
v-if="manglingPosts"
v-bind:progress="progress"
v-bind:description="i18n.restore_progress_description"
v-bind:title="i18n.restore_title"
v-bind:subtitle="i18n.restore_progress_title"
v-bind:total="total"
v-bind:processed="processed"
/>
<ToolResult
v-if="complete"
v-bind:title="i18n.restore_title"
v-bind:subtitle="i18n.restore_success_title"
v-bind:description="i18n.restore_progress_description"
v-bind:button-text="i18n.restore_success_button"
v-bind:total="total"
v-bind:processed="processed"
/>
</div>
</template>
<script>
import axios from 'axios';
import {sprintf} from 'sprintf-js';
import ToolStart from "./ToolStart";
import ToolProcess from "./ToolProcess";
import ToolResult from "./ToolResult";
import ToolFetch from "./ToolFetch";
export default {
components: {ToolFetch, ToolResult, ToolProcess, ToolStart},
data: function () {
return {
fetchingAllPosts: false,
manglingPosts: false,
posts: [],
total: 0,
processed: 0,
currentIndex: 0,
complete: false,
i18n: window.disable_media_pages.i18n,
}
},
computed: {
progress: function () {
return Math.round(this.processed / this.total * 100)
}
},
mounted() {
this.$root.$on('fetch-all-posts-to-restore', this.fetchAllPosts);
this.$root.$on('start-over', this.startOver);
},
beforeDestroy() {
// https://readybytes.in/blog/how-to-fix-duplicate-event-listeners-in-vuejs
this.$root.$off('fetch-all-posts-to-restore', this.fetchAllPosts);
this.$root.$off('start-over', this.startOver);
},
methods: {
sprintf(...args) {
return sprintf(...args)
},
fetchAllPosts() {
this.fetchingAllPosts = true;
const options = {
headers: {
'X-WP-Nonce': window.disable_media_pages.token,
}
}
axios.get(`${window.disable_media_pages.root}disable-media-pages/v1/get-attachments-to-restore`, options).then(response => {
console.log(response)
this.posts = response.data.posts;
this.total = response.data.total;
this.fetchingAllPosts = false;
this.manglingPosts = true;
if (this.total > 0) {
this.processImage(this.posts[0])
} else {
// Nothing to process
this.manglingPosts = false;
this.complete = true;
}
})
},
processImage(id) {
const options = {
headers: {
'X-WP-Nonce': window.disable_media_pages.token,
}
}
axios.post(`${window.disable_media_pages.root}disable-media-pages/v1/restore/${id}`, null, options).then(response => {
}).catch(response => {
// TODO: handle error?
}).finally(() => {
this.processed = this.processed + 1;
let newIndex = this.currentIndex + 1;
if (this.posts[newIndex]) {
this.currentIndex = newIndex;
this.processImage(this.posts[newIndex]);
} else {
this.manglingPosts = false;
this.complete = true;
}
});
},
startOver() {
this.complete = false;
this.posts = [];
this.currentIndex = 0;
this.total = 0;
this.processed = 0;
this.currentIndex = 0;
}
}
}
</script>
@@ -0,0 +1,96 @@
<template>
<div>
<div class="disable-media-pages-tool__title-container">
<h2 class="disable-media-pages-tool__title">{{ i18n.status_title }}</h2>
</div>
<div class="disable-media-pages-tool__card">
<div class="disable-media-pages-health" v-if="loading">
<div class="disable-media-pages-health__icon"
v-html="require('!raw-loader!./icons/icon-loading.svg')"
>
</div>
<div>
<div class="disable-media-pages-health__title">
{{ i18n.status_loading_title }}
</div>
<div class="disable-media-pages-health__description">
{{ i18n.status_loading_description }}
</div>
</div>
</div>
<div class="disable-media-pages-health" v-if="!loading && this.nonUniqueCount === 0">
<div class="disable-media-pages-health__icon" v-html="require('!raw-loader!./icons/icon-ok.svg')"></div>
<div>
<div class="disable-media-pages-health__title">
{{ i18n.status_no_issues_title }}
</div>
<div class="disable-media-pages-health__description">
{{ i18n.status_no_issues_description }}
</div>
</div>
</div>
<div class="disable-media-pages-health" v-if="!loading && this.nonUniqueCount > 0">
<div class="disable-media-pages-health__icon" v-html="require('!raw-loader!./icons/icon-warning.svg')"></div>
<div>
<div class="disable-media-pages-health__title">
<div>{{ i18n.status_some_issues_title }}</div>
</div>
<div class="disable-media-pages-health__description disable-media-pages-health__description--has-button">
<p><span v-if="nonUniqueCount === 1">{{sprintf(i18n.status_non_unique_count_singular, nonUniqueCount)}}</span>
<span v-else>{{sprintf(i18n.status_non_unique_count_plural, nonUniqueCount)}}</span>
<span>{{i18n.status_non_unique_description}}</span></p>
</div>
<div class="disable-media-pages-health__button">
<button class="button button-primary" v-on:click="goToMangle">{{i18n.status_open_tool_button}}</button>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import axios from 'axios';
import {sprintf} from 'sprintf-js';
export default {
components: {},
data: function () {
return {
nonUniqueCount: null,
loading: false,
error: false,
i18n: window.disable_media_pages.i18n,
}
},
computed: {
},
mounted() {
this.fetchStatus();
},
beforeDestroy() {
},
methods: {
sprintf(...args) {
return sprintf(...args)
},
fetchStatus() {
const options = {
headers: {
'X-WP-Nonce': window.disable_media_pages.token,
}
}
this.loading = true;
axios.get(`${window.disable_media_pages.root}disable-media-pages/v1/get_status`, options).then(response => {
console.log(response)
this.loading = false;
this.nonUniqueCount = response.data.non_unique_count;
})
},
goToMangle() {
this.$root.$emit('go-to-mangle');
}
}
}
</script>
@@ -0,0 +1,44 @@
<template>
<div>
<div class="disable-media-pages-tool__title-container">
<h2 class="disable-media-pages-tool__title">{{ title }}</h2>
</div>
<div class="disable-media-pages-tool__card">
<div class="disable-media-pages-tool__subtitle">
{{ subtitle }}
</div>
<div class="disable-media-pages-tool">
<div class="disable-media-pages-tool__progress-title">
{{ sprintf(description, 0) }}
</div>
<div class="disable-media-pages__progress-bar disable-media-pages__progress-bar--indeterminate"></div>
<div class="disable-media-pages-tool__progress-subtitle">
{{ sprintf(i18n.tool_progress_subtitle, 0, '-') }}
</div>
</div>
</div>
</div>
</template>
<script>
import {sprintf} from 'sprintf-js';
export default {
props: ['title', 'description', 'subtitle'],
data: function () {
return {
i18n: window.disable_media_pages.i18n,
}
},
computed: {},
methods: {
sprintf(...args) {
return sprintf(...args)
},
}
}
</script>
@@ -0,0 +1,47 @@
<template>
<div>
<div class="disable-media-pages-tool__title-container">
<h2 class="disable-media-pages-tool__title">{{ title }}</h2>
</div>
<div class="disable-media-pages-tool__card">
<div class="disable-media-pages-tool__subtitle">
{{ subtitle }}
</div>
<div class="disable-media-pages-tool__progress-title">
{{ sprintf(i18n.mangle_progress_description, progress) }}
</div>
<div class="disable-media-pages__progress-bar">
<div class="disable-media-pages__progress-bar-inner" v-bind:style="{
width: `${progress}%`
}">
</div>
</div>
<div class="disable-media-pages-tool__progress-subtitle">
{{ sprintf(i18n.tool_progress_subtitle, processed, total) }}
</div>
</div>
</div>
</template>
<script>
import {sprintf} from 'sprintf-js';
export default {
props: ['title', 'description', 'progress', 'subtitle', 'processed', 'total'],
data: function () {
return {
i18n: window.disable_media_pages.i18n,
}
},
computed: {},
methods: {
sprintf(...args) {
return sprintf(...args)
},
}
}
</script>
@@ -0,0 +1,54 @@
<template>
<div>
<div class="disable-media-pages-tool__title-container">
<h2 class="disable-media-pages-tool__title">{{ title }}</h2>
</div>
<div class="disable-media-pages-tool__card">
<div class="disable-media-pages-tool__subtitle">{{ subtitle }}</div>
<div class="disable-media-pages-tool__progress-title">
{{ sprintf(description, 100) }}
</div>
<div class="disable-media-pages__progress-bar">
<div class="disable-media-pages__progress-bar-inner" v-bind:style="{
width: '100%'
}">
</div>
</div>
<div class="disable-media-pages-tool__progress-subtitle disable-media-pages-tool__progress-subtitle--has-button">
{{ sprintf(i18n.tool_progress_subtitle, processed, total) }}
</div>
<p>
<button class="button button-primary" v-on:click="startOver">{{ buttonText }}</button>
</p>
</div>
</div>
</template>
<script>
import {sprintf} from 'sprintf-js';
import Mangle from "./Mangle";
export default {
props: ['title', 'description', 'buttonText', 'subtitle', 'total', 'processed'],
components: {Mangle},
data: function () {
return {
i18n: window.disable_media_pages.i18n,
}
},
computed: {},
methods: {
sprintf(...args) {
return sprintf(...args)
},
startOver() {
this.$root.$emit('start-over');
}
}
}
</script>
@@ -0,0 +1,42 @@
<template>
<div>
<div class="disable-media-pages-tool__title-container">
<h2 class="disable-media-pages-tool__title">{{ title }}</h2>
</div>
<div class="disable-media-pages-tool__card">
<div class="disable-media-pages-tool__subtitle">
{{subtitle}}
</div>
<div class="disable-media-pages-tool__description">
<p>
{{ description }}
</p>
</div>
<p>
<button class="button button-primary" v-on:click="sendEvent">{{ buttonText }}</button>
</p>
</div>
</div>
</template>
<script>
import {sprintf} from 'sprintf-js';
export default {
props: ['title', 'description', 'button-text', 'event-name', 'subtitle'],
data: function () {
return {
i18n: window.disable_media_pages.i18n,
}
},
computed: {},
methods: {
sprintf(...args) {
return sprintf(...args)
},
sendEvent() {
this.$root.$emit(this.eventName);
}
},
}
</script>
@@ -0,0 +1 @@
<svg width="42" height="42" viewBox="0 0 42 42" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M42 21a21 21 0 1 1-42 0 21 21 0 0 1 42 0Z" fill-opacity=".33" fill="#8D8D8D" fill-rule="nonzero"/><path d="M5 5h32v32H5z"/><path d="M21.5 12.6v3.95l5.25-5.28L21.5 6v3.95a10.52 10.52 0 0 0-8.87 16.17l1.91-1.93a7.9 7.9 0 0 1 6.96-11.6Zm8.87 2.28-1.91 1.93a7.9 7.9 0 0 1-6.96 11.6v-3.96l-5.25 5.28L21.5 35v-3.95a10.52 10.52 0 0 0 8.87-16.17Z" fill="#8D8D8D" fill-rule="nonzero"/></g></svg>

After

Width:  |  Height:  |  Size: 513 B

@@ -0,0 +1 @@
<svg width="42" height="42" viewBox="0 0 42 42" xmlns="http://www.w3.org/2000/svg"><g fill="#4CAF50" fill-rule="evenodd"><path d="M42 21a21 21 0 1 1-42 0 21 21 0 0 1 42 0Z" opacity=".33" fill-rule="nonzero"/><path d="m19.23 29.74 13.06-13.07a1 1 0 0 0 0-1.41l-1.99-2a1 1 0 0 0-1.41 0l-9.66 9.66a1 1 0 0 1-1.42 0l-3.7-3.7a1 1 0 0 0-1.41 0l-2 2a1 1 0 0 0 0 1.41l7.11 7.1a1 1 0 0 0 1.42 0Z"/></g></svg>

After

Width:  |  Height:  |  Size: 399 B

@@ -0,0 +1 @@
<svg width="42" height="42" viewBox="0 0 42 42" xmlns="http://www.w3.org/2000/svg"><g fill="#F44336" fill-rule="evenodd"><path d="M21 0a21 21 0 1 0 0 42 21 21 0 0 0 0-42Z" opacity=".33" fill-rule="nonzero"/><circle cx="21" cy="30" r="3"/><path d="M22.07 24h-2.14a1 1 0 0 1-1-.93l-.85-12a1 1 0 0 1 1-1.07h3.85a1 1 0 0 1 1 1.07l-.86 12a1 1 0 0 1-1 .93Z"/></g></svg>

After

Width:  |  Height:  |  Size: 363 B

@@ -0,0 +1,14 @@
import Vue from 'vue';
import App from "./App";
document.addEventListener('DOMContentLoaded', () => {
let element = document.getElementById('disable-media-pages');
if (element) {
new Vue({
el: element,
components: {
'disable-media-pages': App,
},
});
}
});
@@ -0,0 +1,253 @@
.settings_page_disable-media-pages #wpbody #wpbody-content .notice {
margin: 0;
margin-top: 20px;
margin-right: 20px;
margin-bottom: 20px;
}
.disable-media-pages {
all: initial;
@import '~minireset.css/minireset.sass';
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
.disable-media-pages-toolbar {
margin-left: -20px;
padding-left: 20px;
background: #fff;
border-bottom: 1px solid #ccd0d4;
height: 42px;
display: flex;
overflow-y: auto;
}
.disable-media-pages-toolbar__plugin-title {
height: 42px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 20px;
font-size: 14px;
white-space: nowrap;
h1 {
font-weight: bold;
}
}
.disable-media-pages-toolbar__tabs {
display: flex;
}
.disable-media-pages-toolbar__tabs-tab {
all: inherit;
display: flex;
justify-content: center;
align-items: center;
padding-left: 20px;
padding-right: 20px;
border-bottom: 3px solid transparent;
border-top: 2px solid transparent;
font-size: 14px;
white-space: nowrap;
}
.disable-media-pages-toolbar__tabs-tab--active {
border-bottom: 3px solid #007CBA;
}
.disable-media-pages-content {
margin-left: -20px;
padding: 20px;
}
.disable-media-pages-tool__title-container {
margin-bottom: 20px;
}
.disable-media-pages-tool__title {
font-size: 24px;
line-height: 1.5;
&::before {
content: "";
margin-bottom: -0.4055em;
display: table;
}
&::after {
content: "";
margin-top: -0.3805em;
display: table;
}
}
.disable-media-pages-tool__subtitle {
font-size: 18px;
font-weight: 600;
margin-bottom: 20px;
line-height: 1.5;
&::before {
content: "";
margin-bottom: -0.4055em;
display: table;
}
&::after {
content: "";
margin-top: -0.3805em;
display: table;
}
}
.disable-media-pages-tool__description {
max-width: 800px;
p {
line-height: 1.5;
&::before {
content: "";
margin-bottom: -0.4055em;
display: table;
}
&::after {
content: "";
margin-top: -0.3805em;
display: table;
}
margin-bottom: 20px;
}
}
.disable-media-pages-health {
display: flex;
}
.disable-media-pages-health__icon {
height: 42px;
width: 42px;
border-radius: 50%;
flex-shrink: 0;
margin-right: 20px;
}
.disable-media-pages-health__title {
font-size: 18px;
font-weight: 600;
margin-bottom: 20px;
line-height: 1.5;
&::before {
content: "";
margin-bottom: -0.4055em;
display: table;
}
&::after {
content: "";
margin-top: -0.3805em;
display: table;
}
}
.disable-media-pages-health__description {
max-width: 800px;
p {
line-height: 1.5;
&::before {
content: "";
margin-bottom: -0.4055em;
display: table;
}
&::after {
content: "";
margin-top: -0.3805em;
display: table;
}
}
}
.disable-media-pages-health__description--has-button {
margin-bottom: 20px;
}
.disable-media-pages-tool__progress-title {
margin-bottom: 20px;
line-height: 1.5;
&::before {
content: "";
margin-bottom: -0.4055em;
display: table;
}
&::after {
content: "";
margin-top: -0.3805em;
display: table;
}
}
.disable-media-pages-tool__progress-subtitle {
font-size: 13px;
line-height: 1.5;
opacity: 0.5;
&::before {
content: "";
margin-bottom: -0.4055em;
display: table;
}
&::after {
content: "";
margin-top: -0.3805em;
display: table;
}
}
.disable-media-pages-tool__progress-subtitle--has-button {
margin-bottom: 20px;
}
.disable-media-pages-tool__card {
background-color: white;
border-radius: 3px;
border: 1px solid #D9D9D9;
padding: 20px;
}
.disable-media-pages__progress-bar {
width: 100%;
height: 6px;
background-color: #e9ecef;
margin-bottom: 16px;
}
.disable-media-pages__progress-bar-inner {
height: 6px;
background-color: #007cba;
}
.disable-media-pages__progress-bar--indeterminate {
background-color: #007cba;
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%,
transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%,
rgba(255, 255, 255, 0.15) 75%,
transparent 75%,
transparent);
-webkit-animation: disable-media-pages-progress-bar-stripes 1s linear infinite;
animation: disable-media-pages-progress-bar-stripes 1s linear infinite;
background-size: 1rem 1rem;
}
}
@-webkit-keyframes disable-media-pages-progress-bar-stripes {
from {
background-position: 20px 0;
}
to {
background-position: 0 0;
}
}
@keyframes disable-media-pages-progress-bar-stripes {
from {
background-position: 16px 0;
}
to {
background-position: 0 0;
}
}