*/ if ( ! defined( 'WPINC' ) ) { die; } class Ace_Testimonials_Slider_Public { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of the plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Ace_Testimonials_Slider_Loader as all of the hooks are defined * in that particular class. * * The Ace_Testimonials_Slider_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ $css_path = plugin_dir_path(__FILE__) . 'css/ace-testimonials-slider-public.css'; $css_url = plugin_dir_url(__FILE__) . 'css/ace-testimonials-slider-public.css'; $slick_css_path = plugin_dir_path(__FILE__) . 'assets/slick/css/slick.css'; $slick_css_url = plugin_dir_url(__FILE__) . 'assets/slick/css/slick.css'; $slick_theme_css_path = plugin_dir_path(__FILE__) . 'assets/slick/css/slick-theme.css'; $slick_theme_css_url = plugin_dir_url(__FILE__) . 'assets/slick/css/slick-theme.css'; $css_version = file_exists($css_path) ? filemtime($css_path) : $this->version; $slick_css_version = file_exists($slick_css_path) ? filemtime($slick_css_path) : $this->version; $slick_theme_css_version = file_exists($slick_theme_css_path) ? filemtime($slick_theme_css_path) : $this->version; wp_enqueue_style($this->plugin_name . '-public', $css_url,array(),$css_version,'all'); wp_enqueue_style('slick-css',$slick_css_url,array(),$slick_css_version,'all'); wp_enqueue_style('slick-theme-css',$slick_theme_css_url,array(),$slick_theme_css_version,'all'); } /** * Register the JavaScript for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Ace_Testimonials_Slider_Loader as all of the hooks are defined * in that particular class. * * The Ace_Testimonials_Slider_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ // Main public JS $public_js_path = plugin_dir_path(__FILE__) . 'js/ace-testimonials-slider-public.js'; $public_js_url = plugin_dir_url(__FILE__) . 'js/ace-testimonials-slider-public.js'; $public_js_version = file_exists($public_js_path) ? filemtime($public_js_path) : $this->version; wp_enqueue_script($this->plugin_name . '-public',$public_js_url,array('jquery'),$public_js_version,false ); $slick_js_path = plugin_dir_path(__FILE__) . 'assets/slick/js/slick.min.js'; $slick_js_url = plugin_dir_url(__FILE__) . 'assets/slick/js/slick.min.js'; $slick_js_version = file_exists($slick_js_path) ? filemtime($slick_js_path) : $this->version; wp_enqueue_script('slick-js',$slick_js_url,array('jquery'),$slick_js_version,true); } public function aceslider_shortcode() { ob_start(); $getslider_datas = get_option('aceslider_settings'); $slider_data = !empty($getslider_datas) ? $getslider_datas : []; $sliderarrows = isset($slider_data['showarrows']) ? (int) $slider_data['showarrows'] : 0; $testimonialdata =[]; $args = array( 'post_type' => 'ace-testimonials', 'posts_per_page' => -1, 'post_status'=>'publish', ); $custom_query = new WP_Query( $args ); if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); $postmeta = get_post_meta( get_the_ID(),'_testimonial_rating'); $testimonialdata[] = [ 'id'=>get_the_ID(), 'title' => get_the_title(), 'content' => get_the_content(), 'image' => get_the_post_thumbnail_url( get_the_ID(), 'full' ), 'ratting'=>$postmeta, ]; endwhile; wp_reset_postdata(); else : endif; $slider_alldata = [ 'aceslider_imageshape' => isset($slider_data['image_shape']) ? esc_attr($slider_data['image_shape']) : '', 'aceslider_imagesize' => isset($slider_data['image_size']) ? esc_attr($slider_data['image_size']) : '', 'aceslider_customwidth' => isset($slider_data['custom_width']) ? intval($slider_data['custom_width']) : '', 'aceslider_customheight' => isset($slider_data['custom_height']) ? intval($slider_data['custom_height']) : '', 'aceslider_charlimit' => isset($slider_data['char_limit']) ? intval($slider_data['char_limit']) : 0, 'aceslider_ratingposition' => isset($slider_data['rating_position']) ? esc_attr($slider_data['rating_position']) : '', 'aceslider_showimage' => isset($slider_data['show_image']) ? (int) $slider_data['show_image'] : 0, 'slider_background' => isset($slider_data['slider_bg_color']) ? esc_attr($slider_data['slider_bg_color']) : '#f4f4f4', 'slider_heading_color' => isset($slider_data['slider_heading_color']) ? esc_attr($slider_data['slider_heading_color']) : '#000', 'slider_description_color' => isset($slider_data['slider_description_color']) ? esc_attr($slider_data['slider_description_color']) : '#000', 'aceslider_showdot' => isset($slider_data['showdot']) ? (int) $slider_data['showdot'] : 0, 'aceslider_showarrows' => isset($slider_data['showarrows']) ? (int) $slider_data['showarrows'] : 0, 'aceslider_slidestoShow' => isset($slider_data['slidestoShow']) ? intval($slider_data['slidestoShow']) : 1, 'aceslider_slidesToScroll' => isset($slider_data['slidesToScroll']) ? intval($slider_data['slidesToScroll']) : 1, 'aceslider_autoplaySpeed' => isset($slider_data['autoplaySpeed']) ? intval($slider_data['autoplaySpeed']) : 0, 'aceslider_autoplay' => isset($slider_data['autoplay']) ? (int) $slider_data['autoplay'] : 0, 'ace_testimonials' => $testimonialdata, ]; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/partials/ace-testimonials-slider-public-display.php'; return ob_get_clean(); } /* ============== get data from Testimonial tabel ====================*/ public function aceslider_assets() { $getslider_datas = get_option('aceslider_settings'); $slider_data = !empty($getslider_datas) ? $getslider_datas : []; $slider_alldata = [ 'aceslider_charlimit' => isset($slider_data['char_limit']) ? intval($slider_data['char_limit']) : 0, 'aceslider_slidestoShow' => isset($slider_data['slidestoShow']) ? intval($slider_data['slidestoShow']) : 1, 'aceslider_slidesToScroll' => isset($slider_data['slidesToScroll']) ? intval($slider_data['slidesToScroll']) : 1, 'aceslider_autoplaySpeed' => isset($slider_data['autoplaySpeed']) ? intval($slider_data['autoplaySpeed']) : 0, 'aceslider_autoplay' => isset($slider_data['autoplay']) ? (int) $slider_data['autoplay'] : 0, 'aceslider_showdot' => isset($slider_data['showdot']) ? (int) $slider_data['showdot'] : 0, ]; wp_enqueue_script('aceslider-script',plugin_dir_url(__FILE__) . 'js/ace-testimonials-slider-public.js',array('jquery'),$this->version,true); wp_localize_script('aceslider-script', 'aceslider_script_settings', $slider_alldata); } }