Make Giphy API key configurable via WordPress option: reads from beep_giphy_key option, sets default on init, passes to BeepConfig.giphyKey for frontend JS
This commit is contained in:
+1
-1
@@ -720,7 +720,7 @@
|
||||
}
|
||||
|
||||
/* ---------- GIF Picker (Giphy) ---------- */
|
||||
var GIPHY_API_KEY = 'xuxYxuIvzPqw5tPB4laa7sQO8dFtSlNS';
|
||||
var GIPHY_API_KEY = (window.BeepConfig && window.BeepConfig.giphyKey) || '';
|
||||
|
||||
function openGifPicker(compose) {
|
||||
var modal = document.querySelector('[data-beep-gif-modal]');
|
||||
|
||||
@@ -13,6 +13,11 @@ class Beep_Plugin {
|
||||
Beep_Shortcode::init();
|
||||
|
||||
add_action('wp_enqueue_scripts', [__CLASS__, 'enqueue_assets']);
|
||||
|
||||
// Set default Giphy API key if not already set
|
||||
if (!get_option('beep_giphy_key')) {
|
||||
update_option('beep_giphy_key', 'xuxYxuIvzPqw5tPB4laa7sQO8dFtSlNS');
|
||||
}
|
||||
}
|
||||
|
||||
public static function activate() {
|
||||
@@ -39,12 +44,15 @@ class Beep_Plugin {
|
||||
BEEP_VERSION,
|
||||
true
|
||||
);
|
||||
$giphy_key = get_option('beep_giphy_key', '');
|
||||
|
||||
wp_localize_script('beep', 'BeepConfig', [
|
||||
'restUrl' => esc_url_raw(rest_url('beep/v1/')),
|
||||
'nonce' => wp_create_nonce('wp_rest'),
|
||||
'charLimit' => BEEP_CHAR_LIMIT,
|
||||
'loginUrl' => esc_url_raw(wp_login_url(is_singular() ? get_permalink() : home_url('/'))),
|
||||
'isLoggedIn' => is_user_logged_in(),
|
||||
'giphyKey' => $giphy_key,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user