PluginProbe
Remove Broken Images / trunk
Remove Broken Images vtrunk
trunk 1.1.0 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2-beta-1 1.5.0 1.5.1
remove-broken-images / remove-broken-images.php

remove-broken-images.php in Remove Broken Images trunk, at remove-broken-images.php

112 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Remove Broken Images
4 Plugin URI: https://room34.com
5 Description: Very simply, uses JavaScript to remove broken images from page display.
6 Version: 1.5.1
7 Author: Room 34 Creative Services, LLC
8 Author URI: http://room34.com
9 License: GPLv2
10 Text Domain: remove-broken-images
11 Domain Path: /i18n/languages/
12 */
13
14 /* Copyright 2024 Room 34 Creative Services, LLC (email: info@room34.com)
15
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License, version 2, as
18 published by the Free Software Foundation.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30 // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment
31
32
33 // Don't load directly
34 if (!defined('ABSPATH')) { exit; }
35
36
37 // Load required files
38 //require_once(plugin_dir_path(__FILE__) . 'functions.php');
39 require_once(plugin_dir_path(__FILE__) . 'class-r34rbi.php');
40
41
42 // Initialize plugin functionality
43 function r34rbi_plugins_loaded() {
44
45 // Instantiate class
46 global $r34rbi;
47 $r34rbi = new R34RBI();
48
49 // Conditionally run update function
50 if (is_admin() && version_compare(get_option('r34rbi_version'), $r34rbi->version, '<')) { r34rbi_update(); }
51
52 }
53 add_action('plugins_loaded', 'r34rbi_plugins_loaded');
54
55
56 // Install
57 function r34rbi_install() {
58 global $r34rbi;
59
60 // Flush rewrite rules
61 flush_rewrite_rules();
62
63 // Remember previous version
64 $previous_version = get_option('r34rbi_version');
65 update_option('r34rbi_previous_version', $previous_version);
66
67 // Set version
68 if (isset($r34rbi->version)) {
69 update_option('r34rbi_version', $r34rbi->version);
70 }
71
72 // Admin notice with link to settings
73 $notices = get_option('r34rbi_deferred_admin_notices', array());
74 $notices[] = array(
75 'content' => '<p>' . sprintf(__('Thank you for installing %1$sRemove Broken Images%2$s. To get started, please visit the %3$sSettings%4$s page.', 'remove-broken-images'), '<strong>', '</strong>', '<a href="' . admin_url('options-general.php?page=remove-broken-images') . '"><strong>', '</strong></a>') . '</p>',
76 'status' => 'info'
77 );
78 update_option('r34rbi_deferred_admin_notices', $notices);
79
80 }
81 register_activation_hook(__FILE__, 'r34rbi_install');
82
83
84 // Updates
85 function r34rbi_update() {
86 global $r34rbi;
87
88 // Remember previous version
89 $previous_version = get_option('r34rbi_version');
90 update_option('r34rbi_previous_version', $previous_version);
91
92 // Update version
93 if (isset($r34rbi->version)) {
94 update_option('r34rbi_version', $r34rbi->version);
95 }
96
97 // Version-specific updates
98
99 }
100
101
102 // Deferred install/update admin notices
103 function r34rbi_deferred_admin_notices() {
104 if ($notices = get_option('r34rbi_deferred_admin_notices', array())) {
105 foreach ((array)$notices as $notice) {
106 echo '<div class="notice notice-' . esc_attr($notice['status']) . ' is-dismissible r34rbi-admin-notice">' . wp_kses_post($notice['content']) . '</div>';
107 }
108 }
109 delete_option('r34rbi_deferred_admin_notices');
110 }
111 add_action('admin_notices', 'r34rbi_deferred_admin_notices');
112