Plugin Directory

Changeset 3206765


Ignore:
Timestamp:
12/12/2024 07:28:13 AM (16 months ago)
Author:
biltatous
Message:

Updated trunk with latest code for version 1.3.0, including new features and fixes.

Location:
gallery-5cript/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • gallery-5cript/trunk/gallery_5cript.php

    r3206515 r3206765  
    55 * Plugin URI:        https://gallery.5cript.com/
    66 * Description:       Create a frontend gallery utilizing the fully cross-browser supported <dialog> HTML element, which offers enhanced accessibility and SEO benefits. Additionally, it incorporates the <picture> HTML element to support responsive images, ensuring optimal image sizes based on your website's configuration. This approach minimizes network redundancies by adapting to the device's viewport. The gallery is built using Tailwind CSS and TypeScript, with a simple shortcode for easy implementation.
    7  * Version:           1.2.1
     7 * Version:           1.3.0
    88 * Requires at least: 6.6.0
    99 * Requires PHP:      8.0
     
    116116    public function enqueue_frontend_styles()
    117117    {
     118        // Check if the front-end script is disabled
     119        $disable_script = get_option('gallery_5cript_disable_frontend_script', 0);
     120        if ($disable_script) {
     121            return;
     122        }
    118123        wp_register_style('gallery_5cript_output_css', GALLERY_5CRIPT_URL . 'output.css', [], $this->plugin_data["Version"]);
    119124        wp_enqueue_style('gallery_5cript_output_css');
     
    124129    public function enqueue_frontend_scripts()
    125130    {
     131        // Check if the front-end script is disabled
     132        $disable_script = get_option('gallery_5cript_disable_frontend_script', 0);
     133        if ($disable_script) {
     134            return;
     135        }
    126136        wp_enqueue_script('front_gallery_5cript_js', GALLERY_5CRIPT_URL . 'front/js/front.js', [], $this->plugin_data["Version"], true);
    127137    }
     
    464474        register_setting('gallery_5cript_settings_group', 'gallery_5cript_delete_data_on_uninstall');
    465475        register_setting('gallery_5cript_settings_group', 'gallery_5cript_api_enabled');
     476        register_setting('gallery_5cript_settings_group', 'gallery_5cript_disable_frontend_script');
    466477
    467478        add_settings_section(
     
    487498            'gallery_5cript_settings_section'
    488499        );
     500
     501        add_settings_field(
     502            'gallery_5cript_disable_frontend_script',
     503            'Disable Frontend Script',
     504            [$this, 'disable_frontend_script_callback'],
     505            'gallery_5cript_settings',
     506            'gallery_5cript_settings_section'
     507        );
    489508    }
    490509
     
    508527        echo '<label for="gallery_5cript_api_enabled"> Check this box to enable the Gallery 5cript API.</label>';
    509528    }
     529
     530    /**
     531     * Callback for the disable frontend script field.
     532     */
     533    public function disable_frontend_script_callback()
     534    {
     535        $value = get_option('gallery_5cript_disable_frontend_script', 0);
     536        echo '<input type="checkbox" id="gallery_5cript_disable_frontend_script" name="gallery_5cript_disable_frontend_script" value="1"' . checked(1, $value, false) . ' />';
     537        echo '<label for="gallery_5cript_disable_frontend_script"> Check this box to disable the front-end scripts and styles.</label>';
     538    }
    510539}
     540
     541
    511542new Gallery_5cript_Plugin();
    512543new Gallery_5cript_Settings();
  • gallery-5cript/trunk/helper.php

    r3206419 r3206765  
    5959        $wpdb->flush();
    6060        return $query;
     61    }
     62        /**
     63     * Retrieve an alternative field for an image based on its ID.
     64     *
     65     * @param int $image_id The ID of the image.
     66     * @return string|null The alternative field value, or null if not found.
     67     */
     68    public static function get_image_alternative_field($image_id) {
     69        global $wpdb;
     70        $table_postmeta = $wpdb->prefix . 'postmeta';
     71
     72        // Query to fetch the alternative field for the given image ID.
     73        $query = $wpdb->get_var(
     74            $wpdb->prepare(
     75                "SELECT meta_value
     76                 FROM $table_postmeta
     77                 WHERE post_id = %d AND meta_key = '_wp_attachment_image_alt'",
     78                $image_id
     79            )
     80        );
     81
     82        return $query ? $query : null;
    6183    }
    6284    /**
     
    81103        foreach ($query as $item) {
    82104            $url = wp_get_attachment_image_url($item["media_id"], 'thumbnail');
     105            $alt_field = self::get_image_alternative_field($item["media_id"]);
    83106            array_push(
    84107                $objects, [
    85108                    'id' => $item["id"],
    86                     'order' => $item["order"], 'url' => $url,
     109                    'order' => $item["order"],
     110                    'url' => $url,
    87111                    'media_id' => $item['media_id'],
    88112                    'caption' => $item['caption'],
    89                     'video_id' => $item['video_id']
     113                    'video_id' => $item['video_id'],
     114                    'alt' => $alt_field
    90115                    ]
    91116            );
  • gallery-5cript/trunk/readme.txt

    r3206515 r3206765  
    55Requires at least: 6.0
    66Tested up to: 6.7.1
    7 Stable tag: 1.2.1
     7Stable tag: 1.3.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7373    - It has its own database tables, so it doesn't add extra load to the already heavily used post and meta tables. This also ensures that you can delete it without leaving any residue.
    7474    - New: API
     75
     76
    7577   
    7678== Installation ==
     
    103105== Changelog ==
    104106
     107= 1.3.0 =
     108* Added plugin settings to disable front end scripts and styles. By default it's disabled.
     109
    105110= 1.2.0 =
    106111* Added API endpoints to facilitate gallery management for decoupled applications. Available through plugin settings.
Note: See TracChangeset for help on using the changeset viewer.