devo.uk
Forum Replies Created
-
Forum: Plugins
In reply to: Tiny MCE – Adding the noneditable pluginCracked : removing the text button on the editor so an EDITOR role user only access the html pane
As i said in the todo list, did a bit of searching and found the following code which works !!
Add this to your themes function.php file (should reside or needs creating in the root of your themes directory)
<?php
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
add_action( 'admin_head', 'disable_html_editor' );
function disable_html_editor() {
global $current_user;
get_currentuserinfo();
if ($current_user->user_level != 10) {
echo '<style type="text/css">#content-html, #quicktags {display: none;}</style>';
}
}
My work here is done !!
Forum: Plugins
In reply to: Tiny MCE – Adding the noneditable pluginHi Jack and all.
Finally had another play with the noneditable under the standard wordpress editor. Its not the best solution but it is a working. Not the best solution since I am not sure if a wordpress update may change one of the files so you might have to reapply the fix.
You may be able load the functions and put them in your themes functions.php – I will try and explore later
1) Downloaded tinymce
2) Expand / Search for the tinymce\js\tinymce\plugins directory
you will see the noneditable
3) copy this directory and paste it to wp-includes\js\tinymce\plugins
4) then go to and load the wp-includes\class-wp-editor.php in your text editor and find the code / block/**
* Filter the list of TinyMCE external plugins.
*
* The filter takes an associative array of external plugins for
* TinyMCE in the form 'plugin_name' => 'url'.
*
* The url should be absolute, and should include the js filename
* to be loaded. For example:
* 'myplugin' => 'http://mysite.com/wp-content/plugins/myfolder/mce_plugin.js'.
*
* If the external plugin adds a button, it should be added with
* one of the 'mce_buttons' filters.
*
* @since 2.5.0
*
* @param array $external_plugins An array of external TinyMCE plugins.
*/
$mce_external_plugins = apply_filters( 'mce_external_plugins', array() );$plugins = array(
'charmap',
'colorpicker',
'hr',
'lists',
'media',
'paste',
'tabfocus',
'textcolor',
'fullscreen',
'wordpress',
'wpautoresize',
'wpeditimage',
'wpemoji',
'wpgallery',
'wplink',
'wpdialogs',
'wptextpattern',
'wpview',
'wpembed',);
4) Add the line underneath ‘wpembed’
5)'noneditable',
6) Save the code
7) You can now use the editor in text mode and use<div="noneditable">Protected Area</div>and then when you swap to HTML mode it will now see the code but will be non editableTo take this a stage further you can make it so the noneditable code is not shown
I altered \wp-includes\js\tinymce\skins\lightgray\content.min.css and unminified it and added this around line 68
body#tinymce.mcenoneditable {display:none}
{if you dont want to unminify the file – search the file and paste after
.mce-pagebreak {cursor: default;display: block;border: 0;width: 100%;height: 5px;border: 1px dashed #666;margin-top: 15px;page-break-before: always}Finally by adding an extra bit of code in a functions file, every time you go in to the editor, it will start on the html tab so is a bit safer for a normal editor user
Create a file /wp-content/themes/yourthemenamehere/includes/theme-functions.php and just add this line of code
<?php
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";'));The ultimate on the todo list would be able to assign an editor users which then has the text tab hidden thus reducing risk of a non tech user altering bits but unsure if that would happen, maybe a feature for tinymce to add or wordpress i not really sure.
So i hope this helps anyone out .. as it has taken a lot of blood sweat and tears and many hours of determination !!!
ok after 3 days of looking at this and trying to work out what i could and i cant do within the realms of the php
I found that some functions of wordpress and php would cause the code to crash.
the use of$templatedir = bloginfo('template_directory')
result = shortcode pro to crash or just display the template directory at the top of the pagebut after reading for an alternative i found the
$templatedir = get_bloginfo('template_directory')
result = allowed result for string maipulationi presume how certain functions have to be parsed before the rendering of the page / post and some can be evoked as the page / post text is being built which would be after a header and above is processed
i know the code is not the most tightest but thought that it will give people an insight
The code fills in
- relative root to image (no domain prefix)
from attributes set up - adds the correct alt tag or a blank one if none is entered
- the chance to add height or width or both on the image size
- tidies up the output string so that there is no extra blank spaces between parameters
custom code = php
attributes alt / alt description / text
attributes height / height size % or px / text
attributes width / width size % or px / textif ($atts["alt"] =='alt=""') { $alt='';} else { $alt = 'alt="'.ltrim($atts["alt"]).'"'; } if ($atts["width"] ==' ') { $width='';} else { $width = 'width="'.ltrim($atts["width"]).'"'; } if ($atts["height"] ==' ') { $height='';} else { $height = 'height="'.ltrim($atts["height"]).'"'; } $params = $alt.' '.$width.' '.$height; $returnstring = get_bloginfo('template_directory'). '/images/' .$content.'" '.$params); return '<img src="'. str_replace(' ',' ',$$returnstring).' />';hope this helps someone and gives a guide of how to use the custom code and what pitfalls you may come up against.
i think most people would not take this long to resolve an issue as it would be a fine line of the above and then manually hardcoding shortcode functions but i wanted to see it through
Great work matt with the plugin 🙂
Forum: Fixing WordPress
In reply to: Front Page and Blog(post) on menu permalinks setupthank you for your reply Christine.. you advice confirmed what i did actually get working after some sleep ..
also word of warning if anyone uses wamp as a local test server when trying to achieve this .. you need to make sure you have activated the rewrite_module in apache configuration as after doing the above steps when i clicked on the friendly name it would display a page cant be found
hope this will be some use for someone 🙂
- relative root to image (no domain prefix)