PluginProbe
Powerkit – Supercharge your WordPress Site / 3.1.1
Powerkit – Supercharge your WordPress Site v3.1.1
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / lightbox / public / class-powerkit-lightbox-public.php

class-powerkit-lightbox-public.php in Powerkit – Supercharge your WordPress Site 3.1.1, at modules/lightbox/public/class-powerkit-lightbox-public.php

85 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The public-facing functionality of the module.
4 *
5 * @link https://codesupply.co
6 * @since 1.0.0
7 *
8 * @package Powerkit
9 * @subpackage Modules/public
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * The public-facing functionality of the module.
19 */
20 class Powerkit_Lightbox_Public extends Powerkit_Module_Public {
21
22 /**
23 * Initialize
24 */
25 public function initialize() {
26 add_filter( 'wp_kses_allowed_html', array( $this, 'filter_allowed_html' ), 10, 2 );
27 }
28
29 /**
30 * Allow pinterest data attributes on our links.
31 *
32 * @param array $allowed array The allowed.
33 * @param string $context string The context.
34 */
35 public function filter_allowed_html( $allowed, $context ) {
36 if ( 'post' === $context ) {
37 $allowed['img']['data-lightbox-description'] = true;
38 }
39
40 return $allowed;
41 }
42
43 /**
44 * Register the stylesheets for the public-facing side of the site.
45 */
46 public function wp_enqueue_scripts() {
47 // Styles.
48 wp_enqueue_style( 'glightbox', plugin_dir_url( __FILE__ ) . 'css/glightbox.min.css', array(), powerkit_get_setting( 'version' ), 'all' );
49
50 wp_enqueue_style( 'powerkit-lightbox', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-lightbox.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
51
52 // Add RTL support.
53 wp_style_add_data( 'powerkit-lightbox', 'rtl', 'replace' );
54
55 // Scripts.
56 wp_enqueue_script( 'glightbox', plugin_dir_url( __FILE__ ) . 'js/glightbox.min.js', array( 'jquery', 'imagesloaded' ), powerkit_get_setting( 'version' ), true );
57
58 wp_enqueue_script( 'powerkit-lightbox', plugin_dir_url( __FILE__ ) . 'js/public-powerkit-lightbox.js', array( 'jquery', 'imagesloaded' ), powerkit_get_setting( 'version' ), true );
59
60 $single_image_selectors = get_option( 'powerkit_lightbox_single_image_selectors', array( '.entry-content img' ) );
61 $gallery_selectors = get_option( 'powerkit_lightbox_gallery_selectors', array( '.wp-block-gallery', '.gallery' ) );
62 $exclude_selectors = get_option( 'powerkit_lightbox_exclude_selectors', array() );
63
64 $single_image_selectors = powerkit_lightbox_process_selectors( $single_image_selectors );
65 $gallery_selectors = powerkit_lightbox_process_selectors( $gallery_selectors );
66 $exclude_selectors = powerkit_lightbox_process_selectors( $exclude_selectors );
67
68 $single_image_selectors = apply_filters( 'powerkit_lightbox_image_selectors', $single_image_selectors );
69 $gallery_selectors = apply_filters( 'powerkit_lightbox_gallery_selectors', $gallery_selectors );
70 $exclude_selectors = apply_filters( 'powerkit_lightbox_exclude_selectors', $exclude_selectors );
71
72 wp_localize_script( 'powerkit-lightbox', 'powerkit_lightbox_localize', array(
73 'text_previous' => esc_html__( 'Previous', 'powerkit' ),
74 'text_next' => esc_html__( 'Next', 'powerkit' ),
75 'text_close' => esc_html__( 'Close', 'powerkit' ),
76 'text_loading' => esc_html__( 'Loading', 'powerkit' ),
77 'text_counter' => esc_html__( 'of', 'powerkit' ),
78 'single_image_selectors' => implode( ',', $single_image_selectors ),
79 'gallery_selectors' => implode( ',', $gallery_selectors ),
80 'exclude_selectors' => implode( ',', $exclude_selectors ),
81 'zoom_icon' => get_option( 'powerkit_lightbox_zoom_icon', true ),
82 ) );
83 }
84 }
85