Silverstripe tinyMCE add custom plugin - php

I've downloaded a plugin for tinyMCE I want to use in the CMS Silverstripe backend. I've tried to add the line in mysite/_config.php as told in http://doc.silverstripe.org/htmleditorconfig
HtmlEditorConfig::get('cms')->enablePlugins('../../textmetrics');
HtmlEditorConfig::get('cms')->addButtonsToLine(2, 'TextMetrics'); // positions plugin
And added the Plugin into /sapphire/thirdparty/tinymce/plugins/textmetrics.
That didn't work. So I tried to do the same as in /cms/_config.php where the configuration is set for the editor and put the plugin into /cms/javascript/tinymce_textmetrics. Then I tried to load with
HtmlEditorConfig::get('cms')->enablePlugins(array('TextMetrics' => '../../../cms/javascript/textmetrics/editor_plugin_src.js'));
HtmlEditorConfig::get('cms')->insertButtonsBefore('tablecontrols', 'TextMetrics'); // positions plugin
I've tried to use insertButtonsBefore insteat of addButtonsToLine just to see if there was a problem.
But nothing happens at all.... not even errormessages and I don't know what to do. I need extra plugins to load.
Help appreciated.
Thx Spanky

I've learned now, to test if the plugin works without Silverstripe and if it does, you can use this way to add it in Silverstripe. This is how it worked for me.
Put the Plugin in /htdocs/cms/javascript/pluginname . Then add the following code to /htdocs/cms/_config.php
HtmlEditorConfig::get('cms')->enablePlugins(array('pluginname' => '../../../cms/javascript/pluginname/editor_plugin_src.js'));
HtmlEditorConfig::get('cms')->insertButtonsBefore('tablecontrols', 'pluginname'); // positions plugin*/
It would be nice if TinyMCE would throw errors if it does not work, but apparently it doesn't. Neither does Silverstripe.

Related

Divi - I've hide the global header and footer and cannot find a way to enable again

I've tried to use the frontend builder from Divi to hide the header and footer of the checkout page through Custom css (display:none) at the section settings.
The problem is that this disabled the Global Header and Footer and I can't see the items anymore to remove the code.
I've tried to enable again through the code #main-header { display:block!important; } but it did not work
Any ideas where can I find this code so I can erased it?
Seems like if I create a new template works but I can't find a way to enable the old one.
Best regards
if you've built your header through the theme builder, try to use this CSS
code
.et_pb_section_0_tb_header {
display : block;
}
it worked for me
and just for remark, you can remove the global header from one page without the need for custom CSS
check this blog post to know-how https://diveindivi.com/remove-the-header-and-footer-of-your-divi-website/
Not sure why my previous comment was deleted since this solution absolutely solved my problem. But here I go again, in case bouzina farid's answer does not work for some reason.
I've managed to solve the problem by using the tool "Export model" from Divi's Theme Builder. With the raw code in hands I've searched for the tag "display:none", remove the tag, save it and imported again.

Is it possible to remove or configure menubar from tinymce editor in a WORDPRESS plugin admin page?

I have scoured WordPress, and TinyMCE documentation and stackoverflow and wordpress.stackexchange for an answer to this problem. Right now, I can see NO duplicates to this question.
I want to remove the menubar from a tinymce editor in a WordPress plugin admin page.
I am building a WordPress plugin. As part of the plugin's functionality a user has to add content using TinyMCE. I use wp_editor() which adds a TinyMCE instance to the plugin's admin page.
TinyMCE works fine. I have been able to configure buttons using this answer: https://stackoverflow.com/a/27872094/2298108 . However, this does not help remove or configure the menubar. I have tried adding menubar=>false to the tinymce array.
I've even looked for a frontend hack to access the editor and remove the menubar. Because WordPress instantiates tinymce, I have NO access to tinymce.init(). I have tried using the frontend event addeditor which fires, and gives "access" to the editor, but there doesn't seem to be any method to remove the menubar.
My php inline code:
$settings= ['menubar'=> false,'toolbar1' => 'formatselect,|,bold,italic,underline,|,hr,|bullist,numlist','toolbar2'=>false];
wp_editor($this->form_confirmation,'xxx_form_confirmation_mce',['editor_height'=>200,'media_buttons'=>false,'quicktags'=>false,'menubar' =>false,'tinymce' => $settings]);
$this->form_confirmation is a string and gets added to the content screen of the editor.
NOTE: I am using the "TinyMCE Advanced" WordPress plugin.
You can hook into tiny_mce_before_init to further customize the TinyMCE editor before it gets loaded.
This removed the menu bar for me:
function wp2641_disable_tinymce_menu_bar( $in ) {
$in['menubar'] = false;
return $in;
}
add_filter( 'tiny_mce_before_init', 'wp2641_disable_tinymce_menu_bar' );

How to style author id in WordPress?

How to add css to specific wordpress user to hide plugin fiction over front end? I installed the wp-about-author plugin but I need to set as hidden for admin user. So when the admin make any blog post then the wp-about-author wont be displayed. Unfortunately no feedback from the plugin developer. Thanks for any suggestions.
CSS way is not recommended since the user can check out actual DOM by view the source.
Instead, You can prevent from even showing up in the DOM Tree by modifying a plugin php file.
$level = get_the_author_meta('user_level');
if ($level == 10) {
return;
}
Add this line to wp-about-author.php on line #31.
This works, I tested.
Try to update plugin better then hack css :) You can add to wp-about-author.php on line #102 something like:
if (wp_admin()) $return_content = '';
I didn't check it, but might work for you.

joomla template on view=category

I make my own template , and its work well on www.90km2.com/index.php
But when I want to see com_content&view=category page on this link : http://www.90km2.com/index.php?option=com_content&view=category&id=23&Itemid=102
It doesn't work. Do you know why joomla didn't show my view?
I try another templates to see this page , all of them was worked well , but this view is not work with my own teplate :(
I would try copying the template which works then modify bit by bit to get your custom template then see when problem shows up. Or create a template which has the minimum stuff in there and see if it works. Just have jdoc:include type="component"/> in the body

Wordpress basic concept - how to extend/override/customize a plugin hook?

I am working on a wordpress site and would like to clarify a basic concept that is definitely very important, and this is how to customize/extend a wordpress hook (at least that's what I think I want to do!)
As the real world example, I am setting up a wp-ecommerce site. When a user adds an item to the cart, I would like to do one or two more things than the original function does. Looking through the source, I find:
/wp-content/plugins/wp-e-commerce/wpsc-includes/ajax.functions.php
with the function:
function wpsc_add_to_cart()
I know I could simply edit the code right here, but obviously that is the completely wrong way to go about it as when the plugin is updated, I will lose changes. What is the correct way to extend a function that is part of a plugin, or wordpress for that matter?
Endless thanks in advance.
You can use the wordpress action hooks to resolve the code loss while plugin upgrade.
You can remove the function which is in plugin file by using remove_action hook and do your own code by adding add_action in your function.php file. So that you can customize your plugin code from theme's function.php.
Here are the examples to explain.I hope it will help.
http://codex.wordpress.org/Plugin_API
http://themeshaper.com/2009/05/03/filters-wordpress-child-themes/
I use a little supressed notice function (it lives in my child themes function.php page), for plugins that get irritating eg: please setup twitter account to use , this kind of warning is not useful at certain stages and sometimes just do not care for it.
function supressed_notices_active(){
echo '<div class="error"><p>Supressed Notices are active</p></div>';
}
if(function_exists('the_plugin_custom_function_call')){
remove_action('the_plugin_custom_function_call' );
add_action('admin_notices','supressed_notices_active');
}else{
function test_message_from_me(){
echo '<h1>show</h1>';
}
add_action('admin_notices','test_message_from_me');
}
So I create the supressed notice function to at least create a warning, so i remember.
Check if the target function exists with the function_exists($target_function) hook
then remove this action from running with the remove_action($tag,$target_function) hook
then just add your custom function with the add_action($tag,$target_function) hook (do not need to have a separate function this could just be a closure)
then else if the function does not exist either still run a new action or leave this section, it can be useful for testing to just add anything so you atleast get some feed back.
What you could try... Copy the function within the plugin file,
paste it into your themes functions.php file,
ie:
function wpsc_add_to_cart() {
global $wpdb, $wpsc_cart;
// default values etc..etc..
// new code here?
}
the only thing with this is, if the plugin is updated and that funciton is renamed or removed, changed or something you could start to run into trouble...
could you not ask the plugin developer to possibly add your requirements to it,
possibly for a small fee? but if your using it as your main shopping cart, then chances are, that small investment could be a good thing.
Marty

Categories