$global_script ) ); wp_localize_script( $global_script, 'ckyScanner', apply_filters( 'cky_admin_scripts_scanner_config', array(), $global_script ) ); wp_localize_script( $global_script, 'ckyLanguages', apply_filters( 'cky_admin_scripts_languages', array(), $global_script ) ); wp_localize_script( $global_script, 'ckyBannerConfig', apply_filters( 'cky_admin_scripts_banner_config', array( '_shortCodes' => $this->prepare_shortcodes(), ), $global_script ) ); wp_localize_script( $global_script, 'ckyAppMenus', $this->get_registered_menus( true ) ); wp_localize_script( $global_script, 'ckyAppNotices', $notice->get() ); wp_localize_script( $global_script, 'ckyNoticeExpand', $expand->get() ); } /** * Prepare shortcodes for banner preview. * * @return array */ public function prepare_shortcodes() { $data = array(); $data[] = array( 'key' => 'cky_readmore', 'content' => do_shortcode( '[cky_readmore]' ), 'tag' => 'readmore-button', ); $data[] = array( 'key' => 'cky_show_desc', 'content' => do_shortcode( '[cky_show_desc]' ), 'tag' => 'show-desc-button', 'attributes' => array(), ); $data[] = array( 'key' => 'cky_hide_desc', 'content' => do_shortcode( '[cky_hide_desc]' ), 'tag' => 'hide-desc-button', 'attributes' => array(), ); return $data; } /** * Register main menu and sub menus * * @return void */ public function admin_menu() { $capability = 'manage_options'; $slug = 'cookie-law-info'; $hook = add_menu_page( __( 'CookieYes', 'cookie-law-info' ), __( 'CookieYes', 'cookie-law-info' ), $capability, $slug, array( $this, 'menu_page_template' ), 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCAzNiAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4gPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNy45NTg0IDM1LjcwOEM4LjE5MDcxIDM1LjcwOCAwLjI5MTYyNiAyNy43ODUgMC4yOTE2MjUgMTcuOTk5N0wwLjI5MTYyNSAxNi4wMjY2TDEuN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DUgOC42ODkyMyAxMC43NTA1QzkuNTQ3MTIgMTAuNzUwNSAxMC4yNDI2IDEwLjA1NSAxMC4yNDI2IDkuMTk3MTNaIiBmaWxsPSJ3aGl0ZSIvPiA8cGF0aCBkPSJNNC4xMjQxMiAxMC4yODAzQzQuMTI0MTIgOS4zOTYxNCAzLjQwNzMzIDguNjc5MzUgMi41MjMxMiA4LjY3OTM1QzEuNjM4OTEgOC42NzkzNSAwLjkyMjExOSA5LjM5NjE0IDAuOTIyMTE5IDEwLjI4MDNDMC45MjIxMTkgMTEuMTY0NiAxLjYzODkxIDExLjg4MTMgMi41MjMxMiAxMS44ODEzQzMuNDA3MzMgMTEuODgxMyA0LjEyNDEyIDExLjE2NDYgNC4xMjQxMiAxMC4yODAzWiIgZmlsbD0id2hpdGUiLz4gPHBhdGggZD0iTTE2LjcxNDggMTcuMjUyM0wxNy43MzA4IDE5LjEwMjRMMTguMzUgMjAuMjE1NUwyMy4xNjAzIDEySDI2Ljg3NTJMMjAuMTQzOSAyMy40OTIzSDE2LjQyOUwxMi45OTk5IDE3LjI1MjNIMTYuNzE0OFoiIGZpbGw9IndoaXRlIi8+IDxwYXRoIGQ9Ik0xOS45NDE0IDI1Ljc5MDVIMTYuNDcyNVYyOS4yMzgySDE5Ljk0MTRWMjUuNzkwNVoiIGZpbGw9IndoaXRlIi8+IDwvc3ZnPg==', 40 ); } /** * Redirect the plugin to web app if connected. * * @return void */ public function handle_redirect() { $settings = new \CookieYes\Lite\Admin\Modules\Settings\Includes\Settings(); global $plugin_page; $menu = str_replace( 'cookie-law-info-', '', $plugin_page ); $pages = $this->get_registered_menus(); if ( ! isset( $pages[ $menu ] ) ) { return; } $page = $pages[ $menu ]; $redirect = isset( $page['redirect'] ) ? $page['redirect'] : false; if ( false === $redirect ) { return; } $redirect = add_query_arg( array( 'website_id' => $settings->get_website_id(), ), $redirect ); wp_safe_redirect( esc_url_raw( $redirect ) ); } /** * Get regisered menus from each module. * * @param boolean $minify Whether to minify or not. * @return array */ public function get_registered_menus( $minify = false ) { $menus = apply_filters( 'cky_registered_admin_menus', array() ); if ( true === $minify ) { foreach ( $menus as $key => $menu ) { unset( $menu['callback'] ); $menus[ $key ] = $menu; } } return $menus; } /** * Main menu template * * @return void */ public function menu_page_template() { echo '
'; } /** * Add custom class to admin body tag. * * @param string $classes List of classes. * @return string */ public function admin_body_classes( $classes ) { if ( true === cky_is_admin_page() ) { $classes .= ' cky-app-admin'; } return $classes; } /** * Returns Jed-formatted localization data. Added for backwards-compatibility. * * @since 4.0.0 * * @param string $domain Translation domain. * @return array The information of the locale. */ public function get_jed_locale_data( $domain ) { $translations = get_translations_for_domain( $domain ); $locale = array( '' => array( 'domain' => $domain, 'lang' => is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(), ), ); if ( ! empty( $translations->headers['Plural-Forms'] ) ) { $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; } foreach ( $translations->entries as $msgid => $entry ) { $locale[ $msgid ] = $entry->translations; } // If any of the translated strings incorrectly contains HTML line breaks, we need to return or else the admin is no longer accessible. $json = wp_json_encode( $locale ); if ( preg_match( '/