PluginProbe
Accessibility / 1.0.10
Accessibility v1.0.10
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
accessibility / accessibility.php

accessibility.php in Accessibility 1.0.10, at accessibility.php

333 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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.10
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();
333