Disabling some buttons from wp_editor - wordpress

I use tinyMce editor in meta boxes of Wordpress by the following line of code, I want to remove some buttons when I use there. I don't want to affect the main editor. I know how to remove some buttons, which is told here.
My question is, is it possible to disable some buttons (e.g. more) when I call editor with wp_editor. I checked its manual, arguments doesn't seem to support this.
wp_editor( $careers_settings["description"], "editor", array("media_buttons"=>FALSE, "textarea_name"=>"description", "textarea_rows"=>5) );
Thank you.

I guess it's a bit late to answer but in case it might be useful for someone. Since Tinymce 4, "toolbar1" must be used and "teeny" must be set as false to modify buttons :
wp_editor(
'id',
'value',
array(
'teeny'=>false,
'media_buttons'=>false,
'tinymce' => array(
'toolbar1' => 'bold, italic, underline,|,fontsizeselect',
'toolbar2'=>false
),
)
);
Also I added "toolbar2" to the array. I realized that although I only set toolbar1, additional buttons still appear in some cases. Setting toolbar2 as false will remove default buttons on the second buttons row.

You should check the referenced manual again - it's possible to have tinymce as parameter and pass an array of configuration options, e.g. like
wp_editor($value, "input...", array(
'tinymce' => array( .. //tinymce configuration options here )
))
Haven't tried it out, but it should work like that.

Related

wrap visual composer element(s) in a shortcode

I have some content created with visual composer and I want to wrap some of it in a shortcode like
visual composer elements
[is_mobile]visual composer elements wrapped in shortcode[/is_mobile]
other visual composer elements
please how can it be done? thanks
I believe you need to "register" your shortcodes with Visual Composer. Having unregistered shortcodes confuses Visual Composer; it doesn't really know what to do with them, so it ignores them or does weird things with them (in my case, the content I was trying to wrap in an unregistered shortcode ended up at the top of the page).
So in the following:
name shows in the grid of Visual Composer elements when you are editing a page. You also use it to add your shortcode to the VC Container class (WPBakeryShortCodesContainer).
base is your shortcode's name -- in your example that is is_mobile
as_parent indicates which shortcodes your container can accept as children. I have it set to "except" nothing -- meaning it accepts all Visual Composer shortcodes as children. You can also set it to "only" and list out specific shortcodes you'd like to allow as children (for example if you only wanted to allow people to show or hide an image gallery).
And stuff that didn't matter for me: I'm not really sure why, but I was able to use is_container as true OR false. It made no difference in my situation. show_settings_on_create and content_element are probably irrelevant to your purposes but if you want to know more, they are explained here on VC documentation for vc_map.
This registers your shortcode with Visual Composer:
vc_map( array(
"name" => __("Is Mobile", "my-text-domain"),
"base" => "is_mobile", // your shortcode name
"as_parent" => array('except' => ''), // Use only|except attributes to limit child shortcodes (separate multiple values with comma)
"content_element" => true,
"show_settings_on_create" => false,
"is_container" => true,
"params" => array(
// you can add params same as with any other content element
// i didn't have any options to add onto my element; i was just trying
// to show or hide content based on WP conditions irrelevant to VC
),
"js_view" => 'VcColumnView'
) );
And this makes your shortcode act as a container (i.e., accept other VC elements as children) by extending the default VC container shortcode class. It seems to use the name from the above snippet as the connection.
if ( class_exists( 'WPBakeryShortCodesContainer' ) ) {
class WPBakeryShortCode_Is_Mobile extends WPBakeryShortCodesContainer {
}
}
This page on VC documentation helped me figure this out, though it's fairly sparse.

How to add id to an element in visual composer

I've been trying to figure out how to add an ID to a visual composer element, but I can't figure out how to do so. I've tried editing the row, but the only options I have are Custom CSS Class, Parallax, Full Width and Font Color, but no ID everywhere. I've tried putting id="something" and Id="something" into the shortcode with no good luck.
I need to do this in order to make links to some rows within the same page. If there's another workaround to that, I'm eager to know.
Thanks in advance for any response.
el_id
Use el_id='something'.
Shortcode example:
[vc_row el_id='something'] CONTENT [/vc_row]
It wil be generated like this into the DOM:
<div id="something" class="vc_row wpb_row vc_row-fluid">
I had to solve it also, what I did was to create an "Raw html" module, and add the ID on it:
<div id="section"><div>
and place it above the section you want to link to.
Hope it helps!
This work for me: for add a id to row you can aloso add this code in your function.php theme file:
$attributes = array(
'type' => 'textfield',
'heading' => "HTML ID",
'param_name' => 'element_id',
'value' => '',
'description' => __( "Assign an ID to the row", "discprofile" )
);
vc_add_param( 'vc_row', $attributes );
After if you edit a row you find a new input element titled Html ID.
Source: https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524335
Visual Composer now has a Row ID field. Since v4.5 I believe.
If you are using theme or plugin-specific shortcodes to display content, you are at the mercy of the developer as to whether you can specify an ID. If there's no option for it, there's no good way to add one without modifying the functions of the theme or shortcode.
One workaround could be to do the following:
Set up the shortcode like usual, with all the correct settings other than the ID you want.
View the page. View the source of the page and find the element that was generated by that shortcode.
Copy and paste the rendered code into the TEXT editor in the backend. Add an ID to the element manually. Remove the old shortcode to prevent duplicate data.
You won't be able to easily change shortcode settings, but in a pinch it should work!
This feature is present in some themes like JUPITER but absent in most.
A quick way to achieve this is to use the RAW HTML visual composer element instead of the shortcode options box you were using.
Is verry easy if you want to add with php, for example:
we can do in vc_map function this:
array(
'type' => 'textfield',
'heading' => __( 'ID', 'ezrapp_tech_widget' ),
'param_name' => 'id_item',
'value' => uniqid(),
)
and now have generated uniquie id, but not this was my question.

Adding custom taxonomy to media gallery in wordpress admin

I have added a custom taxonomy to Media, which is showing up as a text field in the Media admin section. I would like this to be the typical checkbox format as it exists in the custom post type admin page. Is there a way to override this in the functions to make this custom taxonomy show in checkboxes, so the user could easily choose which image belongs to a specific taxonomy entry?
Here is the code I used to bring the taxonomy into the Media Gallery:
register_taxonomy('Categories',array('project', 'slides', 'attachment'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'categories' ),
));
In the first line, by adding 'attachment' to the array, it added the Project Categories field in the Media Gallery. Now I just need to make this a list of checkboxes containing the current taxonomy entries. Any thoughts on how to achieve this?
I found this article, but having never used filters, it was a bit perplexing as to how to make this work for me:
https://wordpress.stackexchange.com/questions/29858/adding-category-tag-taxonomy-support-to-images-media
You are most of the way there. To render a taxonomy category as a special HTML display, like a list of checkboxes, the best method is to use the built-in WordPress Walker class. It is made exactly for this sort of thing.
http://codex.wordpress.org/Function_Reference/Walker_Class
I use this very method to create a new "SLP_Tagalong" walker class that renders a list of my taxonomy categories as a list of checkboxes (I only show text names but it could easily show the marker images) whenever anyone edits a store location.
I have the modified Walker Class I can share if you would like to see it. I'd post here but it is 150 lines. Send me a PM and I'll shoot it back that way.
I am sure the walker class would have worked successfully, but looking at the codex reminded me of string theory and existentialism. The upside is with WP 3.5.1, when you associate a taxonomy to 'attachment' set to Hierarchal, the checkbox appears in the Media Library by default.
YAY!!
This may not answer the question posed thoroughly though so I will leave it open for anyone who wants to stab at this.

Button links not redirecting prospect theme wordpress

I recently installed prospect theme and i am having tons of trouble as most things aren't customizable directly from the options interface. You can see a demo here:
http://themes.wpbusinessbundle.com/prospect/
So i'm trying to add buttons, which when i add them look fine, but don't redirect anywhere (redirects to the same page with #). I know it's because of something missing that needs to ''pull'' the link I include in the html when i write/insert the button but can't figure out where to modify it in the css or how.
Any help is appreciated. Btw, Calls to action work but I cannot change their color or their size so that's not much good.
From observation of the PHP, the shortcode for a button should be arranged to match:
"extract(shortcode_atts(array(
'link' => '#',
'target' => '',
'variation' => '',
'size' => '',
'align' ...."
What this means is the button shortcode that the visual editor makes will have to be manually edited to look something like this for example:
[button link="http://google.com" variation="blue" size="large"] TEST [/button]
I'm using the theme myself and I've had to edit a lot of the.. questionable code ;P.
Hope this helps.

How do you remove a Category-style (hierarchical) taxonomy metabox

I was wondering if someone can help me with this. I'm currently following Shibashake's tutorial about creating custom meta-boxes that include taxonomy selection here: http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels .
They show how to remove the standard metabox Wordpress automatically creates for taxonomies using the remove_meta_box function. Only problem is that the function for some reason doesn't seem to work on taxonomies that work as categories ie ones where the hierarchical option is set to true. I know I have the function working because the ones set up as tags disappear easily enough. I can't if it just isn't possible or if there is something special I need to add in one of the parameters to make it work.
Example:
$args = array(
'hierarchical' => false,
'label' =>'People',
'query_var' => true,
'rewrite' => true
);
register_taxonomy('people', 'post',$args);
remove_meta_box('tagsdiv-people','post','side');
That works fine. If I set hierarchical to 'true, however, the meta box stays put.
Can anyone shed some light?
Found the answer asking over at the Wordpress side of StackExchange:
For taxonomies that work like tags, you use "tagsdiv-slug". But for ones that are hierarchical, you use "slugdiv". The answe can be found here:
Thanks to #Jan Fabry for his answer

Resources