wp_register_script example

'https://akismet.com/privacy/'
            ) . '</p>'
        );
    }

    public static function load_form_js() {
        if (
            ! is_admin()
            && ( ! function_exists( 'amp_is_request' ) || ! amp_is_request() )
            && self::get_api_key()
            ) {
            wp_register_script( 'akismet-frontend', plugin_dir_url( __FILE__ ) . '_inc/akismet-frontend.js', array()filemtime( plugin_dir_path( __FILE__ ) . '_inc/akismet-frontend.js' ), true );
            wp_enqueue_script( 'akismet-frontend' );
        }
    }

    /** * Add the form JavaScript when we detect that a supported form shortcode is being parsed. */
    public static function load_form_js_via_filter( $return_value$tag$attr$m ) {
        if ( in_array( $tag, array( 'contact-form', 'gravityform', 'contact-form-7', 'formidable', 'fluentform' ) ) ) {
            self::load_form_js();
        }

        
'plugins.php',
        ) ) ) ) {
            wp_register_style( 'akismet', plugin_dir_url( __FILE__ ) . '_inc/akismet.css', array()filemtime( dirname( __FILE__ ) . '/_inc/akismet.css' ) );
            wp_enqueue_style( 'akismet' );

            wp_register_style( 'akismet-font-inter', plugin_dir_url( __FILE__ ) . '_inc/fonts/inter.css', array()filemtime( dirname( __FILE__ ) . '/_inc/fonts/inter.css' ) );
            wp_enqueue_style( 'akismet-font-inter' );

            wp_register_style( 'akismet-admin', plugin_dir_url( __FILE__ ) . '_inc/akismet-admin.css', array()filemtime( dirname( __FILE__ ) . '/_inc/akismet-admin.css' ) );
            wp_enqueue_style( 'akismet-admin' );

            wp_register_script( 'akismet.js', plugin_dir_url( __FILE__ ) . '_inc/akismet.js', array( 'jquery' ), AKISMET_VERSION );
            wp_enqueue_script( 'akismet.js' );

            wp_register_script( 'akismet-admin.js', plugin_dir_url( __FILE__ ) . '_inc/akismet-admin.js', array( 'jquery' )filemtime( dirname( __FILE__ ) . '/_inc/akismet-admin.js' ) );
            wp_enqueue_script( 'akismet-admin.js' );
        
            $inline_js = array(
                'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
                'strings' => array(
                    'Remove this URL' => __( 'Remove this URL' , 'akismet'),
                    'Removing...'     => __( 'Removing...' , 'akismet'),
                    'URL removed'     => __( 'URL removed' , 'akismet'),
                    

            $register_script_lines[] = sprintf(
                ' wp.blocks.registerBlockStyle( \'%s\', %s );',
                $block_name,
                wp_json_encode( $block_style )
            );
        }
    }
    $register_script_lines[] = '} )();';
    $inline_script           = implode( "\n", $register_script_lines );

    wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true );
    wp_add_inline_script( 'wp-block-styles', $inline_script );
    wp_enqueue_script( 'wp-block-styles' );
}

/** * Enqueues the assets required for the block directory within the block editor. * * @since 5.5.0 */
function wp_enqueue_editor_block_directory_assets() {
    wp_enqueue_script( 'wp-block-directory' );
    
    wp_style_add_data( 'twenty-twenty-one-style', 'rtl', 'replace' );

    // Print styles.     wp_enqueue_style( 'twenty-twenty-one-print-style', get_template_directory_uri() . '/assets/css/print.css', array()wp_get_theme()->get( 'Version' ), 'print' );

    // Threaded comment reply styles.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }

    // Register the IE11 polyfill file.     wp_register_script(
        'twenty-twenty-one-ie11-polyfills-asset',
        get_template_directory_uri() . '/assets/js/polyfills.js',
        array(),
        wp_get_theme()->get( 'Version' ),
        true
    );

    // Register the IE11 polyfill loader.     wp_register_script(
        'twenty-twenty-one-ie11-polyfills',
        null,
        
if ( $is_core_block ) {
        $script_uri = includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) );
    } elseif ( $is_theme_block ) {
        // Get the script path deterministically based on whether or not it was registered in a parent or child theme.         $script_uri = $is_parent_theme_block
            ? get_theme_file_uri( str_replace( $template_path_norm, '', $script_path_norm ) )
            : get_theme_file_uri( str_replace( $stylesheet_path_norm, '', $script_path_norm ) );
    }

    $script_asset        = require $script_asset_path;
    $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array();
    $result              = wp_register_script(
        $script_handle,
        $script_uri,
        $script_dependencies,
        isset( $script_asset['version'] ) ? $script_asset['version'] : false
    );
    if ( ! $result ) {
        return false;
    }

    if ( ! empty( $metadata['textdomain'] ) && in_array( 'wp-i18n', $script_dependencies, true ) ) {
        wp_set_script_translations( $script_handle$metadata['textdomain'] );
    }
Home | Imprint | This part of the site doesn't use cookies.