Instant Indexing for Google - Version 1.1.13

Version Description

Download this release

Release Info

Developer rankmath
Plugin Icon 128x128 Instant Indexing for Google
Version 1.1.13
Comparing to
See all releases

Code changes from version 1.1.12 to 1.1.13

assets/js/console.js CHANGED
@@ -116,23 +116,25 @@ jQuery(document).ready(function($) {
116
  });
117
 
118
  $('#indexnow_reset_key').on( 'click', function( e ) {
119
- e.preventDefault()
120
- var originalValue = $( '#giapi_indexnow_api_key' ).val()
121
- $( '#giapi_indexnow_api_key' ).val( '...' )
122
  $.ajax( {
123
- url: ajaxurl,
124
- type: 'GET',
125
- data: { action: 'rm_giapi_reset_key', _ajax_nonce: $('#reset_key_nonce').val() },
 
 
126
  success: function( response ) {
127
  $( '#giapi_indexnow_api_key' ).val( response.key );
128
  $( '#indexnow_api_key_location').text( response.location );
129
  $( '#indexnow_check_key' ).attr( 'href', response.location );
130
  },
131
  error: function( response ) {
132
- $( '#giapi_indexnow_api_key' ).val( originalValue );
133
  },
134
- } );
135
- } );
136
 
137
  });
138
 
116
  });
117
 
118
  $('#indexnow_reset_key').on( 'click', function( e ) {
119
+ e.preventDefault();
120
+ let originalValue = $( '#giapi_indexnow_api_key' ).val();
121
+ $( '#giapi_indexnow_api_key' ).val( '...' );
122
  $.ajax( {
123
+ url: rankMath.indexNow.restUrl + '/resetKey',
124
+ type: 'POST',
125
+ beforeSend( xhr ) {
126
+ xhr.setRequestHeader( 'X-WP-Nonce', rankMath.api.nonce );
127
+ },
128
  success: function( response ) {
129
  $( '#giapi_indexnow_api_key' ).val( response.key );
130
  $( '#indexnow_api_key_location').text( response.location );
131
  $( '#indexnow_check_key' ).attr( 'href', response.location );
132
  },
133
  error: function( response ) {
134
+ $( '#giapi_indexnow_api_key' ).val( originalValue )
135
  },
136
+ } )
137
+ } )
138
 
139
  });
140
 
assets/js/console.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(e){var s=e("#giapi-response"),i=e("#giapi-submit"),a=e("#giapi-url"),n=e(".giapi-action"),r=e("#giapi-response-userfriendly");e("#giapi-response-trigger").click(function(s){s.preventDefault(),e(this).find(".dashicons").toggleClass("dashicons-arrow-down-alt2 dashicons-arrow-up-alt2"),e("#giapi-response-wrapper").toggle()}),e("#instant-indexing").submit(function(t){t.preventDefault(),i.attr("disabled","disabled");var o=a.val(),l=n.filter(":checked").val(),d=e("#_wpnonce").val();e.ajax({url:ajaxurl,type:"POST",dataType:"json",data:{action:"rm_giapi",url:o,api_action:l,_wpnonce:d}}).always(function(t){!function(i,t,o){var l=(f=new Date).toLocaleTimeString(),d=a.val().split("\n").filter(Boolean),p=d[0],c=!1,g=n.filter(":checked").val();d.length>1&&(p="(batch)",c=!0);var _=g;if("bing_submit"===g&&(_="indexnow_submit"),r.removeClass("not-ready fail success").addClass("ready").find(".response-id").html("<strong>"+_+"</strong> "+p),"bing_submit"!==o)if(c)r.addClass("success").find(".response-status").text(rm_giapi.l10n_success+" ").siblings(".response-message").text(rm_giapi.l10n_see_response),void 0!==i.error?r.addClass("fail").find(".response-status").text(rm_giapi.l10n_error+" "+i.error.code).siblings(".response-message").text(i.error.message):e.each(i,function(e,s){if(void 0!==s.error){var i="";void 0!==s.error.code&&(i=s.error.code),void 0!==s.error.message&&s.error.message,r.addClass("fail").find(".response-status").text(rm_giapi.l10n_error+" "+i).siblings(".response-message").text(s.error.message)}});else if(void 0!==i.error)r.addClass("fail").find(".response-status").text(rm_giapi.l10n_error+" "+i.error.code).siblings(".response-message").text(i.error.message);else{var u=i;void 0!==i.urlNotificationMetadata&&(u=i.urlNotificationMetadata);var f=new Date(u.latestUpdate.notifyTime);r.addClass("success").find(".response-status").text(rm_giapi.l10n_success+" ").siblings(".response-message").text(rm_giapi.l10n_last_updated+" "+f.toString())}else void 0!==i.error?r.addClass("fail").find(".response-status").text(rm_giapi.l10n_error+" "+i.error.code).siblings(".response-message").text(i.error.message):r.addClass("success").find(".response-status").text(rm_giapi.l10n_success+" ").siblings(".response-message").text(rm_giapi.l10n_see_response),g="indexnow_submit";var m=l+" "+g+": "+p+"\n"+JSON.stringify(i,null,2)+"\n"+"-".repeat(56),x=s.val();s.val(m+"\n"+x)}(t,0,l),i.removeAttr("disabled"),e.ajax({url:ajaxurl,type:"POST",dataType:"json",data:{action:"rm_giapi_limits",_wpnonce:d}}).done(function(s){e.each(s,function(s,i){e("#giapi-limit-"+s).text(i)})})})}),rm_giapi.submit_onload&&e("#instant-indexing").submit(),e("#indexnow_show_response_codes").on("click",function(s){s.preventDefault(),e(this).toggleClass("active"),e("#indexnow_response_codes").toggleClass("hidden")}),e("#indexnow_reset_key").on("click",function(s){s.preventDefault();var i=e("#giapi_indexnow_api_key").val();e("#giapi_indexnow_api_key").val("..."),e.ajax({url:ajaxurl,type:"GET",data:{action:"rm_giapi_reset_key",_ajax_nonce:e("#reset_key_nonce").val()},success:function(s){e("#giapi_indexnow_api_key").val(s.key),e("#indexnow_api_key_location").text(s.location),e("#indexnow_check_key").attr("href",s.location)},error:function(s){e("#giapi_indexnow_api_key").val(i)}})})}),jQuery(window).on("load",function(){jQuery("#giapi-submit").prop("disabled",!1)});
1
+ jQuery(document).ready(function(e){var s=e("#giapi-response"),i=e("#giapi-submit"),a=e("#giapi-url"),n=e(".giapi-action"),r=e("#giapi-response-userfriendly");e("#giapi-response-trigger").click(function(s){s.preventDefault(),e(this).find(".dashicons").toggleClass("dashicons-arrow-down-alt2 dashicons-arrow-up-alt2"),e("#giapi-response-wrapper").toggle()}),e("#instant-indexing").submit(function(t){t.preventDefault(),i.attr("disabled","disabled");var o=a.val(),l=n.filter(":checked").val(),d=e("#_wpnonce").val();e.ajax({url:ajaxurl,type:"POST",dataType:"json",data:{action:"rm_giapi",url:o,api_action:l,_wpnonce:d}}).always(function(t){!function(i,t,o){var l=(f=new Date).toLocaleTimeString(),d=a.val().split("\n").filter(Boolean),p=d[0],c=!1,g=n.filter(":checked").val();d.length>1&&(p="(batch)",c=!0);var _=g;if("bing_submit"===g&&(_="indexnow_submit"),r.removeClass("not-ready fail success").addClass("ready").find(".response-id").html("<strong>"+_+"</strong> "+p),"bing_submit"!==o)if(c)r.addClass("success").find(".response-status").text(rm_giapi.l10n_success+" ").siblings(".response-message").text(rm_giapi.l10n_see_response),void 0!==i.error?r.addClass("fail").find(".response-status").text(rm_giapi.l10n_error+" "+i.error.code).siblings(".response-message").text(i.error.message):e.each(i,function(e,s){if(void 0!==s.error){var i="";void 0!==s.error.code&&(i=s.error.code),void 0!==s.error.message&&s.error.message,r.addClass("fail").find(".response-status").text(rm_giapi.l10n_error+" "+i).siblings(".response-message").text(s.error.message)}});else if(void 0!==i.error)r.addClass("fail").find(".response-status").text(rm_giapi.l10n_error+" "+i.error.code).siblings(".response-message").text(i.error.message);else{var u=i;void 0!==i.urlNotificationMetadata&&(u=i.urlNotificationMetadata);var f=new Date(u.latestUpdate.notifyTime);r.addClass("success").find(".response-status").text(rm_giapi.l10n_success+" ").siblings(".response-message").text(rm_giapi.l10n_last_updated+" "+f.toString())}else void 0!==i.error?r.addClass("fail").find(".response-status").text(rm_giapi.l10n_error+" "+i.error.code).siblings(".response-message").text(i.error.message):r.addClass("success").find(".response-status").text(rm_giapi.l10n_success+" ").siblings(".response-message").text(rm_giapi.l10n_see_response),g="indexnow_submit";var m=l+" "+g+": "+p+"\n"+JSON.stringify(i,null,2)+"\n"+"-".repeat(56),x=s.val();s.val(m+"\n"+x)}(t,0,l),i.removeAttr("disabled"),e.ajax({url:ajaxurl,type:"POST",dataType:"json",data:{action:"rm_giapi_limits",_wpnonce:d}}).done(function(s){e.each(s,function(s,i){e("#giapi-limit-"+s).text(i)})})})}),rm_giapi.submit_onload&&e("#instant-indexing").submit(),e("#indexnow_show_response_codes").on("click",function(s){s.preventDefault(),e(this).toggleClass("active"),e("#indexnow_response_codes").toggleClass("hidden")}),e("#indexnow_reset_key").on("click",function(s){s.preventDefault();let i=e("#giapi_indexnow_api_key").val();e("#giapi_indexnow_api_key").val("..."),e.ajax({url:rankMath.indexNow.restUrl+"/resetKey",type:"POST",beforeSend(e){e.setRequestHeader("X-WP-Nonce",rankMath.api.nonce)},success:function(s){e("#giapi_indexnow_api_key").val(s.key),e("#indexnow_api_key_location").text(s.location),e("#indexnow_check_key").attr("href",s.location)},error:function(s){e("#giapi_indexnow_api_key").val(i)}})})}),jQuery(window).on("load",function(){jQuery("#giapi-submit").prop("disabled",!1)});
includes/class-instant-indexing.php CHANGED
@@ -15,7 +15,7 @@ class RM_GIAPI {
15
  *
16
  * @var string
17
  */
18
- public $version = '1.1.12';
19
 
20
  /**
21
  * Holds the admin menu hook suffix for the "dummy" dashboard.
@@ -156,7 +156,6 @@ class RM_GIAPI {
156
  add_action( 'admin_footer', [ $this, 'admin_footer' ], 20 );
157
  add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
158
  add_action( 'wp_ajax_rm_giapi', [ $this, 'ajax_rm_giapi' ] );
159
- add_action( 'wp_ajax_rm_giapi_reset_key', [ $this, 'ajax_reset_key' ] );
160
  add_action( 'wp_ajax_rm_giapi_limits', [ $this, 'ajax_get_limits' ] );
161
  add_action( 'admin_init', [ $this, 'rm_missing_admin_notice_error' ], 20, 1 );
162
  add_action( 'admin_notices', [ $this, 'display_notices' ], 10, 1 );
@@ -407,6 +406,25 @@ class RM_GIAPI {
407
  }
408
  } else {
409
  // IndexNow submit URL.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  $request = $this->rmapi->submit( $url_input, $is_manual );
411
  if ( $request ) {
412
  $data = [
@@ -562,65 +580,13 @@ class RM_GIAPI {
562
  die();
563
  }
564
 
565
- /**
566
- * AJAX handler to generate and save a new API key.
567
- *
568
- * @return void
569
- */
570
- public function ajax_reset_key() {
571
- check_ajax_referer( 'rm_giapi_reset_key' );
572
-
573
- if ( ! current_user_can( apply_filters( 'rank_math/indexing_api/capability', 'manage_options' ) ) ) {
574
- die( '0' );
575
- }
576
-
577
- $this->reset_indexnow_key();
578
-
579
- $settings = get_option( 'rank-math-options-instant-indexing', [] );
580
- $key = $settings['indexnow_api_key'];
581
- $location = trailingslashit( home_url() ) . $key . '.txt';
582
-
583
- wp_send_json(
584
- [
585
- 'status' => 'ok',
586
- 'key' => $key,
587
- 'location' => $location,
588
- ]
589
- );
590
- die();
591
- }
592
-
593
- /**
594
- * Generate new API key and save it.
595
- *
596
- * @return void
597
- */
598
- public function reset_indexnow_key() {
599
- $settings = RankMath\Helper::get_settings( 'instant_indexing', [] );
600
- $settings['indexnow_api_key'] = $this->generate_indexnow_key();
601
- $this->api_key = $settings['indexnow_api_key'];
602
- update_option( 'rank-math-options-instant-indexing', $settings );
603
- }
604
-
605
- /**
606
- * Generate new API key.
607
- *
608
- * @return string
609
- */
610
- public function generate_indexnow_key() {
611
- $api_key = wp_generate_uuid4();
612
- $api_key = preg_replace( '[-]', '', $api_key );
613
-
614
- return $api_key;
615
- }
616
-
617
  /**
618
  * Normalize input URLs.
619
  *
620
  * @return array Input URLs.
621
  */
622
  public function get_input_urls() {
623
- return array_values( array_filter( array_map( 'trim', explode( "\n", sanitize_textarea_field( wp_unslash( $_POST['url'] ) ) ) ) ) );
624
  }
625
 
626
  /**
15
  *
16
  * @var string
17
  */
18
+ public $version = '1.1.13';
19
 
20
  /**
21
  * Holds the admin menu hook suffix for the "dummy" dashboard.
156
  add_action( 'admin_footer', [ $this, 'admin_footer' ], 20 );
157
  add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
158
  add_action( 'wp_ajax_rm_giapi', [ $this, 'ajax_rm_giapi' ] );
 
159
  add_action( 'wp_ajax_rm_giapi_limits', [ $this, 'ajax_get_limits' ] );
160
  add_action( 'admin_init', [ $this, 'rm_missing_admin_notice_error' ], 20, 1 );
161
  add_action( 'admin_notices', [ $this, 'display_notices' ], 10, 1 );
406
  }
407
  } else {
408
  // IndexNow submit URL.
409
+
410
+ /**
411
+ * Filter the URL to be submitted to IndexNow.
412
+ * Returning false will prevent the URL from being submitted.
413
+ *
414
+ * @param bool $is_manual Whether the URL is submitted manually by the user.
415
+ */
416
+ $url_input = apply_filters( 'rank_math/instant_indexing/submit_url', $url_input, $is_manual );
417
+ if ( ! $url_input ) {
418
+ return false;
419
+ }
420
+
421
+ if ( ! $is_manual ) {
422
+ $logs = array_values( array_reverse( $this->rmapi->get_log() ) );
423
+ if ( ! empty( $logs[0] ) && $logs[0]['url'] === $url_input[0] && time() - $logs[0]['time'] < 15 ) {
424
+ return false;
425
+ }
426
+ }
427
+
428
  $request = $this->rmapi->submit( $url_input, $is_manual );
429
  if ( $request ) {
430
  $data = [
580
  die();
581
  }
582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  /**
584
  * Normalize input URLs.
585
  *
586
  * @return array Input URLs.
587
  */
588
  public function get_input_urls() {
589
+ return array_values( array_filter( array_map( 'trim', array_map( 'esc_url_raw', explode( "\n", wp_unslash( $_POST['url'] ) ) ) ) ) );
590
  }
591
 
592
  /**
instant-indexing.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Instant Indexing
4
  * Plugin URI: https://rankmath.com/wordpress/plugin/instant-indexing/
5
  * Description: Get your website crawled immediately by Google using their NEW Indexing APIs.
6
- * Version: 1.1.12
7
  * Author: Rank Math
8
  * Author URI: https://s.rankmath.com/home
9
  * License: GPL v3
3
  * Plugin Name: Instant Indexing
4
  * Plugin URI: https://rankmath.com/wordpress/plugin/instant-indexing/
5
  * Description: Get your website crawled immediately by Google using their NEW Indexing APIs.
6
+ * Version: 1.1.13
7
  * Author: Rank Math
8
  * Author URI: https://s.rankmath.com/home
9
  * License: GPL v3
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: rankmath
3
  Plugin link: https://rankmath.com/wordpress/plugin/instant-indexing/
4
  Tags: indexing api, crawling, live streaming, fast indexing, job posting
5
- Tested up to: 5.9
6
  Requires at least: 5.6
7
  Requires PHP: 7.2
8
- Stable tag: 1.1.12
9
  License: GPL-2.0+
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.txt
11
 
@@ -106,6 +106,11 @@ Technically, yes. That's what the plugin is made to do. But, please note that we
106
 
107
  == Changelog ==
108
 
 
 
 
 
 
109
  = v1.1.12 [Feb 08, 2022] =
110
  * Fixed: Can't update IndexNow post types option
111
 
2
  Contributors: rankmath
3
  Plugin link: https://rankmath.com/wordpress/plugin/instant-indexing/
4
  Tags: indexing api, crawling, live streaming, fast indexing, job posting
5
+ Tested up to: 5.9.2
6
  Requires at least: 5.6
7
  Requires PHP: 7.2
8
+ Stable tag: 1.1.13
9
  License: GPL-2.0+
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.txt
11
 
106
 
107
  == Changelog ==
108
 
109
+ = v1.1.13 [Mar 16, 2022] =
110
+ * Fixed: special characters getting removed from submitted URL
111
+ * Fixed: double IndexNow submissions
112
+ * Improved: use reset key REST API endpoint from Rank Math
113
+
114
  = v1.1.12 [Feb 08, 2022] =
115
  * Fixed: Can't update IndexNow post types option
116
 
views/bing-settings.php CHANGED
@@ -34,7 +34,7 @@ $check_button = '<a href="' . esc_url( $key_location ) . '" id="indexnow_check_k
34
  <p class="description"><?php esc_html_e( 'The IndexNow API key proves the ownership of the site. It is generated automatically. You can change the key if it becomes known to third parties.', 'fast-indexing-api' ); ?></p>
35
  </th>
36
  <td>
37
- <input type="text" class="large-text" id="giapi_indexnow_api_key" readonly="readonly" name="giapi_settings[indexnow_api_key]" value="<?php echo esc_attr( $this->rmapi->get_api_key() ); ?>">
38
  <br />
39
  <?php echo wp_kses_post( $reset_button ); ?>
40
  <?php echo $reset_nonce; ?>
34
  <p class="description"><?php esc_html_e( 'The IndexNow API key proves the ownership of the site. It is generated automatically. You can change the key if it becomes known to third parties.', 'fast-indexing-api' ); ?></p>
35
  </th>
36
  <td>
37
+ <input type="text" class="large-text" id="giapi_indexnow_api_key" readonly="readonly" name="giapi_settings[indexnow_api_key]" value="<?php echo esc_attr( $this->rmapi->get_key() ); ?>">
38
  <br />
39
  <?php echo wp_kses_post( $reset_button ); ?>
40
  <?php echo $reset_nonce; ?>