TinyMCE 4 remove/add attributes for all images

Assuming your TinyMCE4 container has an id of ‘tiny-mce-4’, you could add this js to your functions.php. function toArray (collection) { return Array.prototype.slice.call(collection); } var imgs = toArray(document.querySelectorAll(‘#tiny-mce-4 img’)); imgs.forEach(function(img){ img.setAttribute(‘style’, img.getAttribute(‘style’).replace(/((height:).*?(px;))/g, ‘max-width: 100%;’)); }); <div id=”tiny-mce-4″> <img src=”https://wordpress.stackexchange.com/questions/207673/img1″ style=”height: 500px; width: 800px;” /> <img src=”img2″ style=”height: 500px; width: 800px;” /> <img src=”img3″ style=”height: 500px; … Read more

show/hide div with simple jQuery script [closed]

Most likely, the cause of your problem is that jQuery is in compatibility mode. This means that you can’t use the ‘$’ shortcode. To get your Javascript code to work, replace all ‘$’ with ‘jQuery’ Or, wrap your code in an anonymous function, like this: jQuery(document).ready(function( $ ) { // Put your jQuery code here. … Read more

WordPress Comments – Rich Text

I have found a way by using nicEdit here’s the tutorial. In order to get this fully functioning, I had to amend my script slightly. jQuery(“.stickers img”).click(function(){ var img = jQuery(this).parent().html(); var text = jQuery(“#respond .nicEdit-main”).html(); jQuery(“#respond .nicEdit-main”).html(text + img); }); I hope this helps someone.

WordPress jquery files not being enqueued

I dont really see anything wrong on what I did previously. But in any case I changed the name of the file to navbar.js and then my functions.php looked like this: function scentology_scripts() { wp_enqueue_style( ‘scentology-local-fonts’, get_template_directory_uri() . ‘/fonts/raleway.css’ ); wp_enqueue_style( ‘scentology-style-fontawesome’, ‘https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css’ ); wp_enqueue_style( ‘scentology-style’, get_stylesheet_uri() ); wp_enqueue_script( ‘scentology-menu’, get_template_directory_uri() . ‘/js/navbar.js’, array(‘jquery’), ‘20151215’, … Read more

Exclude some scripts from removing unique scripts from head function

You are removing the hooks from the head that are normally used to register and enqueue scripts. Normally, but not necessarily. You can also skip the intermediate hook and enqueue scripts directly into wp_head like this: add_action(‘wp_head’,’wpse240186_enqueue_jquery’); function wpse240186_enqueue_jquery() { wp_register_script(‘jquery’, ‘path_to/jquery.min.js’); wp_enqueue_script(‘jquery’); } In that way you can move scripts in general to the … Read more