Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
Last active November 17, 2017 14:21
Show Gist options
  • Save obiPlabon/62575b164976fb7e0c53edff433a1bfe to your computer and use it in GitHub Desktop.
Save obiPlabon/62575b164976fb7e0c53edff433a1bfe to your computer and use it in GitHub Desktop.
<?php
/**
* Enqueue assets (js/css)
*/
function prefix_enqueue_assets() {
wp_enqueue_script(
'prefix-script',
get_template_directory_uri() . '/assets/js/scripts.js',
array('jquery'),
null,
true
);
$localize_data = array(
/**
* prefix_get_option(), we wrote this function before
* (check wpian-help-redux.php) as it seems more convenient
* than the old style
*/
'service_content_layout' => esc_js( prefix_get_option( 'p_service_content_layout' ) ),
);
wp_localize_script(
'prefix-script', // This handle must be the same hand we used to enqueue scripts.js
'prefix_l10n',
$localize_data
);
}
add_action( 'wp_enqueue_scripts', 'prefix_enqueue_assets' );
jQuery(document).ready(function(){
jQuery('#service_owl_carousel').owlCarousel({
autoplay: true,
dots: false,
responsive: {
0: {
items:1,
nav:true
},
767: {
items:2,
nav:true
},
991: {
items: prefix_l10n.service_content_layout
nav: true
}
}
});
});
<?php
/**
* Cleaner way to access redux framework based theme options
*/
function prefix_get_option( $option_name, $default = '' ) {
global $prefix_options_var_name;
return isset( $prefix_options_var_name[$option_name] ) ? $prefix_options_var_name[$option_name] : $default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment