Plugin Directory

Changeset 3104692


Ignore:
Timestamp:
06/19/2024 04:37:24 PM (20 months ago)
Author:
pandaboxwp
Message:

Release version 2.1.0

Location:
wp-jquery-lightbox
Files:
236 added
18 deleted
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-jquery-lightbox/tags/2.1.0/class-lightpress.php

    r3104196 r3104692  
    3030
    3131    /**
    32      * The name of the plugin
     32     * Holds the currently active lightbox
     33     *
     34     * @var string|null
     35     */
     36    public static $active_lightbox = null;
     37
     38    /**
     39     * The screen id for the settings page
    3340     *
    3441     * @var string
    3542     */
    36     public static $name = 'LightPress Lightbox';
    37 
    38     /**
    39      * The plugin slug
    40      *
    41      * @var string
    42      */
    43     public static $plugin_slug = 'wp-jquery-lightbox';
    44 
    45     /**
    46      * The group of the lightbox
    47      *
    48      * @var int
    49      */
    50     public static $lightbox_group = -1;
    51 
    52     /**
    53      * Holds the options for the JQuery Lightbox
    54      *
    55      * @var array
    56      */
    57     public static $jqlb_options;
    58 
    59     /**
    60      * Holds the currently active lightbox
    61      *
    62      * @var string|null
    63      */
    64     private static $active_lightbox = null;
    65 
    66     /**
    67      * The screen id for the settings page
    68      *
    69      * @var string
    70      */
    71     public static $screen_id = 'toplevel_page_lightpress-settings';
     43    public static $settings_screen_id = 'toplevel_page_lightpress-settings';
    7244
    7345    /**
     
    10375     */
    10476    public function __construct() {
    105         include LIGHTPRESS_PLUGIN_DIR . 'wp-jquery-lightbox-options.php';
    106 
    10777        // Frontend & Admin.
    10878        self::$active_lightbox = get_option( 'lightpress_active_lightbox', 'wp-jquery-lightbox' );
    109         self::$jqlb_options    = $wp_jquery_lightbox_options;
    11079        load_plugin_textdomain( 'wp-jquery-lightbox', false, LIGHTPRESS_PLUGIN_DIR . 'languages/' );
    11180        add_action( 'wp_loaded', array( $this, 'jqlb_save_date' ) );
    112 
    113         // Frontend.
    114         if ( 'wp-jquery-lightbox' === self::$active_lightbox ) {
    115             add_action( 'wp_print_styles', array( $this, 'enqueue_css' ) );
    116             add_action( 'wp_print_scripts', array( $this, 'enqueue_js' ) );
    117             add_filter( 'the_content', array( $this, 'filter_content' ), 99 );
    118             add_filter( 'post_gallery', array( $this, 'filter_groups' ), 10, 2 );
    119             if ( get_option( 'jqlb_comments' ) === 1 ) {
    120                 remove_filter( 'pre_comment_content', 'wp_rel_nofollow' );
    121                 add_filter( 'comment_text', array( $this, 'lightbox_comment' ), 99 );
    122             }
    123         }
    12481
    12582        // Admin.
     
    12784            add_action( 'admin_menu', array( $this, 'register_menu_items' ) );
    12885            add_filter( 'plugin_row_meta', array( $this, 'set_plugin_meta' ), 2, 10 );
    129             add_action( 'admin_init', array( $this, 'register_and_add_settings' ) );
    130             add_action( 'admin_init', array( __CLASS__, 'add_settings_sections' ) );
    131             add_action( 'admin_init', array( __CLASS__, 'add_settings_fields' ) );
     86            add_action( 'admin_init', array( $this, 'add_plugin_settings' ) );
    13287            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
    133             if ( 'wp-jquery-lightbox' === self::$active_lightbox ) {
    134                 // Removes rel-attributes to image-links added by WP.
    135                 add_filter( 'image_send_to_editor', array( $this, 'remove_rel' ), 10, 2 );
    136             }
    137         }
     88        }
     89
     90        // Include WP JQuery Lightbox.
     91        require_once LIGHTPRESS_PLUGIN_DIR . 'lightboxes/wp-jquery-lightbox/class-wp-jquery-lightbox.php';
     92        $wp_jquery_lightbox = WP_JQuery_Lightbox::get_instance();
    13893    }
    13994
     
    225180     */
    226181    public static function pro_landing_page() {
    227         include LIGHTPRESS_PLUGIN_DIR . '/views/pro-landing-page.php';
     182        include LIGHTPRESS_PLUGIN_DIR . 'admin/views/pro-landing-page.php';
    228183    }
    229184
     
    231186     * Registers and adds settings for plugin and WP JQuery Lightbox.
    232187     */
    233     public static function register_and_add_settings() {
    234         // Register general settings that apply to all lightboxes.
     188    public static function add_plugin_settings() {
     189        // Register general plugin settings.
    235190        register_setting(
    236191            'lightpress-settings-group',
     
    243198        add_option( 'lightpress_active_lightbox', 'wp-jquery-lightbox' );
    244199
    245         // Register settings for WP Jquery lightbox.
    246         foreach ( self::$jqlb_options as $key => $setting ) {
    247             $id                = $setting['id'];
    248             $default           = isset( $setting['default'] ) ? $setting['default'] : '';
    249             $sanitize_callback = isset( $setting['sanitize_callback'] ) ? $setting['sanitize_callback'] : null;
    250             register_setting(
    251                 'lightpress-settings-group',
    252                 $id,
    253                 array(
    254                     'sanitize_callback' => $sanitize_callback,
    255                     'show_in_rest'      => true,
    256                     'default'           => $default,
    257                 )
    258             );
    259             add_option( $id, $default );
    260         }
    261     }
    262 
    263     /**
    264      * Adds settings sections for plugin and WP JQuery lightbox.
    265      */
    266     public static function add_settings_sections() {
    267         // General Lightbox Settings.
     200        // Add general plugin settings section.
    268201        add_settings_section(
    269202            'lightpress-general-settings-section', // Section ID.
     
    277210        );
    278211
    279         // WP JQuery Lightbox.
    280         add_settings_section(
    281             'wp-jquery-lightbox-settings-section', // Section ID.
    282             __( 'WP JQuery Lightbox: All Settings', 'wp-jquery-lightbox' ), // Section title.
    283             null, // Callback for top-of-section content.
    284             'lightpress-settings', // Page ID.
    285             array(
    286                 'before_section' => '<div id="wp-jquery-lightbox-settings-section" class="wp-jquery-lightbox wp-jquery-lightbox-settings-section settings-section sub-settings-section">',
    287                 'after_section'  => '</div>',
    288             )
    289         );
    290     }
    291 
    292     /**
    293      * Add setting fields to settings page using Settings API.
    294      */
    295     public static function add_settings_fields() {
    296         // "Choose Lightbox" field
     212        // Add general plugin settings fields.
    297213        add_settings_field(
    298214            'lightpress_active_lightbox',
     
    303219            array( 'label_for' => 'lightpress_active_lightbox' )
    304220        );
    305 
    306         // Fields for WP Jquery Lightbox Settings.
    307         foreach ( self::$jqlb_options as $key => $setting ) {
    308             $id    = $setting['id'];
    309             $title = $setting['title'] ?? '';
    310             add_settings_field(
    311                 $id, // Setting ID.
    312                 $title, // Setting label.
    313                 array( __CLASS__, 'render_settings_fields' ), // Setting callback.
    314                 'lightpress-settings', // Page ID.
    315                 'wp-jquery-lightbox-settings-section', // Section ID.
    316                 $setting
    317             );
    318         }
    319221    }
    320222
     
    497399        $should_load_js =
    498400            'dashboard' === $screen->id ||
    499             self::$screen_id === $screen->id ||
     401            self::$settings_screen_id === $screen->id ||
    500402            self::$pro_screen_id === $screen->id;
    501403
     
    521423
    522424    /**
    523      * Enqueues JavaScript for the LightPress plugin.
    524      */
    525     public function enqueue_js() {
    526         $enqueue_in_footer = get_option( 'jqlb_enqueue_in_footer' ) ? true : false;
    527         $version           = defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : LIGHTPRESS_VERSION;
    528 
    529         wp_enqueue_script( 'jquery' );
    530         wp_enqueue_script(
    531             'wp-jquery-lightbox-swipe',
    532             LIGHTPRESS_PLUGIN_URL . 'jquery.touchwipe.min.js',
    533             array( 'jquery' ),
    534             $version,
    535             $enqueue_in_footer
    536         );
    537         wp_enqueue_script(
    538             'wp-jquery-lightbox-purify',
    539             LIGHTPRESS_PLUGIN_URL . 'inc/purify.min.js',
    540             array(),
    541             $version,
    542             $enqueue_in_footer
    543         );
    544         if ( get_option( 'jqlb_pinchzoom' ) === '1' ) {
    545             wp_enqueue_script(
    546                 'wp-jquery-lightbox-panzoom',
    547                 plugins_url( 'panzoom.min.js', __FILE__ ),
    548                 array( 'jquery' ),
    549                 $version,
    550                 $enqueue_in_footer
    551             );
    552             wp_enqueue_script(
    553                 'wp-jquery-lightbox',
    554                 plugins_url( 'jquery.lightbox.js', __FILE__ ),
    555                 array( 'jquery', 'wp-jquery-lightbox-panzoom' ),
    556                 $version,
    557                 $enqueue_in_footer
    558             );
    559         } else {
    560             wp_enqueue_script(
    561                 'wp-jquery-lightbox',
    562                 plugins_url( 'jquery.lightbox.js', __FILE__ ),
    563                 array( 'jquery' ),
    564                 $version,
    565                 $enqueue_in_footer
    566             );
    567         }
    568 
    569         wp_localize_script(
    570             'wp-jquery-lightbox',
    571             'JQLBSettings',
    572             array(
    573                 'showTitle'        => get_option( 'jqlb_showTitle' ),
    574                 'useAltForTitle'   => get_option( 'jqlb_useAltForTitle' ),
    575                 'showCaption'      => get_option( 'jqlb_showCaption' ),
    576                 'showNumbers'      => get_option( 'jqlb_showNumbers' ),
    577                 'fitToScreen'      => get_option( 'jqlb_resize_on_demand' ),
    578                 'resizeSpeed'      => get_option( 'jqlb_resize_speed' ),
    579                 'showDownload'     => get_option( 'jqlb_showDownload' ),
    580                 'navbarOnTop'      => get_option( 'jqlb_navbarOnTop' ),
    581                 'marginSize'       => get_option( 'jqlb_margin_size' ),
    582                 'mobileMarginSize' => get_option( 'jqlb_mobile_margin_size' ),
    583                 'slideshowSpeed'   => get_option( 'jqlb_slideshow_speed' ),
    584                 'allowPinchZoom'   => get_option( 'jqlb_pinchzoom' ),
    585                 'borderSize'       => get_option( 'jqlb_borderSize' ),
    586                 'borderColor'      => get_option( 'jqlb_borderColor' ),
    587                 'overlayColor'     => get_option( 'jqlb_overlayColor' ),
    588                 'overlayOpacity'   => get_option( 'jqlb_overlayOpacity' ),
    589                 'newNavStyle'      => get_option( 'jqlb_newNavStyle' ),
    590                 'fixedNav'         => get_option( 'jqlb_fixedNav' ),
    591                 'showInfoBar'      => get_option( 'jqlb_showInfoBar' ),
    592                 'prevLinkTitle'    => __( 'previous image', 'wp-jquery-lightbox' ),
    593                 'nextLinkTitle'    => __( 'next image', 'wp-jquery-lightbox' ),
    594                 'closeTitle'       => __( 'close image gallery', 'wp-jquery-lightbox' ),
    595                 'image'            => __( 'Image ', 'wp-jquery-lightbox' ),
    596                 'of'               => __( ' of ', 'wp-jquery-lightbox' ),
    597                 'download'         => __( 'Download', 'wp-jquery-lightbox' ),
    598                 'pause'            => __( '(Pause Slideshow)', 'wp-jquery-lightbox' ),
    599                 'play'             => __( '(Play Slideshow)', 'wp-jquery-lightbox' ),
    600             )
    601         );
    602     }
    603 
    604     /**
    605      * Enqueues CSS for the LightPress plugin.
    606      */
    607     public function enqueue_css() {
    608         $locale         = $this->get_locale();
    609         $file_name      = "lightbox.min.{$locale}.css";
    610         $have_theme_css = false;
    611 
    612         if ( get_option( 'jqlb_use_theme_styles' ) === 1 ) {
    613             $path_theme     = get_stylesheet_directory() . "/{$file_name}";
    614             $have_theme_css = is_readable( $path_theme );
    615             if ( ! $have_theme_css ) {
    616                 $file_name      = 'lightbox.min.css';
    617                 $path_theme     = get_stylesheet_directory() . "/{$file_name}";
    618                 $have_theme_css = is_readable( $path_theme );
    619             }
    620         }
    621 
    622         if ( ! $have_theme_css ) {
    623             $path = plugin_dir_path( __FILE__ ) . "styles/{$file_name}";
    624             if ( ! is_readable( $path ) ) {
    625                 $file_name = 'lightbox.min.css';
    626             }
    627         }
    628         $uri = ( $have_theme_css )
    629             ? get_stylesheet_directory_uri() . '/' . $file_name
    630             : LIGHTPRESS_PLUGIN_URL . 'styles/' . $file_name;
    631 
    632         wp_enqueue_style(
    633             'jquery.lightbox.min.css',
    634             $uri,
    635             false,
    636             defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : LIGHTPRESS_VERSION
    637         );
    638         wp_enqueue_style(
    639             'jqlb-overrides',
    640             plugin_dir_url( __FILE__ ) . 'styles/overrides.css',
    641             false,
    642             defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : LIGHTPRESS_VERSION
    643         );
    644 
    645         // Add inline styles for new nav arrow styling.
    646         // Needed to apply styles to :before pseudo-selectors.
    647         $nav_arrow_color      = get_option( 'jqlb_navArrowColor' );
    648         $nav_background_color = get_option( 'jqlb_navBackgroundColor' );
    649         $border_width         = get_option( 'jqlb_borderSize' );
    650         $has_box_shadow       = get_option( 'jqlb_boxShadow' );
    651         $has_info_bar         = get_option( 'jqlb_showInfoBar' );
    652         $image_box_shadow     = $has_box_shadow ? '0 0 4px 2px rgba(0,0,0,.2)' : '';
    653         $infobar_box_shadow   = ( $has_box_shadow && $has_info_bar )
    654             ? '0 -4px 0 0 #fff, 0 0 4px 2px rgba(0,0,0,.1);'
    655             : '';
    656         $custom_css           = "
    657             #outerImageContainer {
    658                 box-shadow: {$image_box_shadow};
    659             }
    660             #imageContainer{
    661                 padding: {$border_width}px;
    662             }
    663             #imageDataContainer {
    664                 box-shadow: {$infobar_box_shadow};
    665             }
    666             #prevArrow,
    667             #nextArrow{
    668                 background-color: {$nav_background_color};
    669                 color: {$nav_arrow_color};
    670             }";
    671         wp_add_inline_style( 'jqlb-overrides', $custom_css );
    672     }
    673 
    674     /**
    675      * Gets the locale for the LightPress plugin.
    676      *
    677      * @return string The locale.
    678      */
    679     public function get_locale() {
    680         global $lang_locales;
    681         if ( defined( 'ICL_LANGUAGE_CODE' ) && isset( $lang_locales[ ICL_LANGUAGE_CODE ] ) ) {
    682             $locale = $lang_locales[ ICL_LANGUAGE_CODE ];
    683         } else {
    684             $locale = get_locale();
    685         }
    686         return $locale;
    687     }
    688 
    689     /**
    690      * Filters the content for the LightPress plugin.
    691      *
    692      * @param string $content The content to filter.
    693      * @return string The filtered content.
    694      */
    695     public function filter_content( $content ) {
    696         if ( get_option( 'jqlb_automate' ) === '1' ) {
    697             global $post;
    698             $id      = isset( $post->ID ) ? $post->ID : -1;
    699             $content = $this->do_regexp( $content, $id );
    700         }
    701         return $content;
    702     }
    703 
    704     /**
    705      * Performs a regular expression operation.
    706      *
    707      * @param string $content The content to perform the operation on.
    708      * @param int    $id Post id.
    709      * @return string The result of the operation.
    710      */
    711     public function do_regexp( $content, $id ) {
    712         $id          = esc_attr( $id );
    713         $content     = preg_replace( '/\s+rel="attachment wp-att-[0-9]+"/i', '', $content ); // Remove WP 4.4 garbage.
    714         $pattern     = "/(<a(?![^>]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png|webp)(\?\S{0,}){0,1}['\"][^\>]*)>/i";
    715         $replacement = '$1 rel="lightbox[' . $id . ']">';
    716         return preg_replace( $pattern, $replacement, $content );
    717     }
    718 
    719     /**
    720      * Determines whether to add filter for grouping images in a gallery.
    721      *
    722      * Runs on the post_gallery filter.
    723      *
    724      * @param string $html Content to filter.
    725      * @param array  $attr Array of attributes.
    726      * @return string
    727      */
    728     public function filter_groups( $html, $attr ) {
    729         if ( empty( $attr['group'] ) ) {
    730             $this->lightbox_group = -1;
    731             remove_filter( 'wp_get_attachment_link', array( $this, 'lightbox_gallery_links' ), 10, 1 );
    732         } else {
    733             $this->lightbox_group = $attr['group'];
    734             add_filter( 'wp_get_attachment_link', array( $this, 'lightbox_gallery_links' ), 10, 1 );
    735         }
    736         return '';
    737     }
    738 
    739     /**
    740      * Modifies gallery links to use lightbox, honoring custom group attributes.
    741      *
    742      * @param  string $html Content to filter.
    743      * @return string $html
    744      */
    745     public function lightbox_gallery_links( $html ) {
    746         // No grouping.
    747         if ( ! isset( $this->lightbox_group ) || -1 === $this->lightbox_group ) {
    748             return $html;
    749         }
    750 
    751         // Grouping.
    752         return str_replace( '<a', '<a rel="lightbox[' . $this->lightbox_group . ']"', $html );
    753     }
    754 
    755     /**
    756425     * Add date time stampe when plugin activated
    757426     */
  • wp-jquery-lightbox/tags/2.1.0/readme.txt

    r3104196 r3104692  
    1 === LightPress Lightbox ===
     1=== LightPress Lightbox (WP JQuery Lightbox) ===
    22Contributors: pandaboxwp
    33Tags: lightbox, photo, image, gallery
    44Requires at least: 5.0
    55Tested up to: 6.5.4
    6 Stable tag: 2.0.0
     6Stable tag: 2.1.0
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    1212== Description ==
    1313
    14 A simple, lightweight WordPress lightbox plugin. [See demo here](https://lightpress.io).
     14The LightPress Lightbox was formerly the WP JQuery Lightbox. Along with the name change, we'll be doing signficant development on this plugin in 2024, including the addition of additional, modern lightboxes (both free and pro). We'll still continue to include, support, and enhance the original lightbox!
     15
     16This plugin adds a simple, lightweight lightbox for viewing images. [See demos here](https://lightpress.io).
    1517
    1618**Features**
     
    3133Special thanks to [Ulf Benjaminsson](http://www.ulfbenjaminsson.com), who created this plugin and maintained it for many years.
    3234
    33 This plugin lets you keep [Lightbox 2](http://www.huddletogether.com/projects/lightbox2/) functionality but sheds the bulk of the Prototype Framework and Scriptaculous Effects Library. Warren Krewenki [ported Lightbox to jQuery](http://warren.mesozen.com/jquery-lightbox/) and this plugin is mostly a wrapper to his work.
     35The original WP JQuery Lightbox included with this plugin lets you keep [Lightbox 2](http://www.huddletogether.com/projects/lightbox2/) functionality but sheds the bulk of the Prototype Framework and Scriptaculous Effects Library. Warren Krewenki [ported Lightbox to jQuery](http://warren.mesozen.com/jquery-lightbox/) and this plugin is mostly a wrapper to his work.
    3436
    3537== Screenshots ==
     
    113115== Changelog ==
    114116
    115 = 2.0.0 (2024-06-19) =
     117= 2.1.0 (2024-06-19) =
     118* Major file reorganization
     119* Fix image inserting not working in classic editor
     120* Update plugin banner and icon
     121
     122= 2.0.0 (2024-06-18) =
    116123* Rename plugin to LightPress
    117124* Add core LightPress plugin class
  • wp-jquery-lightbox/tags/2.1.0/wp-jquery-lightbox.php

    r3104196 r3104692  
    44 * Plugin URI: http://wordpress.org/extend/plugins/wp-jquery-lightbox/
    55 * Description: Simple and lightweight lightbox for galleries and images. Formerly WP Jquery Lightbox.
    6  * Version: 2.0.0
     6 * Version: 2.1.0
    77 * Text Domain: wp-jquery-lightbox
    88 * Author: LightPress
     
    2323 * Define constants.
    2424 */
    25 define( 'LIGHTPRESS_VERSION', '2.0.0' );
     25define( 'LIGHTPRESS_VERSION', '2.1.0' );
    2626define( 'LIGHTPRESS_PLUGIN_BASE', plugin_basename( __FILE__ ) );
    2727define( 'LIGHTPRESS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); // Includes ending slash.
     
    2929
    3030if ( defined( 'JQLB_LEGACY' ) && true === JQLB_LEGACY ) {
    31     require_once LIGHTPRESS_PLUGIN_DIR . 'wp-jquery-lightbox-legacy.php';
     31    require_once LIGHTPRESS_PLUGIN_DIR . 'lightboxes/wp-jquery-lightbox/wp-jquery-lightbox-legacy.php';
    3232} else {
    3333    require_once LIGHTPRESS_PLUGIN_DIR . 'class-lightpress.php';
  • wp-jquery-lightbox/trunk/class-lightpress.php

    r3104196 r3104692  
    3030
    3131    /**
    32      * The name of the plugin
     32     * Holds the currently active lightbox
     33     *
     34     * @var string|null
     35     */
     36    public static $active_lightbox = null;
     37
     38    /**
     39     * The screen id for the settings page
    3340     *
    3441     * @var string
    3542     */
    36     public static $name = 'LightPress Lightbox';
    37 
    38     /**
    39      * The plugin slug
    40      *
    41      * @var string
    42      */
    43     public static $plugin_slug = 'wp-jquery-lightbox';
    44 
    45     /**
    46      * The group of the lightbox
    47      *
    48      * @var int
    49      */
    50     public static $lightbox_group = -1;
    51 
    52     /**
    53      * Holds the options for the JQuery Lightbox
    54      *
    55      * @var array
    56      */
    57     public static $jqlb_options;
    58 
    59     /**
    60      * Holds the currently active lightbox
    61      *
    62      * @var string|null
    63      */
    64     private static $active_lightbox = null;
    65 
    66     /**
    67      * The screen id for the settings page
    68      *
    69      * @var string
    70      */
    71     public static $screen_id = 'toplevel_page_lightpress-settings';
     43    public static $settings_screen_id = 'toplevel_page_lightpress-settings';
    7244
    7345    /**
     
    10375     */
    10476    public function __construct() {
    105         include LIGHTPRESS_PLUGIN_DIR . 'wp-jquery-lightbox-options.php';
    106 
    10777        // Frontend & Admin.
    10878        self::$active_lightbox = get_option( 'lightpress_active_lightbox', 'wp-jquery-lightbox' );
    109         self::$jqlb_options    = $wp_jquery_lightbox_options;
    11079        load_plugin_textdomain( 'wp-jquery-lightbox', false, LIGHTPRESS_PLUGIN_DIR . 'languages/' );
    11180        add_action( 'wp_loaded', array( $this, 'jqlb_save_date' ) );
    112 
    113         // Frontend.
    114         if ( 'wp-jquery-lightbox' === self::$active_lightbox ) {
    115             add_action( 'wp_print_styles', array( $this, 'enqueue_css' ) );
    116             add_action( 'wp_print_scripts', array( $this, 'enqueue_js' ) );
    117             add_filter( 'the_content', array( $this, 'filter_content' ), 99 );
    118             add_filter( 'post_gallery', array( $this, 'filter_groups' ), 10, 2 );
    119             if ( get_option( 'jqlb_comments' ) === 1 ) {
    120                 remove_filter( 'pre_comment_content', 'wp_rel_nofollow' );
    121                 add_filter( 'comment_text', array( $this, 'lightbox_comment' ), 99 );
    122             }
    123         }
    12481
    12582        // Admin.
     
    12784            add_action( 'admin_menu', array( $this, 'register_menu_items' ) );
    12885            add_filter( 'plugin_row_meta', array( $this, 'set_plugin_meta' ), 2, 10 );
    129             add_action( 'admin_init', array( $this, 'register_and_add_settings' ) );
    130             add_action( 'admin_init', array( __CLASS__, 'add_settings_sections' ) );
    131             add_action( 'admin_init', array( __CLASS__, 'add_settings_fields' ) );
     86            add_action( 'admin_init', array( $this, 'add_plugin_settings' ) );
    13287            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
    133             if ( 'wp-jquery-lightbox' === self::$active_lightbox ) {
    134                 // Removes rel-attributes to image-links added by WP.
    135                 add_filter( 'image_send_to_editor', array( $this, 'remove_rel' ), 10, 2 );
    136             }
    137         }
     88        }
     89
     90        // Include WP JQuery Lightbox.
     91        require_once LIGHTPRESS_PLUGIN_DIR . 'lightboxes/wp-jquery-lightbox/class-wp-jquery-lightbox.php';
     92        $wp_jquery_lightbox = WP_JQuery_Lightbox::get_instance();
    13893    }
    13994
     
    225180     */
    226181    public static function pro_landing_page() {
    227         include LIGHTPRESS_PLUGIN_DIR . '/views/pro-landing-page.php';
     182        include LIGHTPRESS_PLUGIN_DIR . 'admin/views/pro-landing-page.php';
    228183    }
    229184
     
    231186     * Registers and adds settings for plugin and WP JQuery Lightbox.
    232187     */
    233     public static function register_and_add_settings() {
    234         // Register general settings that apply to all lightboxes.
     188    public static function add_plugin_settings() {
     189        // Register general plugin settings.
    235190        register_setting(
    236191            'lightpress-settings-group',
     
    243198        add_option( 'lightpress_active_lightbox', 'wp-jquery-lightbox' );
    244199
    245         // Register settings for WP Jquery lightbox.
    246         foreach ( self::$jqlb_options as $key => $setting ) {
    247             $id                = $setting['id'];
    248             $default           = isset( $setting['default'] ) ? $setting['default'] : '';
    249             $sanitize_callback = isset( $setting['sanitize_callback'] ) ? $setting['sanitize_callback'] : null;
    250             register_setting(
    251                 'lightpress-settings-group',
    252                 $id,
    253                 array(
    254                     'sanitize_callback' => $sanitize_callback,
    255                     'show_in_rest'      => true,
    256                     'default'           => $default,
    257                 )
    258             );
    259             add_option( $id, $default );
    260         }
    261     }
    262 
    263     /**
    264      * Adds settings sections for plugin and WP JQuery lightbox.
    265      */
    266     public static function add_settings_sections() {
    267         // General Lightbox Settings.
     200        // Add general plugin settings section.
    268201        add_settings_section(
    269202            'lightpress-general-settings-section', // Section ID.
     
    277210        );
    278211
    279         // WP JQuery Lightbox.
    280         add_settings_section(
    281             'wp-jquery-lightbox-settings-section', // Section ID.
    282             __( 'WP JQuery Lightbox: All Settings', 'wp-jquery-lightbox' ), // Section title.
    283             null, // Callback for top-of-section content.
    284             'lightpress-settings', // Page ID.
    285             array(
    286                 'before_section' => '<div id="wp-jquery-lightbox-settings-section" class="wp-jquery-lightbox wp-jquery-lightbox-settings-section settings-section sub-settings-section">',
    287                 'after_section'  => '</div>',
    288             )
    289         );
    290     }
    291 
    292     /**
    293      * Add setting fields to settings page using Settings API.
    294      */
    295     public static function add_settings_fields() {
    296         // "Choose Lightbox" field
     212        // Add general plugin settings fields.
    297213        add_settings_field(
    298214            'lightpress_active_lightbox',
     
    303219            array( 'label_for' => 'lightpress_active_lightbox' )
    304220        );
    305 
    306         // Fields for WP Jquery Lightbox Settings.
    307         foreach ( self::$jqlb_options as $key => $setting ) {
    308             $id    = $setting['id'];
    309             $title = $setting['title'] ?? '';
    310             add_settings_field(
    311                 $id, // Setting ID.
    312                 $title, // Setting label.
    313                 array( __CLASS__, 'render_settings_fields' ), // Setting callback.
    314                 'lightpress-settings', // Page ID.
    315                 'wp-jquery-lightbox-settings-section', // Section ID.
    316                 $setting
    317             );
    318         }
    319221    }
    320222
     
    497399        $should_load_js =
    498400            'dashboard' === $screen->id ||
    499             self::$screen_id === $screen->id ||
     401            self::$settings_screen_id === $screen->id ||
    500402            self::$pro_screen_id === $screen->id;
    501403
     
    521423
    522424    /**
    523      * Enqueues JavaScript for the LightPress plugin.
    524      */
    525     public function enqueue_js() {
    526         $enqueue_in_footer = get_option( 'jqlb_enqueue_in_footer' ) ? true : false;
    527         $version           = defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : LIGHTPRESS_VERSION;
    528 
    529         wp_enqueue_script( 'jquery' );
    530         wp_enqueue_script(
    531             'wp-jquery-lightbox-swipe',
    532             LIGHTPRESS_PLUGIN_URL . 'jquery.touchwipe.min.js',
    533             array( 'jquery' ),
    534             $version,
    535             $enqueue_in_footer
    536         );
    537         wp_enqueue_script(
    538             'wp-jquery-lightbox-purify',
    539             LIGHTPRESS_PLUGIN_URL . 'inc/purify.min.js',
    540             array(),
    541             $version,
    542             $enqueue_in_footer
    543         );
    544         if ( get_option( 'jqlb_pinchzoom' ) === '1' ) {
    545             wp_enqueue_script(
    546                 'wp-jquery-lightbox-panzoom',
    547                 plugins_url( 'panzoom.min.js', __FILE__ ),
    548                 array( 'jquery' ),
    549                 $version,
    550                 $enqueue_in_footer
    551             );
    552             wp_enqueue_script(
    553                 'wp-jquery-lightbox',
    554                 plugins_url( 'jquery.lightbox.js', __FILE__ ),
    555                 array( 'jquery', 'wp-jquery-lightbox-panzoom' ),
    556                 $version,
    557                 $enqueue_in_footer
    558             );
    559         } else {
    560             wp_enqueue_script(
    561                 'wp-jquery-lightbox',
    562                 plugins_url( 'jquery.lightbox.js', __FILE__ ),
    563                 array( 'jquery' ),
    564                 $version,
    565                 $enqueue_in_footer
    566             );
    567         }
    568 
    569         wp_localize_script(
    570             'wp-jquery-lightbox',
    571             'JQLBSettings',
    572             array(
    573                 'showTitle'        => get_option( 'jqlb_showTitle' ),
    574                 'useAltForTitle'   => get_option( 'jqlb_useAltForTitle' ),
    575                 'showCaption'      => get_option( 'jqlb_showCaption' ),
    576                 'showNumbers'      => get_option( 'jqlb_showNumbers' ),
    577                 'fitToScreen'      => get_option( 'jqlb_resize_on_demand' ),
    578                 'resizeSpeed'      => get_option( 'jqlb_resize_speed' ),
    579                 'showDownload'     => get_option( 'jqlb_showDownload' ),
    580                 'navbarOnTop'      => get_option( 'jqlb_navbarOnTop' ),
    581                 'marginSize'       => get_option( 'jqlb_margin_size' ),
    582                 'mobileMarginSize' => get_option( 'jqlb_mobile_margin_size' ),
    583                 'slideshowSpeed'   => get_option( 'jqlb_slideshow_speed' ),
    584                 'allowPinchZoom'   => get_option( 'jqlb_pinchzoom' ),
    585                 'borderSize'       => get_option( 'jqlb_borderSize' ),
    586                 'borderColor'      => get_option( 'jqlb_borderColor' ),
    587                 'overlayColor'     => get_option( 'jqlb_overlayColor' ),
    588                 'overlayOpacity'   => get_option( 'jqlb_overlayOpacity' ),
    589                 'newNavStyle'      => get_option( 'jqlb_newNavStyle' ),
    590                 'fixedNav'         => get_option( 'jqlb_fixedNav' ),
    591                 'showInfoBar'      => get_option( 'jqlb_showInfoBar' ),
    592                 'prevLinkTitle'    => __( 'previous image', 'wp-jquery-lightbox' ),
    593                 'nextLinkTitle'    => __( 'next image', 'wp-jquery-lightbox' ),
    594                 'closeTitle'       => __( 'close image gallery', 'wp-jquery-lightbox' ),
    595                 'image'            => __( 'Image ', 'wp-jquery-lightbox' ),
    596                 'of'               => __( ' of ', 'wp-jquery-lightbox' ),
    597                 'download'         => __( 'Download', 'wp-jquery-lightbox' ),
    598                 'pause'            => __( '(Pause Slideshow)', 'wp-jquery-lightbox' ),
    599                 'play'             => __( '(Play Slideshow)', 'wp-jquery-lightbox' ),
    600             )
    601         );
    602     }
    603 
    604     /**
    605      * Enqueues CSS for the LightPress plugin.
    606      */
    607     public function enqueue_css() {
    608         $locale         = $this->get_locale();
    609         $file_name      = "lightbox.min.{$locale}.css";
    610         $have_theme_css = false;
    611 
    612         if ( get_option( 'jqlb_use_theme_styles' ) === 1 ) {
    613             $path_theme     = get_stylesheet_directory() . "/{$file_name}";
    614             $have_theme_css = is_readable( $path_theme );
    615             if ( ! $have_theme_css ) {
    616                 $file_name      = 'lightbox.min.css';
    617                 $path_theme     = get_stylesheet_directory() . "/{$file_name}";
    618                 $have_theme_css = is_readable( $path_theme );
    619             }
    620         }
    621 
    622         if ( ! $have_theme_css ) {
    623             $path = plugin_dir_path( __FILE__ ) . "styles/{$file_name}";
    624             if ( ! is_readable( $path ) ) {
    625                 $file_name = 'lightbox.min.css';
    626             }
    627         }
    628         $uri = ( $have_theme_css )
    629             ? get_stylesheet_directory_uri() . '/' . $file_name
    630             : LIGHTPRESS_PLUGIN_URL . 'styles/' . $file_name;
    631 
    632         wp_enqueue_style(
    633             'jquery.lightbox.min.css',
    634             $uri,
    635             false,
    636             defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : LIGHTPRESS_VERSION
    637         );
    638         wp_enqueue_style(
    639             'jqlb-overrides',
    640             plugin_dir_url( __FILE__ ) . 'styles/overrides.css',
    641             false,
    642             defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : LIGHTPRESS_VERSION
    643         );
    644 
    645         // Add inline styles for new nav arrow styling.
    646         // Needed to apply styles to :before pseudo-selectors.
    647         $nav_arrow_color      = get_option( 'jqlb_navArrowColor' );
    648         $nav_background_color = get_option( 'jqlb_navBackgroundColor' );
    649         $border_width         = get_option( 'jqlb_borderSize' );
    650         $has_box_shadow       = get_option( 'jqlb_boxShadow' );
    651         $has_info_bar         = get_option( 'jqlb_showInfoBar' );
    652         $image_box_shadow     = $has_box_shadow ? '0 0 4px 2px rgba(0,0,0,.2)' : '';
    653         $infobar_box_shadow   = ( $has_box_shadow && $has_info_bar )
    654             ? '0 -4px 0 0 #fff, 0 0 4px 2px rgba(0,0,0,.1);'
    655             : '';
    656         $custom_css           = "
    657             #outerImageContainer {
    658                 box-shadow: {$image_box_shadow};
    659             }
    660             #imageContainer{
    661                 padding: {$border_width}px;
    662             }
    663             #imageDataContainer {
    664                 box-shadow: {$infobar_box_shadow};
    665             }
    666             #prevArrow,
    667             #nextArrow{
    668                 background-color: {$nav_background_color};
    669                 color: {$nav_arrow_color};
    670             }";
    671         wp_add_inline_style( 'jqlb-overrides', $custom_css );
    672     }
    673 
    674     /**
    675      * Gets the locale for the LightPress plugin.
    676      *
    677      * @return string The locale.
    678      */
    679     public function get_locale() {
    680         global $lang_locales;
    681         if ( defined( 'ICL_LANGUAGE_CODE' ) && isset( $lang_locales[ ICL_LANGUAGE_CODE ] ) ) {
    682             $locale = $lang_locales[ ICL_LANGUAGE_CODE ];
    683         } else {
    684             $locale = get_locale();
    685         }
    686         return $locale;
    687     }
    688 
    689     /**
    690      * Filters the content for the LightPress plugin.
    691      *
    692      * @param string $content The content to filter.
    693      * @return string The filtered content.
    694      */
    695     public function filter_content( $content ) {
    696         if ( get_option( 'jqlb_automate' ) === '1' ) {
    697             global $post;
    698             $id      = isset( $post->ID ) ? $post->ID : -1;
    699             $content = $this->do_regexp( $content, $id );
    700         }
    701         return $content;
    702     }
    703 
    704     /**
    705      * Performs a regular expression operation.
    706      *
    707      * @param string $content The content to perform the operation on.
    708      * @param int    $id Post id.
    709      * @return string The result of the operation.
    710      */
    711     public function do_regexp( $content, $id ) {
    712         $id          = esc_attr( $id );
    713         $content     = preg_replace( '/\s+rel="attachment wp-att-[0-9]+"/i', '', $content ); // Remove WP 4.4 garbage.
    714         $pattern     = "/(<a(?![^>]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png|webp)(\?\S{0,}){0,1}['\"][^\>]*)>/i";
    715         $replacement = '$1 rel="lightbox[' . $id . ']">';
    716         return preg_replace( $pattern, $replacement, $content );
    717     }
    718 
    719     /**
    720      * Determines whether to add filter for grouping images in a gallery.
    721      *
    722      * Runs on the post_gallery filter.
    723      *
    724      * @param string $html Content to filter.
    725      * @param array  $attr Array of attributes.
    726      * @return string
    727      */
    728     public function filter_groups( $html, $attr ) {
    729         if ( empty( $attr['group'] ) ) {
    730             $this->lightbox_group = -1;
    731             remove_filter( 'wp_get_attachment_link', array( $this, 'lightbox_gallery_links' ), 10, 1 );
    732         } else {
    733             $this->lightbox_group = $attr['group'];
    734             add_filter( 'wp_get_attachment_link', array( $this, 'lightbox_gallery_links' ), 10, 1 );
    735         }
    736         return '';
    737     }
    738 
    739     /**
    740      * Modifies gallery links to use lightbox, honoring custom group attributes.
    741      *
    742      * @param  string $html Content to filter.
    743      * @return string $html
    744      */
    745     public function lightbox_gallery_links( $html ) {
    746         // No grouping.
    747         if ( ! isset( $this->lightbox_group ) || -1 === $this->lightbox_group ) {
    748             return $html;
    749         }
    750 
    751         // Grouping.
    752         return str_replace( '<a', '<a rel="lightbox[' . $this->lightbox_group . ']"', $html );
    753     }
    754 
    755     /**
    756425     * Add date time stampe when plugin activated
    757426     */
  • wp-jquery-lightbox/trunk/readme.txt

    r3104196 r3104692  
    1 === LightPress Lightbox ===
     1=== LightPress Lightbox (WP JQuery Lightbox) ===
    22Contributors: pandaboxwp
    33Tags: lightbox, photo, image, gallery
    44Requires at least: 5.0
    55Tested up to: 6.5.4
    6 Stable tag: 2.0.0
     6Stable tag: 2.1.0
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    1212== Description ==
    1313
    14 A simple, lightweight WordPress lightbox plugin. [See demo here](https://lightpress.io).
     14The LightPress Lightbox was formerly the WP JQuery Lightbox. Along with the name change, we'll be doing signficant development on this plugin in 2024, including the addition of additional, modern lightboxes (both free and pro). We'll still continue to include, support, and enhance the original lightbox!
     15
     16This plugin adds a simple, lightweight lightbox for viewing images. [See demos here](https://lightpress.io).
    1517
    1618**Features**
     
    3133Special thanks to [Ulf Benjaminsson](http://www.ulfbenjaminsson.com), who created this plugin and maintained it for many years.
    3234
    33 This plugin lets you keep [Lightbox 2](http://www.huddletogether.com/projects/lightbox2/) functionality but sheds the bulk of the Prototype Framework and Scriptaculous Effects Library. Warren Krewenki [ported Lightbox to jQuery](http://warren.mesozen.com/jquery-lightbox/) and this plugin is mostly a wrapper to his work.
     35The original WP JQuery Lightbox included with this plugin lets you keep [Lightbox 2](http://www.huddletogether.com/projects/lightbox2/) functionality but sheds the bulk of the Prototype Framework and Scriptaculous Effects Library. Warren Krewenki [ported Lightbox to jQuery](http://warren.mesozen.com/jquery-lightbox/) and this plugin is mostly a wrapper to his work.
    3436
    3537== Screenshots ==
     
    113115== Changelog ==
    114116
    115 = 2.0.0 (2024-06-19) =
     117= 2.1.0 (2024-06-19) =
     118* Major file reorganization
     119* Fix image inserting not working in classic editor
     120* Update plugin banner and icon
     121
     122= 2.0.0 (2024-06-18) =
    116123* Rename plugin to LightPress
    117124* Add core LightPress plugin class
  • wp-jquery-lightbox/trunk/wp-jquery-lightbox.php

    r3104196 r3104692  
    44 * Plugin URI: http://wordpress.org/extend/plugins/wp-jquery-lightbox/
    55 * Description: Simple and lightweight lightbox for galleries and images. Formerly WP Jquery Lightbox.
    6  * Version: 2.0.0
     6 * Version: 2.1.0
    77 * Text Domain: wp-jquery-lightbox
    88 * Author: LightPress
     
    2323 * Define constants.
    2424 */
    25 define( 'LIGHTPRESS_VERSION', '2.0.0' );
     25define( 'LIGHTPRESS_VERSION', '2.1.0' );
    2626define( 'LIGHTPRESS_PLUGIN_BASE', plugin_basename( __FILE__ ) );
    2727define( 'LIGHTPRESS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); // Includes ending slash.
     
    2929
    3030if ( defined( 'JQLB_LEGACY' ) && true === JQLB_LEGACY ) {
    31     require_once LIGHTPRESS_PLUGIN_DIR . 'wp-jquery-lightbox-legacy.php';
     31    require_once LIGHTPRESS_PLUGIN_DIR . 'lightboxes/wp-jquery-lightbox/wp-jquery-lightbox-legacy.php';
    3232} else {
    3333    require_once LIGHTPRESS_PLUGIN_DIR . 'class-lightpress.php';
Note: See TracChangeset for help on using the changeset viewer.