@@ -80,7 +80,7 @@ function es_optimizer_init_settings() {
8080/**
8181 * Get default plugin options
8282 *
83- * @return array Default options
83+ * @return array Default options.
8484 */
8585function es_optimizer_get_default_options () {
8686 return array (
@@ -172,7 +172,7 @@ function es_optimizer_settings_page() {
172172/**
173173 * Render performance optimization options
174174 *
175- * @param array $options Plugin options
175+ * @param array $options Plugin options.
176176 */
177177function es_optimizer_render_performance_options ( $ options ) {
178178 // Emoji settings.
@@ -203,7 +203,7 @@ function es_optimizer_render_performance_options( $options ) {
203203/**
204204 * Render header cleanup options
205205 *
206- * @param array $options Plugin options
206+ * @param array $options Plugin options.
207207 */
208208function es_optimizer_render_header_options ( $ options ) {
209209 // WordPress Version settings.
@@ -242,7 +242,7 @@ function es_optimizer_render_header_options( $options ) {
242242/**
243243 * Render additional optimization options
244244 *
245- * @param array $options Plugin options
245+ * @param array $options Plugin options.
246246 */
247247function es_optimizer_render_additional_options ( $ options ) {
248248 // DNS Prefetch settings.
@@ -278,10 +278,10 @@ function es_optimizer_render_additional_options( $options ) {
278278 * - Attribute values are escaped with esc_attr()
279279 * - WordPress checked() function is used for checkbox state
280280 *
281- * @param array $options Plugin options
282- * @param string $option_name Option name
283- * @param string $title Option title
284- * @param string $description Option description
281+ * @param array $options Plugin options.
282+ * @param string $option_name Option name.
283+ * @param string $title Option title.
284+ * @param string $description Option description.
285285 */
286286function es_optimizer_render_checkbox_option ( $ options , $ option_name , $ title , $ description ) {
287287 ?>
@@ -320,10 +320,10 @@ function es_optimizer_render_checkbox_option( $options, $option_name, $title, $d
320320 * - Attribute values are escaped with esc_attr()
321321 * - Textarea content is escaped with esc_textarea()
322322 *
323- * @param array $options Plugin options
324- * @param string $option_name Option name
325- * @param string $title Option title
326- * @param string $description Option description
323+ * @param array $options Plugin options.
324+ * @param string $option_name Option name.
325+ * @param string $title Option title.
326+ * @param string $description Option description.
327327 */
328328function es_optimizer_render_textarea_option ( $ options , $ option_name , $ title , $ description ) {
329329 ?>
@@ -373,8 +373,8 @@ function es_optimizer_render_textarea_option( $options, $option_name, $title, $d
373373 * - URL validation via filter_var()
374374 * - Sanitization via esc_url_raw()
375375 *
376- * @param array $input User submitted options
377- * @return array Validated and sanitized options
376+ * @param array $input User submitted options.
377+ * @return array Validated and sanitized options.
378378 */
379379function es_optimizer_validate_options ( $ input ) {
380380 // Security: Verify nonce for CSRF protection when using WordPress Settings API.
@@ -400,9 +400,15 @@ function es_optimizer_validate_options( $input ) {
400400
401401 // Validate checkboxes (0 or 1).
402402 $ checkboxes = array (
403- 'disable_emojis ' , 'remove_jquery_migrate ' , 'disable_classic_theme_styles ' ,
404- 'remove_wp_version ' , 'remove_wlw_manifest ' , 'remove_shortlink ' ,
405- 'remove_recent_comments_style ' , 'enable_dns_prefetch ' , 'disable_jetpack_ads ' ,
403+ 'disable_emojis ' ,
404+ 'remove_jquery_migrate ' ,
405+ 'disable_classic_theme_styles ' ,
406+ 'remove_wp_version ' ,
407+ 'remove_wlw_manifest ' ,
408+ 'remove_shortlink ' ,
409+ 'remove_recent_comments_style ' ,
410+ 'enable_dns_prefetch ' ,
411+ 'disable_jetpack_ads ' ,
406412 );
407413
408414 foreach ( $ checkboxes as $ checkbox ) {
@@ -420,13 +426,13 @@ function es_optimizer_validate_options( $input ) {
420426/**
421427 * Validate DNS prefetch domains with enhanced security
422428 *
423- * @param string $domains_input Raw domain input from user
424- * @return string Validated and sanitized domains
429+ * @param string $domains_input Raw domain input from user.
430+ * @return string Validated and sanitized domains.
425431 */
426432function es_optimizer_validate_dns_domains ( $ domains_input ) {
427- $ domains = explode ( "\n" , trim ( $ domains_input ) );
433+ $ domains = explode ( "\n" , trim ( $ domains_input ) );
428434 $ sanitized_domains = array ();
429- $ rejected_domains = array ();
435+ $ rejected_domains = array ();
430436
431437 foreach ( $ domains as $ domain ) {
432438 $ domain = trim ( $ domain );
@@ -454,7 +460,7 @@ function es_optimizer_validate_dns_domains( $domains_input ) {
454460/**
455461 * Validate a single DNS prefetch domain
456462 *
457- * @param string $domain Domain to validate
463+ * @param string $domain Domain to validate.
458464 * @return array Validation result with 'valid' boolean and 'domain' or 'error'
459465 */
460466function es_optimizer_validate_single_domain ( $ domain ) {
@@ -488,7 +494,7 @@ function es_optimizer_validate_single_domain( $domain ) {
488494 $ host = $ parsed_url ['host ' ];
489495
490496 // Prevent localhost and private IP ranges for security.
491- $ is_local = in_array ( $ host , array ( 'localhost ' , '127.0.0.1 ' , '::1 ' ) );
497+ $ is_local = in_array ( $ host , array ( 'localhost ' , '127.0.0.1 ' , '::1 ' ), true );
492498 $ is_private_ip = false !== filter_var ( $ host , FILTER_VALIDATE_IP , FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE );
493499
494500 if ( $ is_local || ! $ is_private_ip ) {
@@ -508,11 +514,11 @@ function es_optimizer_validate_single_domain( $domain ) {
508514/**
509515 * Show admin notice for rejected domains
510516 *
511- * @param array $rejected_domains Array of rejected domain strings
517+ * @param array $rejected_domains Array of rejected domain strings.
512518 */
513519function es_optimizer_show_domain_rejection_notice ( $ rejected_domains ) {
514520 // Security: Properly escape and limit the rejected domains in error messages.
515- $ escaped_domains = array_map ( 'esc_html ' , array_slice ( $ rejected_domains , 0 , 3 ) );
521+ $ escaped_domains = array_map ( 'esc_html ' , array_slice ( $ rejected_domains , 0 , 3 ) );
516522 $ rejected_message = implode ( ', ' , $ escaped_domains );
517523
518524 if ( count ( $ rejected_domains ) > 3 ) {
@@ -575,8 +581,8 @@ function disable_emojis() {
575581/**
576582 * Add settings link to plugins page
577583 *
578- * @param array $links Plugin action links
579- * @return array Modified plugin action links
584+ * @param array $links Plugin action links.
585+ * @return array Modified plugin action links.
580586 */
581587function es_optimizer_add_settings_link ( $ links ) {
582588 // The admin_url function is used to properly generate a URL within the WordPress admin area.
@@ -586,14 +592,14 @@ function es_optimizer_add_settings_link( $links ) {
586592 array_unshift ( $ links , $ settings_link );
587593 return $ links ;
588594}
589- $ plugin = plugin_basename ( __FILE__ );
590- add_filter ( "plugin_action_links_ $ plugin " , 'es_optimizer_add_settings_link ' );
595+ $ plugin_basename = plugin_basename ( __FILE__ );
596+ add_filter ( "plugin_action_links_ { $ plugin_basename } " , 'es_optimizer_add_settings_link ' );
591597
592598/**
593599 * Filter function used to remove the tinymce emoji plugin.
594600 *
595- * @param array $plugins
596- * @return array Difference betwen the two arrays
601+ * @param array $plugins Array of TinyMCE plugins.
602+ * @return array Difference betwen the two arrays.
597603 */
598604function disable_emojis_tinymce ( $ plugins ) {
599605 if ( ! is_array ( $ plugins ) ) {
@@ -612,7 +618,7 @@ function disable_emojis_tinymce( $plugins ) {
612618function disable_emojis_remove_dns_prefetch ( $ urls , $ relation_type ) {
613619 if ( 'dns-prefetch ' === $ relation_type ) {
614620 $ emoji_svg_url = apply_filters ( 'emoji_svg_url ' , 'https://s.w.org/images/core/emoji/2/svg/ ' );
615- $ urls = array_diff ( $ urls , array ( $ emoji_svg_url ) );
621+ $ urls = array_diff ( $ urls , array ( $ emoji_svg_url ) );
616622 }
617623 return $ urls ;
618624}
@@ -624,7 +630,7 @@ function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
624630 * Modern themes and plugins generally don't need it, so removing it improves load time.
625631 *
626632 * @since 1.0.0
627- * @param WP_Scripts $scripts WP_Scripts object
633+ * @param WP_Scripts $scripts WP_Scripts object.
628634 */
629635function remove_jquery_migrate ( $ scripts ) {
630636 $ options = get_option ( 'es_optimizer_options ' );
@@ -662,7 +668,7 @@ function disable_classic_theme_styles() {
662668add_action ( 'wp_enqueue_scripts ' , 'disable_classic_theme_styles ' , 100 );
663669
664670/**
665- * Remove WordPress version, WLW manifest, and shortlink
671+ * Remove WordPress version, WLW manifest, and shortlink.
666672 */
667673function remove_header_items () {
668674 $ options = get_option ( 'es_optimizer_options ' );
@@ -685,7 +691,7 @@ function remove_header_items() {
685691add_action ( 'init ' , 'remove_header_items ' );
686692
687693/**
688- * Remove Recent Comments Widget CSS Styles
694+ * Remove Recent Comments Widget CSS Styles.
689695 */
690696function remove_recent_comments_style () {
691697 $ options = get_option ( 'es_optimizer_options ' );
@@ -698,7 +704,7 @@ function remove_recent_comments_style() {
698704add_action ( 'init ' , 'remove_recent_comments_style ' );
699705
700706/**
701- * Add DNS prefetching for common external domains
707+ * Add DNS prefetching for common external domains.
702708 *
703709 * DNS prefetching can reduce latency when connecting to common external services.
704710 * This is particularly helpful for sites using Google Fonts, Analytics, etc.
@@ -753,7 +759,7 @@ function add_dns_prefetch() {
753759add_action ( 'wp_head ' , 'add_dns_prefetch ' , 0 );
754760
755761/**
756- * Disable Jetpack advertisements
762+ * Disable Jetpack advertisements.
757763 */
758764function disable_jetpack_ads () {
759765 $ options = get_option ( 'es_optimizer_options ' );
0 commit comments