Tag Info

Hot answers tagged

3

Have you tried returning an array instead? wp_send_json($an_array_of_your_vals); And then parse the array in the success function? success: function( data ) { var obj = jQuery.parseJSON(data); if( obj.arg_1 ) { $('selector').append( obj.content ); } else if( obj.arg_2 ) { $('other_selector').append( obj.content ); } ...


3

One way to do it (which is probably evil) is to select the control by adding a block of javascript using the tr field of $form_fields: function set_image_data( $form_fields, $post ) { $form_fields['text_color'] = array( 'label' => 'Text Color', 'input' => 'text', 'value' => get_post_meta( $post->ID, '_text_color', ...


1

Your first attempt does not work because get_template_directory_uri returns the URL to your theme directory. Your second attempt will work, but if you don't want to hard code the domain you could either try using a root relative path or fetching the domain portion of your site url. Relative path: wp_register_script('circle-bounce', '/js/general.js', ...


1

Allowing user to control code is explicitly unsafe operation. As you note the purpose of sanitization is pretty much to not let user slip in anything executable and/or with malicious intent. To "sanitize" executable code you would need programmatic understanding of it (code parser) and criteria engine to distinguish what is safe and what is not. For such ...


1

I found a nice way to do this using the preview_post_link filter, which allows you to rewrite the URL used by the preview operation. In my case I did something like: add_filter( 'preview_post_link', function ( $link ) { return 'http://domain.com/mobile-preview/?src=' . urlencode($link) . '%26admin_bar=false'; } ); When I click my preview button ...


1

You gave each each script the same handle/id of 'grid' Try something like this. function banana_scripts() { wp_enqueue_script('grid', get_stylesheet_directory_uri() . '/js/jquery.min.js', null, null); wp_enqueue_script('grid2', get_stylesheet_directory_uri() . '/js/main.js', null, null); } add_action('wp_enqueue_scripts', ...


1

I don't think using React.js without Node.js (or at least V8 or rhino etc) counts as isomorphic, as isomorphic means that you are building JavaScript to run in the browser AND on the server. Specifically, using WordPress certainly means you aren't doing isomorphic javascript (its PHP software). What you could do is use WordPress as a REST API server, and ...


1

As per comments try collecting the ids in an array and then setting the text field once: custom_uploader.on('select', function() { var selection = custom_uploader.state().get('selection'); var ids = selection.map( function (attachment) { return attachment.id; }); ...



Only top voted, non community-wiki answers of a minimum length are eligible