Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#56585 closed defect (bug) (invalid)

Fatal error when putting a code

Reported by: pristinenepal's profile pristinenepal Owned by:
Milestone: Priority: normal
Severity: critical Version: 6.0.2
Component: Themes Keywords:
Focuses: Cc:

Description

Fatal error: Uncaught Error: Call to a member function get_page_permastruct() on null in /home/pristin1/public_html/1663262559598/wp-includes/link-template.php:430 Stack trace: #0 /home/pristin1/public_html/1663262559598/wp-includes/link-template.php(392): _get_page_link(Object(WP_Post), false, false) #1 /home/pristin1/public_html/1663262559598/wp-includes/link-template.php(197): get_page_link(Object(WP_Post), false, false) #2 /home/pristin1/public_html/1663262559598/wp-content/plugins/my-custom-functions/inc/php/functional.php(103) : eval()'d code(59): get_permalink(Object(WP_Post)) #3 /home/pristin1/public_html/1663262559598/wp-content/plugins/my-custom-functions/inc/php/functional.php(103): eval() #4 /home/pristin1/public_html/1663262559598/wp-content/plugins/my-custom-functions/inc/php/functional.php(114): spacexchimp_p001_exec() #5 /home/pristin1/public_html/1663262559598/wp-content/plugins/my-custom-functions/my-custom-functions.php(103): require_once('/home/pristin1/...') #6 /home/pristin1/public_html/1663262559598/wp-settings.php(428): include_once('/home/pristin1/...') #7 /home/pristin1/public_html/1663262559598/wp-config.php(92): require_once('/home/pristin1/...') #8 /home/pristin1/public_html/1663262559598/wp-load.php(50): require_once('/home/pristin1/...') #9 /home/pristin1/public_html/1663262559598/wp-admin/admin.php(34): require_once('/home/pristin1/...') #10 /home/pristin1/public_html/1663262559598/wp-admin/options-general.php(10): require_once('/home/pristin1/...') #11 {main} thrown in /home/pristin1/public_html/1663262559598/wp-includes/link-template.php on line 430

The above error is from the stagging theme. I am trying to put a code through my function.php plugin. The code that I put in the my function php plugin is below.

`<?php

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {

wp_enqueue_style( 'travel-agency-style', get_template_directory_uri() . '/style.css' );

wp_enqueue_style( 'travel-agency-child-style'

, get_stylesheet_directory_uri() . '/child-style.css'
, array('travel-agency-style') declare the dependency

in order to load child-style after parent-style

);

}

add_action( 'wp_ajax_payment_notification', 'payment_notification' );

add_action( 'wp_ajax_nopriv_payment_notification', 'payment_notification' );
function payment_notification(){

$admin_email = "info@…";

$subject = "Online Payment Being Processed";

$message = '<!DOCTYPE html><html><head><title>Online Payment Being Processed</title>

</head>
<body>

You have new trip booked message, <br/>';

$message .= '<label>Trip Name:</label> '. $_POSTtrip_name?.' <br/>';
$message .= '<label>Trip Amount:</label> '. $_POSTtrip_amount?.' <br/>';
$message .= '<label>Name:</label> '. $_POSTuser_name?.' <br/>';

$message .= '<label>Email:</label> '. $_POSTuser_email?.' <br/>';

$message .= '</body></html>';


send_wp_email($admin_email, $subject, $message );

wp_die();

}


function send_wp_email($to, $subject, $message) {

$headers = array('Content-Type: text/html; charset=UTF-8');

wp_mail($to,$subject,$message, $headers);

}


Remove "Wordpress" when receiving email
function remove_from_wordpress($email){
$wpfrom = get_option('blogname');
return $wpfrom;
}
add_filter('wp_mail_from_name', 'remove_from_wordpress');

function travel_agency_pro_header_phone( $fifth = true ){

$phone = get_theme_mod( 'phone', ( '(888) 123-45678', 'travel-agency-pro' ) );
$phone_label = get_theme_mod( 'phone_label',
( 'Call us, we are open 24/7', 'travel-agency-pro' ) );


if( $fifth && $phone ){

echo '<a href="' . esc_url( 'tel:' . preg_replace( '/[\d+]/', , $phone ) ) . '" class="tel-link"><i class="fa fa-phone"></i><span class="phone">' . esc_html( travel_agency_pro_get_header_phone() ) . '</span></a>';

}elseif( !$fifth && ( $phone_label
$phone ) ){

echo '<div class="right">';
if( $phone_label ) echo '<span class="phone-label">' . esc_html( travel_agency_pro_get_phone_label() ) . '</span>';
if( $phone ) echo '<a href="' . esc_url( 'tel:' . preg_replace( '/[\d+]/', , $phone ) ) . '" class="tel-link"><span class="phone">' . esc_html( travel_agency_pro_get_header_phone() ) . '</span></a>';
echo '</div>';

}

added
echo '<div class="right yh-right yh-from-child-themes">

<a href="' . esc_url( get_permalink( get_page_by_title( 'Online Payment' ) ) ) . '">
<img src="'. get_stylesheet_directory_uri().'/images/payment-hbl.jpg' . '">
</a>

</div>';

}

require_once get_stylesheet_directory() . '/yh-hooks.php';`

Also the other php files i uploaded in the wp-content/themes/travel-agency-pro are content-online.php, online_payment.php, yt.hooks.php

Before, the code was working fine but after I update my travel-agency-pro theme the problem occured. The functions.php of Travel agency pro theme is:

`<?php
/

$theme_data = wp_get_theme();
if( ! defined( 'TRAVEL_AGENCY_PRO_THEME_VERSION' ) ) define( 'TRAVEL_AGENCY_PRO_THEME_VERSION', $theme_data->get( 'Version' ) );
if( ! defined( 'TRAVEL_AGENCY_PRO_THEME_NAME' ) ) define( 'TRAVEL_AGENCY_PRO_THEME_NAME', $theme_data->get( 'Name' ) );

/

  • Custom Post Type */

require get_template_directory() . '/inc/cpt/cpt.php';

/

  • Metabox */

require get_template_directory() . '/inc/cpt/metabox.php';

/

  • Custom functions that act independently of the theme templates. */

require get_template_directory() . '/inc/extras.php';

/

  • Custom functions for selective refresh. */

require get_template_directory() . '/inc/partials.php';

/

  • Custom Functions */

require get_template_directory() . '/inc/custom-functions.php';

/

  • Template Functions */

require get_template_directory() . '/inc/template-functions.php';

/

  • Template Functions */

require get_template_directory() . '/inc/performance.php';

/

  • Fontawesome */

require get_template_directory() . '/inc/fontawesome.php';

/

  • Custom Controls

*/
require get_template_directory() . '/inc/custom-controls/custom-control.php';

/

  • Customizer additions. */

require get_template_directory() . '/inc/customizer/customizer.php';

/

  • Widgets */

require get_template_directory() . '/inc/widgets.php';

/

  • Social Sharing */

require get_template_directory() . '/inc/social-sharing.php';

/

  • Getting Started

*/
require get_template_directory() . '/inc/getting-started/getting-started.php';

/

  • Plugin Recommendation

*/
require get_template_directory() . '/inc/tgmpa/recommended-plugins.php';

/

  • Typography Functions */

require get_template_directory() . '/inc/typography/typography.php';

/

  • Dynamic Styles */

require get_template_directory() . '/css/style.php';

/

  • Add theme compatibility function for woocommerce if active

*/
if( is_woocommerce_activated() )
require get_template_directory() . '/inc/woocommerce-functions.php';

/

  • Demo Import

*/
require get_template_directory() . '/inc/import-hooks.php';

/

  • Theme Updater

*/
require get_template_directory() . '/updater/theme-updater.php';`

Attachments (1)

functions.php (3.1 KB) - added by pristinenepal 2 years ago.
this is the file i put in my functions.php plugin

Download all attachments as: .zip

Change History (3)

@pristinenepal
2 years ago

this is the file i put in my functions.php plugin

#1 @ironprogrammer
2 years ago

  • Focuses javascript removed
  • Keywords has-screenshots removed
  • Resolution set to invalid
  • Status changed from new to closed

Hi, @pristinenepal, welcome to WordPress Trac!

I'm sorry you're having issues updating your website. Please note that Core Trac is used for enhancements and bug reports for the WordPress core software, not individual support issues or questions.

Please check out the dedicated support forums for help with your site: https://wordpress.org/support/forums/.

#2 @desrosj
2 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.