19.2 Hiển thị shortcode (ok)

C:\xampp\htdocs\test\wp-content\plugins\plugin-name\public\class-wpf-public_ct.php

<?php  
	class WPF_Public_CT {
		private $plugin_name;
		private $version;
		public static function get_instance() {
      static $instance = null;
      if ( $instance === null ) {
          $instance = new self;
      }
      return $instance;
    }
    private function __construct() {
    	$this->plugin_name = WPF_CT::get_instance()->get_plugin_name();
      $this->version = WPF_CT::get_instance()->get_version();
      add_shortcode( 'searchandfilter', array( $this, 'shortcode' ) );
    }
    public function shortcode( $atts ) {
      if ( empty( $atts['id'] ) ) {
        return;
      }
      $id = sanitize_text_field( $atts['id'] );
      $option = WPF_Options_CT::get_option( $this->plugin_name, $this->version );
      echo '<pre>';
        var_export($option);
      echo '</pre>';
    }
	}
?>

C:\xampp\htdocs\test\wp-content\plugins\plugin-name\includes\class-wpf_ct.php

public function get_version() {
    return self::$version;
  }

Last updated