tinymce is not defined when not using wp_editor

With help from a colleague, we dug through class-wp-editor.php Here are the necessary scripts to initialise jQuery tinyMCE if wp_editor has not been used beforehand (which calls these scripts). // Get the necessary scripts to launch tinymce $baseurl = includes_url( ‘js/tinymce’ ); $cssurl = includes_url(‘css/’); global $tinymce_version, $concatenate_scripts, $compress_scripts; $version = ‘ver=” . $tinymce_version; $css … Read more

wordpress json custom taxonomy problem

I would have done it as following, I am sure experts here will have a better way but following is what I could come up with in hurry. First create your controller file in your theme directory (or any other if you like) with the following content. For this example the file name is korkmaz.php … Read more

How to load the WordPress jquery in the section

By default if you enqueue jquery then it gets added in header but if any plugin is changing the default behavior of it and adding it in footer instead of header then you can use the following code to alter it and force it to add in header again. function insert_jquery(){ wp_enqueue_script(‘jquery’, false, array(), false, … Read more

Do I need both jquery.js and jquery-migrate.min.js?

As stated in the official blog of jQuery. Note that WordPress is mentioned in the quote. jQuery Migrate 1.4.1 released, and the path to jQuery 3.0 Version 1.4.1 of the jQuery Migrate plugin has been released. It has only a few changes but the most important of them fixes a problem with unquoted selectors that … Read more

Passing boolean values with wp_localize_script

Try this: $options = get_option( ‘theme’ ); wp_localize_script( ‘flexslider’, ‘flex_vars’, array ( ‘flex_auto’ => ($options[‘slide-auto’]) ? ‘true’ : ‘false’, ‘flex_animation’ => $options[‘slide-animation’], ‘flex_direction’ => $options[‘slide-direction’] ) ); Assuming slide-auto is the option you made a boolean. This script isn’t tested, I directly typed it in here.

Correct Method to run scripts with dependencies without enqueue?

function script_that_requires_jquery() { wp_register_script( ‘script-with-dependency’, ‘http://www.example.com/script-with-dependency.js’, array( ‘jquery’ ), ‘1.0.0’, true ); wp_enqueue_script( ‘script-with-dependency’ ); } add_action( ‘wp_enqueue_scripts’, ‘script_that_requires_jquery’ ); This is the correct method to enqueue scripts (and styles for that matter). You should always be using wp_enqueue_scripts to hook scripts and styles to. There are a few thing here to check when you … Read more

CSS not pulling in for jQuery UI dialog

There is no jquery-ui-dialog style defined in WordPress Out of the box, you need to ue the stylesheets manually, when i needed to enqueue the jQuery-UI style i pulled it from google api CDN wp_enqueue_style(‘jquery-style’, ‘http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css’); but you can enqueue a local copy if you want like this: wp_enqueue_style( ‘myStylesheet’, WP_PLUGIN_URL . ‘/path/stylesheet.css’ );

Is there a way to enable Cross-Origin Resource Sharing for WordPress’ ajaxurl?

Milo is correct. For instance, go to your theme’s functions.php file, and add the following: add_filter( ‘allowed_http_origins’, ‘add_allowed_origins’ ); function add_allowed_origins( $origins ) { $origins[] = ‘https://site1.example.com’; $origins[] = ‘https://site2.example.com’; return $origins; } Now an ajax call from https://site1.example.com to your site’s ajax url will have the appropriate Access-Control-Allow-Origin header in the response. eg. $.ajax({ … Read more

Display Media Uploader in Own Plugin on WordPress 3.5

Only Uploader below a example code, works only on post edit page. If you will use also on other page, then include the function wp_enqueue_media(), see the next headline. jQuery(document).ready(function($) { var _custom_media = true, _orig_send_attachment = wp.media.editor.send.attachment; $(‘.stag-metabox-table .button’).click(function(e) { var send_attachment_bkp = wp.media.editor.send.attachment; var button = $(this); var id = button.attr(‘id’).replace(‘_button’, ”); _custom_media … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)