organize the execution order of the action and add filter_type_helper in aggrs #349

This commit is contained in:
vnmedeiros 2020-02-06 10:22:46 -03:00
parent 6f859e24e2
commit 9843067b2b
3 changed files with 20 additions and 35 deletions

View File

@ -143,24 +143,7 @@ $Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Relationship
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Taxonomy');
//$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Compound');
//$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$Filter_Type_Helper = \Tainacan\Filter_Types\Filter_Type_Helper::get_instance();
do_action('tainacan-register-filter-type', 'register-type');
//register filter type
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Date');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Selectbox');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Autocomplete');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Taginput');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Checkbox');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyTaginput');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyCheckbox');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Date_Interval');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric_Interval');
// $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric_List_Interval');
//do_action('tainacan-register-filter-type', $Tainacan_Filters);
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();

View File

@ -42,6 +42,11 @@ class Filter_Type_Helper {
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyTaginput');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyCheckbox');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric_List_Interval');
do_action('tainacan-register-filter-type', $this);
}
public function register_filter_type_compoment() {
wp_enqueue_script($this->handle, $this->script_path);
}
/**
@ -51,18 +56,16 @@ class Filter_Type_Helper {
* @param string $class a class name of the filter type
* @param array|string $args
*/
public function register_filter_type($handle, $class_name, $script_path, $type='register-type', $args = []) {
public function register_filter_type($handle, $class_name, $script_path, $args = []) {
global $TAINACAN_EXTRA_FILTER_SCRIPTS;
if($type == 'register-type') {
$this->Tainacan_Filters->register_filter_type($class_name);
return;
}
$this->handle = $handle;
$this->script_path = $script_path;
if($type == 'register-script') {
$this->Tainacan_Filters->register_filter_type($class_name);
if ( ! in_array( $handle, $this->registered_filter_type ) ) {
$TAINACAN_EXTRA_FILTER_SCRIPTS[] = $handle;
wp_enqueue_script($handle, $script_path);
add_action( 'admin_enqueue_scripts', array( &$this, 'register_filter_type_compoment' ), 80 );
$this->registered_filter_type[$handle] = [
'handle' => $handle,
@ -71,7 +74,7 @@ class Filter_Type_Helper {
'args' => $args
];
}
}
}
/**

View File

@ -164,7 +164,6 @@ class Admin {
global $TAINACAN_BASE_URL;
global $TAINACAN_EXTRA_FILTER_SCRIPTS;
do_action('tainacan-register-filter-type', 'register-script');
$deps = ['underscore', 'media-editor', 'media-views', 'customize-controls'];
if ( !empty($TAINACAN_EXTRA_FILTER_SCRIPTS) ) {
foreach($TAINACAN_EXTRA_FILTER_SCRIPTS as $dep) {