From efc4882f77671d059d46117d4a5f8fd08a398c2d Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Wed, 15 May 2024 12:13:33 +0530 Subject: [PATCH 01/10] Fix Uncaught exception Error with message 'Call to undefined function add_action() `error.message` LIKE 'Uncaught exception 'Error' with message 'Call to undefined function add_action()' in /var/www/wp-content/plugins/hello.php:69%' AND `error.class` = 'Error' AND transactionUiName = '/wp-content/plugins/hello.php' 'request_uri': '/wp-content/plugins/hello.php' --- src/wp-content/plugins/hello.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/plugins/hello.php b/src/wp-content/plugins/hello.php index ff55908342290..dc870feed7cf6 100644 --- a/src/wp-content/plugins/hello.php +++ b/src/wp-content/plugins/hello.php @@ -11,7 +11,7 @@ Version: 1.7.2 Author URI: http://ma.tt/ */ - +if ( ! defined( 'ABSPATH' ) ) exit; function hello_dolly_get_lyric() { /** These are the lyrics to Hello Dolly */ $lyrics = "Hello, Dolly From 9c32016be12352ace93225991c3d2a41b5e23302 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Thu, 16 May 2024 18:05:15 +0530 Subject: [PATCH 02/10] Fix Hello Dolly : Uncaught exception 'Error' with message ' suggested changes Trac ticket: https://core.trac.wordpress.org/ticket/61214 --- src/wp-content/plugins/hello.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-content/plugins/hello.php b/src/wp-content/plugins/hello.php index dc870feed7cf6..45a08de2cedcd 100644 --- a/src/wp-content/plugins/hello.php +++ b/src/wp-content/plugins/hello.php @@ -11,7 +11,9 @@ Version: 1.7.2 Author URI: http://ma.tt/ */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} function hello_dolly_get_lyric() { /** These are the lyrics to Hello Dolly */ $lyrics = "Hello, Dolly From b542011b6fae94df3b909f9c7f7caed968ff2479 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Thu, 23 May 2024 11:52:18 +0530 Subject: [PATCH 03/10] PHP message: PHP Fatal error: Uncaught Error: Undefined constant "ABSPATH direct access to wp-includes/rss.php on line 19 https://core.trac.wordpress.org/ticket/61277 --- src/wp-includes/rss.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/rss.php b/src/wp-includes/rss.php index 4d3f35e5cb547..3b1c925154894 100644 --- a/src/wp-includes/rss.php +++ b/src/wp-includes/rss.php @@ -12,7 +12,9 @@ * @subpackage MagpieRSS * @deprecated 3.0.0 Use SimplePie instead. */ - +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} /** * Deprecated. Use SimplePie (class-simplepie.php) instead. */ From e9bfe06d1645388d148382f0c445165c3a39f622 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Thu, 23 May 2024 12:09:46 +0530 Subject: [PATCH 04/10] remove changes --- src/wp-includes/rss.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wp-includes/rss.php b/src/wp-includes/rss.php index 3b1c925154894..4d3f35e5cb547 100644 --- a/src/wp-includes/rss.php +++ b/src/wp-includes/rss.php @@ -12,9 +12,7 @@ * @subpackage MagpieRSS * @deprecated 3.0.0 Use SimplePie instead. */ -if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly -} + /** * Deprecated. Use SimplePie (class-simplepie.php) instead. */ From 0bb77bc67fd98daf756b66e9dc2fd0ebda1252f6 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Mon, 27 May 2024 15:29:53 +0530 Subject: [PATCH 05/10] Update hello.php --- src/wp-content/plugins/hello.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wp-content/plugins/hello.php b/src/wp-content/plugins/hello.php index 45a08de2cedcd..84b8c9bfceac9 100644 --- a/src/wp-content/plugins/hello.php +++ b/src/wp-content/plugins/hello.php @@ -11,9 +11,12 @@ Version: 1.7.2 Author URI: http://ma.tt/ */ + +// Don't load directly. if ( ! defined( 'ABSPATH' ) ) { - exit; + die( '-1' ); } + function hello_dolly_get_lyric() { /** These are the lyrics to Hello Dolly */ $lyrics = "Hello, Dolly From b4f367b58e0c627219bb27bbb9334c9d4ee55d95 Mon Sep 17 00:00:00 2001 From: deepakrohillas Date: Tue, 4 Jun 2024 22:04:35 +0530 Subject: [PATCH 06/10] If wp_attachment_pages_enabled is disable get_attachment_link should return attachment url --- src/wp-includes/link-template.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index dde12c16168be..711cd656396aa 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -479,6 +479,12 @@ function get_attachment_link( $post = null, $leavename = false ) { $parent_id = $post->post_parent; $parent = $parent_id ? get_post( $parent_id ) : false; $parent_valid = true; // Default for no parent. + + // If wp_attachment_pages_enabled is disable get_attachment_link should return attachment url + if ( ! get_option( 'wp_attachment_pages_enabled' ) && false === $parent ) { + return wp_get_attachment_url( $post->ID ); + } + if ( $parent_id && ( From 8c97e93ddd2f9404f51c14583d7e455138a9000a Mon Sep 17 00:00:00 2001 From: deepakrohillas Date: Tue, 4 Jun 2024 22:11:06 +0530 Subject: [PATCH 07/10] If wp_attachment_pages_enabled is disable get_attachment_link should return attachment url --- src/wp-content/plugins/hello.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/wp-content/plugins/hello.php b/src/wp-content/plugins/hello.php index 84b8c9bfceac9..ff55908342290 100644 --- a/src/wp-content/plugins/hello.php +++ b/src/wp-content/plugins/hello.php @@ -12,11 +12,6 @@ Author URI: http://ma.tt/ */ -// Don't load directly. -if ( ! defined( 'ABSPATH' ) ) { - die( '-1' ); -} - function hello_dolly_get_lyric() { /** These are the lyrics to Hello Dolly */ $lyrics = "Hello, Dolly From 319e75dbb299f42494f3d8d771d2e38b6a4f48dd Mon Sep 17 00:00:00 2001 From: deepakrohillas Date: Tue, 4 Jun 2024 22:13:25 +0530 Subject: [PATCH 08/10] If wp_attachment_pages_enabled is disable get_attachment_link should return attachment url --- src/wp-includes/link-template.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 711cd656396aa..5e7753b7070ec 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -479,12 +479,12 @@ function get_attachment_link( $post = null, $leavename = false ) { $parent_id = $post->post_parent; $parent = $parent_id ? get_post( $parent_id ) : false; $parent_valid = true; // Default for no parent. - - // If wp_attachment_pages_enabled is disable get_attachment_link should return attachment url + + // If wp_attachment_pages_enabled is disable get_attachment_link should return attachment url. if ( ! get_option( 'wp_attachment_pages_enabled' ) && false === $parent ) { return wp_get_attachment_url( $post->ID ); } - + if ( $parent_id && ( From 8fd31beef0de6a54f32cf479c1ac84e6a0837ded Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Thu, 27 Jun 2024 18:07:39 +0530 Subject: [PATCH 09/10] Update link-template.php suggested changes done --- src/wp-includes/link-template.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 5e7753b7070ec..baff235b1bf7e 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -474,17 +474,18 @@ function get_attachment_link( $post = null, $leavename = false ) { $link = false; - $post = get_post( $post ); - $force_plain_link = wp_force_plain_post_permalink( $post ); - $parent_id = $post->post_parent; - $parent = $parent_id ? get_post( $parent_id ) : false; - $parent_valid = true; // Default for no parent. + $post = get_post( $post ); // If wp_attachment_pages_enabled is disable get_attachment_link should return attachment url. - if ( ! get_option( 'wp_attachment_pages_enabled' ) && false === $parent ) { + if ( $post && '0' === get_option( 'wp_attachment_pages_enabled' ) ) { return wp_get_attachment_url( $post->ID ); } + $force_plain_link = wp_force_plain_post_permalink( $post ); + $parent_id = $post->post_parent; + $parent = $parent_id ? get_post( $parent_id ) : false; + $parent_valid = true; // Default for no parent. + if ( $parent_id && ( From 65471dd141efb6c297bca260a4f1d1ceefa828eb Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Thu, 27 Jun 2024 18:10:42 +0530 Subject: [PATCH 10/10] Update link-template.php formatting --- src/wp-includes/link-template.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index baff235b1bf7e..847e4eaffb3a2 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -473,7 +473,6 @@ function get_attachment_link( $post = null, $leavename = false ) { global $wp_rewrite; $link = false; - $post = get_post( $post ); // If wp_attachment_pages_enabled is disable get_attachment_link should return attachment url. @@ -485,7 +484,6 @@ function get_attachment_link( $post = null, $leavename = false ) { $parent_id = $post->post_parent; $parent = $parent_id ? get_post( $parent_id ) : false; $parent_valid = true; // Default for no parent. - if ( $parent_id && (