From b7a5eefa7d16e7c84733e966a533cc48385c3523 Mon Sep 17 00:00:00 2001 From: Jonas Date: Thu, 22 Jan 2026 00:21:35 +0100 Subject: [PATCH] feat: update plugin metadata, localize description to German, and apply minor code formatting adjustments --- .DS_Store | Bin 6148 -> 6148 bytes instagram-gallery-sync-pro.php | 304 +++++++++++++++++---------------- 2 files changed, 161 insertions(+), 143 deletions(-) diff --git a/.DS_Store b/.DS_Store index 886eee568c65c13a772b04ec730fb56f8b78a0a2..7cfe88d2fdb253bb119dd9a3ddb223bc674d4891 100644 GIT binary patch delta 106 zcmZoMXffEJ#uEGZBLf2i3xgg*IzuKyNp8N2OHxjL5>Sj|>+!g|rzRYCM3qm$D_@Xd V7@VA+TL9Fs delta 106 zcmZoMXffEJ#u9r^f`Ng7g+Y%YogtHl`qIJ V3{K9^Edc6aU|?g|+|1G_3;prefix . 'instagram_gallery_posts' ); -define( 'IGSP_TABLE_LOG', $wpdb->prefix . 'instagram_gallery_log' ); +define('IGSP_TABLE_POSTS', $wpdb->prefix . 'instagram_gallery_posts'); +define('IGSP_TABLE_LOG', $wpdb->prefix . 'instagram_gallery_log'); /** * Autoloader for plugin classes */ -spl_autoload_register( function( $class ) { +spl_autoload_register(function ($class) { // Check if the class uses our namespace prefix $prefix = 'IGSP_'; - - if ( strpos( $class, $prefix ) !== 0 ) { + + if (strpos($class, $prefix) !== 0) { return; } - + // Convert class name to file name - $class_name = str_replace( $prefix, '', $class ); - $class_name = strtolower( str_replace( '_', '-', $class_name ) ); + $class_name = str_replace($prefix, '', $class); + $class_name = strtolower(str_replace('_', '-', $class_name)); $file = IGSP_PLUGIN_DIR . 'includes/class-' . $class_name . '.php'; - - if ( file_exists( $file ) ) { + + if (file_exists($file)) { require_once $file; } }); @@ -60,15 +60,16 @@ spl_autoload_register( function( $class ) { /** * Main Plugin Class */ -final class Instagram_Gallery_Sync_Pro { - +final class Instagram_Gallery_Sync_Pro +{ + /** * Plugin instance * * @var Instagram_Gallery_Sync_Pro */ private static $instance = null; - + /** * Plugin components */ @@ -80,260 +81,274 @@ final class Instagram_Gallery_Sync_Pro { public $admin; public $shortcode; public $gutenberg; - + /** * Get plugin instance * * @return Instagram_Gallery_Sync_Pro */ - public static function get_instance() { - if ( null === self::$instance ) { + public static function get_instance() + { + if (null === self::$instance) { self::$instance = new self(); } return self::$instance; } - + /** * Constructor */ - private function __construct() { + private function __construct() + { $this->init_hooks(); } - + /** * Initialize hooks */ - private function init_hooks() { + private function init_hooks() + { // Activation and deactivation hooks - register_activation_hook( IGSP_PLUGIN_FILE, array( $this, 'activate' ) ); - register_deactivation_hook( IGSP_PLUGIN_FILE, array( $this, 'deactivate' ) ); - + register_activation_hook(IGSP_PLUGIN_FILE, array($this, 'activate')); + register_deactivation_hook(IGSP_PLUGIN_FILE, array($this, 'deactivate')); + // Initialize plugin after WordPress is loaded - add_action( 'plugins_loaded', array( $this, 'init_plugin' ) ); - + add_action('plugins_loaded', array($this, 'init_plugin')); + // Load text domain - add_action( 'init', array( $this, 'load_textdomain' ) ); + add_action('init', array($this, 'load_textdomain')); } - + /** * Plugin activation */ - public function activate() { + public function activate() + { // Ensure components are loaded $this->load_components(); - + // Create database tables $this->database->create_tables(); - + // Create upload directory $this->create_upload_directory(); - + // Set default options $this->set_default_options(); - + // Schedule cron if enabled $this->cron->schedule_sync(); - + // Log activation - $this->logger->log( 'info', __( 'Plugin activated successfully.', 'instagram-gallery-sync-pro' ) ); - + $this->logger->log('info', __('Plugin activated successfully.', 'instagram-gallery-sync-pro')); + // Flush rewrite rules flush_rewrite_rules(); } - + /** * Plugin deactivation */ - public function deactivate() { + public function deactivate() + { // Clear scheduled cron $this->cron->unschedule_sync(); - + // Clear transients $this->clear_transients(); - + // Log deactivation - $this->logger->log( 'info', __( 'Plugin deactivated.', 'instagram-gallery-sync-pro' ) ); - + $this->logger->log('info', __('Plugin deactivated.', 'instagram-gallery-sync-pro')); + // Flush rewrite rules flush_rewrite_rules(); } - + /** * Initialize plugin components */ - public function init_plugin() { + public function init_plugin() + { $this->load_components(); $this->init_components(); } - + /** * Load plugin components */ - private function load_components() { + private function load_components() + { // Core components - $this->database = new IGSP_Database(); - $this->logger = new IGSP_Logger(); + $this->database = new IGSP_Database(); + $this->logger = new IGSP_Logger(); $this->image_handler = new IGSP_Image_Handler(); - $this->scraper = new IGSP_Scraper(); - $this->cron = new IGSP_Cron(); - + $this->scraper = new IGSP_Scraper(); + $this->cron = new IGSP_Cron(); + // Frontend components $this->shortcode = new IGSP_Shortcode(); $this->gutenberg = new IGSP_Gutenberg_Block(); - + // Admin components (only in admin) - if ( is_admin() ) { + if (is_admin()) { $this->admin = new IGSP_Admin(); } } - + /** * Initialize components */ - private function init_components() { + private function init_components() + { $this->shortcode->init(); $this->gutenberg->init(); $this->cron->init(); - - if ( is_admin() && $this->admin ) { + + if (is_admin() && $this->admin) { $this->admin->init(); } } - + /** * Load plugin text domain */ - public function load_textdomain() { + public function load_textdomain() + { load_plugin_textdomain( 'instagram-gallery-sync-pro', false, - dirname( IGSP_PLUGIN_BASENAME ) . '/languages' + dirname(IGSP_PLUGIN_BASENAME) . '/languages' ); } - + /** * Create upload directory */ - private function create_upload_directory() { + private function create_upload_directory() + { $upload_dir = wp_upload_dir(); $instagram_dir = $upload_dir['basedir'] . '/' . IGSP_UPLOAD_DIR; - - if ( ! file_exists( $instagram_dir ) ) { - wp_mkdir_p( $instagram_dir ); - + + if (!file_exists($instagram_dir)) { + wp_mkdir_p($instagram_dir); + // Create index.php for security - file_put_contents( $instagram_dir . '/index.php', '\n"; $htaccess .= "deny from all\n"; $htaccess .= "\n"; - file_put_contents( $instagram_dir . '/.htaccess', $htaccess ); + file_put_contents($instagram_dir . '/.htaccess', $htaccess); } - + // Create thumbnails subfolder $thumb_dir = $instagram_dir . '/thumbnails'; - if ( ! file_exists( $thumb_dir ) ) { - wp_mkdir_p( $thumb_dir ); - file_put_contents( $thumb_dir . '/index.php', ' '', - 'igsp_max_images' => 12, - 'igsp_save_locally' => 'yes', - 'igsp_image_quality' => 'high', - 'igsp_sync_interval' => 'daily', - 'igsp_last_sync' => '', - + 'igsp_username' => '', + 'igsp_max_images' => 12, + 'igsp_save_locally' => 'yes', + 'igsp_image_quality' => 'high', + 'igsp_sync_interval' => 'daily', + 'igsp_last_sync' => '', + // Layout settings - 'igsp_layout_type' => 'grid', - 'igsp_columns_desktop' => 3, - 'igsp_columns_tablet' => 2, - 'igsp_columns_mobile' => 1, - 'igsp_spacing' => 10, - 'igsp_padding' => 0, - 'igsp_aspect_ratio' => 'square', - 'igsp_object_fit' => 'cover', - 'igsp_border_radius' => 0, - 'igsp_hover_effect' => 'zoom', - + 'igsp_layout_type' => 'grid', + 'igsp_columns_desktop' => 3, + 'igsp_columns_tablet' => 2, + 'igsp_columns_mobile' => 1, + 'igsp_spacing' => 10, + 'igsp_padding' => 0, + 'igsp_aspect_ratio' => 'square', + 'igsp_object_fit' => 'cover', + 'igsp_border_radius' => 0, + 'igsp_hover_effect' => 'zoom', + // Display settings - 'igsp_display_limit' => 12, - 'igsp_order' => 'newest', - 'igsp_show_caption' => 'no', - 'igsp_caption_position' => 'overlay', + 'igsp_display_limit' => 12, + 'igsp_order' => 'newest', + 'igsp_show_caption' => 'no', + 'igsp_caption_position' => 'overlay', 'igsp_show_instagram_btn' => 'yes', - 'igsp_link_behavior' => 'new_tab', - 'igsp_lightbox' => 'yes', - 'igsp_lazy_loading' => 'yes', - 'igsp_loader_type' => 'spinner', - + 'igsp_link_behavior' => 'new_tab', + 'igsp_lightbox' => 'yes', + 'igsp_lazy_loading' => 'yes', + 'igsp_loader_type' => 'spinner', + // Styling - 'igsp_primary_color' => '#e1306c', - 'igsp_hover_color' => '#c13584', - 'igsp_text_color' => '#ffffff', - 'igsp_caption_font_size' => 14, - 'igsp_custom_css' => '', - 'igsp_css_prefix' => 'igsp', - + 'igsp_primary_color' => '#e1306c', + 'igsp_hover_color' => '#c13584', + 'igsp_text_color' => '#ffffff', + 'igsp_caption_font_size' => 14, + 'igsp_custom_css' => '', + 'igsp_css_prefix' => 'igsp', + // Advanced - 'igsp_debug_mode' => 'no', - 'igsp_cache_duration' => 3600, - 'igsp_request_timeout' => 30, - 'igsp_user_agent' => '', - 'igsp_proxy_host' => '', - 'igsp_proxy_port' => '', - 'igsp_auto_delete_days' => 0, + 'igsp_debug_mode' => 'no', + 'igsp_cache_duration' => 3600, + 'igsp_request_timeout' => 30, + 'igsp_user_agent' => '', + 'igsp_proxy_host' => '', + 'igsp_proxy_port' => '', + 'igsp_auto_delete_days' => 0, ); - - foreach ( $defaults as $key => $value ) { - if ( get_option( $key ) === false ) { - add_option( $key, $value ); + + foreach ($defaults as $key => $value) { + if (get_option($key) === false) { + add_option($key, $value); } } } - + /** * Clear all transients */ - public function clear_transients() { + public function clear_transients() + { global $wpdb; - + $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_igsp_%' OR option_name LIKE '_transient_timeout_igsp_%'" ); } - + /** * Get upload directory path * * @return string */ - public function get_upload_path() { + public function get_upload_path() + { $upload_dir = wp_upload_dir(); return $upload_dir['basedir'] . '/' . IGSP_UPLOAD_DIR; } - + /** * Get upload directory URL * * @return string */ - public function get_upload_url() { + public function get_upload_url() + { $upload_dir = wp_upload_dir(); return $upload_dir['baseurl'] . '/' . IGSP_UPLOAD_DIR; } - + /** * Get plugin settings * @@ -341,8 +356,9 @@ final class Instagram_Gallery_Sync_Pro { * @param mixed $default Default value * @return mixed */ - public function get_setting( $key, $default = '' ) { - return get_option( 'igsp_' . $key, $default ); + public function get_setting($key, $default = '') + { + return get_option('igsp_' . $key, $default); } } @@ -351,7 +367,8 @@ final class Instagram_Gallery_Sync_Pro { * * @return Instagram_Gallery_Sync_Pro */ -function igsp() { +function igsp() +{ return Instagram_Gallery_Sync_Pro::get_instance(); } @@ -361,8 +378,9 @@ function igsp() { * @param array $args Gallery arguments * @return void */ -function display_instagram_gallery( $args = array() ) { - echo igsp()->shortcode->render( $args ); +function display_instagram_gallery($args = array()) +{ + echo igsp()->shortcode->render($args); } // Initialize the plugin