I have a problem wih my WordPress plugin, I want to insert Gridster into the plugin but it doesn't work.
Here I am loading the files, which are correctly in the folder.
function add_my_stylesheet()
{
wp_enqueue_style( 'myCSS', plugins_url( '/css/bootstrap.css', __FILE__ ), false );
wp_enqueue_style("gridster-style", plugins_url( '/css/jquery.gridster.min.css', __FILE__ ), false );
}
add_action('admin_print_styles', 'add_my_stylesheet');
function add_my_scripts()
{
//I tried wp_register_script as well as wp_enqueue_script
wp_register_script( "jquery-gridster", plugins_url( '/js/jquery.min.js', __FILE__ ) );
wp_register_script( "gridster-script", plugins_url( '/js/jquery.gridster.min.js', __FILE__ ) );
wp_register_script( "gridster-script-extra", plugins_url( '/js/jquery. gridster.with-extras.min.js', __FILE__ ) );
}
add_action( 'wp_register_scripts', 'add_my_scripts' );
And this is a code sample of the expected output, which of course doesn't work too.
echo'
<section class="demo">
<div class="gridster">
<ul>
<li class="bg-blue" data-row="1" data-col="1" data-sizex="1" data-sizey="1">Box1</li>
<li class="bg-pink" data-row="1" data-col="2" data-sizex="1" data-sizey="1">Box2</li>
<li class="bg-pink" data-row="1" data-col="3" data-sizex="1" data-sizey="2">Box3</li>
</ul>
</div>
</section>
<script type="text/javascript">
var gridster;
$(function() {
gridtster = $(".gridster > ul").gridster({
widget_margins: [10, 10],
widget_base_dimensions: [140, 140],
min_cols: 6
}).data("gridster");
});
</script>';
I tried including it in the templates' header file as well as in the plugin, but it only shows me the text and I am not able to drag and drop them.