File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -877,6 +877,31 @@ public function validate_options( $input ) {
877
877
return $ options ;
878
878
}
879
879
880
+ /**
881
+ * Allow other actors to activate a new key programmatically
882
+ *
883
+ * @param $api_key
884
+ *
885
+ * @return void
886
+ * @since 2.9.2
887
+ */
888
+ public function activate_new_key ( $ api_key ) {
889
+ $ result = $ this ->activate ( [ 'api_key ' => $ api_key ] );
890
+ if ( ! empty ( $ result ) ) {
891
+ $ result = json_decode ( $ result , true );
892
+ if ( $ result ['success ' ] === true && $ result ['activated ' ] === true ) {
893
+ update_option ( 'wc_am_ ' . $ this ->product_id . '_activate_success ' , $ result ['message ' ] );
894
+ update_option ( $ this ->wc_am_activated_key , 'Activated ' );
895
+ update_option ( $ this ->wc_am_deactivate_checkbox_key , 'off ' );
896
+ update_option ( $ this ->data_key , [ "{$ this ->data_key }_api_key " => $ api_key ] );
897
+ } else {
898
+ wc_get_logger ()->error ( print_r ( $ result , true ),
899
+ array ( 'source ' => 'wc_product_sample ' )
900
+ );
901
+ }
902
+ }
903
+ }
904
+
880
905
// Deactivates the API Key to allow key to be used on another blog
881
906
public function wc_am_license_key_deactivation ( $ input ) {
882
907
$ activation_status = get_option ( $ this ->wc_am_activated_key );
You can’t perform that action at this time.
0 commit comments