File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -83,9 +83,20 @@ public function link()
83
83
*/
84
84
public function get_key ()
85
85
{
86
+ if ( $ this ->key )
87
+ return $ this ->key ;
88
+
86
89
if ( ! $ this ->key )
87
90
$ this ->key = WPCF7 ::get_option ( 'wpcf7_pdf_forms_pdfninja_key ' );
88
91
92
+ if ( ! $ this ->key )
93
+ {
94
+ // attempt to get the key from another plugin
95
+ $ key = $ this ->get_external_key ();
96
+ if ( $ key )
97
+ $ this ->set_key ( $ key );
98
+ }
99
+
89
100
if ( ! $ this ->key )
90
101
{
91
102
// don't try to get the key from the API on every page load!
@@ -121,6 +132,24 @@ public function set_key( $value )
121
132
return true ;
122
133
}
123
134
135
+ /**
136
+ * Searches for key in other plugins
137
+ */
138
+ public function get_external_key ()
139
+ {
140
+ // from PDF Forms Filler for WPForms
141
+ $ option = get_option ( 'wpforms_settings ' );
142
+ if ( $ option !== false && is_array ( $ option ) && isset ( $ option ['pdf-ninja-api_key ' ] ) )
143
+ return $ option ['pdf-ninja-api_key ' ];
144
+
145
+ // from PDF Forms Filler for WooCommerce
146
+ $ option = get_option ( 'pdf-forms-for-woocommerce-settings-pdf-ninja-api-key ' );
147
+ if ( $ option !== false )
148
+ return $ option ;
149
+
150
+ return null ;
151
+ }
152
+
124
153
/*
125
154
* Determines administrator's email address (for use with requesting a new key from the API)
126
155
*/
You can’t perform that action at this time.
0 commit comments