Commit realizado el 12:13:52 08-04-2024
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.rank-math-ui.dashboard-wrapper.seo-analysis.seo_analyzer{position:relative;visibility:visible;padding-top:50px;background:#fff}.rank-math-ui.dashboard-wrapper.seo-analysis.seo_analyzer .button{display:none}.rank-math-ui.dashboard-wrapper.seo-analysis.seo_analyzer .rank-math-tooltip{display:none}.rank-math-ui.dashboard-wrapper.seo-analysis.seo_analyzer .chart span{animation:none !important}.rank-math-ui.dashboard-wrapper.seo-analysis.seo_analyzer .rank-math-result-table{-moz-column-break-after:page;break-after:page}.rank-math-ui.dashboard-wrapper.seo-analysis.seo_analyzer .rank-math-result-table.rank-math-result-category-priority,.rank-math-ui.dashboard-wrapper.seo-analysis.seo_analyzer .rank-math-result-table:last-child{-moz-column-break-after:initial;break-after:initial}.print-logo{display:block;position:absolute;top:-26px;left:30px}.print-logo img{width:160px}body.wp-admin.wp-core-ui.rank-math_page_rank-math-seo-analysis{visibility:hidden;background:#fff;-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important}header.rank-math-box a{display:none !important}.rank-math-header{display:none !important}div#wpadminbar{display:none}html.wp-toolbar{padding-top:0}div#adminmenumain{display:none}div#wpcontent{margin-left:0}.rank-math-page .dashboard-wrapper:before{display:none}.rank-math-page div.rank-math-tab-nav{display:none !important}.wrap.rank-math-wrap.rank-math-seo-analysis-wrap.dashboard{margin-top:0}.wrap.rank-math-wrap.rank-math-seo-analysis-wrap.dashboard>:not(.rank-math-ui){display:none !important}div.rank-math-result-filters{display:none}.rank-math-box{border:none !important}div.rank-math-result-tables{padding:0}div.rank-math-result-table .table-row,div.rank-math-result-table .category-title{border:none;border-bottom:1px solid #dadfe4}div.rank-math-result-table .category-title{font-size:1.25rem;font-weight:600;border-bottom:3px solid #b5bfc9}div.rank-math-result-table .row-title{padding-left:0}div.rank-math-result-table .row-content a{text-decoration:none;pointer-events:none;color:unset}.rank-math-result-graphs .three-col{flex-wrap:wrap !important;justify-content:center !important}.rank-math-result-graphs .rank-math-analysis-date{position:absolute;top:-58px;right:0}.rank-math-result-graphs .rank-math-analysis-date span{display:none}.rank-math-result-graphs .graphs-side{flex:0 0 45% !important;margin-left:80px !important}.serp-preview{width:100%;margin-top:40px}.rank-math-result-graphs.rank-math-box{padding-bottom:0}ul.info-list{overflow:auto;max-height:unset}
|
@@ -0,0 +1 @@
|
||||
.rank-math-seo-analysis-wrap .competitor_analyzer #competitor_url{display:block}.rank-math-seo-analysis-wrap .competitor_analyzer .rank-math-result-graphs{border-radius:6px}.is-loaded .competitor_analyzer .rank-math-analyzer-result,.is-loading .competitor_analyzer .rank-math-analyzer-result{display:block}.is-loaded .competitor_analyzer .rank-math-recheck,.is-loading .competitor_analyzer .rank-math-recheck{display:inline-block}.has-results .progress-bar{display:none}.competitor_analyzer .progress-bar{display:none}.is-loading .competitor_analyzer .progress-bar{display:block}span.input-loading{display:none !important}.rank-math-print-results.print-loading{pointer-events:none;color:#6b7278 !important;border:1px solid #7f868d !important;box-shadow:none !important}.rank-math-print-results.print-loading .dashicons-printer{display:none}.rank-math-print-results.print-loading .input-loading{display:inline-block !important;margin-right:7px;margin-left:-2px;vertical-align:-7px}.print-logo{display:none}
|
@@ -0,0 +1 @@
|
||||
jQuery((function(){jQuery("#competitor_url").length&&jQuery("#competitor_url").on("keyup",(function(e){if("Enter"===e.key){if(""===e.target.value)return;e.preventDefault(),document.querySelector(".rank-math-recheck").click(),document.querySelector("#competitor_url").blur()}})).on("input",(function(e){""===e.target.value?document.querySelector(".rank-math-recheck").disabled=!0:document.querySelector(".rank-math-recheck").disabled=!1})).trigger("input"),jQuery("#rank-math-print-results").on("click",(function(e){var t=window.location.href;-1===(t=t.split("#")[0]).indexOf("?")?t+="?":t+="&";var n=this.classList;n.add("print-loading","disabled");var r=document.createElement("iframe");r.style.display="none",r.setAttribute("src",t+"print=1"),document.body.appendChild(r),r.addEventListener("load",(function(){setTimeout((function(){r.contentWindow.print(),n.remove("print-loading","disabled")}),1e3)})),e.preventDefault()}))}));
|
@@ -0,0 +1,52 @@
|
||||
const initCompetitorAnalysis = function() {
|
||||
jQuery( '#competitor_url' ).on( 'keyup', function( event ) {
|
||||
if ( 'Enter' === event.key ) {
|
||||
// If the input is empty, don't do anything.
|
||||
if ( '' === event.target.value ) {
|
||||
return
|
||||
}
|
||||
|
||||
event.preventDefault()
|
||||
document.querySelector( '.rank-math-recheck' ).click()
|
||||
document.querySelector( '#competitor_url' ).blur()
|
||||
}
|
||||
} ).on( 'input', function( event ) {
|
||||
if ( '' === event.target.value ) {
|
||||
document.querySelector( '.rank-math-recheck' ).disabled = true
|
||||
} else {
|
||||
document.querySelector( '.rank-math-recheck' ).disabled = false
|
||||
}
|
||||
} ).trigger( 'input' )
|
||||
}
|
||||
|
||||
jQuery( function() {
|
||||
if ( jQuery( '#competitor_url' ).length ) {
|
||||
initCompetitorAnalysis()
|
||||
}
|
||||
|
||||
jQuery( '#rank-math-print-results' ).on( 'click', function( event ) {
|
||||
let uri = window.location.href
|
||||
uri = uri.split( '#' )[ 0 ]
|
||||
if ( -1 === uri.indexOf( '?' ) ) {
|
||||
uri += '?'
|
||||
} else {
|
||||
uri += '&'
|
||||
}
|
||||
|
||||
const classes = this.classList
|
||||
classes.add( 'print-loading', 'disabled' )
|
||||
|
||||
const iframe = document.createElement( 'iframe' )
|
||||
iframe.style.display = 'none'
|
||||
iframe.setAttribute( 'src', uri + 'print=1' )
|
||||
document.body.appendChild( iframe )
|
||||
iframe.addEventListener( 'load', function() {
|
||||
setTimeout( function() {
|
||||
iframe.contentWindow.print()
|
||||
classes.remove( 'print-loading', 'disabled' )
|
||||
}, 1000 )
|
||||
} )
|
||||
event.preventDefault()
|
||||
} )
|
||||
} )
|
||||
|
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* SEO Analyzer module - Competitor Analyzer feature.
|
||||
*
|
||||
* @since 1.0
|
||||
* @package RankMathPro
|
||||
* @subpackage RankMathPro\Admin
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMathPro\SEO_Analysis;
|
||||
|
||||
use RankMath\Traits\Ajax;
|
||||
use RankMath\Traits\Hooker;
|
||||
use MyThemeShop\Helpers\Param;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* SEO_Analysis_Pro class.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Competitor_Analysis {
|
||||
|
||||
use Hooker, Ajax;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->filter( 'rank_math/analysis/is_allowed_url', 'allow_competitor_urls', 10, 2 );
|
||||
$this->filter( 'rank_math/seo_analysis/api_endpoint', 'set_ca_param' );
|
||||
$this->action( 'rank_math/seo_analysis/after_analyze', 'store_results' );
|
||||
$this->action( 'rank_math/seo_analysis/after_set_url', 'load_previous_results' );
|
||||
$this->action( 'rank_math/tools/clear_seo_analysis', 'clear_competitor_results', 5 );
|
||||
}
|
||||
|
||||
/**
|
||||
* ALlow competitor URLs to be analyzed with the SEO Analyzer.
|
||||
*
|
||||
* @param bool $allowed Allowed or not.
|
||||
* @param string $url Site URL.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function allow_competitor_urls( $allowed, $url ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the ca parameter to the API URL when appropriate.
|
||||
*
|
||||
* @param string $url API URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function set_ca_param( $url ) {
|
||||
if ( ! Param::request( 'competitor_analyzer' ) ) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
return add_query_arg( 'ca', '1', $url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the results of a competitor analysis.
|
||||
*
|
||||
* @param object $seo_analyzer SEO Analyzer object.
|
||||
*/
|
||||
public function store_results( $seo_analyzer ) {
|
||||
if ( ! Param::request( 'competitor_analyzer' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_option( 'rank_math_seo_analysis_competitor_results', $seo_analyzer->results, false );
|
||||
update_option( 'rank_math_seo_analysis_competitor_url', $seo_analyzer->analyse_url, false );
|
||||
update_option( 'rank_math_seo_analysis_competitor_date', time(), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the previous results of a competitor analysis.
|
||||
*
|
||||
* @param object $seo_analyzer SEO Analyzer object.
|
||||
*/
|
||||
public function load_previous_results( $seo_analyzer ) {
|
||||
if ( 'competitor_analyzer' !== Param::get( 'view' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$seo_analyzer->get_results_from_storage( 'rank_math_seo_analysis_competitor' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the competitor analysis results.
|
||||
*/
|
||||
public function clear_competitor_results() {
|
||||
delete_option( 'rank_math_seo_analysis_competitor_results' );
|
||||
delete_option( 'rank_math_seo_analysis_competitor_url' );
|
||||
delete_option( 'rank_math_seo_analysis_competitor_date' );
|
||||
}
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* SEO Analyzer module - Pro features.
|
||||
*
|
||||
* @since 1.0
|
||||
* @package RankMathPro
|
||||
* @subpackage RankMathPro\Admin
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMathPro\SEO_Analysis;
|
||||
|
||||
use RankMath\Traits\Hooker;
|
||||
use MyThemeShop\Helpers\Param;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* SEO_Analysis_Pro class.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class SEO_Analysis_Pro {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->filter( 'rank_math/seo_analysis/admin_tab_view', 'add_tab_views', 20, 2 );
|
||||
$this->action( 'admin_enqueue_scripts', 'enqueue' );
|
||||
|
||||
remove_all_actions( 'rank_math/analyzer/results_header', 15 );
|
||||
$this->action( 'rank_math/analyzer/results_header', 'add_print_button', 20 );
|
||||
$this->action( 'rank_math/analyzer/results_header', 'add_logo', 25 );
|
||||
|
||||
new Competitor_Analysis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add include files for the additional tabs.
|
||||
*
|
||||
* @param string $file Include file.
|
||||
* @param string $current_tab Current tab.
|
||||
*/
|
||||
public function add_tab_views( $file, $current_tab ) {
|
||||
if ( 'competitor_analyzer' === $current_tab ) {
|
||||
$file = dirname( __FILE__ ) . '/views/competitor-analysis.php';
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue styles and scripts.
|
||||
*
|
||||
* @param string $hook Page hook name.
|
||||
*/
|
||||
public function enqueue( $hook ) {
|
||||
if ( 'rank-math_page_rank-math-seo-analysis' !== $hook ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'rank-math-pro-seo-analysis', RANK_MATH_PRO_URL . 'includes/modules/seo-analysis/assets/css/seo-analysis.css', [], RANK_MATH_PRO_VERSION );
|
||||
wp_enqueue_script( 'rank-math-pro-seo-analysis', RANK_MATH_PRO_URL . 'includes/modules/seo-analysis/assets/js/seo-analysis-pro.js', [ 'jquery' ], RANK_MATH_PRO_VERSION, true );
|
||||
|
||||
if ( Param::get( 'print' ) ) {
|
||||
wp_enqueue_style( 'rank-math-pro-seo-analysis-print', RANK_MATH_PRO_URL . 'includes/modules/seo-analysis/assets/css/seo-analysis-print.css', [], RANK_MATH_PRO_VERSION );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add print button to the results header.
|
||||
*/
|
||||
public function add_print_button() {
|
||||
?>
|
||||
<a href="#print" class="button button-secondary rank-math-print-results" id="rank-math-print-results">
|
||||
<span class="dashicons dashicons-printer"></span>
|
||||
<span class="input-loading"></span>
|
||||
<?php esc_html_e( 'Print', 'rank-math-pro' ); ?>
|
||||
</a>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Rank Math logo to the results header.
|
||||
*/
|
||||
public function add_logo() {
|
||||
?>
|
||||
<div class="print-logo">
|
||||
<img src="<?php echo esc_url( rank_math()->plugin_url() . 'assets/admin/img/logo.svg' ); ?>">
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* SEO Analyzer - Competitor Analysis
|
||||
*
|
||||
* @package RANK_MATH
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
* @license GPL-2.0+
|
||||
* @link https://rankmath.com/wordpress/plugin/seo-suite/
|
||||
* @copyright 2019 Rank Math
|
||||
*/
|
||||
|
||||
use RankMath\Helper;
|
||||
|
||||
$module = Helper::get_module( 'seo-analysis' );
|
||||
$analyzer = $module->admin->analyzer;
|
||||
|
||||
// Check rank_math_seo_analysis_competitor_url option.
|
||||
$url = '';
|
||||
if ( ! empty( $analyzer->results ) ) {
|
||||
$url = get_option( 'rank_math_seo_analysis_competitor_url' );
|
||||
}
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
?>
|
||||
<div class="rank-math-box">
|
||||
<h2>
|
||||
<?php esc_html_e( 'Competitor Analysis', 'rank-math-pro' ); ?>
|
||||
</h2>
|
||||
<p><?php esc_html_e( 'Enter a site URL to see how it ranks for the same SEO criteria as your site.', 'rank-math-pro' ); ?></p>
|
||||
|
||||
<div class="url-form">
|
||||
<input type="text" name="competitor_url" id="competitor_url" class="rank-math-analyze-url" placeholder="https://" value="<?php echo esc_attr( $url ); ?>" />
|
||||
<input type="hidden" name="competitor_analyzer" id="competitor_analyzer" value="1" />
|
||||
<button type="button" class="button button-primary rank-math-recheck no-autostart" id="competitor_url_submit"><?php esc_html_e( 'Start Audit', 'rank-math-pro' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rank-math-box rank-math-analyzer-result <?php echo '' === $url ? '' : esc_attr( 'has-results' ); ?>">
|
||||
|
||||
<span class="wp-header-end"></span>
|
||||
|
||||
<div class="progress-bar">
|
||||
<div class="progress"></div>
|
||||
<div class="progress-text"><span>0%</span> <?php esc_html_e( 'Complete', 'rank-math-pro' ); ?></div>
|
||||
</div>
|
||||
|
||||
<div class="rank-math-results-wrapper">
|
||||
<?php $analyzer->display(); ?>
|
||||
</div>
|
||||
|
||||
<p style="text-align: right;"><em><strong><?php esc_html_e( 'Note:', 'rank-math-pro' ); ?></strong> <?php esc_html_e( "The total test count is different for the competitor as we don't have access to their database.", 'rank-math-pro' ); ?></em></p>
|
||||
|
||||
</div>
|
Reference in New Issue
Block a user