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

View File

@@ -0,0 +1,17 @@
<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase -- This filename format is required to dynamically load the necessary block dependencies.
/**
* Block script dependencies.
*
* @package RankMath
* @subpackage RankMath\ContentAI
* @author Rank Math <support@rankmath.com>
*/
return [
'dependencies' => [
'wp-element',
'wp-block-editor',
'lodash',
],
'version' => rank_math()->version,
];

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "rank-math/command",
"title": "AI Assistant [Content AI]",
"icon": "star",
"category": "rank-math-blocks",
"description": "Generate content without any hassle, powered by Rank Math's Content AI.",
"keywords": [ "ai", "content", "rank math", "rankmath", "content ai", "seo" ],
"textdomain": "rank-math-pro",
"editorScript": "file:../js/index.js",
"attributes": {
"content": {
"type": "string",
"source": "html",
"selector": "p",
"default": "<span>//</span>",
"__experimentalRole": "content"
}
}
}

View File

@@ -0,0 +1,229 @@
/**
* WordPress dependencies
*/
import {
RichText,
useBlockProps,
BlockControls,
store as blockEditorStore,
} from '@wordpress/block-editor'
import { useDispatch } from '@wordpress/data'
import { useRef, useEffect } from '@wordpress/element'
import { __ } from '@wordpress/i18n'
/**
* Internal dependencies
*/
import hasError from '../../../../assets/src/helpers/hasError'
import insertCommandBox, { useBlock, regenerateOutput, writeMore } from '../../../../assets/src/shortcutCommand/insertCommandBox'
import getWriteAttributes from '../../../../assets/src/helpers/getWriteAttributes'
import getBlockContent from '../../../../assets/src/helpers/getBlockContent'
const getErrorMessage = () => {
// This function can be simplified now that the error message comes from the API.
// It's still useful for showing general errors not from the API.
if ( ! rankMath.contentAI.isUserRegistered ) {
return (
<>
{ __( 'Start using Content AI by connecting your RankMath account.', 'rank-math' ) }
<a href={ rankMath.connectSiteUrl }>{ __( 'Connect Now', 'rank-math' ) }</a>
</>
)
}
if ( ! rankMath.contentAI.plan ) {
return (
<>
{ __( 'You do not have a Content AI plan.', 'rank-math' ) }
<a href="https://rankmath.com/kb/how-to-use-content-ai/?play-video=ioPeVIntJWw&utm_source=Plugin&utm_medium=Buy+Plan+Button&utm_campaign=WP">
{ __( 'Choose your plan', 'rank-math' ) }
</a>
</>
)
}
return (
<>
{ __( 'You have exhausted your Content AI Credits.', 'rank-math' ) }
<a href="https://rankmath.com/kb/how-to-use-content-ai/?play-video=ioPeVIntJWw&utm_source=Plugin&utm_medium=Buy+Credits+Button&utm_campaign=WP" target="_blank" rel="noreferrer">
{ __( 'Get more', 'rank-math' ) }
</a>
</>
)
}
export default ( {
attributes,
onReplace,
setAttributes,
clientId,
} ) => {
// Note the addition of `hasApiError` in the attributes destructuring.
const { content, isAiGenerated, hasApiError, endpoint, params } = attributes
const blockProps = useBlockProps( {
className: 'rank-math-content-ai-command',
} )
const { updateBlockAttributes, removeBlock } = useDispatch( blockEditorStore )
const blockHook = useBlock // assign the hook to a variable
const contentEditableRef = useRef( null )
useEffect( () => {
const { current: contentEditable } = contentEditableRef
if ( ! contentEditable ) {
return
}
contentEditable.focus()
const range = document.createRange()
const selection = window.getSelection()
range.selectNodeContents( contentEditable )
range.collapse( false )
selection.removeAllRanges()
selection.addRange( range )
}, [] )
const handleRunCommand = () => {
const text = getBlockContent( { attributes } )
if ( ! text.trim() ) {
return
}
updateBlockAttributes(
clientId,
{
content: '',
className: '',
}
)
insertCommandBox( 'Write', getWriteAttributes( text ), clientId )
}
const handleDismissCommand = () => {
removeBlock( clientId )
}
const handleUseBlock = () => {
blockHook( clientId, attributes )
}
const handleRegenerateOutput = () => {
regenerateOutput( clientId, endpoint, params )
}
const handleWriteMore = () => {
writeMore( clientId )
}
const handleKeyDown = ( event ) => {
if ( event.key === 'Enter' && ! isAiGenerated ) {
event.preventDefault()
handleRunCommand()
}
}
const contentTrimmed = content.replace( /(<([^>]+)>)/ig, '' ).trim()
const renderActionButtons = () => {
// This is the correct condition to show the dismiss button on API error.
if ( hasApiError ) {
return (
<button
className="button button-small rank-math-content-ai-dismiss"
title={ __( 'Dismiss', 'rank-math' ) }
onClick={ handleDismissCommand }
contentEditable={ false }
>
{ __( 'Dismiss', 'rank-math' ) }
</button>
)
}
if ( isAiGenerated ) {
return (
<div className="rank-math-content-ai-command-buttons">
<button
className="button button-small rank-math-content-ai-use"
onClick={ handleUseBlock }
>
<span>{ __( 'Use', 'rank-math' ) }</span>
</button>
<button
className="button button-small rank-math-content-ai-regenerate"
onClick={ handleRegenerateOutput }
>
<span>{ __( 'Regenerate', 'rank-math' ) }</span>
</button>
<button
className="button button-small rank-math-content-ai-write-more"
onClick={ handleWriteMore }
>
<span>{ __( 'Write More', 'rank-math' ) }</span>
</button>
</div>
)
}
// This is the condition for the initial command box.
if ( contentTrimmed.length > 0 ) {
return (
<>
<button
className="rank-math-content-ai-command-button"
title={ __( 'Click or Press Enter', 'rank-math' ) }
onClick={ handleRunCommand }
contentEditable={ false }
>
<i className="rm-icon rm-icon-enter-key"></i>
</button>
<button
className="rank-math-command-dismiss-button"
title={ __( 'Dismiss', 'rank-math' ) }
onClick={ handleDismissCommand }
contentEditable={ false }
>
{ __( 'Close', 'rank-math' ) }
</button>
</>
)
}
return null
}
return (
<div { ...blockProps }>
<BlockControls />
{
hasError() &&
<div className="rich-text" ref={ contentEditableRef }>
{ getErrorMessage() }
</div>
}
{ ! hasError() &&
<>
<RichText
tagName="div"
allowedFormats={ [] }
value={ content }
onChange={ ( newContent ) => {
setAttributes( { content: newContent } )
} }
onSplit={ () => false }
onReplace={ onReplace }
data-empty={ content ? false : true }
onKeyDown={ handleKeyDown }
ref={ contentEditableRef }
/>
<div className="rank-math-content-ai-command-buttons">
{ renderActionButtons() }
</div>
</>
}
</div>
)
}

View File

@@ -0,0 +1,21 @@
/**
* WordPress dependencies
*/
import { registerBlockType } from '@wordpress/blocks'
/**
* Internal dependencies
*/
import edit from './edit'
import metadata from './block.json'
const { name } = metadata
export { metadata, name }
export const settings = {
icon: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17.08 18.02"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M16.65,12.08a.83.83,0,0,0-1.11.35A7.38,7.38,0,1,1,9,1.63a7.11,7.11,0,0,1,.92.06A2.52,2.52,0,0,1,11,.23,8.87,8.87,0,0,0,9,0a9,9,0,1,0,8,13.19A.83.83,0,0,0,16.65,12.08Z"/><path d="M7.68,7.29A1.58,1.58,0,0,0,6.2,8.94a1.57,1.57,0,0,0,1.48,1.64A1.56,1.56,0,0,0,9.16,8.94,1.57,1.57,0,0,0,7.68,7.29Z" /><path d="M13.34,4.71a2.45,2.45,0,0,1-1,.2A2.53,2.53,0,0,1,9.93,3,7.18,7.18,0,0,0,9.12,3a6,6,0,1,0,4.22,1.73ZM10.53,11.3a.75.75,0,1,1-1.5,0v-.06a2.4,2.4,0,0,1-1.66.69,2.81,2.81,0,0,1-2.58-3,2.82,2.82,0,0,1,2.58-3A2.39,2.39,0,0,1,9,6.64a.75.75,0,0,1,1.5.07Zm2.56,0a.75.75,0,1,1-1.5,0V6.71a.75.75,0,1,1,1.5,0Z" /><circle cx="12.42" cy="2.37" r="1.45" /></g></g></svg>,
edit,
}
registerBlockType( { name, ...metadata }, settings )

View File

@@ -0,0 +1,65 @@
<?php
/**
* The TOC Block
*
* @since 1.0.104
* @package RankMath
* @subpackage RankMath\ContentAI
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\ContentAI;
use WP_Block_Type_Registry;
use RankMath\Helper;
use RankMath\Traits\Hooker;
defined( 'ABSPATH' ) || exit;
/**
* Content AI Command Block class.
*/
class Block_Command {
use Hooker;
/**
* Block type name.
*
* @var string
*/
private $block_type = 'rank-math/command';
/**
* The single instance of the class.
*
* @var Block_Command
*/
protected static $instance = null;
/**
* Retrieve main Block_Command instance.
*
* Ensure only one instance is loaded or can be loaded.
*
* @return Block_Command
*/
public static function get() {
if ( is_null( self::$instance ) && ! ( self::$instance instanceof Block_Command ) ) {
self::$instance = new Block_Command();
}
return self::$instance;
}
/**
* The Constructor.
*/
public function __construct() {
if ( WP_Block_Type_Registry::get_instance()->is_registered( $this->block_type ) ) {
return;
}
register_block_type( RANK_MATH_PATH . 'includes/modules/content-ai/blocks/command/assets/src/block.json' );
}
}