Adding custom meta filter to Advanced Post Manager results in two metaboxes.

Home Forums Calendar Products Events Calendar PRO Adding custom meta filter to Advanced Post Manager results in two metaboxes.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #996783
    integrity
    Participant

    I’m running the The Event Calendar, The Event Calendar Pro and the Advanced Post Manager all at version 3.10. (We rolled back to 3.10 because of some community events problems.) These are the only three plugins currently activated. I added the following snippet of code to my functions.php file in order to add a new filter/column to the backend Events page:

    add_action('init', 'setup_cpt_filters');
    function setup_cpt_filters() {
    	global $my_cpt_filters;
    	$filter_array = array(
    	  'my_meta_filter_key' => array(
    	      'name' => 'Funded by XYZ',
    	      'meta' => '_ecp_custom_2'
    	  )
    	);
    	$my_cpt_filters = tribe_setup_apm('tribe_events', $filter_array);
    }

    This resulted in two metaboxes with the same id (“tribe-filters”) appearing on the backend Events page. Both metaboxes are partially broken. One of them can successfully add filters (the other does nothing when you select a filter from the dropdown). This one’s dropdown only includes my custom filter, “Event Categories” and “Tags.” The other can successfully add columns (the other does nothing when you select a column from the dropdown and the column options cannot be dragged and reordered). My custom filter appears as a column in both metaboxes.

    Clicking “Apply” works on both metaboxes.

    If I changed my code snippet to specific a non-default metabox, the same problem occurs.

    add_action('init', 'setup_cpt_filters');
    function setup_cpt_filters() {
    	global $my_cpt_filters;
    	$filter_array = array(
    	  'my_meta_filter_key' => array(
    	      'name' => 'Funded by XYZ',
    	      'meta' => '_ecp_custom_2',
    	      'metabox' => 'unique_box'
    	  )
    	);
    
    	$metaboxes = array( 'unique_box' => 'A Unique Box');
    	$my_cpt_filters = tribe_setup_apm('tribe_events', $filter_array, $metaboxes);
    }

    Album of images of the issue: http://imgur.com/a/1jPvs

    Two metaboxes
    Filter options for metabox 1.
    Column options for metabox 1.
    Filter options for metabox 2.
    Column options for metabox 2.
    Trying to set filters and add/remove columns.
    Clicked apply on metabox 1.
    Clicked apply on metabox 2.

    Is this a bug? User error? Ghosts?

    • This topic was modified 10 years, 8 months ago by integrity.
    • This topic was modified 10 years, 8 months ago by integrity.
    #996967
    Barry
    Member

    Hi @integrity,

    Thanks for the question. The first thing I have to highlight is that we can’t go into too much depth with custom development questions like this one, but I’d be happy to explore it a little and hopefully get you pointed in the right direction 🙂

    The second thing I would highlight is that the documentation that comes with Advanced Post Manager (which I think you have based your own code upon) isn’t really geared toward helping you manipulate the filters added by Events Calendar PRO: rather these are general purpose instructions that can help you add filters to any post type, regardless of whether Events Calendar PRO is activated or not.

    In this case, your code is creating a second APM object for the same post type, hence the second set of filters. APM isn’t really designed to accommodate that scenario, exactly, and I think in any case you are interested in modifying and extending the APM object that Events Calendar PRO creates.

    https://gist.github.com/barryhughes/74b14b0be8a6ad2c91f4

    Does the above help at all in showing an alternative way to approach this?

    #997009
    integrity
    Participant

    That worked like a charm, thank you!

    #997013
    Barry
    Member

    Glad it helped 🙂

    I’ll close this topic as you’ve marked it “resolved”, but of course please feel free to create new topics as needed and one of the team will be only too happy to assist.

    Thanks again!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Adding custom meta filter to Advanced Post Manager results in two metaboxes.’ is closed to new replies.