Forum Replies Created

Viewing 15 replies - 1 through 15 (of 106 total)
  • Thread Starter cruxwireweb

    (@cruxwireweb)

    Thank you very much for your reply and explanation.

    Thread Starter cruxwireweb

    (@cruxwireweb)

    Also, other plug-ins are Akismet, Contact Form 7, Shortcode Exec PHP, and Wordfence. Everything is up to date.

    Thread Starter cruxwireweb

    (@cruxwireweb)

    It fixed itself – go figure.

    Thread Starter cruxwireweb

    (@cruxwireweb)

    More info…, the alt tags are not displaying either.

    Can anyone recommend a debugging app for Android?

    Thread Starter cruxwireweb

    (@cruxwireweb)

    Sorry – the site is not live, so I can’t give you a link.

    Thread Starter cruxwireweb

    (@cruxwireweb)

    In my first post, I linked to an article but the link doesn’t work. The correct URL is http://www.wpexplorer.com/wordpress-tinymce-tweaks/.

    It’ a great article with other helpful tweaks.

    Thread Starter cruxwireweb

    (@cruxwireweb)

    Unfortunately, I was not able to figure out how to add a class to the selected element (instead of adding it to a surrounding span.) Nor was I able to figure out how to change the label of the button to anything other than “Formats.”

    Thread Starter cruxwireweb

    (@cruxwireweb)

    You are right – I totally suck for that. I’m sorry. Here’s what I figured out.

    I created a plug-in. The plug-in contains one PHP file and one js file in a folder titled js.

    PHP File

    This is the relevant code. The file contains some other code as well, such as defining custom colors. (More info here.)

    /*
    Plugin Name: CW Custom TinyMCE
    Description: Customizations for TinyMCE 4
    */
    
    // --- CUSTOM TINY MCE BUTTON ----------------------------
    // Use the PHP below in functions.php and also add the javascript in a seperate file in the theme's js folder.
    
    // Hooks your functions into the correct filters
    	function my_add_mce_button() {
    		// check user permissions
    		if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
    			return;
    		}
    		// check if WYSIWYG is enabled
    		if ( 'true' == get_user_option( 'rich_editing' ) ) {
    			add_filter( 'mce_external_plugins', 'my_add_tinymce_plugin' );
    		}
    	}
    	add_action('admin_head', 'my_add_mce_button');
    
    	// Declare script for new button
    	function my_add_tinymce_plugin( $plugin_array ) {
    		// customize for each button
    		$plugin_array['cw_font_size_btn'] = plugins_url( 'js/tinymce-custom.js', __FILE__ );
    		return $plugin_array;
    	}

    JS File

    My javascript is definitely amateur, but this works for me.

    (function() {
    	tinymce.PluginManager.add('cw_font_size_btn', function( editor, url ) {
    		editor.addButton( 'cw_font_size_btn', {
    			type: 'listbox',
    			text: 'Font Size',// name on the listbox in the ui
    			icon: false,
    			classes: 'fixed-width widget btn',// adds classes to the div surrounding the <button>.  don't need the 'mce-' prefix
    			onselect: function(e) {
    			},
    			values: [
    				{text: 'Bigger', onclick : function() {
    					var selected2 = tinyMCE.activeEditor.selection.getContent();
    					var content2 = '';
    					var spantitleclass = ' class="bigger"';
    					if (selected2 !== '') {
    						content2 = '<span'+spantitleclass+'>' + selected2 + '</span>';
    					} else {
    						content2 = '<span'+spantitleclass+'></span>';
    					}
    					tinymce.execCommand('mceInsertContent', false, content2);
    				}},
    
    				{text: 'Big', onclick : function() {
    					var selected2 = tinyMCE.activeEditor.selection.getContent();
    					var content2 = '';
    					var spantitleclass = ' class= "big"';
    					if (selected2 !== '') {
    						content2 = '<span'+spantitleclass+'>' + selected2 + '</span>';
    					} else {
    						content2 = '<span'+spantitleclass+'></span>';
    					}
    					tinymce.execCommand('mceInsertContent', false, content2);
    				}},
    
    				{text: 'Small', onclick : function() {
    					var selected2 = tinyMCE.activeEditor.selection.getContent();
    					var content2 = '';
    					var spantitleclass = ' class= "small"';
    					if (selected2 !== '') {
    						content2 = '<span'+spantitleclass+'>' + selected2 + '</span>';
    					} else {
    						content2 = '<span'+spantitleclass+'></span>';
    					}
    					tinymce.execCommand('mceInsertContent', false, content2);
    				}},	
    
    				{text: 'Smaller', onclick : function() {
    					var selected2 = tinyMCE.activeEditor.selection.getContent();
    					var content2 = '';
    					var spantitleclass = ' class= "smaller"';
    					if (selected2 !== '') {
    						content2 = '<span'+spantitleclass+'>' + selected2 + '</span>';
    					} else {
    						content2 = '<span'+spantitleclass+'></span>';
    					}
    					tinymce.execCommand('mceInsertContent', false, content2);
    				}},
    			]
    		});
    	});
    })();

    Upload and activate the plug-in.

    Thread Starter cruxwireweb

    (@cruxwireweb)

    I figured this out, but don’t have time to post the solution – gotta run. I will post the solution tonight or tomorrow though.

    cruxwireweb

    (@cruxwireweb)

    I second this.

    cruxwireweb

    (@cruxwireweb)

    Thread Starter cruxwireweb

    (@cruxwireweb)

    Bump. Can anyone help?

    Thread Starter cruxwireweb

    (@cruxwireweb)

    OK. I was hoping to avoid the line-by-line thing, but at least I know there isn’t a viable alternative. Thanks again for your help.

    Thread Starter cruxwireweb

    (@cruxwireweb)

    Unless Wordfence or Sucuri checked the database?

    Thread Starter cruxwireweb

    (@cruxwireweb)

    Actually, I haven’t checked he database yet – still figuring out how. 😉 Do you know if there is a tool I can use for this?

Viewing 15 replies - 1 through 15 (of 106 total)