2. Hiển thị shortcode to front-end (ok)

C:\xampp\htdocs\wptest\wp-content\plugins\pointfindercoreelements\pointfindercoreelements.php

<?php

/**
 * Plugin Name:       PointFinder Core Elements
 * Plugin URI:        https://themeforest.net/user/webbu/portfolio
 * Description:       PointFinder theme core elements plugin.
 * Version:           1.1.8
 * Author:            Webbu
 * Author URI:        https://themeforest.net/user/webbu
 * License:           Themeforest Split License
 * License URI:       https://themeforest.net/licenses/terms/regular
 * Text Domain:       pointfindercoreelements
 * Domain Path:       /languages
 */
if (!defined('WPINC')) {
  die;
}
define('PFCOREPLUGIN_NAME_VERSION', '1.1.8');
define('PFCOREELEMENTSDIR', plugin_dir_path(__FILE__));
define('PFCOREELEMENTSURL', plugin_dir_url(__FILE__));
define('PFCOREELEMENTSURLADMIN', plugin_dir_url(__FILE__) . 'admin/');
define('PFCOREELEMENTSURLPUBLIC', plugin_dir_url(__FILE__) . 'public/');
define('PFCOREELEMENTSURLINC', plugin_dir_url(__FILE__) . 'includes/');
require PFCOREELEMENTSDIR . 'includes/traits/options.php';
require PFCOREELEMENTSDIR . 'includes/class-pointfindercoreelements.php';
$plugin = new Pointfindercoreelements();
$plugin->run();

C:\xampp\htdocs\wptest\wp-content\plugins\pointfindercoreelements\includes\class-pointfindercoreelements.php

<?php
class Pointfindercoreelements {
  protected $loader;
  protected $plugin_name;
  protected $version;
  private $post_type_name;
  private $agent_post_type_name;
  public function __construct() {
    $this->version              = '1.0.0';
    $this->plugin_name          = 'pointfindercoreelements';
    $this->post_type_name       = 'pfitemfinder';
    $this->agent_post_type_name = 'agents';
    $this->load_dependencies();
  }
  private function load_dependencies() {
    require_once PFCOREELEMENTSDIR . 'admin/fields/pfgetsearchfields.php';
    require_once PFCOREELEMENTSDIR . 'includes/customshortcodes/pf-search.php';
    require_once PFCOREELEMENTSDIR . 'includes/class-pointfindercoreelements-loader.php';
    $this->loader = new Pointfindercoreelements_Loader();
  }
  public function run() {
    $this->loader->run();
  }
}
?>

C:\xampp\htdocs\wptest\wp-content\plugins\pointfindercoreelements\includes\class-pointfindercoreelements-loader.php

<?php
class Pointfindercoreelements_Loader {
  protected $actions;
  public function __construct() {
    $this->actions = array();
  }
  public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1) {
    $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
  }
  private function add($hooks, $hook, $component, $callback, $priority, $accepted_args) {
    $hooks[] = array(
      'hook'          => $hook,
      'component'     => $component,
      'callback'      => $callback,
      'priority'      => $priority,
      'accepted_args' => $accepted_args,
    );
    return $hooks;
  }
  public function run() {
    foreach ($this->actions as $hook) {
      add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']);
    }
  }
}

Last updated