PluginProbe
Accessibility / 1.0.2
Accessibility v1.0.2
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.2, at accessibility.php

266 lines 9.3 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.1
8 * Author: Octa Code
9 * Author URI: http://octa-code.com
10 * Plugin URI: http://acc.magixite.com
11 * Copyright: 2015 Octa Code
12 * Last Update: 18/08/2016
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 protected $loader;
33 protected $version;
34 protected $plugin_slug;
35
36 /**
37 * Constructor
38 */
39 public function __construct() {
40 $this->plugin_slug = 'accessibility';
41 load_plugin_textdomain($this->plugin_slug, false, basename(dirname(__FILE__)) . '/languages/');
42 $this->version = '1.0.0';
43
44
45 $this->define_constants();
46 $this->setup_actions();
47 $this->load_dependencies();
48
49 add_action('admin_menu', array($this, 'accessibility_create_menu'));
50 }
51
52 /**
53 * Hook WC Brands into WordPress
54 */
55 private function setup_actions() {
56 add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
57 add_action('admin_enqueue_scripts', array($this, 'enqueue_adminscripts'));
58 add_action('wp_footer', array($this, 'magixite_script'));
59 }
60
61 public function magixite_script() {
62 if (get_option('oc-accessibility-status', 0) < 1) {
63 echo '<script type="text/javascript" src="' . OCACCESSIBILITY_PLUGINURL . '/freeCode?oatk=w0rdpre55"></script>';
64 }
65 else {
66 echo '<script type="text/javascript" src="' . OCACCESSIBILITY_PLUGINURL . '/license/lw?litk=' . get_option('oc-accessibility') . '"></script>';
67 }
68 $language_setting = "";
69 if (get_option('oc-accessibility-language', "en_us") !== 'oc_system') {
70 $language_setting = "'language': '" . get_option('oc-accessibility-language', "en_us") . "'";
71 }
72 echo "<script type=\"text/javascript\">setTimeout(function(){octLoader({" . $language_setting . "})}, 1000);</script>";
73 }
74
75 // Styles Handling
76 public function enqueue_styles() {
77
78 }
79
80 public function enqueue_adminscripts() {
81 wp_enqueue_style('admin-style', OCACCESSIBILITY_ASSETS_URL . '/css/admin-style.css', array(), OCACCESSIBILITY_VERSION);
82 }
83
84 /**
85 * Define Accessibilty constants
86 */
87 private function define_constants() {
88 define('OCACCESSIBILITY_VERSION', $this->version);
89 define('OCACCESSIBILITY_BASE_URL', trailingslashit(plugins_url('accessibility')));
90 define('OCACCESSIBILITY_ASSETS_URL', trailingslashit(OCACCESSIBILITY_BASE_URL . 'assets'));
91 define('OCACCESSIBILITY_PATH', plugin_dir_path(__FILE__));
92 define('OCACCESSIBILITY_PLUGINURL', '//acc.magixite.com');
93 }
94
95 /**
96 * WP Admin menu links.
97 */
98 public function accessibility_create_menu() {
99 //create new top-level menu
100 add_menu_page(
101 __('Accessibility Settings', $this->plugin_slug), __('Accessibility', $this->plugin_slug), 'manage_options', 'oc-accessibility-admin', array($this, 'accessibility_settings_page'), 'dashicons-universal-access-alt'
102 );
103 add_submenu_page(
104 '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'
105 );
106 }
107
108 /**
109 * General Settings.
110 */
111 public function accessibility_settings_page() {
112 if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['action']) && $_POST['action'] == "save_accessibility_settings") {
113 $this->_admin_update_accessibility_settings();
114 }
115
116 include("includes/accessibility-settings.php");
117 }
118 /**
119 * Attachments media handler.
120 */
121 public function accessibility_admin_media_page() {
122 // update_post_meta($pid, '_wp_attachment_image_alt', $palt);
123 if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['action']) && $_POST['action'] == "save_accessibility_attachments_settings") {
124 $this->_admin_update_attachments();
125 }
126 include("includes/accessibility-attachments-alt.php");
127 }
128
129 private function load_dependencies() {
130 require_once OCACCESSIBILITY_PATH . 'includes/class-accesibility-loader.php';
131
132 $this->loader = new OcAcceibility_Loader();
133 }
134
135 public function run() {
136 $this->loader->run();
137 }
138
139 public function get_version() {
140 return $this->version;
141 }
142
143 public function _admin_update_attachments() {
144 $alt_data = $_POST['attachments_alt'];
145 $title_data = $_POST['attachments_title'];
146 foreach($alt_data as $pid => $p_alt) {
147 update_post_meta($pid, '_wp_attachment_image_alt', $p_alt);
148 }
149 foreach($title_data as $pid => $p_title) {
150 $post = array(
151 'ID' => $pid,
152 'post_title' => $p_title,
153 );
154 wp_update_post($post);
155 }
156 $class = "update-nag";
157
158 // Validate the license.
159 $message = __("Saved Changes Successfully", $this->plugin_slug);
160 $message_two = "";
161 echo "<div class=\"$class\"> <p>$message</p><p>$message_two</p></div>";
162 }
163
164 public function get_language_options() {
165 $languages = array();
166
167 $languages['auto_detect'] = (object) array('name' => 'Auto Detect');
168 $languages['he_il'] = (object) array('name' => 'Hebrew');
169 $languages['en_us'] = (object) array('name' => 'English');
170 $languages['es_es'] = (object) array('name' => 'Spanish');
171 $languages['ru_ru'] = (object) array('name' => 'Russian');
172 $languages['oc_system'] = (object) array('name' => '- From License');
173
174 return $languages;
175 }
176
177 private function _get_license_data($lkey) {
178 if ($lkey == "") {
179 return new stdClass();
180 }
181
182 $jsonRsp = file_get_contents("http:" . OCACCESSIBILITY_PLUGINURL . "/license/v?litk=" . $lkey);
183
184 $licenseData = json_decode($jsonRsp);
185 return $licenseData;
186 }
187
188 /**
189 * Post form action for the update prices for brand.
190 */
191 function _admin_update_accessibility_settings() {
192 $lkey = sanitize_text_field($_POST["magixite_license"]);
193 update_option('oc-accessibility', $lkey);
194 update_option('oc-accessibility-language', $_POST["ac_language"]);
195 if ($lkey == '') {
196 $status = 0;
197 }
198 else {
199 $licenseData = $this->_get_license_data($lkey);
200 if ($licenseData->status == 'Success') {
201 $status = 1;
202 }
203 else {
204 $status = -1;
205 }
206 }
207
208 update_option('oc-accessibility-status', $status);
209 $class = "update-nag";
210
211 // Validate the license.
212 $message = __("Saved Settings Successfully", $this->plugin_slug);
213 $message_two = "";
214 echo "<div class=\"$class\"> <p>$message</p><p>$message_two</p></div>";
215 }
216
217 function _get_license_message($license_data) {
218 if (!$license_data) {
219 return "Get your <strong>free</strong> license <a href=\"https:" . OCACCESSIBILITY_PLUGINURL . "?wp-ref\" target=\"_blank\">here</a> to unlock more design options.";
220 }
221 if ($license_data->status == 'Failure') {
222 return "<span style=\"color: red;\">License Did not validate</span>";
223 }
224 if (isset($license_data->data->expiry)) {
225 $daysLeft = (intval($license_data->data->expiry) - time()) / (3600 * 24);
226 if ($daysLeft > 0) {
227 return "Success! <strong>" . round($daysLeft) . "</strong> days for license renewal.";
228 }
229 else {
230 return "Oh Oh! <strong> Your license has expired " . round($daysLeft * (-1)) . " days ago.</strong><br/>Please go ahead and renew.";
231 }
232 }
233
234 return "Nothing to tell ya..";
235 }
236
237 public function get_attachments($all = false) {
238 global $wpdb;
239
240 // $query_only_with_alt = "SELECT `wp`.`ID`, `wp`.`post_author`, `wp`.`post_date`, `wp`.`post_title`, `wp`.`post_name`,
241 // `wp`.`guid`, `wp`.`post_parent`, `wpm`.`meta_key`, `wpm`.`meta_value`
242 // FROM $wpdb->posts `wp`
243 // LEFT JOIN $wpdb->postmeta `wpm` ON `wp`.`ID` = `wpm`.`post_id`
244 // WHERE `wp`.`post_type` = 'attachment' AND `wpm`.`meta_key` = \"_wp_attachment_image_alt\" AND `wpm`.`meta_value` != ''";
245
246 $query_all_attachments = "SELECT `wp`.`ID`, `wp`.`post_author`, `wp`.`post_date`, `wp`.`post_title`, `wp`.`post_name`,
247 `wp`.`guid`, `wp`.`post_parent`, `wpp`.`post_title` `parent_title` FROM $wpdb->posts `wp` "
248 . " LEFT JOIN $wpdb->posts `wpp` ON `wp`.`post_parent` = `wpp`.`ID`"
249 . " WHERE `wp`.`post_type` = 'attachment' ORDER BY `wp`.`ID` DESC";
250
251 $posts = $wpdb->get_results($query_all_attachments);
252
253 return $posts;
254 }
255
256 }
257
258 endif;
259
260 function run_accessibility_plugin() {
261 $plugin = new OcAccessibilityPlugin();
262 $plugin->run();
263 }
264
265 run_accessibility_plugin();
266