Browse Source

Add user/group autocomplete

develop^2
Sam Black 1 year ago
parent
commit
0b6e86b075
Signed by: samwwwblack GPG Key ID: 0FF0223994EA47D8
  1. 12
      admin/class-bespokomatic-ebs-admin.php
  2. 1
      bespokomatic-ebs.php
  3. 3
      includes/booked/lib/Common/SmartyPage.php
  4. 4
      includes/booked/tpl/Admin/Resources/manage_resources.tpl
  5. 3
      includes/class-bespokomatic-ebs.php

12
admin/class-bespokomatic-ebs-admin.php

@ -231,6 +231,18 @@ class Bespokomatic_Ebs_Admin {
require_once plugin_dir_path( __FILE__ ) . 'partials/bespokomatic-ebs-admin-settings.php';
}
/**
* Admin AJAX autocomplete
*/
public function ajax_admin_autocomplete() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Pages/Ajax/AutoCompletePage.php';
$page = new AutoCompletePage();
$page->PageLoad();
wp_die();
}
/**
* Admin resources page
*

1
bespokomatic-ebs.php

@ -30,6 +30,7 @@ if ( ! defined( 'WPINC' ) ) {
}
define( 'BESPOKOMATIC_EBS_NAME', 'bespokomatic-ebs' );
define( 'BESPOKOMATIC_EBS_AJAX_PREFIX', 'bespokomatic_ebs' );
define( 'BESPOKOMATIC_EBS_VERSION', '0.1' );
define( 'BESPOKOMATIC_EBS_BOOKED_VERSION', '2.8.4' );
define( 'BESPOKOMATIC_EBS_BOOKED_MAJOR_VERSION', '2.8' );

3
includes/booked/lib/Common/SmartyPage.php

@ -78,6 +78,9 @@ class SmartyPage extends Smarty
$this->assign( 'WP_ADMIN_AJAX', admin_url('admin-ajax.php') );
$this->assign( 'WP_ADMIN_AJAX_PREFIX', '' );
// Autocomplete calls
$this->assign( 'WP_ADMIN_AJAX_AUTOCOMPLETE', admin_url('admin-ajax.php') . '?action=' . BESPOKOMATIC_EBS_AJAX_PREFIX . '_autocomplete&' );
$this->assign( 'WP_ADMIN_PAGE', $_GET['page'] );
// Insert our own template directory to override booked's if required
$this->AddTemplateDirectory(BESPOKOMATIC_EBS_TEMPLATES_DIR);

4
includes/booked/tpl/Admin/Resources/manage_resources.tpl

@ -1731,8 +1731,8 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
submitUrl: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}',
saveRedirect: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}',
actions: actions,
userAutocompleteUrl: "../ajax/autocomplete.php?type={AutoCompleteType::User}",
groupAutocompleteUrl: "../ajax/autocomplete.php?type={AutoCompleteType::Group}",
userAutocompleteUrl: "{$WP_ADMIN_AJAX_AUTOCOMPLETE|default:'../ajax/autocomplete.php?'}type={AutoCompleteType::User}",
groupAutocompleteUrl: "{$WP_ADMIN_AJAX_AUTOCOMPLETE|default:'../ajax/autocomplete.php?'}type={AutoCompleteType::Group}",
permissionsUrl: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}',
copyText: '{{translate key=Copy}|escape:"javascript"}'
};

3
includes/class-bespokomatic-ebs.php

@ -208,6 +208,9 @@ class Bespokomatic_Ebs {
// Add menu items.
$this->loader->add_action( 'admin_menu', $plugin_admin, 'admin_menu' );
// Admin autocomplete AJAX hook
$this->loader->add_action( 'wp_ajax_' . BESPOKOMATIC_EBS_AJAX_PREFIX . '_autocomplete', $plugin_admin, 'ajax_admin_autocomplete' );
// Admin resource post functions
foreach ( $plugin_admin->admin_resource_post_endpoints()->getConstants() as $key => $value ) {
$this->loader->add_action( 'admin_post_resource_' . $value, $plugin_admin, 'post_admin_resources' );

Loading…
Cancel
Save