title: Changed hooks from constructor to init in wordpress plugin class - Not working any more
body: <p>In the previous version ( >5 ) of WordPress the plugin was working correctly. When I transferred it to an updated WordPress (v5.xx) website. </p>
  
  <p>It was giving me an error "visaBooking class does not have init method".</p>
  
  <p>I changed the hooks initialization to init() from _construct(). Now the error is gone but the shortcodes are not working anymore?</p>
  
  <pre><code>function visaBooking() { 
      return visaBooking::instance();
  }
  
  add_action( 'plugins_loaded', 'visaBooking' );
  
  
  
  class visaBooking{
  
  
  
      private static $_instance = null;
  
      private $categories = array();
  
      private $pricing   = array();
  
      private $discount  = array();
  
      private $insurance = array();
  
      private $pricingDetails = array();
  
  
  
      public static function instance() {
  
          if ( is_null( self::$_instance ) )
  
              self::$_instance = new self();
  
          return self::$_instance;
  
      } // End instance()
  
  
  
      public function __construct(){
  
  
  
          # Read countries json file 
  
          $countriesFile = plugin_dir_url( __FILE__ ).'countries.json';
  
          $countriesFileResponse = wp_remote_get( $countriesFile );
  
          $countriesFileBody = json_decode( $countriesFileResponse['body'] , true );
  
  
  
          if( $this-&gt;isJson( $countriesFileResponse['body'] ) ){
  
              $categories = json_decode( $countriesFileResponse['body'] , true );
  
              if( !empty( $categories ) ){
  
                  foreach( $categories as $category ){
  
                      switch( $category['Price Type'] ){
  
                          case 'Medium':
  
                              $newCategory['medium'][] = $category['Country Codes'];
  
                          break;
  
  
  
                          case 'Expensive':
  
                              $newCategory['expensive'][] = $category['Country Codes'];
  
                          break;
  
  
  
                          case 'Cheaper':
  
                              $newCategory['cheaper'][] = $category['Country Codes'];
  
                          break;
  
                      }
  
                  }
  
                  $this-&gt;categories = $newCategory;
  
              }   
  
          }
  
  
  
          # Read services json file 
  
          $file = plugin_dir_url( __FILE__ ).'config.json';
  
          $response = wp_remote_get( $file );
  
          #$body = json_decode( $response['body'] , true );
  
          if( $this-&gt;isJson( $response['body'] ) ){
  
              $this-&gt;pricing = json_decode( $response['body'] , true );
  
          } 
      }
  
      public function init () {
  
  
          add_action( 'template_redirect', array( $this, 'initialization' ) );
  
  
  
          # Get price shortcode
  
          add_shortcode( 'visa-booking-price' , array( $this, 'visaBookingPrice' ) );
  
  
  
          # Get form shortcode
  
          add_shortcode( 'visa-booking-form' , array( $this, 'visaBookingForm' ) );
  
  
  
          add_filter( 'gform_pre_render', array( $this, 'modifyPricing' ) );
  
  
  
          add_action( 'wp_enqueue_scripts', array( $this, 'enqueueScript') );
  
  
  
          add_action('wp_head', array( $this, 'enqueueJs') );
  
  
  
          add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
  
  
  
          add_filter('gform_replace_merge_tags', array( $this, 'replace_merge_tag_code' ), 10, 7);
  
  
  
          add_action( 'gform_admin_pre_render', array( $this, 'add_merge_tags' ) );
  
  
  
          add_filter( 'gform_shortcode_conditional', array( $this, 'gform_shortcode_conditional_custom' ), 10, 3 );
  
  
  
          add_shortcode('page_number', function(){
  
              return $_POST['page_number'];
  
          });
  
  
  
          add_filter( 'gform_confirmation', array( $this, 'hide_boxed' ), 10, 4 );
  
  
  
  
  
          add_shortcode('template_header', function($args){
  
              ob_start();
  
              include( plugin_dir_path( __FILE__ )."email-templates/header.php");
  
              $text = ob_get_clean();
  
              return do_shortcode($text);
  
          });
  
  
  
          add_shortcode('order_details', function($args){
  
  
  
              $temp = array(
  
                  'form_id'  =&gt; 1,
  
                  'entry_id' =&gt; 1,
  
                  'isadmin'  =&gt; 'false'
  
              );
  
  
  
              $args = array_merge( $temp, $args );
  
  
  
              ob_start();
  
  
  
              switch($args['type']){
  
                  case 'flight';
  
                      include( plugin_dir_path( __FILE__ )."email-templates/flight-order-details.php");
  
                  break;
  
  
  
                  case 'hotel';
  
                      include( plugin_dir_path( __FILE__ )."email-templates/hotel-order-details.php");
  
                  break;
  
  
  
                  case 'flight-hotel';
  
                      include( plugin_dir_path( __FILE__ )."email-templates/flight-hotel-order-details.php");
  
                  break;
  
  
  
                  case 'flight-hotel-insurance';
  
                      include( plugin_dir_path( __FILE__ )."email-templates/flight-hotel-insurance-order-details.php");
  
                  break;
  
  
  
                  case 'insurance';
  
                      include( plugin_dir_path( __FILE__ )."email-templates/insurance-order-details.php");
  
                  break;
  
              }
  
  
  
              $entry = GFAPI::get_entry( $args['entry_id'] );
  
              $form = GFAPI::get_form( $args['form_id'] );
  
  
  
              $text = ob_get_clean();
  
              $text = GFCommon::replace_variables( $text, $form, $entry, false, false, false, 'html' );
  
              return do_shortcode($text);
  
  
  
          });
  
  
  
          add_shortcode('template_footer', function($args){
  
              ob_start();
  
              include( plugin_dir_path( __FILE__ )."email-templates/footer.php");
  
              $text = ob_get_clean();
  
              return do_shortcode($text);
  
          });
      }
  </code></pre>
  
  <p>I thought it would run smoothly now but as mentioned above now the short code is not working.</p>