Changeset 3206765
- Timestamp:
- 12/12/2024 07:28:13 AM (16 months ago)
- Location:
- gallery-5cript/trunk
- Files:
-
- 3 edited
-
gallery_5cript.php (modified) (6 diffs)
-
helper.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gallery-5cript/trunk/gallery_5cript.php
r3206515 r3206765 5 5 * Plugin URI: https://gallery.5cript.com/ 6 6 * 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.17 * Version: 1.3.0 8 8 * Requires at least: 6.6.0 9 9 * Requires PHP: 8.0 … … 116 116 public function enqueue_frontend_styles() 117 117 { 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 } 118 123 wp_register_style('gallery_5cript_output_css', GALLERY_5CRIPT_URL . 'output.css', [], $this->plugin_data["Version"]); 119 124 wp_enqueue_style('gallery_5cript_output_css'); … … 124 129 public function enqueue_frontend_scripts() 125 130 { 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 } 126 136 wp_enqueue_script('front_gallery_5cript_js', GALLERY_5CRIPT_URL . 'front/js/front.js', [], $this->plugin_data["Version"], true); 127 137 } … … 464 474 register_setting('gallery_5cript_settings_group', 'gallery_5cript_delete_data_on_uninstall'); 465 475 register_setting('gallery_5cript_settings_group', 'gallery_5cript_api_enabled'); 476 register_setting('gallery_5cript_settings_group', 'gallery_5cript_disable_frontend_script'); 466 477 467 478 add_settings_section( … … 487 498 'gallery_5cript_settings_section' 488 499 ); 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 ); 489 508 } 490 509 … … 508 527 echo '<label for="gallery_5cript_api_enabled"> Check this box to enable the Gallery 5cript API.</label>'; 509 528 } 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 } 510 539 } 540 541 511 542 new Gallery_5cript_Plugin(); 512 543 new Gallery_5cript_Settings(); -
gallery-5cript/trunk/helper.php
r3206419 r3206765 59 59 $wpdb->flush(); 60 60 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; 61 83 } 62 84 /** … … 81 103 foreach ($query as $item) { 82 104 $url = wp_get_attachment_image_url($item["media_id"], 'thumbnail'); 105 $alt_field = self::get_image_alternative_field($item["media_id"]); 83 106 array_push( 84 107 $objects, [ 85 108 'id' => $item["id"], 86 'order' => $item["order"], 'url' => $url, 109 'order' => $item["order"], 110 'url' => $url, 87 111 'media_id' => $item['media_id'], 88 112 'caption' => $item['caption'], 89 'video_id' => $item['video_id'] 113 'video_id' => $item['video_id'], 114 'alt' => $alt_field 90 115 ] 91 116 ); -
gallery-5cript/trunk/readme.txt
r3206515 r3206765 5 5 Requires at least: 6.0 6 6 Tested up to: 6.7.1 7 Stable tag: 1. 2.17 Stable tag: 1.3.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 73 73 - 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. 74 74 - New: API 75 76 75 77 76 78 == Installation == … … 103 105 == Changelog == 104 106 107 = 1.3.0 = 108 * Added plugin settings to disable front end scripts and styles. By default it's disabled. 109 105 110 = 1.2.0 = 106 111 * Added API endpoints to facilitate gallery management for decoupled applications. Available through plugin settings.
Note: See TracChangeset
for help on using the changeset viewer.