From 2ef61e3869748d3d6d98d36d227ceda891ccbc45 Mon Sep 17 00:00:00 2001 From: AL Date: Mon, 28 Oct 2019 11:40:23 +0100 Subject: [PATCH] Move settings to their own packages --- sleek-settings.php | 61 ---------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/sleek-settings.php b/sleek-settings.php index 2c36374..c2ff615 100644 --- a/sleek-settings.php +++ b/sleek-settings.php @@ -60,83 +60,22 @@ function get_setting ($name) { }, SETTINGS_SECTION_NAME); # NOTE: WP Docs says this should be the add_options_page slug but that doesn't work. It needs to be the same as is later passed to do_settings_section # Built-in fields - add_setting('google_maps_api_key', 'text', __('Google Maps API Key', 'sleek')); - # TODO: Move to sleek-google-search -# add_setting('google_search_api_key', 'text', __('Google Search API Key', 'sleek')); -# add_setting('google_search_engine_id', 'text', __('Google Search Engine ID', 'sleek')); add_setting('head_code', 'textarea', esc_html__('Code inside ', 'sleek')); add_setting('foot_code', 'textarea', esc_html__('Code just before ', 'sleek')); - add_setting('cookie_consent', 'textarea', esc_html__('Cookie consent text', 'sleek')); - add_setting('site_notice', 'textarea', esc_html__('Site notice', 'sleek')); }); ######## # Header add_action('wp_head', function () { - # Custom head code if ($code = get_setting('head_code')) { echo $code; } - - # Cookie consent text - if ($consent = get_setting('cookie_consent')) { - $cookieConsent = $consent; - } - else { - $cookieUrl = get_option('wp_page_for_privacy_policy') ? get_permalink(get_option('wp_page_for_privacy_policy')) : 'https://cookiesandyou.com/'; - $cookieConsent = apply_filters('sleek_cookie_consent', sprintf(__('We use cookies to bring you the best possible experience when browsing our site. Read more | Accept', 'sleek'), $cookieUrl), $cookieUrl); - } - -# echo ''; }); ######## # Footer add_action('wp_footer', function () { - # Custom foot code if ($code = get_setting('foot_code')) { echo $code; } - - # Google Maps - if ($key = get_setting('google_maps_api_key')) { - echo ""; - } -}); - -############################ -# Include google maps JS api -add_action('wp_enqueue_scripts', function () { - if ($key = get_setting('google_maps_api_key')) { - wp_register_script('google_maps', 'https://maps.googleapis.com/maps/api/js?key=' . $key . '&callback=gmAsyncInit', [], null, true); - wp_enqueue_script('google_maps'); - } -}); - -################################ -# Add Google Maps API Key to ACF -add_action('init', function () { - if ($key = get_setting('google_maps_api_key')) { - add_filter('acf/fields/google_map/api', function ($api) use ($key) { - $api['key'] = $key; - - return $api; - }); - } });