Plugin Directory

Changeset 3028541


Ignore:
Timestamp:
01/30/2024 06:26:48 AM (2 years ago)
Author:
urlslab
Message:

Upload v2.120.1

Location:
urlslab/trunk
Files:
83 added
83 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • urlslab/trunk/admin/src/components/DetailsPanel.jsx

    r3027290 r3028541  
    128128                                                {
    129129                                                    row[ 'edit_' + name[ 0 ] ]?.length > 0 &&
     130
    130131                                                    <Tooltip title={ __( 'Edit Post' ) } arrow placement="bottom">
    131132                                                        <IconButton size="xs" component="a" href={ row[ 'edit_' + name[ 0 ] ] }
  • urlslab/trunk/admin/src/elements/RefreshTableButton.jsx

    r3025823 r3028541  
    1515
    1616    const handleRefresh = () => {
    17         queryClient.invalidateQueries( [ slug ] );
     17        queryClient.invalidateQueries( {
     18            predicate: ( query ) =>
     19                query.queryKey[ 0 ] === slug && query.queryKey[ 1 ] !== 'count',
     20        } );
    1821
    1922        if ( ! noCount ) {
  • urlslab/trunk/admin/src/tables/CSPViolationsTable.jsx

    r3027290 r3028541  
    1 import { useEffect, useMemo } from 'react';
     1import { useEffect, useMemo, useCallback } from 'react';
    22import { __ } from '@wordpress/i18n/';
    33
     
    99import useChangeRow from '../hooks/useChangeRow';
    1010import DescriptionBox from '../elements/DescriptionBox';
     11import Button from '@mui/joy/Button';
     12
     13import { postFetch } from '../api/fetching.js';
     14import { setNotification } from '../hooks/useNotifications.jsx';
    1115
    1216const paginationId = 'blocked_url_id';
     17const optionalSelector = 'violated_directive';
    1318
    1419const header = {
     
    3035    const { isSelected, selectRows, deleteRow } = useChangeRow( );
    3136
     37    const addToCSPSettings = useCallback( async ( cell ) => {
     38        const { violated_directive, blocked_url_id } = cell?.row.original;
     39        setNotification( blocked_url_id, { message: __( 'Appending to CSP Settings…' ), status: 'info' } );
     40
     41        const response = await postFetch( `security/add_to_csp_settings/${ violated_directive }/${ blocked_url_id }`, {} );
     42        const result = await response.json();
     43
     44        if ( ! response?.ok ) {
     45            setNotification( blocked_url_id, { message: result?.message, status: 'error' } );
     46            return false;
     47        }
     48        setNotification( blocked_url_id, { message: result?.message, status: 'success' } );
     49    }, [] );
     50
    3251    useEffect( () => {
    3352        useTableStore.setState( () => (
     
    4261                        header,
    4362                        id: 'url',
     63                        optionalSelector,
    4464                    },
    4565                },
     
    7595            tooltip: ( cell ) => cell.getValue(),
    7696            header: ( th ) => <SortBy { ...th } />,
    77             minSize: 30,
     97            minSize: 300,
    7898        } ),
    7999        columnHelper.accessor( 'blocked_url', {
     
    86106            cell: ( val ) => <DateTimeFormat datetime={ val.getValue() } />,
    87107            header: ( th ) => <SortBy { ...th } />,
    88             minSize: 80,
     108            minSize: 100,
    89109        } ),
    90110        columnHelper.accessor( 'editRow', {
    91111            className: 'editRow',
    92112            cell: ( cell ) => <RowActionButtons
    93                 onDelete={ () => deleteRow( { cell } ) }
     113                onDelete={ () => deleteRow( { cell, optionalSelector } ) }
    94114            >
     115                <Button
     116                    size="xxs"
     117                    onClick={ () => addToCSPSettings( cell ) }
     118                >
     119                    { __( 'Add To CSP Settings' ) }
     120                </Button>
    95121            </RowActionButtons>,
    96122            header: null,
  • urlslab/trunk/blocks/build/ai-content.asset.php

    r3027290 r3028541  
    1 <?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '79ff3a86a704dd89062f');
     1<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '4edae5c50a37d8f98ef9');
  • urlslab/trunk/blocks/build/ai-content.js

    r3027290 r3028541  
    1 !function(){var e={184:function(e,t){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var c=typeof r;if("string"===c||"number"===c)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===c){if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]")){e.push(r.toString());continue}for(var i in r)n.call(r,i)&&r[i]&&e.push(i)}}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var c=t[n]={exports:{}};return e[n](c,c.exports,r),c.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.blocks;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e,r,n){return o=function(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r),(r="symbol"==t(o)?o:String(o))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e;var o}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,c,a,i=[],l=!0,u=!1;try{if(c=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=c.call(r)).done)&&(i.push(n.value),i.length!==t);l=!0);}catch(e){u=!0,o=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var a=window.React,i=r(184),l=r.n(i),u=window.wp.i18n,s=window.wp.compose,h=window.wp.element,p=window.wp.blockEditor,f=window.wp.components;function v(e,t,r,n,o,c,a){try{var i=e[c](a),l=i.value}catch(e){return void r(e)}i.done?t(l):Promise.resolve(l).then(n,o)}function d(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var c=e.apply(t,r);function a(e){v(c,n,o,a,i,"next",e)}function i(e){v(c,n,o,a,i,"throw",e)}a(void 0)}))}}var m=window.regeneratorRuntime,b=r.n(m);function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e){return O.apply(this,arguments)}function O(){return O=d(b().mark((function e(t){var r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(wpApiSettings.root+"urlslab/v1".concat(t?"/".concat(t):""),{method:"GET",headers:{"Content-Type":"application/json",accept:"application/json","X-WP-Nonce":window.wpApiSettings.nonce},credentials:"include"});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),O.apply(this,arguments)}function E(){return E=d(b().mark((function e(t,r,n){var o;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(wpApiSettings.root+"urlslab/v1/".concat(t),{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","X-WP-Nonce":window.wpApiSettings.nonce},credentials:"include",body:JSON.stringify(g({},r)),signal:null==n?void 0:n.signal});case 3:return o=e.sent,e.abrupt("return",o);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),E.apply(this,arguments)}var j=function(){var e=d(b().mark((function e(t){var r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w("module/".concat(t)).then((function(e){return e}));case 2:if(!(r=e.sent).ok){e.next=5;break}return e.abrupt("return",r.json());case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function S(){return S=d(b().mark((function e(t,r){var n;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(wpApiSettings.root+"urlslab/v1/module/".concat(t),{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","X-WP-Nonce":window.wpApiSettings.nonce},credentials:"include",body:JSON.stringify(r)});case 3:return n=e.sent,e.abrupt("return",n);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),S.apply(this,arguments)}function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var P="ai-content",x="urlslab-generator",I=JSON.parse('{"u2":"urlslab-blocks/ai-content"}');(0,e.registerBlockType)(I.u2,{icon:function(){return(0,a.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",fillRule:"evenodd",strokeLinejoin:"round",strokeMiterlimit:"2",clipRule:"evenodd",viewBox:"0 0 48 48"},(0,a.createElement)("g",{transform:"scale(.88785 .91788)"},(0,a.createElement)("path",{fill:"none",d:"M0 0H54.063V52.295H0z"}),(0,a.createElement)("clipPath",{id:"a"},(0,a.createElement)("path",{d:"M0 0H54.063V52.295H0z"})),(0,a.createElement)("g",{clipPath:"url(#a)"},(0,a.createElement)("path",{fill:"none",d:"M33.139 71.738H511.5V554.5H33.139z",transform:"matrix(.10952 0 0 .10832 -3.63 -7.771) translate(7.653 .003)"}),(0,a.createElement)("g",{transform:"matrix(.10952 0 0 .10832 -3.63 -7.771) translate(7.141 -.205)"},(0,a.createElement)("clipPath",{id:"b"},(0,a.createElement)("path",{d:"M33.139 71.738H511.5V554.5H33.139z"})),(0,a.createElement)("g",{clipPath:"url(#b)"},(0,a.createElement)("path",{d:"M5385.86 466.265h1.14V273h-252v389h-305V273h-252v389h-304V273h-252v389h-294V273h-263v389h-294V273h-262v389l-.64-.002V746h.64v472h262V746h294v472h263V746h294v472h252V746h304v472h252V746h305v472h250.86V466.265ZM6499.12 3948h.88v-252h-389v-294h389v-262h-389v-294h389v-263h-389v-294h389v-262h-389v-294h389v-263h-.88v5.45H5565V1733h462v294h-462v262h462v294h-462v263h462v294h-462v262h462v294h-462v244.98h934.12v7.02ZM2741 3940.98V3696h-473v-294h473v-262h-473v-294h473v-263h-473v-294h473v-262h-473v-294h473v-257.55h-945V1733h388v294h-388v262h388v294h-388v263h388v294h-388v262h388v294h-388v244.98h945Zm2646 1009.18h-1.14V4211H5135v472h-305v-472h-252v472h-304v-472h-252v472h-294v-472h-263v472h-294v-472h-262l-.64 29.72V4618h.64v527h262v-378h294v378h263v-378h294v378h252v-378h304v378h252v-378h305v378h252v-194.84Z",transform:"matrix(.10157 0 0 -.09932 -148.481 582.385)"}),(0,a.createElement)("path",{d:"M100.454 128.324H479.35V518.842H100.454z",transform:"matrix(1.00901 0 0 1.00015 -19.43 -10.577)"}),(0,a.createElement)("path",{d:"M487.278 128.324c0-4.319-3.55-7.82-7.928-7.82H100.454c-4.378 0-7.927 3.501-7.927 7.82v390.518c0 4.319 3.549 7.82 7.927 7.82H479.35c4.378 0 7.928-3.501 7.928-7.82V128.324Zm-15.855 7.82v374.878H108.382V136.144h363.041Z",transform:"matrix(1.00901 0 0 1.00015 -19.43 -10.577)"}),(0,a.createElement)("g",{fill:"#fff",fillRule:"nonzero",transform:"matrix(1.06648 0 0 1.04286 -157.333 62.739)"},(0,a.createElement)("path",{d:"M414.791 271.858h-71.005l-18.477 40.284h-26.963l82.07-176.28 79.17 176.28h-27.392l-17.403-40.284Zm-10.205-23.525-24.599-56.396-25.782 56.396h50.381Z"}),(0,a.createElement)("path",{d:"M480.319 146.282H505.348V312.141H480.319z"})))))))},edit:function e(t){var r,o=t.attributes,i=t.setAttributes,v=(0,s.useInstanceId)(e),d="urlslab-".concat(P,"-input-").concat(v),m=function(e){var t,r=e.moduleSlug,n=c((0,a.useState)(),2),o=n[0],i=n[1];return(0,a.useEffect)((function(){j(r).then((function(e){i(e)}))}),[r]),o&&null!==(t=Object.keys(o))&&void 0!==t&&t.length,{moduleStatus:o,activateModule:function(e){(function(e,t){return S.apply(this,arguments)})(e,{active:!0}).then((function(e){return e.json()})).then((function(e){return i(e)}))}}}({moduleSlug:x}),b=m.moduleStatus,y=m.activateModule,g=c((0,h.useState)([]),2),w=g[0],O=g[1],I=c((0,h.useState)([]),2),_=I[0],C=I[1];(0,h.useEffect)((function(){(function(e,t,r){return E.apply(this,arguments)})("generator/shortcode",{sorting:[{dir:"ASC"}],filters:[],rows_per_page:500}).then((function(e){if(e.ok)return e.json()})).then((function(e){O(e),i({shortcodeObject:e.filter((function(e){return Number(e.shortcode_id)===o.shortcodeId}))[0]})}))}),[o.shortcodeId,i]),(0,h.useEffect)((function(){var e;_.length&&i({shortcodeId:null===(e=_[0])||void 0===e?void 0:e.value})}),[i,_]);var k=(0,h.useMemo)((function(){var e=null==w?void 0:w.filter((function(e){return o.shortcodeVideo?"V"===e.shortcode_type:"S"===e.shortcode_type})).map((function(e){return{label:e.shortcode_name,value:e.shortcode_id}}));return C(e),e}),[o.shortcodeVideo,w]),A=(0,h.useCallback)((function(e){var t=w.filter((function(t){return Number(t.shortcode_id)===e}))[0];i({shortcodeId:e}),i({shortcodeObject:t})}),[w,i]);return(0,a.createElement)(a.Fragment,null,b&&(null==b?void 0:b.active)&&(0,a.createElement)(p.InspectorControls,{key:"setting"},(0,a.createElement)(f.PanelBody,{title:(0,u.__)("AI Content Options","urlslab"),initialOpen:!0},(0,a.createElement)(f.ToggleControl,{label:(0,u.__)("Is Video Content","urlslab"),checked:o.shortcodeVideo,onChange:function(e){i({shortcodeVideo:e}),i({shortcodeVideoId:""})}}),(null==_?void 0:_.length)>0&&(0,a.createElement)(f.ComboboxControl,{label:(0,u.__)("Select AI Content Shortcode","urlslab"),value:o.shortcodeId,options:_,onChange:function(e){return A(e)},onFilterValueChange:function(e){return C(k.filter((function(t){return t.label.toLowerCase().startsWith(e.toLowerCase())})))}}),o.shortcodeVideo&&(0,a.createElement)(f.TextControl,{label:(0,u.__)("Video ID","urlslab"),help:(0,u.__)("Insert valid ID of YouTube video","urlslab"),value:o.shortcodeVideoId,onChange:function(e){return i({shortcodeVideoId:e})}}))),(0,a.createElement)("div",function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},(0,p.useBlockProps)({className:l()("urlslab-block","urlslab-block-".concat(P),"components-placeholder")})),(0,a.createElement)("label",{htmlFor:d,className:"components-placeholder__label"},(0,u.__)("AI Content","urlslab")),(0,a.createElement)("div",{className:"urlslab-fullwidth-wrapper"},b&&null!=b&&b.active?Object.keys(o.shortcodeObject||{}).length>0&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("p",null,(0,a.createElement)("strong",null,"Shortcode inserted:")),(0,a.createElement)("div",null,o.shortcodeVideo?o.shortcodeVideoId?(0,a.createElement)("strong",null,'[urlslab-generator id="',o.shortcodeId,'"  videoid="',o.shortcodeVideoId,'"]'):(0,a.createElement)("strong",{className:"error"},"Video ID is not entered!!!"):(0,a.createElement)("strong",null,'[urlslab-generator id="',o.shortcodeId,'"]')),(0,a.createElement)("p",null,(0,a.createElement)("strong",null,"AI Content Promp:")),(0,a.createElement)("div",null,(0,a.createElement)("code",null,null===(r=o.shortcodeObject)||void 0===r?void 0:r.prompt))):b?(0,a.createElement)(a.Fragment,null,(0,a.createElement)("p",null,(0,u.__)("AI Content module in URLsLab is not activated. If you want to use this widget, activate it please.")),(0,a.createElement)(f.Button,{variant:"primary",text:(0,u.__)("Activate AI Content module"),onClick:function(){return y(x)}})):(0,a.createElement)(f.Spinner,null))))},save:function(){return null}})}()}();
     1!function(){var e={184:function(e,t){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var c=typeof r;if("string"===c||"number"===c)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===c){if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]")){e.push(r.toString());continue}for(var i in r)n.call(r,i)&&r[i]&&e.push(i)}}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var c=t[n]={exports:{}};return e[n](c,c.exports,r),c.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.blocks;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e,r,n){return o=function(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r),(r="symbol"==t(o)?o:String(o))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e;var o}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,c,a,i=[],l=!0,u=!1;try{if(c=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=c.call(r)).done)&&(i.push(n.value),i.length!==t);l=!0);}catch(e){u=!0,o=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var a=window.React,i=r(184),l=r.n(i),u=window.wp.i18n,s=window.wp.compose,h=window.wp.element,p=window.wp.blockEditor,d=window.wp.components;function v(e,t,r,n,o,c,a){try{var i=e[c](a),l=i.value}catch(e){return void r(e)}i.done?t(l):Promise.resolve(l).then(n,o)}function f(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var c=e.apply(t,r);function a(e){v(c,n,o,a,i,"next",e)}function i(e){v(c,n,o,a,i,"throw",e)}a(void 0)}))}}var m=window.regeneratorRuntime,b=r.n(m);function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e){return O.apply(this,arguments)}function O(){return O=f(b().mark((function e(t){var r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(wpApiSettings.root+"urlslab/v1".concat(t?"/".concat(t):""),{method:"GET",headers:{"Content-Type":"application/json",accept:"application/json","X-WP-Nonce":window.wpApiSettings.nonce},credentials:"include"});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),O.apply(this,arguments)}function j(){return j=f(b().mark((function e(t,r,n){var o;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(wpApiSettings.root+"urlslab/v1/".concat(t),{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","X-WP-Nonce":window.wpApiSettings.nonce},credentials:"include",body:JSON.stringify(g({},r)),signal:null==n?void 0:n.signal});case 3:return o=e.sent,e.abrupt("return",o);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),j.apply(this,arguments)}var E=function(){var e=f(b().mark((function e(t){var r;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w("module/".concat(t)).then((function(e){return e}));case 2:if(!(r=e.sent).ok){e.next=5;break}return e.abrupt("return",r.json());case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function S(){return S=f(b().mark((function e(t,r){var n;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(wpApiSettings.root+"urlslab/v1/module/".concat(t),{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","X-WP-Nonce":window.wpApiSettings.nonce},credentials:"include",body:JSON.stringify(r)});case 3:return n=e.sent,e.abrupt("return",n);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),S.apply(this,arguments)}function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var P="ai-content",_="urlslab-generator",x=JSON.parse('{"u2":"urlslab-blocks/ai-content"}');(0,e.registerBlockType)(x.u2,{icon:function(){return(0,a.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",fillRule:"evenodd",strokeLinejoin:"round",strokeMiterlimit:"2",clipRule:"evenodd",viewBox:"0 0 48 48"},(0,a.createElement)("g",{transform:"scale(.88785 .91788)"},(0,a.createElement)("path",{fill:"none",d:"M0 0H54.063V52.295H0z"}),(0,a.createElement)("clipPath",{id:"a"},(0,a.createElement)("path",{d:"M0 0H54.063V52.295H0z"})),(0,a.createElement)("g",{clipPath:"url(#a)"},(0,a.createElement)("path",{fill:"none",d:"M33.139 71.738H511.5V554.5H33.139z",transform:"matrix(.10952 0 0 .10832 -3.63 -7.771) translate(7.653 .003)"}),(0,a.createElement)("g",{transform:"matrix(.10952 0 0 .10832 -3.63 -7.771) translate(7.141 -.205)"},(0,a.createElement)("clipPath",{id:"b"},(0,a.createElement)("path",{d:"M33.139 71.738H511.5V554.5H33.139z"})),(0,a.createElement)("g",{clipPath:"url(#b)"},(0,a.createElement)("path",{d:"M5385.86 466.265h1.14V273h-252v389h-305V273h-252v389h-304V273h-252v389h-294V273h-263v389h-294V273h-262v389l-.64-.002V746h.64v472h262V746h294v472h263V746h294v472h252V746h304v472h252V746h305v472h250.86V466.265ZM6499.12 3948h.88v-252h-389v-294h389v-262h-389v-294h389v-263h-389v-294h389v-262h-389v-294h389v-263h-.88v5.45H5565V1733h462v294h-462v262h462v294h-462v263h462v294h-462v262h462v294h-462v244.98h934.12v7.02ZM2741 3940.98V3696h-473v-294h473v-262h-473v-294h473v-263h-473v-294h473v-262h-473v-294h473v-257.55h-945V1733h388v294h-388v262h388v294h-388v263h388v294h-388v262h388v294h-388v244.98h945Zm2646 1009.18h-1.14V4211H5135v472h-305v-472h-252v472h-304v-472h-252v472h-294v-472h-263v472h-294v-472h-262l-.64 29.72V4618h.64v527h262v-378h294v378h263v-378h294v378h252v-378h304v378h252v-378h305v378h252v-194.84Z",transform:"matrix(.10157 0 0 -.09932 -148.481 582.385)"}),(0,a.createElement)("path",{d:"M100.454 128.324H479.35V518.842H100.454z",transform:"matrix(1.00901 0 0 1.00015 -19.43 -10.577)"}),(0,a.createElement)("path",{d:"M487.278 128.324c0-4.319-3.55-7.82-7.928-7.82H100.454c-4.378 0-7.927 3.501-7.927 7.82v390.518c0 4.319 3.549 7.82 7.927 7.82H479.35c4.378 0 7.928-3.501 7.928-7.82V128.324Zm-15.855 7.82v374.878H108.382V136.144h363.041Z",transform:"matrix(1.00901 0 0 1.00015 -19.43 -10.577)"}),(0,a.createElement)("g",{fill:"#fff",fillRule:"nonzero",transform:"matrix(1.06648 0 0 1.04286 -157.333 62.739)"},(0,a.createElement)("path",{d:"M414.791 271.858h-71.005l-18.477 40.284h-26.963l82.07-176.28 79.17 176.28h-27.392l-17.403-40.284Zm-10.205-23.525-24.599-56.396-25.782 56.396h50.381Z"}),(0,a.createElement)("path",{d:"M480.319 146.282H505.348V312.141H480.319z"})))))))},edit:function e(t){var r,o=t.attributes,i=t.setAttributes,v=(0,s.useInstanceId)(e),f="urlslab-".concat(P,"-input-").concat(v),m=function(e){var t,r=e.moduleSlug,n=c((0,a.useState)(),2),o=n[0],i=n[1];return(0,a.useEffect)((function(){E(r).then((function(e){i(e)}))}),[r]),o&&null!==(t=Object.keys(o))&&void 0!==t&&t.length,{moduleStatus:o,activateModule:function(e){(function(e,t){return S.apply(this,arguments)})(e,{active:!0}).then((function(e){return e.json()})).then((function(e){return i(e)}))}}}({moduleSlug:_}),b=m.moduleStatus,y=m.activateModule,g=c((0,h.useState)([]),2),w=g[0],O=g[1],x=c((0,h.useState)([]),2),I=x[0],k=x[1];(0,h.useEffect)((function(){(function(e,t,r){return j.apply(this,arguments)})("generator/shortcode",{sorting:[{dir:"ASC"}],filters:[],rows_per_page:500}).then((function(e){if(e.ok)return e.json()})).then((function(e){O(e),i({shortcodeObject:e.filter((function(e){return Number(e.shortcode_id)===o.shortcodeId}))[0]})}))}),[o.shortcodeId,i]),(0,h.useEffect)((function(){var e,t;!I.length||null!==(e=Object.keys(o.shortcodeObject||{}))&&void 0!==e&&e.length||i({shortcodeId:null===(t=I[0])||void 0===t?void 0:t.value})}),[I,o.shortcodeObject,i]);var C=(0,h.useMemo)((function(){var e=null==w?void 0:w.filter((function(e){return o.shortcodeVideo?"V"===e.shortcode_type:"S"===e.shortcode_type})).map((function(e){return{label:e.shortcode_name,value:e.shortcode_id}}));return k(e),e}),[o.shortcodeVideo,w]),A=(0,h.useCallback)((function(e){var t=w.filter((function(t){return Number(t.shortcode_id)===e}))[0];i({shortcodeId:e}),i({shortcodeObject:t})}),[w,i]);return(0,a.createElement)(a.Fragment,null,b&&(null==b?void 0:b.active)&&(0,a.createElement)(p.InspectorControls,{key:"setting"},(0,a.createElement)(d.PanelBody,{title:(0,u.__)("AI Content Options","urlslab"),initialOpen:!0},(0,a.createElement)(d.ToggleControl,{label:(0,u.__)("Is Video Content","urlslab"),checked:o.shortcodeVideo,onChange:function(e){i({shortcodeObject:{}}),i({shortcodeVideo:e}),i({shortcodeVideoId:""})}}),(null==I?void 0:I.length)>0&&(0,a.createElement)(d.ComboboxControl,{label:(0,u.__)("Select AI Content Shortcode","urlslab"),value:o.shortcodeId,options:I,onChange:function(e){return A(e)},onFilterValueChange:function(e){return k(C.filter((function(t){return t.label.toLowerCase().startsWith(e.toLowerCase())})))}}),o.shortcodeVideo&&(0,a.createElement)(d.TextControl,{label:(0,u.__)("Video ID","urlslab"),help:(0,u.__)("Insert valid ID of YouTube video","urlslab"),value:o.shortcodeVideoId,onChange:function(e){return i({shortcodeVideoId:e})}}))),(0,a.createElement)("div",function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},(0,p.useBlockProps)({className:l()("urlslab-block","urlslab-block-".concat(P),"components-placeholder")})),(0,a.createElement)("label",{htmlFor:f,className:"components-placeholder__label"},(0,u.__)("AI Content","urlslab")),(0,a.createElement)("div",{className:"urlslab-fullwidth-wrapper"},b&&null!=b&&b.active?Object.keys(o.shortcodeObject||{}).length>0&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("p",null,(0,a.createElement)("strong",null,(0,u.__)("Shortcode inserted:"))),(0,a.createElement)("div",null,o.shortcodeVideo?o.shortcodeVideoId?(0,a.createElement)("strong",null,'[urlslab-generator id="',o.shortcodeId,'"  videoid="',o.shortcodeVideoId,'"]'):(0,a.createElement)("strong",{className:"error"},(0,u.__)("Video ID is not entered!!!")):(0,a.createElement)("strong",null,'[urlslab-generator id="',o.shortcodeId,'"]')),(0,a.createElement)("p",null,(0,a.createElement)("strong",null,(0,u.__)("AI Content Prompt:"))),(0,a.createElement)("div",null,(0,a.createElement)("code",null,null===(r=o.shortcodeObject)||void 0===r?void 0:r.prompt))):b?(0,a.createElement)(a.Fragment,null,(0,a.createElement)("p",null,(0,u.__)("AI Content module in URLsLab is not activated. If you want to use this widget, activate it please.")),(0,a.createElement)(d.Button,{variant:"primary",text:(0,u.__)("Activate AI Content module"),onClick:function(){return y(_)}})):(0,a.createElement)(d.Spinner,null))))},save:function(){return null}})}()}();
  • urlslab/trunk/blocks/src/blocks/ai-content/edit.js

    r3027290 r3028541  
    3333
    3434    useEffect( () => {
    35         if ( filteredOptions.length ) {
     35        if ( filteredOptions.length && ! Object.keys( attributes.shortcodeObject || {} )?.length ) {
    3636            setAttributes( { shortcodeId: filteredOptions[ 0 ]?.value } );
    3737        }
    38     }, [ setAttributes, filteredOptions ] );
     38    }, [ filteredOptions, attributes.shortcodeObject, setAttributes ] );
    3939
    4040    const options = useMemo( () => {
     
    7171                            checked={ attributes.shortcodeVideo }
    7272                            onChange={ ( val ) => {
     73                                setAttributes( { shortcodeObject: {} } );
    7374                                setAttributes( { shortcodeVideo: val } );
    7475                                setAttributes( { shortcodeVideoId: '' } );
     
    125126                        ? Object.keys( attributes.shortcodeObject || {} ).length > 0 &&
    126127                        <>
    127                             <p><strong>Shortcode inserted:</strong></p>
     128                            <p><strong>{ __( 'Shortcode inserted:' ) }</strong></p>
    128129                            <div>
    129130                                { attributes.shortcodeVideo
    130                                     ? attributes.shortcodeVideoId ? <strong>[urlslab-generator id="{ attributes.shortcodeId }"  videoid="{ attributes.shortcodeVideoId }"]</strong> : <strong className="error">Video ID is not entered!!!</strong>
     131                                    ? attributes.shortcodeVideoId ? <strong>[urlslab-generator id="{ attributes.shortcodeId }"  videoid="{ attributes.shortcodeVideoId }"]</strong> : <strong className="error">{ __( 'Video ID is not entered!!!' ) }</strong>
    131132                                    : <strong>[urlslab-generator id="{ attributes.shortcodeId }"]</strong>
    132133                                }
    133134                            </div>
    134135
    135                             <p><strong>AI Content Promp:</strong></p>
     136                            <p><strong>{ __( 'AI Content Prompt:' ) }</strong></p>
    136137                            <div>
    137138                                <code>{ attributes.shortcodeObject?.prompt }</code>
  • urlslab/trunk/includes/api/class-urlslab-api-security.php

    r3027290 r3028541  
    5555            )
    5656        );
     57        register_rest_route(
     58            self::NAMESPACE,
     59            $base . '/add_to_csp_settings/(?P<violated_directive>[a-z\-]+)/(?P<blocked_url_id>[0-9]+)',
     60            array(
     61                array(
     62                    'methods'             => WP_REST_Server::EDITABLE,
     63                    'callback'            => array( $this, 'add_to_csp_settings' ),
     64                    'permission_callback' => array(
     65                        $this,
     66                        'add_to_csp_settings_permissions_check',
     67                    ),
     68                    'args'                => array(),
     69                ),
     70            )
     71        );
    5772
    5873        register_rest_route(
     
    7388    }
    7489
     90
     91    public function add_to_csp_settings_permissions_check( $request ) {
     92        return current_user_can( 'activate_plugins' ) || current_user_can( self::CAPABILITY_ADMINISTRATION ) || current_user_can( 'administrator' );
     93    }
    7594
    7695    private function get_route_get_items(): array {
     
    103122
    104123        return new WP_REST_Response( $rows, 200 );
     124    }
     125
     126    public function add_to_csp_settings( $request ) {
     127        $violated_directive = $request->get_param( 'violated_directive' );
     128        $blocked_url_id     = $request->get_param( 'blocked_url_id' );
     129        $csp_violation      = new Urlslab_Data_Csp(
     130            array(
     131                'violated_directive' => $violated_directive,
     132                'blocked_url_id'     => $blocked_url_id,
     133            ),
     134            false
     135        );
     136
     137        if ( ! $csp_violation->load() ) {
     138            return new WP_Error( 'error', __( 'Failed to load item', 'urlslab' ), array( 'status' => 404 ) );
     139        }
     140
     141        /** @var Urlslab_Widget_Security $widget */
     142        $widget = Urlslab_User_Widget::get_instance()->get_widget( Urlslab_Widget_Security::SLUG );
     143        if ( $widget->add_to_csp_settings( $csp_violation ) ) {
     144            return new WP_REST_Response(
     145                array(
     146                    'message' => __( 'CSP settings enhanced', 'urlslab' ),
     147                    200,
     148                )
     149            );
     150        }
     151
     152        return new WP_REST_Response(
     153            array(
     154                'message' => __( 'Failed to enhance the CSP settings, edit value manually in Settings section', 'urlslab' ),
     155                400,
     156            )
     157        );
    105158    }
    106159
     
    159212        }
    160213
    161         return new WP_REST_Response( '', 200, $this->get_headers_no_cache() );
     214        return new WP_REST_Response(
     215            array(
     216                'message' => '',
     217                200,
     218                $this->get_headers_no_cache(),
     219            )
     220        );
    162221    }
    163222
  • urlslab/trunk/includes/class-urlslab-admin.php

    r3025823 r3028541  
    175175            null,
    176176            URLSLAB_PLUGIN_URL . 'admin/assets/urlslab-logo.png',
    177             80
     177            2
    178178        );
    179179
  • urlslab/trunk/includes/cron/class-urlslab-cron-convert-avif-images.php

    r3027290 r3028541  
    176176        $avif_file->set_fileid( $avif_file->get_fileid() ); // init file id
    177177
     178        if ( ! $avif_file->get_file_pointer()->get_driver_object()->file_exists( $avif_file ) ) {
     179            return null;
     180        }
     181
    178182        if ( $avif_file->insert() ) {
    179183            return $avif_file;
  • urlslab/trunk/includes/cron/class-urlslab-cron-convert-webp-images.php

    r3027290 r3028541  
    124124        $webp_file->set_fileid( $webp_file->get_fileid() ); // init file id
    125125
     126        if ( ! $webp_file->get_file_pointer()->get_driver_object()->file_exists( $webp_file ) ) {
     127            return null;
     128        }
     129
    126130        if ( $webp_file->insert() ) {
    127131            return $webp_file;
  • urlslab/trunk/includes/data/class-urlslab-data-serp-query.php

    r3025823 r3028541  
    33class Urlslab_Data_Serp_Query extends Urlslab_Data {
    44    public const STATUS_NOT_PROCESSED = 'X';
    5     public const STATUS_PROCESSING    = 'P';
    6     public const STATUS_PROCESSED     = 'A';
    7     public const STATUS_ERROR         = 'E';
    8     public const STATUS_SKIPPED       = 'S';
    9 
    10     public const TYPE_USER         = 'U';
     5    public const STATUS_PROCESSING = 'P';
     6    public const STATUS_PROCESSED = 'A';
     7    public const STATUS_ERROR = 'E';
     8    public const STATUS_SKIPPED = 'S';
     9
     10    public const TYPE_USER = 'U';
    1111    public const TYPE_SERP_RELATED = 'S';
    12     public const TYPE_SERP_FAQ     = 'F';
    13     public const TYPE_GSC          = 'C';
    14 
    15     public const VOLUME_STATUS_NEW      = 'N';
    16     public const VOLUME_STATUS_ERROR    = 'E';
    17     public const VOLUME_STATUS_PENDING  = 'P';
     12    public const TYPE_SERP_FAQ = 'F';
     13    public const TYPE_GSC = 'C';
     14
     15    public const VOLUME_STATUS_NEW = 'N';
     16    public const VOLUME_STATUS_ERROR = 'E';
     17    public const VOLUME_STATUS_PENDING = 'P';
    1818    public const VOLUME_STATUS_FINISHED = 'F';
    1919
    20     public const INTENT_UNDEFINED     = 'U';
    21     public const INTENT_OTHER         = 'O';
    22     public const INTENT_QUESTION      = 'Q';
     20    public const INTENT_UNDEFINED = 'U';
     21    public const INTENT_OTHER = 'O';
     22    public const INTENT_QUESTION = 'Q';
    2323    public const INTENT_INFORMATIONAL = 'I';
    24     public const INTENT_COMMERCIAL    = 'C';
    25     public const INTENT_NAVIGATIONAL  = 'N';
     24    public const INTENT_COMMERCIAL = 'C';
     25    public const INTENT_NAVIGATIONAL = 'N';
    2626    public const INTENT_TRANSCATIONAL = 'T';
    2727
    28     public const SCHEDULE_INTERVAL_DAILY          = 'D';
    29     public const SCHEDULE_INTERVAL_WEEKLY         = 'W';
    30     public const SCHEDULE_INTERVAL_MONTHLY        = 'M';
    31     public const SCHEDULE_INTERVAL_YEARLY         = 'Y';
    32     public const SCHEDULE_INTERVAL_ONCE           = 'O';
     28    public const SCHEDULE_INTERVAL_DAILY = 'D';
     29    public const SCHEDULE_INTERVAL_WEEKLY = 'W';
     30    public const SCHEDULE_INTERVAL_MONTHLY = 'M';
     31    public const SCHEDULE_INTERVAL_YEARLY = 'Y';
     32    public const SCHEDULE_INTERVAL_ONCE = 'O';
    3333    public const SCHEDULE_INTERVAL_SYSTEM_DEFAULT = '';
    3434
    35     public const LEVEL_HIGH    = 'H';
    36     public const LEVEL_MEDIUM  = 'M';
    37     public const LEVEL_LOW     = 'L';
     35    public const LEVEL_HIGH = 'H';
     36    public const LEVEL_MEDIUM = 'M';
     37    public const LEVEL_LOW = 'L';
    3838    public const LEVEL_DEFAULT = '';
    3939
     
    4141        return array(
    4242            self::TYPE_USER         => __( 'User Defined', 'urlslab' ),
    43             self::TYPE_SERP_RELATED => __( 'Search Console', 'urlslab' ),
    44             self::TYPE_SERP_FAQ    => __( 'People also search for', 'urlslab' ),
    45             self::TYPE_GSC          => __( 'People also ask', 'urlslab' ),
     43            self::TYPE_GSC          => __( 'Search Console', 'urlslab' ),
     44            self::TYPE_SERP_RELATED => __( 'People also search for', 'urlslab' ),
     45            self::TYPE_SERP_FAQ     => __( 'People also ask', 'urlslab' ),
    4646        );
    4747    }
     
    287287        if ( 1 < strlen( $country_level ) ) {
    288288            $country_level = substr( $country_level, 0, 1 );
    289         } elseif ( null == $country_level ) {
     289        } else if ( null == $country_level ) {
    290290            $country_level = '';
    291291        }
     
    400400        if ( 'type' === $column ) {
    401401            return self::queryTypes();
    402         } elseif ( 'status' === $column ) {
     402        } else if ( 'status' === $column ) {
    403403            return array(
    404404                self::STATUS_ERROR         => __( 'Error', 'urlslab' ),
     
    408408                self::STATUS_SKIPPED       => __( 'Skipped', 'urlslab' ),
    409409            );
    410         } elseif ( 'intent' === $column ) {
     410        } else if ( 'intent' === $column ) {
    411411            return array(
    412412                self::INTENT_COMMERCIAL    => __( 'Commercial', 'urlslab' ),
     
    418418                self::INTENT_UNDEFINED     => __( 'Undefined', 'urlslab' ),
    419419            );
    420         } elseif ( 'country_vol_status' === $column ) {
     420        } else if ( 'country_vol_status' === $column ) {
    421421            return array(
    422422                self::VOLUME_STATUS_NEW      => __( 'New', 'urlslab' ),
     
    425425                self::VOLUME_STATUS_FINISHED => __( 'Finished', 'urlslab' ),
    426426            );
    427         } elseif ( 'country_level' === $column ) {
     427        } else if ( 'country_level' === $column ) {
    428428            return array(
    429                 self::LEVEL_HIGH => __( 'High' ),
    430                 self::LEVEL_MEDIUM => __( 'Medium' ),
    431                 self::LEVEL_LOW => __( 'Low' ),
    432                 self::LEVEL_DEFAULT  => __( '-' ),
     429                self::LEVEL_HIGH    => __( 'High' ),
     430                self::LEVEL_MEDIUM  => __( 'Medium' ),
     431                self::LEVEL_LOW     => __( 'Low' ),
     432                self::LEVEL_DEFAULT => __( '-' ),
    433433            );
    434         } elseif ( 'schedule_interval' === $column ) {
     434        } else if ( 'schedule_interval' === $column ) {
    435435            return array(
    436436                self::SCHEDULE_INTERVAL_DAILY          => __( 'Daily', 'urlslab' ),
     
    472472
    473473
    474 
    475474        $wpdb->query(
    476475            $wpdb->prepare(
    477             'UPDATE ' . URLSLAB_SERP_QUERIES_TABLE . // phpcs:ignore
     476                'UPDATE ' . URLSLAB_SERP_QUERIES_TABLE . // phpcs:ignore
    478477                ' qq
    479478                    INNER JOIN (
     
    487486                            COUNT(m.url_id) AS internal_links
    488487                        FROM ' . URLSLAB_SERP_QUERIES_TABLE . // phpcs:ignore
    489             '           q   LEFT JOIN ' . URLSLAB_SERP_POSITIONS_TABLE . $first_gsc_join . // phpcs:ignore
    490             '           LEFT JOIN ' . URLSLAB_SERP_URLS_TABLE . // phpcs:ignore
     488                '           q   LEFT JOIN ' . URLSLAB_SERP_POSITIONS_TABLE . $first_gsc_join . // phpcs:ignore
     489                '           LEFT JOIN ' . URLSLAB_SERP_URLS_TABLE . // phpcs:ignore
    491490                '            u ON p.url_id=u.url_id
    492491                        LEFT JOIN ' . URLSLAB_SERP_POSITIONS_TABLE . $second_gsc_join . // phpcs:ignore
    493             '           LEFT JOIN ' . URLSLAB_SERP_URLS_TABLE . // phpcs:ignore
     492                '           LEFT JOIN ' . URLSLAB_SERP_URLS_TABLE . // phpcs:ignore
    494493                '            cu ON cp.url_id=cu.url_id
    495494                        LEFT JOIN ' . URLSLAB_KEYWORDS_TABLE . // phpcs:ignore
     
    524523        if ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_DAILY, 0, 1 ) === $interval ) {
    525524            return 86400;
    526         } elseif ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_WEEKLY, 0, 1 ) === $interval ) {
     525        } else if ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_WEEKLY, 0, 1 ) === $interval ) {
    527526            return 86400 * 7;
    528         } elseif ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_MONTHLY, 0, 1 ) === $interval ) {
     527        } else if ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_MONTHLY, 0, 1 ) === $interval ) {
    529528            return 86400 * 30;
    530         } elseif ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_YEARLY, 0, 1 ) === $interval ) {
     529        } else if ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_YEARLY, 0, 1 ) === $interval ) {
    531530            return 86400 * 365;
    532531        } else {
     
    547546        if ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_DAILY, 0, 1 ) === $interval ) {
    548547            return Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_DAILY;
    549         } elseif ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_WEEKLY, 0, 1 ) === $interval ) {
     548        } else if ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_WEEKLY, 0, 1 ) === $interval ) {
    550549            return Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_DAILY; //for weekly we use daily
    551         } elseif ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_MONTHLY, 0, 1 ) === $interval ) {
     550        } else if ( substr( Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_MONTHLY, 0, 1 ) === $interval ) {
    552551            return Urlslab_Vendor\OpenAPI\Client\Model\DomainDataRetrievalSerpApiSearchRequest::NOT_OLDER_THAN_WEEKLY; //for monthly we use weekly
    553552        }
  • urlslab/trunk/includes/driver/class-urlslab-driver-file.php

    r3027290 r3028541  
    7474
    7575        if ( false !== strpos( $file->get_url(), $upload_dir['baseurl'] ) ) {
    76             return $upload_dir['basedir'] . substr( substr( $file->get_url(), strlen( $upload_dir['baseurl'] ) ), 0, - strlen( $file->get_filename() ) );
     76            return $upload_dir['basedir'] . substr( substr( $file->get_url(), strlen( $upload_dir['baseurl'] ) ), 0, -strlen( $file->get_filename() ) );
    7777        }
    7878
     
    9191            $file_path     = $upload_dir['basedir'] . $relative_path;
    9292        } else {
    93             $file_path = $upload_dir['path'] . '/' . $file->get_filehash() . '_' . $file->get_filename();
     93            if ( ! empty( $file->get_filehash() ) ) {
     94                $file_path = $upload_dir['path'] . '/' . $file->get_filehash() . '_' . $file->get_filename();
     95            } else {
     96                return '';
     97            }
    9498        }
    9599
     
    103107
    104108    public function create_url( Urlslab_Data_File $file ): string {
    105         return wp_upload_dir()['url'] . '/' . $file->get_filehash() . '_' . $file->get_filename();
     109        if ( ! empty( $file->get_filehash() ) ) {
     110
     111            return wp_upload_dir()['url'] . '/' . $file->get_filehash() . '_' . $file->get_filename();
     112        }
     113
     114        return wp_upload_dir()['url'] . '/' . $file->get_filename();
    106115    }
    107116
     
    109118        $filename = $this->get_upload_file_name( $file_obj );
    110119
    111         return false !== $filename;
     120        return ! empty( $filename ) && file_exists( $filename );
    112121    }
    113122}
  • urlslab/trunk/includes/driver/class-urlslab-driver.php

    r3027290 r3028541  
    2424        self::DRIVER_LOCAL_FILE,
    2525    );
     26    private static array $system_url_paths = array();
    2627
    2728    public function get_existing_local_file( $url ) {
    28         // Get the WordPress base directory.
    29         $wp_base_dir = ABSPATH;
    30 
    31         // Parse the URL to get the path.
    32         $parsed_url = parse_url( $url );
    33         $url_path   = $parsed_url['path'] ?? '';
    34 
    35         // Convert to a local path.
    36         $local_path = realpath( $wp_base_dir . $url_path );
    37 
    38         // Check if the path is within our WordPress installation
    39         if ( strpos( $local_path, $wp_base_dir ) !== 0 ) {
    40             // The file is outside the WordPress directory and is considered invalid or potentially harmful.
     29        try {
     30            $url_obj = new Urlslab_Url( $url, true );
     31        } catch ( Exception $e ) {
    4132            return false;
    4233        }
    4334
    44         // Check if the file exists and is not a directory.
    45         if ( is_file( $local_path ) ) {
    46             return $local_path;
     35        if ( empty( self::$system_url_paths ) ) {
     36            self::$system_url_paths                                   = array();
     37            self::$system_url_paths[ wp_get_upload_dir()['basedir'] ] = new Urlslab_Url( wp_get_upload_dir()['baseurl'], true );
     38            self::$system_url_paths[ WP_PLUGIN_DIR ]                  = new Urlslab_Url( WP_PLUGIN_URL, true );
     39            self::$system_url_paths[ WPMU_PLUGIN_DIR ]                = new Urlslab_Url( WPMU_PLUGIN_URL, true );
     40            self::$system_url_paths[ WP_CONTENT_DIR ]                 = new Urlslab_Url( WP_CONTENT_URL, true );
     41            if ( defined( 'WP_SITEURL' ) ) {
     42                self::$system_url_paths[ ABSPATH ] = new Urlslab_Url( WP_SITEURL, true );
     43            }
     44        }
     45
     46        foreach ( self::$system_url_paths as $system_dir => $system_url_obj ) {
     47            if ( $url_obj->get_domain_id() === $system_url_obj->get_domain_id() && strpos( $url_obj->get_url_path(), $system_url_obj->get_url_path() ) === 0 ) {
     48                $url_path = substr( $url_obj->get_url_path(), strlen( $system_url_obj->get_url_path() ) );
     49
     50                return realpath( $system_dir . $url_path );
     51            }
    4752        }
    4853
     
    173178        }
    174179
    175         if ( ! $file->get_file_pointer()->load() ) {
     180        if ( ! $file->get_file_pointer()->load() || ! $file->get_file_pointer()->get_driver_object()->file_exists( $file ) ) {
    176181            if ( $this->save_file_to_storage( $file, $file_name ) ) {
    177182                //create pointer
     
    238243        }
    239244
     245        if ( Urlslab_User_Widget::get_instance()->get_activated_widgets( Urlslab_Widget_Redirects::SLUG ) && Urlslab_User_Widget::get_instance()->get_widget( Urlslab_Widget_Redirects::SLUG )->get_option( Urlslab_Widget_Redirects::SETTING_NAME_IMG_EMPTY_ON_404 ) ) {
     246            $file_size = filesize( $local_tmp_file );
     247            if ( 1024 > $file_size ) {
     248                $content = file_get_contents( $local_tmp_file );
     249                if ( Urlslab_Widget_Redirects::EMPTY_GIF_CONTENT == $content || Urlslab_Widget_Redirects::EMPTY_PNG_CONTENT == $content ) {
     250                    unlink( $local_tmp_file );
     251
     252                    return '';
     253                }
     254            }
     255        }
     256
    240257        return $local_tmp_file;
    241258    }
  • urlslab/trunk/includes/tool/class-urlslab-tool-config.php

    r3025823 r3028541  
    7979
    8080    public static function get_config_file_name() {
    81         if ( ! function_exists( 'WP_Filesystem' ) ) {
     81        if ( ! function_exists( 'WP_Filesystem' ) && is_file( ABSPATH . '/wp-admin/includes/file.php' ) ) {
    8282            require_once ABSPATH . '/wp-admin/includes/file.php';
    8383            WP_Filesystem();
     
    8686        global $wp_filesystem;
    8787
    88         if ( file_exists( $wp_filesystem->abspath() . 'wp-config.php' ) ) {
    89             return $wp_filesystem->abspath() . 'wp-config.php';
    90         } else if ( file_exists( dirname( $wp_filesystem->abspath() ) . '/wp-config.php' ) ) {
    91             return dirname( $wp_filesystem->abspath() ) . '/wp-config.php';
     88        if ( $wp_filesystem ) {
     89            if ( file_exists( $wp_filesystem->abspath() . 'wp-config.php' ) ) {
     90                return $wp_filesystem->abspath() . 'wp-config.php';
     91            } else if ( file_exists( dirname( $wp_filesystem->abspath() ) . '/wp-config.php' ) ) {
     92                return dirname( $wp_filesystem->abspath() ) . '/wp-config.php';
     93            }
    9294        }
    9395
  • urlslab/trunk/includes/tool/class-urlslab-tool-htaccess.php

    r3027290 r3028541  
    3434
    3535    public function get_htaccess_file_name() {
    36         if ( ! function_exists( 'WP_Filesystem' ) ) {
     36        if ( file_exists( ABSPATH . 'wp-config.php' ) ) {
     37            return ABSPATH . '.htaccess';
     38        } else if ( file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
     39            return dirname( ABSPATH ) . '/.htaccess';
     40        }
     41
     42        if ( ! function_exists( 'WP_Filesystem' ) && is_file( ABSPATH . '/wp-admin/includes/file.php' ) ) {
    3743            require_once ABSPATH . '/wp-admin/includes/file.php';
    3844            WP_Filesystem();
     
    4147        global $wp_filesystem;
    4248
    43         if ( file_exists( $wp_filesystem->abspath() . 'wp-config.php' ) ) {
    44             return $wp_filesystem->abspath() . '.htaccess';
    45         } else if ( file_exists( dirname( $wp_filesystem->abspath() ) . '/wp-config.php' ) ) {
    46             return dirname( $wp_filesystem->abspath() ) . '/.htaccess';
     49        if ( $wp_filesystem ) {
     50            if ( file_exists( $wp_filesystem->abspath() . 'wp-config.php' ) ) {
     51                return $wp_filesystem->abspath() . '.htaccess';
     52            } else if ( file_exists( dirname( $wp_filesystem->abspath() ) . '/wp-config.php' ) ) {
     53                return dirname( $wp_filesystem->abspath() ) . '/.htaccess';
     54            }
    4755        }
    4856
     
    8391        }
    8492        $file_name = $this->get_htaccess_file_name();
    85         $fp        = fopen( $file_name . '.lock', 'w' );
     93        $fp        = @fopen( $file_name . '.lock', 'w' );
     94        $result    = false;
    8695        if ( $fp ) {
    8796            if ( flock( $fp, LOCK_EX ) ) {
  • urlslab/trunk/includes/widget/class-urlslab-widget-cache.php

    r3027290 r3028541  
    303303            $file_path = $this->get_page_cache_file_name( $url_obj->get_domain_name(), $url_obj->get_url_path() );
    304304
    305             if ( ! function_exists( 'WP_Filesystem' ) ) {
     305            if ( ! function_exists( 'WP_Filesystem' ) && is_file( ABSPATH . '/wp-admin/includes/file.php' ) ) {
    306306                require_once ABSPATH . '/wp-admin/includes/file.php';
    307307                WP_Filesystem();
     
    429429
    430430    public function invalidate_old_cache() {
    431         if ( ! function_exists( 'WP_Filesystem' ) ) {
     431        if ( ! function_exists( 'WP_Filesystem' ) && is_file( ABSPATH . '/wp-admin/includes/file.php' ) ) {
    432432            require_once ABSPATH . '/wp-admin/includes/file.php';
    433433            WP_Filesystem();
     
    435435        /** @var WP_Filesystem_Base $wp_filesystem */
    436436        global $wp_filesystem;
    437         $dir_name = wp_get_upload_dir()['basedir'] . '/urlslab/page/';
    438         //get list of directories in $dir_name
    439         $dir_list = glob( $dir_name . '*', GLOB_ONLYDIR | GLOB_NOSORT );
    440         foreach ( $dir_list as $dir ) {
    441             if ( preg_match( '/\/(\d+)$/', $dir, $matches ) ) {
    442                 if ( is_numeric( $matches[1] ) && $matches[1] < $this->get_option( self::SETTING_NAME_CACHE_VALID_FROM ) ) {
    443                     $wp_filesystem->delete( $dir, true );
     437        if ( $wp_filesystem ) {
     438            $dir_name = wp_get_upload_dir()['basedir'] . '/urlslab/page/';
     439            //get list of directories in $dir_name
     440            $dir_list = glob( $dir_name . '*', GLOB_ONLYDIR | GLOB_NOSORT );
     441            foreach ( $dir_list as $dir ) {
     442                if ( preg_match( '/\/(\d+)$/', $dir, $matches ) ) {
     443                    if ( is_numeric( $matches[1] ) && $matches[1] < $this->get_option( self::SETTING_NAME_CACHE_VALID_FROM ) ) {
     444                        $wp_filesystem->delete( $dir, true );
     445                    }
    444446                }
    445447            }
  • urlslab/trunk/includes/widget/class-urlslab-widget-media-offloader.php

    r3027290 r3028541  
    5858    // speed: Default value 6. Accepted values are int the range of 0 (slowest) through 10 (fastest). Integers outside the 0-10 range are clamped.
    5959    public const SETTING_DEFAULT_AVIF_SPEED = 1;
    60     public const SETTING_NAME_MEDIA_CACHE_EXPIRE_TIME = 'urlslab_media_cache_expire';
    6160
    6261    public const SETTING_NAME_IMAGE_RESIZING = 'urlslab_img_resize';
     
    147146            false,
    148147            null,
    149             'main'
    150         );
    151 
    152         $this->add_option_definition(
    153             self::SETTING_NAME_MEDIA_CACHE_EXPIRE_TIME,
    154             31536000,
    155             true,
    156             function () {
    157                 return __( 'Cache Expiration', 'urlslab' );
    158             },
    159             function () {
    160                 return __( 'Specify caching duration for images in the browser or CDN.', 'urlslab' );
    161             },
    162             self::OPTION_TYPE_LISTBOX,
    163             function () {
    164                 return array(
    165                     3600     => __( 'One hour', 'urlslab' ),
    166                     28800    => __( 'Eight hours', 'urlslab' ),
    167                     86400    => __( 'One day', 'urlslab' ),
    168                     604800   => __( 'One week', 'urlslab' ),
    169                     2592000  => __( 'One moth', 'urlslab' ),
    170                     7776000  => __( 'Three months', 'urlslab' ),
    171                     15552000 => __( 'Six months', 'urlslab' ),
    172                     31536000 => __( 'One year', 'urlslab' ),
    173                     0        => __( 'No cache', 'urlslab' ),
    174                 );
    175             },
    176             function ( $value ) {
    177                 return is_numeric( $value ) && 0 <= $value;
    178             },
    179148            'main'
    180149        );
     
    11161085    }
    11171086
    1118     private function schedule_missing_images( array $urls ) {
     1087    private function schedule_missing_images( array $urls ): void {
     1088        if ( empty( $urls ) ) {
     1089            return;
     1090        }
     1091
    11191092        $save_internal = $this->get_option( self::SETTING_NAME_SAVE_INTERNAL );
    11201093        $save_external = $this->get_option( self::SETTING_NAME_SAVE_EXTERNAL );
     
    12531226            @header( 'Content-Disposition: inline; filename="' . $file->get_filename() . '"' );
    12541227            @header( 'Content-Transfer-Encoding: binary' );
    1255             @header( 'Content-length: ' . strlen( $content ) );
     1228            @header( 'Content-length: ' . $file->get_filesize() );
    12561229            echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    12571230            flush();
  • urlslab/trunk/includes/widget/class-urlslab-widget-redirects.php

    r3025823 r3028541  
    22
    33class Urlslab_Widget_Redirects extends Urlslab_Widget {
    4     public const SLUG                                    = 'redirects';
    5     public const SETTING_NAME_LOGGING                    = 'urlslab_redir_log';
    6     public const SETTING_NAME_LOG_HISTORY_MAX_TIME       = 'urlslab_redir_log_max_time';
    7     public const SETTING_NAME_LOG_HISTORY_MAX_ROWS       = 'urlslab_redir_log_max_rows';
    8     public const SETTING_NAME_DEFAULT_REDIRECT_URL       = 'urlslab_redir_default_url';
     4    public const SLUG = 'redirects';
     5    public const SETTING_NAME_LOGGING = 'urlslab_redir_log';
     6    public const SETTING_NAME_LOG_HISTORY_MAX_TIME = 'urlslab_redir_log_max_time';
     7    public const SETTING_NAME_LOG_HISTORY_MAX_ROWS = 'urlslab_redir_log_max_rows';
     8    public const SETTING_NAME_DEFAULT_REDIRECT_URL = 'urlslab_redir_default_url';
    99    public const SETTING_NAME_DEFAULT_REDIRECT_URL_IMAGE = 'urlslab_redir_default_url_image';
    1010
    11     public const CACHE_GROUP            = 'Urlslab_Widget_Redirects';
    12     const SETTING_NAME_AI_REDIRECTS     = 'urlslab_redir_ai_redirects';
    13     const SETTING_NAME_MIN_404_COUNT    = 'urlslab_redir_min_404_count';
     11    public const CACHE_GROUP = 'Urlslab_Widget_Redirects';
     12    const SETTING_NAME_AI_REDIRECTS = 'urlslab_redir_ai_redirects';
     13    const SETTING_NAME_MIN_404_COUNT = 'urlslab_redir_min_404_count';
    1414    const SETTING_NAME_IMG_EMPTY_ON_404 = 'urlslab_redir_img_on_404';
    1515    const SETTING_NAME_REDIRECT_TO_HTTPS = 'urlslab-cache-redirect-to-https';
     
    1717    const NONWWW_TO_WWW = 'nw';
    1818    const WWW_TO_NONWWW = 'wn';
     19    public const EMPTY_GIF_CONTENT = "\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x90\x00\x00\xff\x00\x00\x00\x00\x00\x21\xf9\x04\x05\x10\x00\x00\x00\x2c\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x04\x01\x00\x3b";
     20    public const EMPTY_PNG_CONTENT = "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\x00\x00\x01\x00\x00\x00\x01\x01\x03\x00\x00\x00\x25\xdb\x56\xca\x00\x00\x00\x03\x50\x4c\x54\x45\x00\x00\x00\xa7\x7a\x3d\xda\x00\x00\x00\x01\x74\x52\x4e\x53\x00\x40\xe6\xd8\x66\x00\x00\x00\x0a\x49\x44\x41\x54\x08\xd7\x63\x60\x00\x00\x00\x02\x00\x01\xe2\x21\xbc\x33\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
    1921
    2022    public function get_widget_labels(): array {
     
    658660                if ( preg_match( '/\.gif/i', $_SERVER['REQUEST_URI'] ) ) {
    659661                    @header( 'Content-Type: image/gif' );
    660                     die( "\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x90\x00\x00\xff\x00\x00\x00\x00\x00\x21\xf9\x04\x05\x10\x00\x00\x00\x2c\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x04\x01\x00\x3b" );
     662                    die( self::EMPTY_GIF_CONTENT ); // phpcs:ignore
    661663                }
    662664                @header( 'Content-Type: image/png' );
    663                 die( "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\x00\x00\x01\x00\x00\x00\x01\x01\x03\x00\x00\x00\x25\xdb\x56\xca\x00\x00\x00\x03\x50\x4c\x54\x45\x00\x00\x00\xa7\x7a\x3d\xda\x00\x00\x00\x01\x74\x52\x4e\x53\x00\x40\xe6\xd8\x66\x00\x00\x00\x0a\x49\x44\x41\x54\x08\xd7\x63\x60\x00\x00\x00\x02\x00\x01\xe2\x21\xbc\x33\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82" );
     665                die( self::EMPTY_PNG_CONTENT ); // phpcs:ignore
    664666            }
    665667        }
  • urlslab/trunk/includes/widget/class-urlslab-widget-security.php

    r3025823 r3028541  
    5454    );
    5555
     56    public function add_to_csp_settings( Urlslab_Data_Csp $csp_violation ): bool {
     57        switch ( $csp_violation->get_violated_directive() ) {
     58            case 'script-src':
     59                $setting_name = self::SETTING_NAME_CSP_SCRIPT;
     60                break;
     61            case 'script-src-elem':
     62                $setting_name = self::SETTING_NAME_CSP_ELEM;
     63                break;
     64            case 'script-src-attr':
     65                $setting_name = self::SETTING_NAME_CSP_SCR_ATTR;
     66                break;
     67            case 'style-src':
     68                $setting_name = self::SETTING_NAME_CSP_STYLE;
     69                break;
     70            case 'style-src-elem':
     71                $setting_name = self::SETTING_NAME_CSP_SRC_ELEM;
     72                break;
     73            case 'style-src-attr':
     74                $setting_name = self::SETTING_NAME_CSP_SRC_ATTR;
     75                break;
     76            case 'img-src':
     77                $setting_name = self::SETTING_NAME_CSP_IMG;
     78                break;
     79            case 'font-src':
     80                $setting_name = self::SETTING_NAME_CSP_FONT;
     81                break;
     82            case 'connect-src':
     83                $setting_name = self::SETTING_NAME_CSP_CONNECT;
     84                break;
     85            case 'media-src':
     86                $setting_name = self::SETTING_NAME_CSP_MEDIA;
     87                break;
     88            case 'object-src':
     89                $setting_name = self::SETTING_NAME_CSP_OBJECT;
     90                break;
     91            case 'child-src':
     92                $setting_name = self::SETTING_NAME_CSP_CHILD;
     93                break;
     94            case 'frame-src':
     95                $setting_name = self::SETTING_NAME_CSP_FRAME;
     96                break;
     97            case 'manifest-src':
     98                $setting_name = self::SETTING_NAME_CSP_MANIFEST;
     99                break;
     100            case 'worker-src':
     101                $setting_name = self::SETTING_NAME_CSP_WORKER;
     102                break;
     103            case 'base-uri':
     104                $setting_name = self::SETTING_NAME_CSP_BASE_URI;
     105                break;
     106            case 'form-action':
     107                $setting_name = self::SETTING_NAME_CSP_ACTION;
     108                break;
     109            case 'default-src':
     110                $setting_name = self::SETTING_NAME_CSP_DEFAULT;
     111                break;
     112            default:
     113                return false;
     114        }
     115
     116        $setting_values = explode( ' ', $this->get_option( $setting_name ) );
     117        $value          = $csp_violation->get_blocked_url();
     118        switch ( $value ) {
     119            case 'self':
     120                $value = "'self'";
     121                break;
     122            case 'unsafe-inline':
     123                $value = "'unsafe-inline'";
     124                break;
     125            case 'unsafe-eval':
     126                $value = "'unsafe-eval'";
     127                break;
     128            case 'unsafe-hashes':
     129                $value = "'unsafe-hashes'";
     130                break;
     131            case 'wasm-unsafe-eval':
     132                $value = "'wasm-unsafe-eval'";
     133                break;
     134            case 'strict-dynamic':
     135                $value = "'strict-dynamic'";
     136                break;
     137            case 'report-sample':
     138                $value = "'report-sample'";
     139                break;
     140            case 'inline-speculation-rules':
     141                $value = "'inline-speculation-rules'";
     142                break;
     143            case 'blob':
     144                $value = 'blob:';
     145                break;
     146            case 'data':
     147                $value = 'data:';
     148                break;
     149            default:
     150                try {
     151                    $url   = new Urlslab_Url( $value, true );
     152                    $value = $url->get_domain_name();
     153                } catch ( Exception $e ) {
     154                    return false;
     155                }
     156                break;
     157        }
     158
     159        if ( ! in_array( $value, $setting_values, true ) ) {
     160            $setting_values[] = $value;
     161            return $this->update_option( $setting_name, trim( implode( ' ', $setting_values ) ) );
     162        }
     163
     164        return false;
     165    }
     166
    56167    private static function is_valid_csp_value( $value ): bool {
    57168        // Split the directive value into parts to validate each source separately
  • urlslab/trunk/readme.txt

    r3027290 r3028541  
    55Tested up to: 6.4
    66Requires PHP: 7.4
    7 Stable tag: 2.120.0
     7Stable tag: 2.120.1
    88License: GPLv2
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    144144== Changelog ==
    145145
     146= 2.120.1 - 2024-01-30 =
     147
     148* Experience a smoother user journey with our under-the-hood enhancements.
     149
    146150= 2.120.0 - 2024-01-26 =
    147151
  • urlslab/trunk/uninstall.php

    r3025823 r3028541  
    6868}
    6969
    70 $htaccess = new Urlslab_Tool_Htaccess();
    71 $htaccess->cleanup();
    72 Urlslab_Tool_Config::clear_advanced_cache();
     70if ( file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
     71    $file_name = dirname( ABSPATH ) . '/.htaccess';
     72} else {
     73    $file_name = ABSPATH . '.htaccess';
     74}
    7375
    74 return;
     76insert_with_markers( $file_name, 'URLSLAB', array() );
  • urlslab/trunk/urlslab.php

    r3027290 r3028541  
    1717 * Plugin URI:        https://github.com/QualityUnit/wp-urlslab
    1818 * Description:       URLsLab WordPress Plugin to optimize your website for search engines and enhance automatically content
    19  * Version: 2.120.0
     19 * Version: 2.120.1
    2020 * Requires at least: 6.0
    2121 * Requires PHP:      7.4
     
    3131}
    3232
    33 define( 'URLSLAB_VERSION', '2.120.0' );
     33define( 'URLSLAB_VERSION', '2.120.1' );
    3434define( 'URLSLAB_VERSION_SETTING', 'urlslab_ver' );
    3535define( 'URLSLAB_PLUGIN', __FILE__ );
  • urlslab/trunk/vendor_prefixed/composer/installed.php

    r3027290 r3028541  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '915c2308fa0fe2310e8d1d01326031d97a07ca1d',
     6        'reference' => '004c8cb2280583798f651840b8005b0a58b7b3ea',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '915c2308fa0fe2310e8d1d01326031d97a07ca1d',
     16            'reference' => '004c8cb2280583798f651840b8005b0a58b7b3ea',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../',
Note: See TracChangeset for help on using the changeset viewer.