Changeset 3325770
- Timestamp:
- 07/10/2025 02:29:02 PM (9 months ago)
- Location:
- siteimprove/trunk
- Files:
-
- 7 edited
-
admin/class-siteimprove-admin.php (modified) (18 diffs)
-
admin/css/siteimprove-preview.css (modified) (1 diff)
-
admin/js/siteimprove.js (modified) (3 diffs)
-
admin/partials/class-siteimprove-admin-settings.php (modified) (25 diffs)
-
includes/class-siteimprove.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
siteimprove.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
siteimprove/trunk/admin/class-siteimprove-admin.php
r3064701 r3325770 50 50 51 51 $this->plugin_name = $plugin_name; 52 $this->version = $version;52 $this->version = $version; 53 53 54 54 $this->load_dependencies(); … … 91 91 $prepublish_enabled = intval( get_option( 'siteimprove_prepublish_enabled', 0 ) ); 92 92 93 if ( ( $wp_query->is_preview() || $wp_query->is_singular() ) && 1 === $prepublish_allowed && 1 === $prepublish_enabled ) {93 if ( ( $wp_query->is_preview() || $wp_query->is_singular() || is_front_page() ) && 1 === $prepublish_allowed && 1 === $prepublish_enabled ) { 94 94 wp_enqueue_style( 'siteimprove_preview_css', plugin_dir_url( __FILE__ ) . 'css/siteimprove-preview.css', array(), $this->version, 'all' ); 95 95 } … … 107 107 */ 108 108 public function gutenberg_siteimprove_plugin() { 109 global $post; 110 111 if ( $post && $post->ID ) { 112 $permalink = get_permalink( $post->ID ); 113 if ( $permalink ) { 114 $this->siteimprove_add_js( $permalink, 'siteimprove_input' ); 115 116 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { 117 error_log( 'Siteimprove Debug: Gutenberg - Post ID: ' . $post->ID ); 118 error_log( 'Siteimprove Debug: Gutenberg - Permalink: ' . $permalink ); 119 } 120 } 121 } 122 109 123 wp_enqueue_script( 110 124 'gutenberg-siteimprove-plugin', … … 114 128 false 115 129 ); 130 131 $post_id = $post ? $post->ID : 0; 132 $url = $post_id ? get_permalink( $post_id ) : ''; 133 116 134 $si_js_args = array( 117 135 'token' => get_option( 'siteimprove_token' ), 118 136 'text' => __( 'Siteimprove Recheck', 'siteimprove' ), 119 'url' => get_permalink( $post_id ),137 'url' => $url, 120 138 ); 121 139 wp_localize_script( … … 132 150 global $pagenow; 133 151 152 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { 153 error_log( 'Siteimprove Debug: Current page: ' . $pagenow ); 154 error_log( 'Siteimprove Debug: GET params: ' . print_r( $_GET, true ) ); 155 } 156 134 157 $urls = get_transient( 'siteimprove_url_' . get_current_user_id() ); 135 158 136 159 if ( ! wp_doing_ajax() && ! empty( $urls ) ) { 137 160 if ( is_array( $urls ) && count( $urls ) > 1 ) { 138 $url = esc_url( home_url() );161 $url = esc_url( home_url() ); 139 162 $method = 'siteimprove_recrawl'; 140 163 } else { 141 $url = array_pop( $urls );164 $url = array_pop( $urls ); 142 165 $method = 'siteimprove_recheck'; 143 166 } … … 148 171 switch ( $pagenow ) { 149 172 case 'post.php': 150 $post_id = wp_verify_nonce( $this->settings->request_siteimprove_nonce(), 'siteimprove_nonce' ) && ! empty( $_GET['post'] ) ? (int) $_GET['post'] : 0; 151 $permalink = get_permalink( $post_id ); 152 153 if ( $permalink ) { 173 $post_id = ! empty( $_GET['post'] ) ? (int) $_GET['post'] : 0; 174 $permalink = $post_id ? get_permalink( $post_id ) : false; 175 176 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { 177 error_log( 'Siteimprove Debug: Post ID: ' . $post_id ); 178 error_log( 'Siteimprove Debug: Permalink: ' . $permalink ); 179 error_log( 'Siteimprove Debug: Token: ' . get_option( 'siteimprove_token', 'NOT_SET' ) ); 180 error_log( 'Siteimprove Debug: User can edit posts: ' . ( current_user_can( 'edit_posts' ) ? 'yes' : 'no' ) ); 181 } 182 183 if ( $permalink && current_user_can( 'edit_posts' ) ) { 154 184 $this->siteimprove_add_js( get_permalink( $post_id ), 'siteimprove_input' ); 155 185 // Only display recheck button in published posts. … … 162 192 case 'term.php': 163 193 case 'edit-tags.php': 164 $tag_id = wp_verify_nonce( $this->settings->request_siteimprove_nonce(), 'siteimprove_nonce' ) && ! empty( $_GET['tag_ID'] ) ? (int) $_GET['tag_ID'] : 0; 165 $taxonomy = wp_verify_nonce( $this->settings->request_siteimprove_nonce(), 'siteimprove_nonce' ) && ! empty( $_GET['taxonomy'] ) ? sanitize_key( $_GET['taxonomy'] ) : ''; 166 167 if ( 'term.php' === $pagenow || ( 'edit-tags.php' === $pagenow && wp_verify_nonce( $this->settings->request_siteimprove_nonce(), 'siteimprove_nonce' ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) ) { 168 $this->siteimprove_add_js( get_term_link( (int) $tag_id, $taxonomy ), 'siteimprove_input' ); 169 $this->siteimprove_add_js( get_term_link( (int) $tag_id, $taxonomy ), 'siteimprove_recheck_button' ); 194 $tag_id = ! empty( $_GET['tag_ID'] ) ? (int) $_GET['tag_ID'] : 0; 195 $taxonomy = ! empty( $_GET['taxonomy'] ) ? sanitize_key( $_GET['taxonomy'] ) : ''; 196 197 if ( ( 'term.php' === $pagenow || ( 'edit-tags.php' === $pagenow && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) ) && current_user_can( 'manage_categories' ) ) { 198 $term_link = get_term_link( (int) $tag_id, $taxonomy ); 199 if ( ! is_wp_error( $term_link ) ) { 200 $this->siteimprove_add_js( $term_link, 'siteimprove_input' ); 201 $this->siteimprove_add_js( $term_link, 'siteimprove_recheck_button' ); 202 } 170 203 } 171 204 break; 172 205 173 206 default: 174 $host = isset( $_SERVER['HTTP_HOST'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';207 $host = isset( $_SERVER['HTTP_HOST'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : ''; 175 208 $request = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; 176 209 $this->siteimprove_add_js( $host . $request, 'siteimprove_domain' ); … … 208 241 if ( isset( $_GET['si_preview_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['si_preview_nonce'] ) ), 'siteimprove_nonce' ) ) { 209 242 return; 210 } 211 else { 243 } else { 212 244 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/siteimprove.js', array( 'jquery' ), $this->version, false ); 245 246 /* 247 Pass any server-side vars down to JS. These will be exposed as 248 php_vars.variablename for example 249 */ 250 $jsarray = array( 251 'prepublish_allowed' => intval( get_option( 'siteimprove_prepublish_allowed', 0 ) ), 252 'prepublish_enabled' => intval( get_option( 'siteimprove_prepublish_enabled', 0 ) ), 253 'has_api_key' => intval( strlen( get_option( 'siteimprove_api_key', 0 ) ) > 0 ), 254 ); 255 wp_localize_script( $this->plugin_name, 'php_vars', $jsarray ); 213 256 wp_enqueue_script( 'siteimprove_overlay', $overlay_path, array(), $this->version, true ); 214 257 } … … 217 260 if ( ! empty( $public_url ) ) { 218 261 $parsed_url = wp_parse_url( $url ); 219 $url = "$public_url$parsed_url[path]" . ( isset( $parsed_url['query'] ) ? "?$parsed_url[query]" : '' );220 } 221 222 $is_content_page = is_preview() || is_singular() ;262 $url = "$public_url$parsed_url[path]" . ( isset( $parsed_url['query'] ) ? "?$parsed_url[query]" : '' ); 263 } 264 265 $is_content_page = is_preview() || is_singular() || is_front_page(); 223 266 224 267 $si_js_args = array( 225 268 'token' => get_option( 'siteimprove_token' ), 226 'txt' => __( 'Siteimprove Recheck', 'siteimprove' ),227 'url' => $url,269 'txt' => __( 'Siteimprove Recheck', 'siteimprove' ), 270 'url' => $url, 228 271 'version' => $disabled_new_version, 229 272 'is_content_page' => $is_content_page, … … 242 285 'siteimprove_plugin_text', 243 286 array( 244 'loading' => __( 'Loading... Please wait.', 'siteimprove' ),287 'loading' => __( 'Loading... Please wait.', 'siteimprove' ), 245 288 'prepublish_activate_running' => __( 'We are now activating prepublish for your website... Please keep the current page open while the process is running.', 'siteimprove' ), 246 'prepublish_feature_ready' => __( 'Prepublish feature is already enabled for the current website. To use it please go to the preview of any page/post or content that you want to check and click the button <strong>Siteimprove Prepublish Check</strong> located on the top bar of the admin panel.', 'siteimprove' ),289 'prepublish_feature_ready' => __( 'Prepublish feature is already enabled for the current website. To use it please go to the preview of any page/post or content that you want to check and click the button <strong>Siteimprove Prepublish Check</strong> located on the top bar of the admin panel.', 'siteimprove' ), 247 290 'prepublish_activation_error' => __( 'Error activating prepublish. Please contact support team.', 'siteimprove' ), 248 291 ) … … 298 341 public function siteimprove_save_session_url_post( $post_ID ) { 299 342 if ( ! wp_is_post_revision( $post_ID ) && ! wp_is_post_autosave( $post_ID ) ) { 300 $urls = get_transient( 'siteimprove_url_' . get_current_user_id() );343 $urls = get_transient( 'siteimprove_url_' . get_current_user_id() ); 301 344 $urls[] = get_permalink( $post_ID ); 302 345 set_transient( 'siteimprove_url_' . get_current_user_id(), $urls, 900 ); … … 313 356 */ 314 357 public function siteimprove_save_session_url_term( $term_id, $tt_id, $taxonomy ) { 315 $urls = get_transient( 'siteimprove_url_' . get_current_user_id() );358 $urls = get_transient( 'siteimprove_url_' . get_current_user_id() ); 316 359 $urls[] = get_term_link( (int) $term_id, $taxonomy ); 317 360 set_transient( 'siteimprove_url_' . get_current_user_id(), $urls, 900 ); … … 336 379 ) 337 380 ) { 338 $urls = get_transient( 'siteimprove_url_' . get_current_user_id() );381 $urls = get_transient( 'siteimprove_url_' . get_current_user_id() ); 339 382 $urls[] = get_permalink( $post->ID ); 340 383 set_transient( 'siteimprove_url_' . get_current_user_id(), $urls, 900 ); … … 347 390 public function siteimprove_wp_head() { 348 391 349 $user = wp_get_current_user();392 $user = wp_get_current_user(); 350 393 $allowed_roles = array( 351 394 'shop_manager', … … 359 402 $type = $this->get_current_page_type(); 360 403 switch ( $type ) { 404 case 'front': 405 case 'home': 361 406 case 'page': 362 407 case 'single': … … 368 413 369 414 default: 370 $host = isset( $_SERVER['HTTP_HOST'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';415 $host = isset( $_SERVER['HTTP_HOST'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : ''; 371 416 $request = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; 372 417 $this->siteimprove_add_js( $host . $request, 'siteimprove_domain' ); … … 426 471 $prepublish_allowed = intval( get_option( 'siteimprove_prepublish_allowed', 0 ) ); 427 472 $prepublish_enabled = intval( get_option( 'siteimprove_prepublish_enabled', 0 ) ); 428 429 if ( ( is_preview() || is_singular() ) && 1 === $prepublish_allowed && 1 === $prepublish_enabled) {430 $prepublish_button = 431 '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" height="28px" width="28px" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="28px" viewBox="0 0 300 300" style="enable-background:new 0 0 300 300;" xml:space="preserve">473 $has_api_key = intval( strlen( get_option( 'siteimprove_api_key', 0 ) ) > 0 ); 474 if ( ( is_preview() || is_singular() || is_front_page() ) && 1 === $prepublish_allowed && 1 === $prepublish_enabled && 1 === $has_api_key ) { 475 $prepublish_button = 476 '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" height="28px" width="28px" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="28px" viewBox="0 0 300 300" style="enable-background:new 0 0 300 300;" xml:space="preserve"> 432 477 <circle fill="#0D4CD3" cx="150" cy="150" r="150"/> 433 478 <g> … … 437 482 $admin_bar->add_menu( 438 483 array( 439 'id' => 'siteimprove-trigger-contentcheck',484 'id' => 'siteimprove-trigger-contentcheck', 440 485 'title' => $prepublish_button . __( 'Prepublish', 'siteimprove' ), 441 486 'group' => null, 442 'href' => '#',443 'meta' => array(487 'href' => '#', 488 'meta' => array( 444 489 'title' => __( 'Siteimprove Prepublish', 'siteimprove' ), 445 490 'class' => 'siteimprove-trigger-contentcheck', -
siteimprove/trunk/admin/css/siteimprove-preview.css
r3064701 r3325770 9 9 padding-left: 30px; 10 10 } 11 @keyframes highlight-blink {12 50% {13 background-color: rgba(0, 0, 0, 0);14 border-color: rgba(0, 0, 0, 0);15 }16 }17 18 .si-highlight {19 background-color: rgba(221, 10, 27, 0.2);20 border: 2px solid #DD0A1B;21 animation-name: highlight-blink;22 animation-duration: 0.4s;23 animation-iteration-count: 4;24 animation-timing-function: ease;25 }26 27 body.si-full-highlight {28 position: relative;29 }30 31 /* For highlighting of the body, we don't want to wrap an element around the body itself,32 as that will cause a re-render of the page of our CMS Plugin, body has to be the first element as well33 So instead we add a class to body, and in it we got a pseudo element that is ontop of the body's children */34 body.si-full-highlight:before {35 content: "";36 height: 100%;37 width: 100%;38 position: absolute;39 z-index: 9999;40 background-color: rgba(221, 10, 27, 0.2);41 border: 2px solid #DD0A1B;42 animation-name: highlight-blink;43 animation-duration: 0.4s;44 animation-iteration-count: 4;45 animation-timing-function: ease;46 }47 48 .si-overlay {49 position:absolute;50 top:0;51 left:0;52 right:0;53 bottom:0;54 background-color:rgba(0, 0, 0, 0.55);55 background: url(data:;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABl0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuNUmK/OAAAAATSURBVBhXY2RgYNgHxGAAYuwDAA78AjwwRoQYAAAAAElFTkSuQmCC) repeat scroll transparent\9; /* ie fallback png background image */56 z-index:100000;57 color:white;58 } -
siteimprove/trunk/admin/js/siteimprove.js
r3064701 r3325770 23 23 adminBar.id = 'wpadminbar-disabled'; 24 24 } 25 const cleanDom = iframe.contentWindow.document .cloneNode(true);25 const cleanDom = iframe.contentWindow.document; 26 26 document.body.removeChild(iframeContainer); 27 27 resolve(cleanDom); … … 103 103 104 104 _si.push(['onHighlight', function(highlightInfo) { 105 // Function to wrap a specific text node within an element with a new element 106 function wrapTextNode(element, from, length, wrapTag) { 107 $(element).contents().each(function() { 108 // 3 = text node 109 if (this.nodeType === 3 && this.nodeValue) { 110 if (from < this.nodeValue.length) { 111 var before = this.nodeValue.substr(0, from); 112 var middle = this.nodeValue.substr(from, length); 113 var after = this.nodeValue.substr(from + length); 114 $(this).before(before).before(wrapTag.clone().text(middle)).before(after).remove(); 115 // Break out of the each loop 116 return false; 117 } else { 118 from -= this.nodeValue.length; 119 } 120 } 121 }); 122 } 123 124 function resetHighlights() { 125 $(".si-highlight").each(function() { 126 // This takes the element of the .si-highlight inner HTML and replaces the element with it 127 $(this).replaceWith($(this).html()); 128 }); 129 // We handle body tag highlight specificially, so we also need to remove it specificially from HTML element 130 if($("body").hasClass("si-full-highlight")) { 131 $("body").removeClass("si-full-highlight"); 132 } 133 } 134 135 function applyHighlights() { 136 var wrapTag = $("<span class='si-highlight'></span>"); 137 // Apply new highlights based on the information received 138 $.each(highlightInfo.highlights, function(index, highlight) { 139 var $element = $(highlight.selector); 140 if (highlight.offset) { 141 wrapTextNode($element[0], highlight.offset.start, highlight.offset.length, wrapTag); 142 } else { 143 if ($element.is('body')) { 144 // Add the class to the HTML tag instead, so we can have full height of the highlight 145 $element.addClass("si-full-highlight"); 146 } 147 else if ($element.is('img') || $element.children().is("img")) { 148 $element.wrap("<div class='si-highlight' style='padding: 5px;'></div>"); 149 } else { 150 $element.wrapInner("<span class='si-highlight'></span>"); 151 } 152 } 153 }); 154 } 155 156 resetHighlights(); 157 applyHighlights(); 158 // Scroll to the target element 159 $([document.documentElement, document.body]).stop().animate({ 160 scrollTop: $(".si-highlight").offset().top - $("#wpadminbar").height() 161 }, 1500); 105 _si.push(["applyDefaultHighlighting", highlightInfo, document, window]); 162 106 }]); 163 107 … … 171 115 // 1 = overlay-latest.js 172 116 if (this.version == 1 && this.is_content_page) { 173 _si.push(['registerPrepublishCallback', getDomCallback, this.token]); 174 } 175 117 var { has_api_key, prepublish_allowed, prepublish_enabled } = php_vars; 118 var cb = 119 Boolean(+has_api_key) && 120 Boolean(+prepublish_allowed) && 121 Boolean(+prepublish_enabled) 122 ? getDomCallback 123 : null 124 _si.push(['registerPrepublishCallback', cb, this.token]); 125 } 176 126 177 127 _si.push([this.method, this.url, this.token]); -
siteimprove/trunk/admin/partials/class-siteimprove-admin-settings.php
r3064701 r3325770 39 39 */ 40 40 public function register_section() { 41 $this->siteimprove_nonce = wp_create_nonce( 'siteimprove-options' ); 41 42 // Register settings for siteimprove plugin settings page. 42 43 register_setting( 'siteimprove', 'siteimprove_token' ); … … 108 109 109 110 // Register a new section in the siteimprove page. 110 if ( isset( $_GET['devmode'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'siteimprove-options' )) {111 if ( isset( $_GET['devmode'] ) ) { 111 112 add_settings_section( 112 113 'siteimprove_dev_mode_section', … … 151 152 'siteimprove' 152 153 ); 153 154 $this->siteimprove_nonce = wp_create_nonce( 'siteimprove_nonce' );155 154 } 156 155 … … 179 178 if ( 'siteimprove_prepublish' === $args['id'] ) { 180 179 $siteimprove_api_key = get_option( 'siteimprove_api_key', '' ); 181 $prepublish_allowed = intval( get_option( 'siteimprove_prepublish_allowed', 0 ) );182 $prepublish_enabled = intval( get_option( 'siteimprove_prepublish_enabled', 0 ) );180 $prepublish_allowed = intval( get_option( 'siteimprove_prepublish_allowed', 0 ) ); 181 $prepublish_enabled = intval( get_option( 'siteimprove_prepublish_enabled', 0 ) ); 183 182 if ( ! empty( $siteimprove_api_key ) ) { 184 183 if ( 1 === $prepublish_allowed ) { 185 184 ?> 186 <p>You can use Prepublish on your account.</p>187 <?php188 if ( 0 === $prepublish_enabled ) :189 ?>190 <p class="siteimprove_prepublish_activation_messages">191 <?php192 echo wp_kses(193 __( 'To enable prepublish for this website click <a href="#" id="siteimprove_enable_prepublish" class="button button-primary">here</a>', 'siteimprove' ),194 array(195 'a' => array(196 'href'=> array(),197 'id'=> array(),198 'class' => array(),199 ),200 )201 );202 ?>203 </p>204 <?php205 else :206 ?>207 <p>208 <?php209 echo wp_kses(210 __( 'Prepublish feature is already enabled for the current website. To use it please go to the preview of any page/post or content that you want to check and click the button <strong>Siteimprove Prepublish Check</strong> located on the top bar of the admin panel', 'siteimprove' ),211 array(212 'strong' => array(),213 )214 );215 ?>216 </p>217 <?php218 endif;185 <p>You can use Prepublish on your account.</p> 186 <?php 187 if ( 0 === $prepublish_enabled ) : 188 ?> 189 <p class="siteimprove_prepublish_activation_messages"> 190 <?php 191 echo wp_kses( 192 __( 'To enable prepublish for this website click <a href="#" id="siteimprove_enable_prepublish" class="button button-primary">here</a>', 'siteimprove' ), 193 array( 194 'a' => array( 195 'href' => array(), 196 'id' => array(), 197 'class' => array(), 198 ), 199 ) 200 ); 201 ?> 202 </p> 203 <?php 204 else : 205 ?> 206 <p> 207 <?php 208 echo wp_kses( 209 __( 'Prepublish feature is already enabled for the current website. To use it please go to the preview of any page/post or content that you want to check and click the button <strong>Siteimprove Prepublish Check</strong> located on the top bar of the admin panel', 'siteimprove' ), 210 array( 211 'strong' => array(), 212 ) 213 ); 214 ?> 215 </p> 216 <?php 217 endif; 219 218 } else { 220 219 ?> 221 <p>222 <?php223 esc_html_e( 'You can\'t use Prepublish on your account. Please contact sales team to enable this feature for the current website', 'siteimprove' );224 ?>225 </p>226 <?php220 <p> 221 <?php 222 esc_html_e( 'You can\'t use Prepublish on your account. Please contact sales team to enable this feature for the current website', 'siteimprove' ); 223 ?> 224 </p> 225 <?php 227 226 } 228 227 } else { 229 228 ?> 230 <p>231 <?php232 esc_html_e( 'Please provide a valid API Username and API Key before using this feature.', 'siteimprove' );233 ?>234 </p>235 <?php229 <p> 230 <?php 231 esc_html_e( 'Please provide a valid API Username and API Key before using this feature.', 'siteimprove' ); 232 ?> 233 </p> 234 <?php 236 235 } 237 236 } … … 239 238 if ( 'siteimprove_public_url' === $args['id'] ) { 240 239 ?> 241 <p>242 <?php243 esc_html_e( 'Please provide the Public URL for the current site if for any reasons it\'s not the same as the Admin Panel URL. Otherwise you can leave this field empty.' );244 ?>245 </p>246 <p>247 <?php248 esc_html_e( 'Example: Website Admin Panel is hosted at: http://stg-thewebsite.com but the final Public URL will be http://thewebsite.com', 'siteimprove' );249 ?>250 </p>251 <?php240 <p> 241 <?php 242 esc_html_e( 'Please provide the Public URL for the current site if for any reasons it\'s not the same as the Admin Panel URL. Otherwise you can leave this field empty.' ); 243 ?> 244 </p> 245 <p> 246 <?php 247 esc_html_e( 'Example: Website Admin Panel is hosted at: http://stg-thewebsite.com but the final Public URL will be http://thewebsite.com', 'siteimprove' ); 248 ?> 249 </p> 250 <?php 252 251 } 253 252 254 253 if ( 'siteimprove_version_section' === $args['id'] ) { 255 254 ?> 256 <p>257 <?php258 esc_html_e( 'A new version of the plugin is now available. Please note it is a work in progress and may update over time.' );259 ?>260 </p>261 <?php255 <p> 256 <?php 257 esc_html_e( 'A new version of the plugin is now available. Please note it is a work in progress and may update over time.' ); 258 ?> 259 </p> 260 <?php 262 261 } 263 262 } … … 278 277 } 279 278 ?> 280 <input type="checkbox" id="siteimprove_disable_new_version_field" name="siteimprove_disable_new_version" value='1' <?php echo esc_attr( $is_checked ); ?> />281 <?php279 <input type="checkbox" id="siteimprove_disable_new_version_field" name="siteimprove_disable_new_version" value='1' <?php echo esc_attr( $is_checked ); ?> /> 280 <?php 282 281 } 283 282 … … 291 290 ?> 292 291 293 <input type="text" id="siteimprove_token_field" name="siteimprove_token" value="<?php echo esc_attr( get_option( 'siteimprove_token' ) ); ?>" maxlength="50" size="50" />294 <input class="button" id="siteimprove_token_request" type="button" value="<?php echo esc_attr( __( 'Request new token', 'siteimprove' ) ); ?>" />295 <?php292 <input type="text" id="siteimprove_token_field" name="siteimprove_token" value="<?php echo esc_attr( get_option( 'siteimprove_token' ) ); ?>" maxlength="50" size="50" /> 293 <input class="button" id="siteimprove_token_request" type="button" value="<?php echo esc_attr( __( 'Request new token', 'siteimprove' ) ); ?>" /> 294 <?php 296 295 } 297 296 … … 304 303 public static function siteimprove_public_url_field( $args ) { 305 304 ?> 306 <input type="text" id="siteimprove_public_url_field" name="siteimprove_public_url" value="<?php echo esc_attr( get_option( 'siteimprove_public_url' ) ); ?>" size="50" />307 <?php305 <input type="text" id="siteimprove_public_url_field" name="siteimprove_public_url" value="<?php echo esc_attr( get_option( 'siteimprove_public_url' ) ); ?>" size="50" /> 306 <?php 308 307 } 309 308 … … 317 316 ?> 318 317 319 <input type="text" id="siteimprove_api_username_field" name="siteimprove_api_username" value="<?php echo esc_attr( get_option( 'siteimprove_api_username' ) ); ?>" maxlength="50" size="50" />320 <?php318 <input type="text" id="siteimprove_api_username_field" name="siteimprove_api_username" value="<?php echo esc_attr( get_option( 'siteimprove_api_username' ) ); ?>" maxlength="50" size="50" /> 319 <?php 321 320 } 322 321 … … 330 329 ?> 331 330 332 <input type="text" id="siteimprove_api_key_field" name="siteimprove_api_key" value="<?php echo esc_attr( get_option( 'siteimprove_api_key' ) ); ?>" maxlength="50" size="50" />333 <?php331 <input type="text" id="siteimprove_api_key_field" name="siteimprove_api_key" value="<?php echo esc_attr( get_option( 'siteimprove_api_key' ) ); ?>" maxlength="50" size="50" /> 332 <?php 334 333 } 335 334 … … 343 342 ?> 344 343 345 <input type="text" id="siteimprove_overlayjs_file_field" name="siteimprove_overlayjs_file" value="<?php echo esc_attr( get_option( 'siteimprove_overlayjs_file' ) ); ?>" size="50" />346 <?php344 <input type="text" id="siteimprove_overlayjs_file_field" name="siteimprove_overlayjs_file" value="<?php echo esc_attr( get_option( 'siteimprove_overlayjs_file' ) ); ?>" size="50" /> 345 <?php 347 346 } 348 347 … … 358 357 settings_errors( 'siteimprove_messages' ); 359 358 ?> 360 <div class="wrap">361 <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>362 <form action="options.php" method="post">363 <?php364 // Display settings fields.365 settings_fields( 'siteimprove' );366 do_settings_sections( 'siteimprove' );367 // Submit button.368 submit_button( __( 'Save Settings', 'siteimprove' ) );369 ?>370 </form>371 </div>372 <?php359 <div class="wrap"> 360 <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> 361 <form action="options.php" method="post"> 362 <?php 363 // Display settings fields. 364 settings_fields( 'siteimprove' ); 365 do_settings_sections( 'siteimprove' ); 366 // Submit button. 367 submit_button( __( 'Save Settings', 'siteimprove' ) ); 368 ?> 369 </form> 370 </div> 371 <?php 373 372 } 374 373 … … 412 411 isset( $_POST['siteimprove_api_username'], $_POST['siteimprove_api_key'], $_REQUEST['_wpnonce'] ) 413 412 && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'siteimprove-options' ) 414 ) {415 $username = sanitize_text_field( wp_unslash( $_POST['siteimprove_api_username'] ) );416 $key= sanitize_text_field( wp_unslash( $_POST['siteimprove_api_key'] ) );417 $result= self::check_credentials( $username, $key );413 ) { 414 $username = sanitize_text_field( wp_unslash( $_POST['siteimprove_api_username'] ) ); 415 $key = sanitize_text_field( wp_unslash( $_POST['siteimprove_api_key'] ) ); 416 $result = self::check_credentials( $username, $key ); 418 417 if ( 'false' === $result['status'] ) { 419 418 // return previous username when error is returned from checking both fields. … … 433 432 public static function validate_siteimprove_overlayjs_file( $value ) { 434 433 if ( ! empty( $value ) ) { 435 $old_value = get_option( 'siteimprove_overlayjs_file' );434 $old_value = get_option( 'siteimprove_overlayjs_file' ); 436 435 if ( ! preg_match( '/.+\..{2,}/', $value ) ) { 437 436 add_settings_error( 'siteimprove_messages', 'siteimprove_api_key_error', __( 'Overlay file not saved - Invalid format (please verify if name and extention are correct).', 'siteimprove' ) ); … … 443 442 isset( $_POST['siteimprove_overlayjs_file'], $_REQUEST['_wpnonce'] ) 444 443 && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'siteimprove-options' ) 445 ) {446 return $value;444 ) { 445 return $value; 447 446 } 448 447 } … … 469 468 } else { 470 469 /* 471 Now if API username and key are set, it's time to test both472 against the API endpoint to check if it's a valid user/key set473 and also if the keys correspond to the current website474 */470 Now if API username and key are set, it's time to test both 471 against the API endpoint to check if it's a valid user/key set 472 and also if the keys correspond to the current website 473 */ 475 474 if ( 476 isset( $_POST['siteimprove_api_username'], $_POST['siteimprove_api_key'], $_REQUEST['_wpnonce'] )477 && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'siteimprove-options' )475 isset( $_POST['siteimprove_api_username'], $_POST['siteimprove_api_key'], $_REQUEST['_wpnonce'] ) 476 && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'siteimprove-options' ) 478 477 ) { 479 478 $username = sanitize_text_field( wp_unslash( $_POST['siteimprove_api_username'] ) ); 480 $key = sanitize_text_field( wp_unslash( $_POST['siteimprove_api_key'] ) );481 $result = self::check_credentials( $username, $key );479 $key = sanitize_text_field( wp_unslash( $_POST['siteimprove_api_key'] ) ); 480 $result = self::check_credentials( $username, $key ); 482 481 if ( 'false' === $result['status'] ) { 483 482 add_settings_error( 'siteimprove_messages', 'siteimprove_api_credentials_error', $result['error'] ); … … 529 528 $params = array( 530 529 'httpversion' => '1.1', 531 'blocking' => true,532 'headers' => array(530 'blocking' => true, 531 'headers' => array( 533 532 'Authorization' => 'Basic ' . base64_encode( $username . ':' . $key ), 534 'sslverify' => false,533 'sslverify' => false, 535 534 ), 536 535 ); … … 562 561 $return = array( 563 562 'status' => 'false', 564 'error' => __( 'Unable to check API Credentials, please try again', 'siteimprove' ),563 'error' => __( 'Unable to check API Credentials, please try again', 'siteimprove' ), 565 564 ); 566 565 … … 576 575 577 576 if ( isset( $request['response'] ) && 200 === $request['response']['code'] ) { 578 $results = json_decode( $request['body'] );577 $results = json_decode( $request['body'] ); 579 578 $account_sites = $results->items; 580 579 … … 587 586 } 588 587 589 $domain = wp_parse_url( $site_url, PHP_URL_HOST );588 $domain = wp_parse_url( $site_url, PHP_URL_HOST ); 590 589 $site_found = false; 591 590 … … 627 626 } else { 628 627 /* 629 TODO: Figure out how to find if the feature is allowed but not enabled yet. For now we630 are considering that if there are no errors, then we can keep going and suppose it's631 then possibly allowed to be enabled by the user whenever he wishes to do so.632 */628 TODO: Figure out how to find if the feature is allowed but not enabled yet. For now we 629 are considering that if there are no errors, then we can keep going and suppose it's 630 then possibly allowed to be enabled by the user whenever he wishes to do so. 631 */ 633 632 update_option( 'siteimprove_prepublish_allowed', 1 ); 634 633 635 634 /* 636 Now we'll try to see if the prepublish feature is already enabled.637 If not, then we can show the user a button so he can enable it himself.638 */635 Now we'll try to see if the prepublish feature is already enabled. 636 If not, then we can show the user a button so he can enable it himself. 637 */ 639 638 $results = json_decode( $request['body'] ); 640 639 if ( isset( $results->is_ready ) && true === $results->is_ready ) { … … 653 652 public function prepublish_manual_activation() { 654 653 $siteimprove_api_username = get_option( 'siteimprove_api_username', '' ); 655 $siteimprove_api_key = get_option( 'siteimprove_api_key', '' );654 $siteimprove_api_key = get_option( 'siteimprove_api_key', '' ); 656 655 657 656 $return = array( 658 657 'message' => 'activation_triggered', 659 'result' => true,658 'result' => true, 660 659 ); 661 660 … … 678 677 public function check_prepublish_activation() { 679 678 $siteimprove_api_username = get_option( 'siteimprove_api_username', '' ); 680 $siteimprove_api_key = get_option( 'siteimprove_api_key', '' );679 $siteimprove_api_key = get_option( 'siteimprove_api_key', '' ); 681 680 682 681 $return = array( 683 682 'message' => 'enabled', 684 'result' => false,683 'result' => false, 685 684 ); 686 685 … … 703 702 return; 704 703 } 705 704 706 705 // Check if the nonce is set and is valid. 707 706 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'siteimprove-options' ) ) { … … 711 710 wp_die(); 712 711 } 713 712 714 713 wp_die(); 715 714 } -
siteimprove/trunk/includes/class-siteimprove.php
r3064701 r3325770 61 61 62 62 $this->plugin_name = 'siteimprove'; 63 $this->version = '2.0. 7';63 $this->version = '2.0.8'; 64 64 65 65 $this->load_dependencies(); -
siteimprove/trunk/readme.txt
r3064701 r3325770 3 3 Tags: accessibility, analytics, insights, spelling, seo 4 4 Requires at least: 4.7.2 5 Tested up to: 6. 4.36 Stable tag: 2.0. 75 Tested up to: 6.7.1 6 Stable tag: 2.0.8 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 86 86 87 87 == Changelog == 88 = 2.0.8 = 89 * Updated - "Tested up to" 90 * Bugfix - Fixed overlay live view not showing on home page 91 * Bugfix - Fixed overlay not showing in editor pages 92 88 93 = 2.0.7 = 89 94 * Change - Changed name of the plugin from "Siteimprove Plugin" to "Siteimprove" -
siteimprove/trunk/siteimprove.php
r3064701 r3325770 10 10 * Plugin URI: https://www.siteimprove.com/integrations/cms-plugin/wordpress/ 11 11 * Description: Integration with Siteimprove. 12 * Version: 2.0. 712 * Version: 2.0.8 13 13 * Author: Siteimprove 14 14 * Author URI: http://www.siteimprove.com/
Note: See TracChangeset
for help on using the changeset viewer.