translate_link_target_global_state = $translate_link_target_global_state; $this->translate_link_targets = $this->create_translate_link_target(); $this->post_data = $post_data; } public function run() { if ( wp_verify_nonce( $this->post_data['nonce'], 'WPML_Ajax_Update_Link_Targets' ) ) { $this->translate_link_target_global_state->clear_rescan_required(); $last_processed = $this->translate_link_targets->fix( $this->post_data['last_processed'], $this->post_data['number_to_process'] ); return new WPML_Ajax_Response( true, array( 'last_processed' => (int)$last_processed, 'number_left' => $last_processed ? $this->translate_link_targets->get_number_to_be_fixed( $last_processed + 1 ) : 0, 'links_fixed' => $this->translate_link_targets->get_number_of_links_that_were_fixed() ) ); } else { return new WPML_Ajax_Response( false, 'wrong nonce' ); } } abstract protected function create_translate_link_target(); }