[wp-trac] [WordPress Trac] #56585: Fatal error when putting a code

WordPress Trac noreply at wordpress.org
Fri Sep 16 09:56:58 UTC 2022


#56585: Fatal error when putting a code
---------------------------+-----------------------------
 Reporter:  pristinenepal  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Themes         |    Version:  6.0.2
 Severity:  critical       |   Keywords:  has-screenshots
  Focuses:  javascript     |
---------------------------+-----------------------------
 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 at pristinenepal.com";
     $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> '. $_POST['trip_name'].'
 <br/>';
     $message .= '<label>Trip Amount:</label> '. $_POST['trip_amount'].'
 <br/>';
     $message .= '<label>Name:</label> '. $_POST['user_name'].' <br/>';
      $message .= '<label>Email:</label> '. $_POST['user_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
 /**
  * Travel Agency Pro functions and definitions
  *
  * @link https://developer.wordpress.org/themes/basics/theme-functions/
  *
  * @package Travel_Agency_Pro
  */

 $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';`

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56585>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list