WPBakery Page Builder with taxonomy dropdown not working - php

I am trying to build a custom element for WPBakery Page Builder with a dropdown where custom taxonomy elements (categories) are listed.
Unfortunately I end up with empty dropdown elements. What am I doing wrong here?
The $options array gets filled perfectly when I var_dump it.
$terms = get_terms(array(
'taxonomy' => 'team',
'hide_empty' => false,
));
$options = array();
foreach($terms as $team) {
$options[$team->name] = $team->slug;
}
This is my params array inside the vc_map() function:
'params' => array(
array(
'type' => 'dropdown',
'holder' => 'div',
'class' => '',
'heading' => 'Team',
'param_name' => 'category',
'value' => $options
)
)

We had the same problem today.
After four hours fiddling around and trying everything, we finally found out that we were using a reserved word as our param_name, it was post_category, which by the way, is not on the Codex's Reserved Terms page, even though it definitely was one of them.
label also isn't on the list, but given that the error and behaviour was exactly the same, I'd advice trying to switch it for something else.

Related

How To Call Only Specific Tag Slugs

I'm trying to call only specific tags in my WordPress get_tags() function. Right now they're displaying ALL tags instead of just the terms in the array. Even if the tag doesn't have a post I want the tag to show which is why hide_empty => false exists. I've been toying with this along with the codex but I feel like I'm accidentally canceling out what I'm trying to do. Guidance is greatly appreciated.
<?php
$tags = get_tags(array(
'taxonomy' => 'post_tag',
'hide_empty' => false, //want to show the tags called in the terms array even if they're empty
'field' => 'slug',
'terms' => array(
'tag1',
'tag2',
),
));
Looks like your formatting is a little off. Below should return an array of tags that match your terms. The include argument requires a comma or space delimited list of ids.
You can also limit the objects it returns with the "fields" argument. See get_tags() for more info.
$tag1 = get_term_by("slug", "tag1", "post_tag");
$tag2 = get_term_by("slug", "tag2", "post_tag");
$tags_array = get_tags(array(
"hide_empty" => false,
"include" => "{$tag1->term_id},{$tag2->term_id}",
));

get_comments not working properly after WordPress v4.4 update

I just found a wired thing on my website after v4.4 update. In my blog pages I use 2 functions to fetch comments.
First I use
wp_list_comments( array( "callback" => "checkout_comment", "type" => "comment") );
To fetch the comments only. Then I run a count check if any trackbacks exists by using
$trackback_count = get_comments( array(
'status' => 'approve',
'post_id'=> get_the_ID(),
'type'=> 'pings',
'count' => true)
);
and if the do exists the I show the trackbacks/pingsbacks like this
wp_list_comments( array( "callback" => "checkout_comment", "type" => "pings", "reply_text" => null, "format" => "html5") );
Now, after v4.4 update the comments are showing fine but the trackbacks list are not showing.
Can anyone tell me why? What I might need to change to fix this?

PHP/WordPress Get Users and Load into Plugin

This is my first question on StackOverflow! I'm a PHP and WP developer beginner, and I'm doing my best to learn and pull information together, but I'm stumped.
I'm using Ninja Forms for WordPress. I want to return a full list of users and have them display in the drop down selection. The code below is based off this: Foreach loop inside array.
$blogusers = get_users( array( 'fields' => array( 'user_email') ) );
$args = array(
'name' => 'Select User',
'edit_options' => array(
array(
'type' => 'select',
'name' => 'select_users_from_group',
'label' => 'Select a User',
'options' => array()
),
),
'display_function' => 'select_users_from_group',
'edit_function' => 'select_users_from_group_edit',
'sidebar' => 'template_fields'
);
foreach($blogusers as $key=>$user) {
$args['edit_options'][0]['options'][] = array(
// 'name' => $user=>user_email,;
);
}
if( function_exists( 'ninja_forms_register_field' ) ) {
ninja_forms_register_field('select_users_from_group', $args);
}
I know my foreach loop is no good, but I don't know what to do to make it work. It fails when I remove the comment.
Eventually, I'd like for another field to return a user_meta value based on the user selected here, but I have no idea where to even begin on that.
Any help is appreciated. Not looking for you to write it for me. I'd rather learn how it works. Thanks in advance!

Change subpanel order in SugarCRM 7

How can one change the order on each subpanel either by code or through the GUI?
In Sugar 6 the user could change the order simply by dragging and dropping the subpanels under each module.
From what I can see this is not possible in 7.x.
I have tried to change
'order' => 1
in
custom/Extension/modules/Opportunities/Ext/Layoutdefs/some_file.php
with no luck at all..
UPDATE:
As UTAlan stated,
this will become part of the stock functionality of Sugar starting in version 7.5.0: https://web.sugarcrm.com/support/issues/66590
Until then, here is the reason and the solution:
The 'order' => 1, does not seem to work on Sugar 7 at the moment.
Solution
Copy the file
modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
to
custom/modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
Now, add your custom subpanel definition to the beginning of the array or in any order you desire.
My example looks like this now:
$viewdefs['Opportunities']['base']['layout']['subpanels'] = array(
'components' => array(
// This is my custom module
array(
'layout' => 'subpanel',
'label' => 'LBL_OPPORTUNITIES_FOOBAR_TITLE',
'context' => array(
'link' => 'opportunities_foobar_1',
),
),
.. // Code ommited
array(
'layout' => 'subpanel',
'label' => 'LBL_EMAILS_SUBPANEL_TITLE',
'context' => array (
'link' => 'archived_emails',
),
),
),
'type' => 'subpanels',
'span' => 12,
);
Long Answer:
Why is 'order' => 1 not working anymore?
Inside include/MetaDataManager/MetaDataConverter.php:327:
public function toLegacySubpanelLayoutDefs(array $layoutDefs, SugarBean $bean) {
..
foreach ($layoutDefs as $order => $def) {
..
$return[$def['context']['link']] = array(
'order' => $order,
..
}
The order that is being rendered in the view is based on which order each bean-name is inserted inside the 'components'-key inside this file:
modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
Core modules are hard-coded inside the subpanel file for Opportunities.
This will become part of the stock functionality of Sugar starting in version 7.5.0: https://web.sugarcrm.com/support/issues/66590

WPAlchemy Meta Box: Place meta box on specific post / page... conflict with "types" argument

I'm using the WPAlchemy class to create a metabox. I want to place this metabox in a number of post editors in the backend.
Currently it's working just fine with the following code:
$video_metabox = new WPAlchemy_MetaBox(array
(
'id' => '_videoMeta',
'title' => 'Videos',
'types' => array('characters','homepage'),
'template' => THEMEASSETS . '/functions/video_meta.php'
));
What I want to do though is additionally place the metabox on the post editor for post ID #22. Supposedly the following code should work:
$video_metabox = new WPAlchemy_MetaBox(array
(
'id' => '_videoMeta',
'title' => 'Videos',
'types' => array('characters','homepage'),
'template' => THEMEASSETS . '/functions/video_meta.php',
'include_post_id' => 22
));
But it doesn't work unless I add in 'page' into the array of post types, which adds the metabox to all pages (not just post ID 22).
Is there a way to use poth the types and the include post ID arguments?
I had the same issue. Acutally, I had set a metabox to two custom post types and wanted it to be displayed on a specific page.
$video_metabox = new WPAlchemy_MetaBox(array(
'id' => '_videoMeta',
'title' => 'Videos',
'types' => array('characters','homepage', 'page'),
'template' => THEMEASSETS . '/functions/video_meta.php',
'include_post_id' => 22
));
Just add the bult in 'page' post type and everything should work fine. It did for me.

Categories