tag for the enqueued script. * @param string $handle The script's registered handle. */ public function js_attributes( $tag, $handle ) { if ( 'powerkit-pinterest' !== $handle ) { return $tag; } return str_replace( ' src', ' async="async" defer="defer" src', $tag ); } /** * Allow pinterest data attributes on our links. * * @param array $allowed array The allowed. * @param string $context string The context. */ public function filter_allowed_html( $allowed, $context ) { if ( 'post' === $context ) { $allowed['img']['data-pin-description'] = true; } return $allowed; } /** * Register the stylesheets for the public-facing side of the site. */ public function wp_enqueue_scripts() { // Styles. wp_enqueue_style( 'powerkit-pinterest', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-pinterest.css' ), array(), powerkit_get_setting( 'version' ), 'all' ); // Add RTL support. wp_style_add_data( 'powerkit-pinterest', 'rtl', 'replace' ); // Scripts. wp_enqueue_script( 'powerkit-pin-it', plugin_dir_url( __FILE__ ) . 'js/public-powerkit-pin-it.js', array( 'powerkit-pinterest', 'jquery', 'imagesloaded' ), powerkit_get_setting( 'version' ), true ); $image_selectors = get_option( 'powerkit_pinit_image_selectors', array( '.entry-content img' ) ); $exclude_selectors = get_option( 'powerkit_pinit_exclude_selectors', array() ); $image_selectors = powerkit_pinit_process_selectors( $image_selectors ); $exclude_selectors = powerkit_pinit_process_selectors( $exclude_selectors ); $image_selectors = apply_filters( 'powerkit_pinit_image_selectors', $image_selectors ); $exclude_selectors = apply_filters( 'powerkit_pinit_exclude_selectors', $exclude_selectors ); wp_localize_script( 'powerkit-pin-it', 'powerkit_pinit_localize', array( 'image_selectors' => implode( ',', $image_selectors ), 'exclude_selectors' => implode( ',', $exclude_selectors ), 'only_hover' => get_option( 'powerkit_pinit_only_hover', true ), ) ); } }