16.1 Hiển thị popup chỉnh sửa (ok)

C:\xampp\htdocs\reset\wp-content\plugins\themify-wc-product-filter\admin\class-wpf-admin.php

add_action('wp_ajax_wpf_edit_ct',array($this,'add_template'));
public function add_template() {
    check_ajax_referer($this->plugin_name . '_edit', 'nonce', true);
    if (current_user_can('manage_options')) {
      if ($_REQUEST['action'] === 'wpf_edit_ct' && !empty($_REQUEST['slug'])) {
        global $cpt_id;
        $cpt_id = sanitize_key($_REQUEST['slug']);
      }
      include_once 'partials/form_ct.php';
    }
    wp_die();
  }

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

function column_title($item) {
    $page                = isset($_REQUEST['page']) ? $_REQUEST['page'] : 'wpf_search';
    static $nonce_edit   = null;
    static $nonce_delete = null;
    if (is_null($nonce_edit)) {
      $nonce_edit = wp_create_nonce($this->plugin_name . '_edit');
    }
    if (is_null($nonce_delete)) {
      $nonce_delete = wp_create_nonce($this->plugin_name . '_delete');
    }
    //Build row actions
    $actions = array(
      'edit'   => sprintf(
        '<a title="%1$s" href="%2$s" class="wpf_lightbox wpf_edit">%3$s</a>', sprintf(__('Edit Product Filter %s', 'wpf'), $item['name']), add_query_arg(array('action' => 'wpf_edit_ct', 'nonce' => $nonce_edit, 'slug' => $item['slug']), admin_url('admin-ajax.php')), __('Edit', 'wpf')
      ),
      'export' => sprintf(
        '<a title="%1$s" href="%2$s" class="wpf_export">%3$s</a>', sprintf(__('Export Product Filter %s', 'wpf'), $item['name']), add_query_arg(array('page' => $page, 'action' => 'wpf_export', 'slug' => $item['slug']), admin_url('admin.php')), __('Export', 'wpf')
      ),
      'delete' => sprintf(
        '<a title="%1$s" href="%2$s" class="wpf_delete">%3$s</a>', sprintf(__('Delete Product Filter %s', 'wpf'), $item['name']), add_query_arg(array('action' => 'wpf_delete', 'nonce' => $nonce_delete, 'slug' => $item['slug']), admin_url('admin-ajax.php')), __('Delete', 'wpf')
      ),
    );
    return sprintf('%1$s %2$s', $item['name'], $this->row_actions($actions)
    );
  }

Last updated