file_path = AABIRINDEXINGDIR_PLUGIN_DIR . "aabirindexing.txt"; } public function AabirPagecssscript() { wp_enqueue_style( 'aabir-indexing', ( AABIRINDEXINGURL_PLUGIN_URL . './aabirdis.css' ), array(), filemtime( AABIRINDEXINGDIR_PLUGIN_DIR . './aabirdis.css' ) ); wp_enqueue_script( 'aabir-indexing', ( AABIRINDEXINGURL_PLUGIN_URL . './aabirdisi.js' ), array(), filemtime( AABIRINDEXINGDIR_PLUGIN_DIR . './aabirdisi.js' ), false ); } private function aabir_update_file_content() { // Open the file for writing (create the file if it doesn't exist) if ( file_exists( $this->file_path ) ) { return file_get_contents( $this->file_path ); } return 'No content available.'; } private function aabir_read_txt_file() { $file_path = AABIRINDEXINGDIR_PLUGIN_DIR . 'aabirindexing.txt'; if ( file_exists( $file_path ) ) { return file_get_contents( $file_path ); } else { return 'File not found: ' . $file_path; } } private function aabir_read_txt_services() { $this->data = $this->aabir_read_txt_file(); $this->data = '['.$this->aabir_read_txt_file().']'; if ($this->data <> "") { $this->datar = json_decode($this->data, true); if(is_array($this->datar) && count($this->datar) > 0) { foreach($this->datar as $datad) { return $datad['type']; } }return 'n';} } public function Aabirmanageopt(){ add_menu_page('Price & Terms','Indexing Api', 'manage_options', 'aabir-indexing-google-api',[$this, 'aabirapiPagestatus'],AABIRINDEXINGURL_PLUGIN_URL.'aabirsmall.png'); } public function aabirapiPagestatus() { ?>

 

Google Indexing Api



Instant Indexing

aabir_read_txt_services(); if (isset($_POST['aabir_link_submit'])) { if ( ! isset( $_POST['aabir_link_submit_nonce'] ) || ! wp_verify_nonce( sanitize_textarea_field(wp_unslash($_POST['aabir_link_submit_nonce'])), 'aabir_link_submit_settings' ) ) { return; } if (!isset($_POST['aabirlink_field'])) return; $urls=sanitize_text_field(wp_unslash($_POST['aabirlink_field'])); $servicetype= $this->aabir_read_txt_services(); if($urls!='' && $servicetype=='service_account'){ require_once AABIRINDEXINGDIR_PLUGIN_DIR.'vendor/autoload.php'; $client = new Google_Client(); // service_account_file.json is the private key that you created for your service account. $client->setAuthConfig(AABIRINDEXINGDIR_PLUGIN_DIR.'aabirindexing.txt'); $client->addScope('https://www.googleapis.com/auth/indexing'); // Get a Guzzle HTTP Client $httpClient = $client->authorize(); $endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish'; // Define contents here. The structure of the content is described in the next step. $content = '{ "url": "'.$urls.'", "type": "URL_UPDATED" }'; $response = $httpClient->post($endpoint, [ 'body' => $content ]); $status_code = $response->getStatusCode(); //echo $status_code."-------
".$response->getBody();
    }else if($servicetype=='n'){$status_code=2;}else{$status_code=1;}
    }
    
   ?>
     





Success

getBody()); ?>



Google Instant Indexing API Settings

Google JSON Key:

Upload the Service Account JSON key file you obtained from Google API Console or paste its contents in the field.

file_path, $aabirdata ); } ?>