Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,124 @@
/**
* External dependencies
*/
import { map } from 'lodash'
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n'
import { withSelect } from '@wordpress/data'
import { InspectorControls } from '@wordpress/block-editor'
import { PanelBody, SelectControl, TextControl } from '@wordpress/components'
/**
* Format array of image sizes.
*
* @param {Array} imageSizes Array of image sizes.
* @return {Array} Formatted array.
*/
const getImageSizeOptions = ( imageSizes ) => {
return map( imageSizes, ( { name, slug } ) => ( {
value: slug,
label: name,
} ) )
}
/**
* Adds controls to the editor sidebar to control params.
*
* @param {Object} props This component's props.
*/
const Inspector = ( { imageSizes, attributes, setAttributes } ) => {
const imageSizeOptions = getImageSizeOptions( imageSizes )
return (
<InspectorControls key={ 'inspector' }>
<PanelBody title={ __( 'FAQ Options', 'rank-math' ) }>
<SelectControl
label={ __( 'List Style', 'rank-math' ) }
value={ attributes.listStyle }
options={ [
{
value: '',
label: __( 'None', 'rank-math' ),
},
{
value: 'numbered',
label: __( 'Numbered', 'rank-math' ),
},
{
value: 'unordered',
label: __( 'Unordered', 'rank-math' ),
},
] }
onChange={ ( listStyle ) => {
setAttributes( { listStyle } )
} }
/>
<SelectControl
label={ __( 'Title Wrapper', 'rank-math' ) }
value={ attributes.titleWrapper }
options={ [
{ value: 'h2', label: __( 'H2', 'rank-math' ) },
{ value: 'h3', label: __( 'H3', 'rank-math' ) },
{ value: 'h4', label: __( 'H4', 'rank-math' ) },
{ value: 'h5', label: __( 'H5', 'rank-math' ) },
{ value: 'h6', label: __( 'H6', 'rank-math' ) },
{ value: 'p', label: __( 'P', 'rank-math' ) },
{ value: 'div', label: __( 'DIV', 'rank-math' ) },
] }
onChange={ ( titleWrapper ) => {
setAttributes( { titleWrapper } )
} }
/>
<SelectControl
label={ __( 'Image Size', 'rank-math' ) }
value={ attributes.sizeSlug }
options={ imageSizeOptions }
onChange={ ( sizeSlug ) => {
setAttributes( { sizeSlug } )
} }
/>
</PanelBody>
<PanelBody title={ __( 'Styling Options', 'rank-math' ) }>
<TextControl
label={ __( 'Title Wrapper CSS Class(es)', 'rank-math' ) }
value={ attributes.titleCssClasses }
onChange={ ( titleCssClasses ) => {
setAttributes( { titleCssClasses } )
} }
/>
<TextControl
label={ __( 'Content Wrapper CSS Class(es)', 'rank-math' ) }
value={ attributes.contentCssClasses }
onChange={ ( contentCssClasses ) => {
setAttributes( { contentCssClasses } )
} }
/>
<TextControl
label={ __( 'List CSS Class(es)', 'rank-math' ) }
value={ attributes.listCssClasses }
onChange={ ( listCssClasses ) => {
setAttributes( { listCssClasses } )
} }
/>
</PanelBody>
</InspectorControls>
)
}
export default withSelect( ( select, props ) => {
const { getSettings } = select( 'core/block-editor' )
const { imageSizes } = getSettings()
return {
...props,
imageSizes,
}
} )( Inspector )

View File

@@ -0,0 +1,155 @@
/**
* External dependencies
*/
import classnames from 'classnames'
/**
* Internal dependencies
*/
import MediaUploader from '@blocks/shared/MediaUploader'
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n'
import { applyFilters } from '@wordpress/hooks'
import { Button } from '@wordpress/components'
import { Component } from '@wordpress/element'
import { RichText, MediaUpload } from '@wordpress/block-editor'
/**
* A Question and answer pair within FAQ block.
*/
class Question extends Component {
/**
* Renders the component.
*
* @return {Component} Question editor.
*/
render() {
const {
title,
content,
visible,
imageID,
sizeSlug,
titleWrapper,
titleCssClasses,
contentCssClasses,
} = this.props
const wrapperClasses = classnames( 'rank-math-question-wrapper', {
'question-not-visible': ! visible,
} )
return (
<div className={ wrapperClasses }>
<div className="rank-math-item-header">
<RichText
tagName={ titleWrapper }
className={
'rank-math-faq-question rank-math-block-title' +
titleCssClasses
}
value={ title }
onChange={ ( newTitle ) => {
this.setQuestionProp( 'title', newTitle )
} }
placeholder={ __( 'Question…', 'rank-math' ) }
/>
<div className="rank-math-block-actions">
{ applyFilters( 'rank_math_block_faq_actions', '', this.props, this ) }
<Button
className="rank-math-item-visbility"
icon={ visible ? 'visibility' : 'hidden' }
onClick={ this.toggleVisibility }
label={ __( 'Hide Question', 'rank-math' ) }
showTooltip={ true }
/>
<Button
icon="trash"
className="rank-math-item-delete"
onClick={ this.deleteQuestion }
label={ __( 'Delete Question', 'rank-math' ) }
showTooltip={ true }
/>
</div>
</div>
<div className="rank-math-item-content">
<RichText
tagName="div"
className={ 'rank-math-faq-answer ' + contentCssClasses }
value={ content }
onChange={ ( newContent ) => {
this.setQuestionProp( 'content', newContent )
} }
placeholder={ __(
'Enter the answer to the question',
'rank-math'
) }
/>
<MediaUpload
allowedTypes={ [ 'image' ] }
multiple={ false }
value={ imageID }
render={ ( { open } ) => (
<MediaUploader
imageID={ imageID }
sizeSlug={ sizeSlug }
open={ open }
removeImage={ () => {
this.setQuestionProp( 'imageID', 0 )
} }
/>
) }
onSelect={ ( image ) => {
this.setQuestionProp( 'imageID', image.id )
} }
/>
</div>
</div>
)
}
/**
* Update question properties.
*
* @param {string} prop Poperty name.
* @param {string} value Property value.
*/
setQuestionProp( prop, value ) {
const { setAttributes, index } = this.props
const questions = [ ...this.props.questions ]
questions[ index ][ prop ] = value
setAttributes( { questions } )
}
/**
* Toggle question visibility.
*/
toggleVisibility = () => {
const { setAttributes, index } = this.props
const questions = [ ...this.props.questions ]
questions[ index ].visible = ! this.props.visible
setAttributes( { questions } )
}
/**
* Delete question from block.
*/
deleteQuestion = () => {
const { setAttributes, index } = this.props
const questions = [ ...this.props.questions ]
questions.splice( index, 1 )
setAttributes( { questions } )
}
}
export default Question

View File

@@ -0,0 +1,141 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash'
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n'
import { Fragment } from '@wordpress/element'
import { Button, Dashicon } from '@wordpress/components'
import { BlockControls, AlignmentToolbar, useBlockProps } from '@wordpress/block-editor'
/**
* Internal dependencies
*/
import getLink from '@helpers/getLink'
import Inspector from './components/Inspector'
import Question from './components/Question'
import generateId from '@helpers/generateId'
/**
* Render Quetion component.
*
* @param {Object} props Block attributes
*
* @return {Array} Array of question editor.
*/
const renderQuestions = ( props ) => {
const {
sizeSlug,
titleWrapper,
titleCssClasses,
contentCssClasses,
} = props.attributes
let { questions } = props.attributes
if ( isEmpty( questions ) ) {
questions = [
{
id: generateId( 'faq-question' ),
title: '',
content: '',
visible: true,
},
]
props.setAttributes( { questions } )
}
return questions.map( ( question, index ) => {
return (
<li key={ question.id }>
<Question
{ ...question }
index={ index }
key={ question.id + '-question' }
questions={ questions }
setAttributes={ props.setAttributes }
sizeSlug={ sizeSlug }
titleWrapper={ titleWrapper }
titleCssClasses={ titleCssClasses }
contentCssClasses={ contentCssClasses }
/>
</li>
)
} )
}
/**
* Add an empty Question into block.
*
* @param {Object} props Block props.
*/
const addNew = ( props ) => {
const questions = [ ...props.attributes.questions ]
questions.push( {
id: generateId( 'faq-question' ),
title: '',
content: '',
visible: true,
} )
props.setAttributes( { questions } )
}
/**
* FAQ block edit component.
*
* @param {Object} props Block props.
*/
export default ( props ) => {
const { className, isSelected } = props
const { textAlign } = props.attributes
const blockProps = useBlockProps()
return (
<div { ...blockProps }>
<div
id="rank-math-faq"
className={ 'rank-math-block ' + className }
>
{ isSelected && <Inspector { ...props } /> }
{ isSelected && (
<Fragment>
<BlockControls>
<AlignmentToolbar
value={ textAlign }
onChange={ ( nextTextAlignment ) =>
props.setAttributes( {
textAlign: nextTextAlignment,
} )
}
/>
</BlockControls>
</Fragment>
) }
<ul style={ { textAlign } }>{ renderQuestions( props ) }</ul>
<Button
variant="primary"
onClick={ () => {
addNew( props )
} }
>
{ __( 'Add New FAQ', 'rank-math' ) }
</Button>
<a
href={ getLink( 'faq-schema-block', 'Add New FAQ' ) }
rel="noopener noreferrer"
target="_blank"
title={ __( 'More Info', 'rank-math' ) }
className={ 'rank-math-block-info' }
>
<Dashicon icon="info" />
</a>
</div>
</div>
)
}

View File

@@ -0,0 +1,18 @@
/**
* FAQ eample for in block preview pane.
*
* @type {Object}
*/
export default {
attributes: {
questions: [
{
visible: true,
titleWrapper: 'div',
title: 'Question',
content:
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
},
],
},
}

View File

@@ -0,0 +1,25 @@
/**
* WordPress dependencies
*/
import { registerBlockType } from '@wordpress/blocks'
/**
* Internal dependencies
*/
import example from './example'
import edit from './edit'
import transforms from './transforms'
import save from './save'
/**
* Register FAQ block.
*/
registerBlockType(
'rank-math/faq-block',
{
example,
edit,
save,
transforms,
}
)

View File

@@ -0,0 +1,52 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash'
/**
* WordPress dependencies
*/
import { RichText, useBlockProps } from '@wordpress/block-editor'
/**
* Save block for display on front
*
* @param {Object} props This component's props.
*/
export default ( props ) => {
const { questions, titleWrapper } = props.attributes
if ( isEmpty( questions ) ) {
return null
}
return (
<div { ...useBlockProps.save() }>
{ questions.map( ( question, index ) => {
if (
isEmpty( question.title ) ||
isEmpty( question.content ) ||
false === question.visible
) {
return null
}
return (
<div className="rank-math-faq-item" key={ index }>
<RichText.Content
tagName={ titleWrapper }
value={ question.title }
className="rank-math-question"
/>
<RichText.Content
tagName="div"
value={ question.content }
className="rank-math-answer"
/>
</div>
)
} ) }
</div>
)
}

View File

@@ -0,0 +1,35 @@
/**
* WordPress dependencies
*/
import { createBlock } from '@wordpress/blocks'
/**
* Transform yoast faq block.
*
* @type {Array}
*/
export default {
from: [
{
type: 'block',
blocks: [ 'yoast/faq-block' ],
transform: ( yoast ) => {
const questions = yoast.questions.map( ( question ) => {
return {
title: question.jsonQuestion,
content: question.jsonAnswer,
visible: true,
}
} )
const attributes = {
titleWrapper: 'h3',
questions,
className: yoast.className,
}
return createBlock( 'rank-math/faq-block', attributes )
},
},
],
}