PluginProbe
Accessibility / trunk
Accessibility vtrunk
trunk 1.0 1.0.1 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
← All changes | accessibility.php +332 -250 1.0trunk View file →
@@ -1,250 +1,332 @@
1 -<?php
2 -/*
3 - * Accessibility: Wordpress Accessibility Plugin
4 - *
5 - * Plugin Name: Accessibility
6 - * Description: Accessibility Utility
7 - * Version: 1.0.0
8 - * Author: Octa Code
9 - * Author URI: http://magixite.com
10 - * Copyright: 2015 Octa Code
11 - * Last Update: 24/12/2015
12 - *
13 - * Domain Path: /languages/
14 - */
15 -
16 -if (!defined('ABSPATH')) {
17 - exit; // disable direct access
18 -}
19 -
20 -
21 -if (!class_exists('OcAccessibilityPlugin')) :
22 -
23 - /**
24 - * Register the plugin.
25 - *
26 - * Display the administration panel, insert JavaScript etc.
27 - */
28 - class OcAccessibilityPlugin {
29 -
30 - protected $loader;
31 - protected $version;
32 - protected $plugin_slug;
33 -
34 - /**
35 - * Constructor
36 - */
37 - public function __construct() {
38 - load_plugin_textdomain('accesibility', false, dirname(plugin_basename(__FILE__)) . '/languages');
39 - $this->version = '1.0.0';
40 - $this->plugin_slug = 'oc-accesibility';
41 -
42 - $this->define_constants();
43 - $this->setup_actions();
44 - $this->load_dependencies();
45 -
46 - add_action('admin_menu', array($this, 'accessibility_create_menu'));
47 - }
48 -
49 - /**
50 - * Hook WC Brands into WordPress
51 - */
52 - private function setup_actions() {
53 - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
54 - add_action('admin_enqueue_scripts', array($this, 'enqueue_adminscripts'));
55 - add_action('wp_footer', array($this, 'magixite_script'));
56 - }
57 -
58 - public function magixite_script() {
59 - if (get_option('oc-accessibility-status', 0) < 1) {
60 - echo '<script type="text/javascript" src="' . OCACCESSIBILITY_PLUGINURL . '/freeCode?oatk=w0rdpre55"></script>';
61 - }
62 - else {
63 - echo '<script type="text/javascript" src="' . OCACCESSIBILITY_PLUGINURL . '/license/lw?litk=' . get_option('oc-accessibility') . '"></script>';
64 - }
65 - $language_setting = "";
66 - if (get_option('oc-accessibility-language', "en_us") !== 'oc_system') {
67 - $language_setting = "'language': '" . get_option('oc-accessibility-language', "en_us") . "'";
68 - }
69 - echo "<script type=\"text/javascript\">setTimeout(function(){octLoader({".$language_setting."})}, 1000);</script>";
70 - }
71 -
72 - // Styles Handling
73 - public function enqueue_styles() {
74 - }
75 -
76 - public function enqueue_adminscripts() {
77 - wp_enqueue_style('admin-style', OCACCESSIBILITY_ASSETS_URL . '/css/admin-style.css', array(), OCACCESSIBILITY_VERSION);
78 - }
79 -
80 - /**
81 - * Define Accessibilty constants
82 - */
83 - private function define_constants() {
84 - define('OCACCESSIBILITY_VERSION', $this->version);
85 - define('OCACCESSIBILITY_BASE_URL', trailingslashit(plugins_url('accessibility')));
86 - define('OCACCESSIBILITY_ASSETS_URL', trailingslashit(OCACCESSIBILITY_BASE_URL . 'assets'));
87 - define('OCACCESSIBILITY_PATH', plugin_dir_path(__FILE__));
88 - define('OCACCESSIBILITY_PLUGINURL', '//acc.magixite.com');
89 - }
90 -
91 - public function accessibility_create_menu() {
92 - //create new top-level menu
93 - add_menu_page('Accesibility Settings', 'Accesibility', 'manage_options', 'oc-accessibility-admin', array($this, 'accesibility_settings_page'), 'dashicons-universal-access-alt');
94 - }
95 -
96 - public function accesibility_settings_page() {
97 - ?>
98 - <div class="wrap">
99 - <h2>Accessibility Options</h2>
100 -
101 - <?php if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['action']) && $_POST['action'] == "save_accessibility_settings"): ?>
102 - <?php $this->_admin_update_accessibility_settings(); ?>
103 - <?php
104 - endif;
105 - $magixiteLicense = get_option('oc-accessibility', "");
106 - $license_data = $this->_get_license_data($magixiteLicense);
107 - ?>
108 - <form class="oc-accessibilty-form" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
109 - <h2>General Options</h2>
110 - <input type="hidden" name="action" value="save_accessibility_settings">
111 - <a class="oc-accessibilty-tabletop" href="<?php echo OCACCESSIBILITY_PLUGINURL; ?>" alt="MagiXite" title="MagiXite"><img src="<?php echo OCACCESSIBILITY_ASSETS_URL; ?>/images/logo.png" /></a>
112 - <table class="form-table oc-accessibilty-style">
113 - <tbody>
114 - <tr valign="top">
115 - <th scope="row"><?php echo __('Magixite License'); ?></th>
116 - <td>
117 - <input type="text" name="magixite_license" placeholder="Paste your license key" value="<?php echo $magixiteLicense; ?>" />
118 - <?php if ($magixiteLicense == ""): ?>
119 - <p>
120 -
121 - </p>
122 - <?php else: ?>
123 - <p><?php echo $this->_get_license_message($license_data); ?></p>
124 - <?php endif; ?>
125 - </td>
126 - </tr>
127 -
128 - <tr valign="top">
129 - <th scope="row"><?php echo __('Select Preferred Language'); ?></th>
130 - <?php $language_options = $this->get_language_options(); ?>
131 - <td>
132 - <select name="ac_language">
133 - <?php foreach ($language_options as $key => $l): ?>
134 - <option <?php if ($key == get_option('oc-accessibility-language', "")): echo "selected=\"selected\"";
135 - endif;
136 - ?> value="<?php echo $key; ?>"><?php echo $l->name; ?></option>
137 - <?php endforeach; ?>
138 - </select>
139 - <p>* <strong>Auto Detect</strong> - Automatically choose language by user browser language setting.</p>
140 - </td>
141 - </tr>
142 -
143 - <tr class="creditRow"><th colspan="2">Brought To You By <a href="<?php echo OCACCESSIBILITY_PLUGINURL; ?>" alt="MagiXite"><img src="<?php echo OCACCESSIBILITY_ASSETS_URL; ?>/images/text_logo.png" /></a></th></tr>
144 - </tbody>
145 - </table>
146 - <p class="submit">
147 - <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
148 - </p>
149 -
150 - </form>
151 - </div>
152 - <?php
153 - }
154 -
155 - private function load_dependencies() {
156 - require_once OCACCESSIBILITY_PATH . 'includes/class-accesibility-loader.php';
157 -
158 - $this->loader = new OcAcceibility_Loader();
159 - }
160 -
161 - public function run() {
162 - $this->loader->run();
163 - }
164 -
165 - public function get_version() {
166 - return $this->version;
167 - }
168 -
169 - public function get_language_options() {
170 - $languages = array();
171 -
172 - $languages['auto_detect'] = (object) array('name' => 'Auto Detect');
173 - $languages['he_il'] = (object) array('name' => 'Hebrew');
174 - $languages['en_us'] = (object) array('name' => 'English');
175 - $languages['ru_ru'] = (object) array('name' => 'Russian');
176 -// $languages['custom'] = (object) array('name' => 'Custom');
177 -
178 - return $languages;
179 - }
180 -
181 - private function _get_license_data($lkey) {
182 - if ($lkey == "") {
183 - return new stdClass();
184 - }
185 -
186 - $jsonRsp = file_get_contents("http:" . OCACCESSIBILITY_PLUGINURL . "/license/v?litk=" . $lkey);
187 -
188 - $licenseData = json_decode($jsonRsp);
189 - return $licenseData;
190 - }
191 -
192 - /**
193 - * Post form action for the update prices for brand.
194 - */
195 - function _admin_update_accessibility_settings() {
196 - $lkey = sanitize_text_field($_POST["magixite_license"]);
197 - update_option('oc-accessibility', $lkey);
198 - update_option('oc-accessibility-language', $_POST["ac_language"]);
199 - if ($lkey == '') {
200 - $status = 0;
201 - }
202 - else {
203 - $licenseData = $this->_get_license_data($lkey);
204 - if ($licenseData->status == 'Success') {
205 - $status = 1;
206 - }
207 - else {
208 - $status = -1;
209 - }
210 - }
211 -
212 - update_option('oc-accessibility-status', $status);
213 - $class = "update-nag";
214 -
215 - // Validate the license.
216 - $message = "Saved Settings";
217 - $message_two = "";
218 - echo "<div class=\"$class\"> <p>$message</p><p>$message_two</p></div>";
219 - }
220 -
221 - function _get_license_message($license_data) {
222 - if (!$license_data) {
223 - return "Get your <strong>free</strong> license <a href=\"https:" . OCACCESSIBILITY_PLUGINURL . "?wp-ref\" target=\"_blank\">here</a> to unlock more design options.";
224 - }
225 - if ($license_data->status == 'Failure') {
226 - return "<span style=\"color: red;\">License Did not validate</span>";
227 - }
228 - if (isset($license_data->data->expiry)) {
229 - $daysLeft = (intval($license_data->data->expiry) - time()) / (3600 * 24);
230 - if ($daysLeft > 0) {
231 - return "Success! <strong>" . round($daysLeft) . "</strong> days for license renewal.";
232 - }
233 - else {
234 - return "Oh Oh! <strong> Your license has expired " . round($daysLeft * (-1)) . " days ago.</strong><br/>Please go ahead and renew.";
235 - }
236 - }
237 -
238 - return "Nothing to tell ya..";
239 - }
240 -
241 - }
242 -
243 - endif;
244 -
245 -function run_accessibility_plugin() {
246 - $plugin = new OcAccessibilityPlugin();
247 - $plugin->run();
248 -}
249 -
250 -run_accessibility_plugin();
1 +<?php
2 +/**
3 + * Accessibility: Wordpress Accessibility Plugin
4 + *
5 + * Plugin Name: Accessibility
6 + * Description: Accessibility Utility Widget - A high quality solution for making your WordPress website accessible ready.
7 + * Version: 1.0.9
8 + * Author: Octa Code
9 + * Author URI: https://octa-code.com
10 + * Plugin URI: https://acc.magixite.com
11 + * Copyright: 2025 Octa Code
12 + * Last Update: 06/19/2025
13 + *
14 + * Text Domain: accessibility
15 + * Domain Path: /languages/
16 + */
17 +
18 +if (!defined('ABSPATH')) {
19 + exit; // disable direct access
20 +}
21 +
22 +
23 +if (!class_exists('OcAccessibilityPlugin')) :
24 +
25 + /**
26 + * Register the plugin.
27 + *
28 + * Display the administration panel, insert JavaScript etc.
29 + */
30 + class OcAccessibilityPlugin
31 + {
32 +
33 + protected $loader;
34 + protected $version;
35 + protected $plugin_slug;
36 +
37 + private function __cleanInput($str)
38 + {
39 + // Using str_replace() function
40 + // to replace the word
41 + $res = str_replace(
42 + array( '\'', '"',
43 + ',' , ';', '<', '>' ), ' ', $str
44 + );
45 +
46 + // Returning the result
47 + return $res;
48 + }
49 +
50 + /**
51 + * Constructor
52 + */
53 + public function __construct()
54 + {
55 + $this->plugin_slug = 'accessibility';
56 + load_plugin_textdomain($this->plugin_slug, false, basename(dirname(__FILE__)) . '/languages/');
57 + $this->version = '1.0.6';
58 +
59 +
60 + $this->define_constants();
61 + $this->setup_actions();
62 + $this->load_dependencies();
63 +
64 + add_action('admin_menu', array($this, 'accessibility_create_menu'));
65 + }
66 +
67 + /**
68 + * Hook WC Brands into WordPress
69 + */
70 + private function setup_actions()
71 + {
72 + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
73 + add_action('wp_enqueue_scripts', array($this, 'enqueue_adminscripts'));
74 + add_action('admin_enqueue_scripts', array($this, 'enqueue_adminscripts'));
75 + add_action('wp_footer', array($this, 'magixite_script'));
76 + }
77 +
78 + public function magixite_script()
79 + {
80 + if (get_option('oc-accessibility-status', 0) < 1) {
81 + $licenseUrl = OCACCESSIBILITY_PLUGINURL . '/freeCode?oatk=w0rdpre55';
82 + }
83 + else {
84 + $licenseUrl = OCACCESSIBILITY_PLUGINURL . '/license/lw?litk=' . $this->__cleanInput(get_option('oc-accessibility'));
85 + }
86 + wp_enqueue_script(
87 + 'accessibility',
88 + $licenseUrl,
89 + array(),
90 + $this->version,
91 + true
92 + );
93 + $language_setting = "";
94 + if (get_option('oc-accessibility-language', "en_us") !== 'oc_system') {
95 + $language_setting = "'language': '" . get_option('oc-accessibility-language', "en_us") . "'";
96 + }
97 +
98 + wp_register_script('accessibility-init', '', [], '', true);
99 + wp_enqueue_script('accessibility-init');
100 + wp_add_inline_script('accessibility-init', "setTimeout(function(){octLoader({" . $language_setting . "})}, 1000);");
101 + }
102 +
103 + // Styles Handling
104 + public function enqueue_styles()
105 + {
106 +
107 + }
108 +
109 + public function enqueue_adminscripts()
110 + {
111 + wp_enqueue_style('admin-style', OCACCESSIBILITY_ASSETS_URL . '/css/admin-style.css', array(), OCACCESSIBILITY_VERSION);
112 + }
113 +
114 + /**
115 + * Define Accessibility constants
116 + */
117 + private function define_constants()
118 + {
119 + define('OCACCESSIBILITY_VERSION', $this->version);
120 + define('OCACCESSIBILITY_BASE_URL', trailingslashit(plugins_url('accessibility')));
121 + define('OCACCESSIBILITY_ASSETS_URL', trailingslashit(OCACCESSIBILITY_BASE_URL . 'assets'));
122 + define('OCACCESSIBILITY_PATH', plugin_dir_path(__FILE__));
123 + define('OCACCESSIBILITY_PLUGINURL', '//acc.magixite.com');
124 + }
125 +
126 + /**
127 + * WP Admin menu links.
128 + */
129 + public function accessibility_create_menu()
130 + {
131 + //create new top-level menu
132 + add_menu_page(
133 + __('Accessibility Settings', $this->plugin_slug), __('Accessibility', $this->plugin_slug), 'manage_options', 'oc-accessibility-admin', array($this, 'accessibility_settings_page'), 'dashicons-universal-access-alt'
134 + );
135 + add_submenu_page(
136 + 'oc-accessibility-admin', __('Attachments alt', $this->plugin_slug), __('Attachments alt', $this->plugin_slug), 'manage_options', 'oc-accessibility-media', array($this, 'accessibility_admin_media_page'), 'dashicons-admin-media'
137 + );
138 + }
139 +
140 + /**
141 + * General Settings.
142 + */
143 + public function accessibility_settings_page()
144 + {
145 + if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['action']) && $_POST['action'] == "save_accessibility_settings") {
146 + if (isset($_POST['form_nonce']) && wp_verify_nonce($_POST['form_nonce'],'oc-accessibility') && is_user_logged_in()) {
147 + $this->_admin_update_accessibility_settings();
148 + } else {
149 + echo '<p>Error: Goodbye hackers! Better luck next time. </p>';
150 + }
151 + }
152 +
153 + include "includes/accessibility-settings.php";
154 + }
155 + /**
156 + * Attachments media handler.
157 + */
158 + public function accessibility_admin_media_page()
159 + {
160 + // update_post_meta($pid, '_wp_attachment_image_alt', $palt);
161 + if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['action']) && $_POST['action'] == "save_accessibility_attachments_settings") {
162 + if (isset($_POST['form_nonce']) && wp_verify_nonce($_POST['form_nonce'],'oc-accessibility') && is_user_logged_in()) {
163 + $this->_admin_update_attachments();
164 + } else {
165 + echo '<p>Error: Goodbye hackers! Better luck next time. </p>';
166 + }
167 + }
168 + include "includes/accessibility-attachments-alt.php";
169 + }
170 +
171 + private function load_dependencies()
172 + {
173 + include_once OCACCESSIBILITY_PATH . 'includes/class-accessibility-loader.php';
174 +
175 + $this->loader = new OcAccessibility_Loader();
176 + }
177 +
178 + public function run()
179 + {
180 + $this->loader->run();
181 + }
182 +
183 + public function get_version()
184 + {
185 + return $this->version;
186 + }
187 +
188 + public function _admin_update_attachments()
189 + {
190 + $alt_data = $this->__cleanInput($_POST['attachments_alt']);
191 + $title_data = $this->__cleanInput($_POST['attachments_title']);
192 + if ($alt_data == "" && $title_data == "") {
193 + $message = __("Nothing Changed", $this->plugin_slug);
194 + echo "<div class=\"".esc_attr($class)."\"> <p>".esc_html($message)."</p></div>";
195 + return;
196 + }
197 + foreach($alt_data as $pid => $p_alt) {
198 + update_post_meta($pid, '_wp_attachment_image_alt', $p_alt);
199 + }
200 + foreach($title_data as $pid => $p_title) {
201 + $post = array(
202 + 'ID' => $pid,
203 + 'post_title' => $p_title,
204 + );
205 + wp_update_post($post);
206 + }
207 + $class = "update-nag";
208 +
209 + // Validate the license.
210 + $message = __("Saved Changes Successfully", $this->plugin_slug);
211 + $message_two = "";
212 + echo "<div class=\"".esc_attr($class)."\"> <p>".esc_html($message)."</p><p>".esc_html($message_two)."</p></div>";
213 + }
214 +
215 + public function get_language_options()
216 + {
217 + $languages = array();
218 +
219 + $languages['auto_detect'] = (object) array('name' => 'Auto Detect');
220 + $languages['he_il'] = (object) array('name' => 'Hebrew');
221 + $languages['en_us'] = (object) array('name' => 'English');
222 + $languages['es_es'] = (object) array('name' => 'Spanish');
223 + $languages['ru_ru'] = (object) array('name' => 'Russian');
224 + $languages['oc_system'] = (object) array('name' => '- From License');
225 +
226 + return $languages;
227 + }
228 +
229 + private function _get_license_data($lkey)
230 + {
231 + if ($lkey == "") {
232 + return new stdClass();
233 + }
234 +
235 + $siteSrc = urlencode(site_url());
236 + $remoteGetOptions = array('sslverify' => false);
237 + $rsp = wp_safe_remote_get("http:" . OCACCESSIBILITY_PLUGINURL . "/license/v?litk=" . $lkey . "&utm_source=" . $siteSrc, $remoteGetOptions);
238 +
239 + $jsonRsp = wp_remote_retrieve_body($rsp);
240 +
241 + $licenseData = json_decode($jsonRsp);
242 + return $licenseData;
243 + }
244 +
245 + /**
246 + * Post form action for the update prices for brand.
247 + */
248 + function _admin_update_accessibility_settings() {
249 + $lkey = sanitize_text_field($_POST["magixite_license"]);
250 + update_option('oc-accessibility', $lkey);
251 + update_option('oc-accessibility-language', sanitize_text_field($_POST["ac_language"]));
252 + if ($lkey == '') {
253 + $status = 0;
254 + }
255 + else {
256 + $licenseData = $this->_get_license_data($lkey);
257 + if ($licenseData->status == 'Success') {
258 + $status = 1;
259 + }
260 + else {
261 + $status = -1;
262 + }
263 + }
264 +
265 + update_option('oc-accessibility-status', $status);
266 + $class = "update-nag";
267 +
268 + // Validate the license.
269 + $message = __("Saved Settings Successfully", $this->plugin_slug);
270 + $message_two = "";
271 + echo "<div class=\"".esc_attr($class)."\"> <p>".esc_html($message)."</p><p>".esc_html($message_two)."</p></div>";
272 + }
273 +
274 + function _get_license_message($license_data)
275 + {
276 + if (!$license_data) {
277 + $licenseObtainLink = 'https:' . OCACCESSIBILITY_PLUGINURL . '?wp-ref';
278 + return "Get your <strong>free</strong> license <a href=\"".esc_attr($licenseObtainLink)."\" target=\"_blank\">here</a> to unlock more design options.";
279 + }
280 + if ($license_data->status == 'Failure') {
281 + return "<span style=\"color: red;\">License Did not validate</span>";
282 + }
283 + if (isset($license_data->data->expiry)) {
284 + $daysLeft = (intval($license_data->data->expiry) - time()) / (3600 * 24);
285 + if ($daysLeft > 0) {
286 + return "Success! <strong>" . esc_html(round($daysLeft)) . "</strong> days for license renewal.";
287 + }
288 + else {
289 + return "Oh Oh! <strong> Your license has expired " . esc_html(round($daysLeft * (-1))) . " days ago.</strong><br/>Please go ahead and renew.";
290 + }
291 + }
292 +
293 + return "Nothing to tell ya..";
294 + }
295 +
296 + public function get_attachments($all = false)
297 + {
298 + global $wpdb;
299 +
300 + // $query_only_with_alt = "SELECT `wp`.`ID`, `wp`.`post_author`, `wp`.`post_date`, `wp`.`post_title`, `wp`.`post_name`,
301 + // `wp`.`guid`, `wp`.`post_parent`, `wpm`.`meta_key`, `wpm`.`meta_value`
302 + // FROM $wpdb->posts `wp`
303 + // LEFT JOIN $wpdb->postmeta `wpm` ON `wp`.`ID` = `wpm`.`post_id`
304 + // WHERE `wp`.`post_type` = 'attachment' AND `wpm`.`meta_key` = \"_wp_attachment_image_alt\" AND `wpm`.`meta_value` != ''";
305 +
306 + $query_all_attachments = "SELECT `wp`.`ID`, `wp`.`post_author`, `wp`.`post_date`, `wp`.`post_title`, `wp`.`post_name`,
307 + `wp`.`guid`, `wp`.`post_parent`, `wpp`.`post_title` `parent_title` FROM $wpdb->posts `wp` "
308 + . " LEFT JOIN $wpdb->posts `wpp` ON `wp`.`post_parent` = `wpp`.`ID`"
309 + . " WHERE `wp`.`post_type` = 'attachment' ORDER BY `wp`.`ID` DESC";
310 +
311 + $posts = $wpdb->get_results($query_all_attachments);
312 +
313 + return $posts;
314 + }
315 +
316 + }
317 +
318 +endif;
319 +
320 +/**
321 + * Runs the main instance of OC_Accessibility to prevent the need to use globals.
322 + *
323 + * @since 1.0.0
324 + * @return object OC_Accessibility
325 + */
326 +function Run_Accessibility_plugin()
327 +{
328 + $plugin = new OcAccessibilityPlugin();
329 + $plugin->run();
330 +}
331 +
332 +Run_Accessibility_plugin();