@grapplerulrich
Fatal error: Cannot redeclare enqueue_scripts() (previously declared)
// plugin.php
function enqueue_scripts() {}
// Theme functions.php
function enqueue_scripts() {}
// Before prefixing
function enqueue_scripts() {}
// Prefixed function
function prefix_enqueue_scripts() {}
Beautiful Vienna
beautiful_vienna_
breathtaking_vancouver_
bv_
function vienna_enqueue_scripts() {}
// PHP Class
class Vienna_Class() {
// Exception: Function within a class
public function init() {}
}
// PHP global
global $vienna_version;
// PHP Constants
define( 'VIENNA_SUPER_MODE', true );
function vienna_content_width() {
$content_width = apply_filters(
'vienna_content_width', // Filter name
640
);
}
function vienna_launch() {
do_action(
'vienna_launch', // Action name
$date,
$time
);
}
add_image_size( 'vienna-full-width', 1000, 500 );
add_option( 'vienna_settings', '255' );
add_menu_page(
__( 'Custom Page Title', 'vienna' ),
__( 'Custom Menu Title', 'vienna' ),
'manage_options',
'vienna-settings', // unique page slug
'',
'dashicons-chart-pie',
6
);
wp_enqueue_style(
'style', // style handle
get_stylesheet_uri()
);
wp_enqueue_style(
'vienna-style',
get_stylesheet_uri()
);
wp_enqueue_script(
'jquery-fitvids',
get_template_directory_uri() . '/jquery.fitvids.js'
);
wp_enqueue_script( 'jquery-fitvids' );
wp_localize_script(
'jquery-fitvids',
'vienna_data', // Object name
array(
'title' => __( 'WCEU is great!', 'vienna' ),
)
);
// alerts 'WCEU is great!'
alert( vienna_data.title );
~800 | ~1 100 | ~7 000 | ~15 000 |
---|
~800 | ~1 100 | ~7 000 | ~15 000 |
---|
<script src="<?php echo get_template_directory_uri(); ?>/fitvids.js">
</script>
wp_enqueue_script(
'jquery-fitvids',
get_template_directory_uri() . '/jquery.fitvids.js'
);
wp_enqueue_script( 'jquery' );
wp_enqueue_script(
'jquery-fitvids',
get_template_directory_uri() . '/jquery.fitvids.js'
);
wp_enqueue_script(
'jquery-fitvids',
get_template_directory_uri() . '/jquery.fitvids.js',
array( 'jquery' ) // Dependencies
);
function vienna_enqueue_styles() {
if ( is_archive() ) {
wp_enqueue_style(
'vienna-style',
get_stylesheet_uri()
);
}
}
add_action(
'wp_enqueue_scripts',
'vienna_enqueue_styles'
);
function vienna_admin_scripts( $hook_suffix ) {
// Only load on edit.php
if ( 'edit.php' !== $hook_suffix ) {
return;
}
wp_enqueue_script(
'vienna-admin',
get_template_directory_uri() . '/admin.js',
);
}
add_action(
'admin_enqueue_scripts',
'vienna_admin_scripts'
);
function vienna_enqueue_customizer_scripts() {
wp_enqueue_script(
'vienna-customizer',
get_template_directory_uri() . '/customizer.js'
);
}
add_action(
'customize_preview_init',
'vienna_enqueue_customizer_scripts'
);
// Load the html5 shiv.
wp_enqueue_script(
'vienna-html5',
get_template_directory_uri() . '/js/html5.js',
);
wp_script_add_data(
'vienna-html5',
'conditional',
'lt IE 9'
);
wp_enqueue_script( 'jquery-fitvids' );
wp_add_inline_script(
'jquery-fitvids',
'jQuery(document).ready(function(){
// Target your .container
$("#thing-with-videos").fitVids();
});'
);