(bool) did_action( 'sfw/init' ), 'version' => sfw_version(), 'debug' => (bool) SCRIPT_DEBUG, 'synced' => (bool) sfw_is_synced(), 'home' => home_url(), 'url' => sfw_url(), 'continueShoppingLink' => sfw_get_continue_shopping_url(), 'rest' => array( 'url' => sfw_rest_url(), 'nonce' => wp_create_nonce( 'wp_rest' ), 'proxy_url' => sfw_get_proxy_url(), ), ); if( did_action( 'sfw/init' ) && is_admin() ) { $args['rest']['apikey'] = sfw_apikey(); //if( current_user_can( 'manage_options' ) ) // $args['rest']['secret'] = sfw_secret(); } if( did_action( 'sfw/init' ) ) { $args += array( 'shop' => sfw_get_shop(), 'currency' => sfw_get_currency(), 'language' => sfw_get_language(), 'country' => sfw_get_country(), 'host' => sfw_get_host(), 'locale' => sfw_get_locale(), ); /** * Data passed to the Javascript interface * * Only when the Shop is already configured and the 'sfw/init' Action did run * * @param array $args * * @since 1.0.0 */ $args = apply_filters( 'sfw/js', $args ); } /** * Data passed to the Javascript interface * * This Hook is triggerd always, even if the Shop was not configured yet. * * @param array $args * * @since 1.0.0 */ $args = apply_filters( 'sfw/wp_localize_script', $args ); $string = 'var sfw_config = ' . json_encode( $args ) . ';'; // add data to skript wp_add_inline_script( $scripthandle, $string, 'before' ); } /** * Switches Script inclusion depending on SCRIPT_DEBUG constant * * @param string $compressed Url of the minified file * @param string $uncompressed Url of the expanded source file * * @since 1.0.0 */ function sfw_asset_min( $compressed, $uncompressed ) { if( ( defined( 'SCRIPT_DEBUG' ) && constant( 'SCRIPT_DEBUG' ) ) || sfw_do_debug() ) { return $uncompressed; } else { return $compressed; } } /** * enqueue script after wp_enqueue_script was probably called already * * @param string $handle * @param integer $priority * @since 1.0.0 */ function sfw_wp_enqueue_footer_script( $handle, $priority = 100 ) { if( did_action( 'wp_enqueue_scripts' ) ) { wp_enqueue_script( 'sfw-confomat'); } else { add_action( 'wp_enqueue_scripts', function() use ( $handle ){ wp_enqueue_script( 'sfw-confomat'); }, $priority ); } }