Changeset 2743511
- Timestamp:
- 06/16/2022 12:46:38 PM (4 years ago)
- Location:
- greenweb
- Files:
-
- 34 added
- 5 edited
-
tags/1.1.1 (added)
-
tags/1.1.1/LICENSE.txt (added)
-
tags/1.1.1/README.txt (added)
-
tags/1.1.1/admin (added)
-
tags/1.1.1/admin/class-greenweb-admin.php (added)
-
tags/1.1.1/admin/css (added)
-
tags/1.1.1/admin/css/greenweb-admin.css (added)
-
tags/1.1.1/admin/index.php (added)
-
tags/1.1.1/admin/js (added)
-
tags/1.1.1/admin/js/greenweb-admin.js (added)
-
tags/1.1.1/admin/partials (added)
-
tags/1.1.1/admin/partials/apart-admin-display.php (added)
-
tags/1.1.1/apart.php (added)
-
tags/1.1.1/greenweb_globals.php (added)
-
tags/1.1.1/includes (added)
-
tags/1.1.1/includes/class-greenweb-activator.php (added)
-
tags/1.1.1/includes/class-greenweb-deactivator.php (added)
-
tags/1.1.1/includes/class-greenweb-i18n.php (added)
-
tags/1.1.1/includes/class-greenweb-loader.php (added)
-
tags/1.1.1/includes/class-greenweb.php (added)
-
tags/1.1.1/includes/index.php (added)
-
tags/1.1.1/index.php (added)
-
tags/1.1.1/languages (added)
-
tags/1.1.1/languages/greenweb.pot (added)
-
tags/1.1.1/public (added)
-
tags/1.1.1/public/class-greenweb-public.php (added)
-
tags/1.1.1/public/css (added)
-
tags/1.1.1/public/css/greenweb-public.css (added)
-
tags/1.1.1/public/index.php (added)
-
tags/1.1.1/public/js (added)
-
tags/1.1.1/public/js/greenweb-public.js (added)
-
tags/1.1.1/public/partials (added)
-
tags/1.1.1/public/partials/greenweb-public-display.php (added)
-
tags/1.1.1/uninstall.php (added)
-
trunk/README.txt (modified) (1 diff)
-
trunk/admin/class-greenweb-admin.php (modified) (1 diff)
-
trunk/admin/js/greenweb-admin.js (modified) (1 diff)
-
trunk/apart.php (modified) (3 diffs)
-
trunk/greenweb_globals.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
greenweb/trunk/README.txt
r2738505 r2743511 79 79 == Changelog == 80 80 81 = 1.1.1 = 82 * Bugfix: If there is no prefix or wrong/failing prefix the plugin will not alter the src of image. 83 * Bugfix: Where admin settings can't be reached. 84 81 85 = 1.1.0 = 82 86 * Name change from Greenweb to Apart -
greenweb/trunk/admin/class-greenweb-admin.php
r2738502 r2743511 74 74 */ 75 75 public function set_admin_menu() { 76 add_menu_page( $this->plugin_name, greenweb_globals\pluginName, 'manage_options', $this->plugin_name.'/admin/partials/apart-admin-display.php');76 add_menu_page( $this->plugin_name, greenweb_globals\pluginName, 'manage_options', greenweb_globals\rootFolder.'/admin/partials/apart-admin-display.php'); 77 77 } 78 78 } -
greenweb/trunk/admin/js/greenweb-admin.js
r2732598 r2743511 39 39 40 40 function greenweb_check_Prefix(func, val) { 41 fetch(optiUrl + val + latestEnd).then((response) => 42 func(val, response.status) 43 );41 fetch(optiUrl + val + latestEnd).then((response) => { 42 func(val, response.status); 43 }); 44 44 } 45 45 46 46 $(document).ready(function () { 47 47 if (pref) greenweb_check_Prefix(checkStatusStart, pref); 48 49 48 $('#gwForm').submit(function (e) { 50 49 e.preventDefault(); 51 50 const val = e.target[0].value.trim(); 52 51 53 if (!/^[A-Za-z0-9]*$/.test(val)) {54 checkStatus(400);55 return;56 }52 // if (!/^[A-Za-z0-9]*$/.test(val)) { 53 // checkStatus(400); 54 // return; 55 // } 57 56 greenweb_check_Prefix(updateOption, val); 58 57 }); -
greenweb/trunk/apart.php
r2738502 r2743511 13 13 * Plugin URI: seenthis.co 14 14 * Description: APART reduces your site’s carbon footprint and improves user experience by reducing its image data transfer and improving image load times. 15 * Version: 1.1. 015 * Version: 1.1.1 16 16 * Author: Seenthis 17 17 * Author URI: https://www.seenthis.co … … 101 101 <?php } 102 102 103 add_action('wp_head', 'hook_javascript'); 104 105 /** 106 * Set links for greenweb at plugins. 107 * @return Url to plugin settings 108 */ 109 function getSettingsUrl(){ 110 return admin_url() . 'admin.php?page='. greenweb_globals\baseName .'/admin/partials/apart-admin-display.php'; 111 } 112 113 /** 114 * Set links for greenweb at plugins. 115 * @param $links 116 * @return mixed 117 */ 118 function addSettingsLink($links) { 119 $links[] = '<a href="' . getSettingsUrl() . '">Settings</a>'; 120 121 return $links; 122 } 123 124 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'addSettingsLink'); 125 126 /** 127 * When redirect to adminpage when activated 128 * @param $plugin 129 */ 130 function redirectOnActivate($plugin) { 131 if( $plugin === plugin_basename(__FILE__) ) { 132 exit( wp_redirect( getSettingsUrl() ) ); 133 } 134 } 135 136 add_action( 'activated_plugin', 'redirectOnActivate' ); 137 138 /** 139 * Change src for greenweb. 140 * @param $content 141 * @return mixed 142 */ 143 function greenweb($content) { 103 add_action('wp_head', 'hook_javascript'); 104 105 /** 106 * Set links for greenweb at plugins. 107 * @return Url to plugin settings 108 */ 109 function getSettingsUrl(){ 110 return admin_url() . 'admin.php?page='. greenweb_globals\rootFolder .'/admin/partials/apart-admin-display.php'; 111 } 112 113 /** 114 * Set links for greenweb at plugins. 115 * @param $links 116 * @return mixed 117 */ 118 function addSettingsLink($links) { 119 $links[] = '<a href="' . getSettingsUrl() . '">Settings</a>'; 120 121 return $links; 122 } 123 124 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'addSettingsLink'); 125 126 /** 127 * When redirect to adminpage when activated 128 * @param $plugin 129 */ 130 function redirectOnActivate($plugin) { 131 if( $plugin === plugin_basename(__FILE__) ) { 132 exit( wp_redirect( getSettingsUrl() ) ); 133 } 134 } 135 136 add_action( 'activated_plugin', 'redirectOnActivate' ); 137 138 139 /** 140 * Function to change greenweb option from ajax 141 * @param 142 */ 143 function update_greenweb_option_ajax(){ 144 145 $val = sanitize_text_field($_POST["option"]); 146 147 if (!preg_match('/[^A-Za-z0-9]/', $val)){ 148 update_option(greenweb_globals\option, $val); 149 return http_response_code(200); 150 } else return http_response_code(403); 151 die(); 152 } 153 154 add_action( 'wp_ajax_' . 'greenweb_option_ajax', 'update_greenweb_option_ajax' ); 155 add_action( 'wp_ajax_nopriv_' . 'greenweb_option_ajax', 'update_greenweb_option_ajax' ); 156 157 global $greenweb_globals; 158 global $latest; 159 160 161 // Check if prefix is ok othervise dont load plugin functions 162 if (!$greenweb_globals->prefix || $greenweb_globals->prefix === '403') { 163 return; 164 } 165 $response = wp_remote_get($latest); 166 $http_code = wp_remote_retrieve_response_code($response); 167 if ($http_code !== 200) { 168 return; 169 } 170 171 /** 172 * Change src for greenweb. 173 * @param $content 174 * @return mixed 175 */ 176 function greenweb($content) { 144 177 $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'); 145 178 if ($content) { … … 221 254 } 222 255 223 224 // Function to change greenweb option from ajax225 function update_greenweb_option_ajax(){226 227 $val = sanitize_text_field($_POST["option"]);228 229 if (!preg_match('/[^A-Za-z0-9]/', $val)){230 update_option(greenweb_globals\option, $val);231 return http_response_code(200);232 } else return http_response_code(403);233 die();234 }235 236 add_action( 'wp_ajax_' . 'greenweb_option_ajax', 'update_greenweb_option_ajax' );237 add_action( 'wp_ajax_nopriv_' . 'greenweb_option_ajax', 'update_greenweb_option_ajax' );238 239 256 //Cron 240 257 -
greenweb/trunk/greenweb_globals.php
r2738502 r2743511 8 8 const pluginName = 'Apart'; 9 9 const baseName = 'apart'; 10 const version = '1.1.0'; 10 const rootFolder = 'greenweb'; 11 const version = '1.1.1'; 11 12 12 13 class greenweb_settings{
Note: See TracChangeset
for help on using the changeset viewer.