Automatically decrease font size for long words

I’ve done something similar taking the simple approach of adding a CSS class to titles based on their character count. That CSS class then decreases letter-spacing and/or font-size. // Count the characters, taking Unicode into account $chars = mb_strlen($post->post_title); // For every 10 characters after the first 20, add a size $size = max(0, ceil(($chars … Read more

How do I use WP’s jQuery

WP’s jQuery is not mapped to $ like you may expect, it is loaded in noConflict mode so you’ll need to use jQuery() instead of $(), unless you map it yourself. When you include your js file you’ll want to make sure to set jQuery as a dependency as well: wp_enqueue_script( ‘your-script-handle’, get_stylesheet_directory_uri() . ‘/js/your-script.js’, … Read more

AJAX call returns 0

Note that the action should be inside the data key. In your post request there is no key named as action therefore, the callback function is never being called. Consider this example:- jQuery.ajax({ type:”POST”, url: “/wp-admin/admin-ajax.php”, data: { action: “my_test_action”, form_data : newFormChange }, success: function (data) { console.log(data); } }); Also Note: Never use … Read more

WooCommerce single product edit flexslider settings

After a little digging through the source I found there is a filter called woocommerce_single_product_carousel_options that can be used to modify the flex slider options for example: function my_product_carousel_options($options) { $options[‘animation’] = ‘fade’; return $options; } add_filter(“woocommerce_single_product_carousel_options”, “my_product_carousel_options”, 10);

Using Underscore Templates in WordPress

Your plugin index file: add_action( ‘print_media_templates’, ‘wpse8170_admin_footer’ ); function wpse8170_admin_footer() { require ‘templates.php’; } Your templates.php: <script id=”tmpl-mytemplate” type=”text/html”> <h1>Hello {{data.name}}!</h1> </script> Your media js file: wp.media.view.MyView = wp.media.View.extend({ template: wp.media.template(‘mytemplate’), render: function() { this.$el.html(this.template({name: ‘world’})); } });

Loading style.css and Jquery using HTTPS

Since you are behind a load balancer (confirmed in your comments above), your WordPress installation won’t be able to detect SSL using the is_ssl() function, and will not serve any enqueued scripts or stylesheets with https: protocol URIs. If you are behind a load balancer that supports the HTTP_X_FORWARDED_PROTO server variable, you can fix your … Read more

How to handle multiple instance of “send_to_editor” js function

only overwrite the send_to_editor function when your link or button is click but store the old function to restore it so try this on a click event: //store old send to editor function window.restore_send_to_editor = window.send_to_editor; //overwrite send to editor function window.send_to_editor = function(html) { var imgurl = jQuery(‘img’,html).attr(‘src’); current_item.siblings(‘.upload_image’).val(imgurl); current_item.parent().prepend(‘<div><img width=”300″ src=”‘+imgurl+'” alt=”banner image” … Read more