//Download the slick zip then move on main directroy
download my plugin click here
//js file code
jQuery(document).ready(function($){
$('.slide').slick({
dots: true,
infinite: true,
speed: 300,
slidesToShow: 1,
adaptiveHeight: true
});
});
//main file and include files above
<?php
/**
* Plugin Name: My Basics slider
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Handle the basics with this plugin.
* Version: 1.10.3
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: John Smith
*
*/
// Exit if accessed directly.
if (!defined('ABSPATH'))
{
exit();
}
/**
* register activation hook
*/
function task_activate_plugin_cb()
{
//code here
}
register_activation_hook(__FILE__, 'task_activate_plugin_cb');
/**
* register deactivation hook
*/
function task_deactivate_plugin_cb()
{
//code here
}
register_deactivation_hook(__FILE__, 'task_deactivate_plugin_cb');
/**
* register Uninstall hook
*/
function task_uninstall_hook_cb()
{
//code here
}
register_uninstall_hook(__FILE__, 'task_uninstall_hook_cb');
function task_enqueue_scripts_for_slick_cb()
{
// including css for slick
wp_enqueue_style('bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css'); //enqueue slick style sheet
wp_enqueue_style('slick-style', plugin_dir_url(__FILE__) . 'slick/slick.css'); //enqueue slick style sheet
wp_enqueue_style('slick-theme-style', plugin_dir_url(__FILE__) . 'slick/slick-theme.css'); //enqueue slick style sheet
// include js file
//wp_enqueue_script( 'jquery','http://code.jquery.com/jquery-migrate-1.2.1.js'); //alternative for slick.js
wp_enqueue_script('slick-carouseal-min-js', plugin_dir_url(__FILE__) . 'slick/slick.min.js', ['jquery']); //alternative for slick.js
wp_enqueue_script('slick-carouseal-js', plugin_dir_url(__FILE__) . 'slick/slick.js', ['jquery']); //alternative for slick.min.js
wp_enqueue_script('custom-js', plugin_dir_url(__FILE__) . 'myjs.js', ['jquery']); //jquery is need
}
add_action('wp_enqueue_scripts', 'task_enqueue_scripts_for_slick_cb'); //for enqueqe script for slick
function ctest_shortcode($atts)
{
extract(shortcode_atts(array(
'imgurl' => '',
'carousel' => '',
) , $atts));
/* Call to template */
if (empty($res) && is_array($res)):
// if($res==''|| $imgurl == ''):
echo '<div class="alert alert-danger">You need to add image in [test imgurl="example.jpg"] </div>"';
else:
$res = explode(';', $imgurl);
$showresult = "";
if ($carousel == true):
foreach ($res as $key):
$showresult .= '<div>true <img src="' . $key . '"> </div>';
endforeach;
return "<div class='slide'>" . $showresult . "</div>";
else:
foreach ($res as $key):
$showresult .= '<div class="col-md-6"> false <img src="' . $key . '"> </div>';
endforeach;
return "<div class='row'>" . $showresult . "</div>";
endif;
endif;
?>
</div>
<?php
}
add_shortcode('test', 'ctest_shortcode');
?>
<? php
0 Comments