Commit realizado el 12:13:52 08-04-2024
This commit is contained in:
161
wp-content/plugins/seo-by-rank-math-pro/includes/3rdparty/elementor/class-elementor.php
vendored
Normal file
161
wp-content/plugins/seo-by-rank-math-pro/includes/3rdparty/elementor/class-elementor.php
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* Elementor integration.
|
||||
*
|
||||
* @since 2.0.8
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Core
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMathPro\Elementor;
|
||||
|
||||
use RankMath\Helper;
|
||||
use RankMath\Traits\Hooker;
|
||||
use Elementor\Controls_Manager;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Elementor class.
|
||||
*/
|
||||
class Elementor {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->action( 'elementor/editor/before_enqueue_scripts', 'editor_scripts' );
|
||||
$this->action( 'elementor/widgets/register', 'add_breadcrumb_widget' );
|
||||
$this->action( 'elementor/element/accordion/section_title/before_section_end', 'add_faq_setting', 99 );
|
||||
$this->filter( 'rank_math/json_ld', 'add_faq_schema', 99 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the editor scripts.
|
||||
*/
|
||||
public function editor_scripts() {
|
||||
|
||||
wp_dequeue_script( 'rank-math-pro-metabox' );
|
||||
wp_enqueue_style(
|
||||
'rank-math-pro-editor',
|
||||
RANK_MATH_PRO_URL . 'assets/admin/css/elementor.css',
|
||||
[],
|
||||
RANK_MATH_PRO_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'rank-math-pro-editor',
|
||||
RANK_MATH_PRO_URL . 'assets/admin/js/elementor.js',
|
||||
[
|
||||
'rank-math-editor',
|
||||
],
|
||||
RANK_MATH_PRO_VERSION,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Breadcrumb Widget in Elementor Editor.
|
||||
*
|
||||
* @param Widgets_Manager $widget The widgets manager.
|
||||
*/
|
||||
public function add_breadcrumb_widget( $widget ) {
|
||||
$widget->register( new Widget_Breadcrumbs() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add toggle to enable/disable FAQ schema in Accordion Widget.
|
||||
*
|
||||
* @param Controls_Stack $widget The control.
|
||||
*/
|
||||
public function add_faq_setting( $widget ) {
|
||||
$widget->add_control(
|
||||
'rank_math_add_faq_schema',
|
||||
[
|
||||
'label' => esc_html__( 'Add FAQ Schema Markup', 'rank-math-pro' ),
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'separator' => 'before',
|
||||
'description' => esc_html__( 'Added by the Rank Math SEO Plugin.', 'rank-math-pro' ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add FAQ schema using the accordion content.
|
||||
*
|
||||
* @param array $data Array of json-ld data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_faq_schema( $data ) {
|
||||
if ( ! is_singular() ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
global $post;
|
||||
$elementor_document = \Elementor\Plugin::$instance->documents->get( $post->ID );
|
||||
if ( ! $elementor_document || ! $elementor_document->is_built_with_elementor() ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$elementor_data = get_post_meta( $post->ID, '_elementor_data', true );
|
||||
if ( ! empty( $elementor_data ) && is_string( $elementor_data ) ) {
|
||||
$elementor_data = json_decode( $elementor_data, true );
|
||||
}
|
||||
|
||||
$accordion_data = $this->get_accordion_data( $elementor_data );
|
||||
if ( empty( $accordion_data ) ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data['faq-data'] = [
|
||||
'@type' => 'FAQPage',
|
||||
];
|
||||
|
||||
foreach ( $accordion_data as $faqs ) {
|
||||
foreach ( $faqs as $faq ) {
|
||||
$data['faq-data']['mainEntity'][] = [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['tab_title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['tab_content'],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get accordion data.
|
||||
*
|
||||
* @param array $elements Elements Data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_accordion_data( $elements ) {
|
||||
if ( ! is_array( $elements ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$results = [];
|
||||
if (
|
||||
isset( $elements['rank_math_add_faq_schema'] ) &&
|
||||
'yes' === $elements['rank_math_add_faq_schema'] &&
|
||||
! empty( $elements['tabs'] )
|
||||
) {
|
||||
$results[] = $elements['tabs'];
|
||||
}
|
||||
|
||||
foreach ( $elements as $element ) {
|
||||
$results = array_merge( $results, $this->get_accordion_data( $element ) );
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
232
wp-content/plugins/seo-by-rank-math-pro/includes/3rdparty/elementor/class-widget-breadcrumbs.php
vendored
Normal file
232
wp-content/plugins/seo-by-rank-math-pro/includes/3rdparty/elementor/class-widget-breadcrumbs.php
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/**
|
||||
* Elementor Integration.
|
||||
*
|
||||
* @since 2.0.8
|
||||
* @package RankMathPro
|
||||
* @subpackage RankMath\Core
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
* @copyright Copyright (C) 2008-2019, Elementor Ltd
|
||||
* The following code is a derivative work of the code from the Elementor(https://github.com/elementor/elementor/), which is licensed under GPL v3.
|
||||
*/
|
||||
|
||||
namespace RankMathPro\Elementor;
|
||||
|
||||
use RankMath\Helper;
|
||||
use Elementor\Widget_Base;
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Typography;
|
||||
use Elementor\Core\Schemes\Typography;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Elementor Breadcrumb Widget class.
|
||||
*/
|
||||
class Widget_Breadcrumbs extends Widget_Base {
|
||||
|
||||
/**
|
||||
* Get element name.
|
||||
*
|
||||
* @return string The name.
|
||||
*/
|
||||
public function get_name() {
|
||||
return 'breadcrumbs';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element title.
|
||||
*
|
||||
* @return string Element title.
|
||||
*/
|
||||
public function get_title() {
|
||||
return __( 'Breadcrumbs', 'rank-math-pro' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element icon.
|
||||
*
|
||||
* @return string Element icon.
|
||||
*/
|
||||
public function get_icon() {
|
||||
return 'eicon-rank-math';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget keywords.
|
||||
*
|
||||
* @return array Widget keywords.
|
||||
*/
|
||||
public function get_keywords() {
|
||||
return [ 'rankmath', 'seo', 'breadcrumbs', 'rank math', 'schema' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register model controls. Used to add new controls to the page settings model.
|
||||
*/
|
||||
protected function register_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_breadcrumbs_content',
|
||||
[
|
||||
'label' => __( 'Breadcrumbs', 'rank-math-pro' ),
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! Helper::is_breadcrumbs_enabled() ) {
|
||||
$this->add_control(
|
||||
'html_disabled_alert',
|
||||
[
|
||||
'raw' => __( 'Breadcrumbs are disabled in the Rank Math SEO', 'rank-math-pro' ) . ' ' . sprintf( '<a href="%s" target="_blank">%s</a>', admin_url( 'admin.php?page=rank-math-options-general#setting-panel-breadcrumbs' ), __( 'Breadcrumbs Panel', 'rank-math-pro' ) ),
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'content_classes' => 'elementor-panel-alert elementor-panel-alert-danger',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$this->add_responsive_control(
|
||||
'align',
|
||||
[
|
||||
'label' => __( 'Alignment', 'rank-math-pro' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'options' => [
|
||||
'left' => [
|
||||
'title' => __( 'Left', 'rank-math-pro' ),
|
||||
'icon' => 'eicon-text-align-left',
|
||||
],
|
||||
'center' => [
|
||||
'title' => __( 'Center', 'rank-math-pro' ),
|
||||
'icon' => 'eicon-text-align-center',
|
||||
],
|
||||
'right' => [
|
||||
'title' => __( 'Right', 'rank-math-pro' ),
|
||||
'icon' => 'eicon-text-align-right',
|
||||
],
|
||||
],
|
||||
'prefix_class' => 'elementor%s-align-',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'html_tag',
|
||||
[
|
||||
'label' => __( 'HTML Tag', 'rank-math-pro' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => [
|
||||
'' => __( 'Default', 'rank-math-pro' ),
|
||||
'p' => 'p',
|
||||
'div' => 'div',
|
||||
'nav' => 'nav',
|
||||
'span' => 'span',
|
||||
],
|
||||
'default' => '',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'html_description',
|
||||
[
|
||||
'raw' => __( 'Additional settings are available in the Rank Math SEO', 'rank-math-pro' ) . ' ' . sprintf( '<a href="%s" target="_blank">%s</a>', admin_url( 'admin.php?page=rank-math-options-general#setting-panel-breadcrumbs' ), __( 'Breadcrumbs Panel', 'rank-math-pro' ) ),
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'content_classes' => 'elementor-descriptor',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_style',
|
||||
[
|
||||
'label' => __( 'Breadcrumbs', 'rank-math-pro' ),
|
||||
'tab' => Controls_Manager::TAB_STYLE,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'name' => 'typography',
|
||||
'selector' => '{{WRAPPER}}',
|
||||
'scheme' => Typography::TYPOGRAPHY_2,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'text_color',
|
||||
[
|
||||
'label' => __( 'Text Color', 'rank-math-pro' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'default' => '',
|
||||
'selectors' => [
|
||||
'{{WRAPPER}}' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->start_controls_tabs( 'tabs_breadcrumbs_style' );
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_color_normal',
|
||||
[
|
||||
'label' => __( 'Normal', 'rank-math-pro' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'link_color',
|
||||
[
|
||||
'label' => __( 'Link Color', 'rank-math-pro' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'default' => '',
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} a' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_color_hover',
|
||||
[
|
||||
'label' => __( 'Hover', 'rank-math-pro' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'link_hover_color',
|
||||
[
|
||||
'label' => __( 'Color', 'rank-math-pro' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} a:hover' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML tag. Retrieve the section element HTML tag.
|
||||
*
|
||||
* @param array $args Html tags args.
|
||||
*
|
||||
* @return array Section HTML tag.
|
||||
*/
|
||||
public function get_html_tag( $args ) {
|
||||
$html_tag = $this->get_settings( 'html_tag' );
|
||||
if ( $html_tag ) {
|
||||
$args['wrap_before'] = "<{$html_tag}>";
|
||||
$args['wrap_after'] = "</{$html_tag}>";
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render element. Generates the final HTML on the frontend.
|
||||
*/
|
||||
protected function render() {
|
||||
add_filter( 'rank_math/frontend/breadcrumb/args', [ $this, 'get_html_tag' ] );
|
||||
rank_math_the_breadcrumbs();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user