plugin_name = $plugin_name; $this->version = $version; } public function enqueue_styles() { wp_enqueue_style( $this->plugin_name, plugin_dir_url(__FILE__) . 'css/gallery-admin.css', array(), $this->version, 'all' ); // Add Dashicons for feature icons wp_enqueue_style('dashicons'); } public function enqueue_scripts() { wp_enqueue_media(); wp_enqueue_script( $this->plugin_name, plugin_dir_url(__FILE__) . 'js/gallery-admin.js', array('jquery'), $this->version, false ); } public function add_admin_menu() { add_management_page( 'Advanced Gallery Fields Settings', 'Advanced Gallery Fields', 'manage_options', 'advanced-gallery-fields', array($this, 'display_settings_page') ); } public function register_settings() { register_setting( 'advanced_gallery_settings', 'advanced_gallery_post_types', array( 'type' => 'array', 'sanitize_callback' => array($this, 'sanitize_post_types'), ) ); } /** * Sanitize the post types array * * @param array $input Array of post types to sanitize * @return array Sanitized array of post types */ public function sanitize_post_types($input) { if (!is_array($input)) { return array('post'); } return array_map('sanitize_key', $input); } public function display_settings_page() { $post_types = get_post_types(['public' => true], 'objects'); $saved_post_types = get_option('advanced_gallery_post_types', ['post']); ?>

Enhance your content with beautiful, customizable galleries

Enable Gallery Fields

Select which post types should have the custom gallery field available. The gallery field will appear in the editor for the selected post types.

Support the Development

If you find this plugin useful, consider supporting its development. Your support helps maintain and improve the plugin with new features and updates!

Buy me a coffee

Need Help?

Check out the plugin documentation or support forums for assistance. If you cannot find what you're looking for, please send an email.

Check Out My Other Plugins

Love Spotify? Try Spotiembed, my plugin that lets you easily embed Spotify content in your WordPress posts and pages.

View Spotiembed Plugin
ID, '_advanced_gallery', true); $gallery_ids = $this->sanitize_gallery_ids($gallery_ids); ?> sanitize_gallery_ids(sanitize_text_field(wp_unslash($_POST['gallery_data']))); if ($gallery_data !== false) { update_post_meta($post_id, '_advanced_gallery', $gallery_data); } } } /** * Sanitize and validate gallery IDs * * @param string $gallery_ids Comma-separated list of gallery image IDs * @return string|false Sanitized comma-separated list of gallery image IDs, or false on error */ private function sanitize_gallery_ids($gallery_ids) { if (empty($gallery_ids)) { return ''; } // Basic input validation if (!is_string($gallery_ids)) { return false; } // Convert to array and ensure all values are numeric $ids_array = array_filter( explode(',', $gallery_ids), function($value) { return is_numeric(trim($value)); } ); if (empty($ids_array)) { return false; } // Convert all IDs to positive integers and remove duplicates $ids_array = array_unique(array_map('absint', $ids_array)); // Filter out any invalid attachment IDs $valid_ids = array_filter($ids_array, array($this, 'is_valid_attachment')); if (empty($valid_ids)) { return false; } return implode(',', $valid_ids); } /** * Validate if an ID represents a valid attachment * * @param int $attachment_id The attachment ID to validate * @return bool Whether the attachment ID is valid */ private function is_valid_attachment($attachment_id) { $attachment = get_post($attachment_id); return !empty($attachment) && $attachment->post_type === 'attachment'; } }