wordpress file upload from direct directory not working

I fix this problems with wordpress file upload method: php file: add_action( ‘wp_ajax_file_upload’, ‘file_upload_callbacks’ ); add_action( ‘wp_ajax_nopriv_file_upload’, ‘file_upload_callbacks’ ); function file_upload_callbacks() { $arr_img_ext = array(‘application/pdf’); if (in_array($_FILES[‘file’][‘type’], $arr_img_ext)) { $upload = wp_upload_bits($_FILES[“file”][“name”], null, file_get_contents($_FILES[“file”][“tmp_name”])); //$upload[‘url’] will gives you uploaded file path //var_dump($upload[‘url’]); wp_send_json( $upload[‘url’] ); } wp_die(); }

$ not defined using jQuery in WordPress

You can wrap your javascript inside a self-invoking function, then pass jQuery as an argument to it, using $ as the local variable name. For example: (function($) { $(document).ready(function(){ $(“ul.vimeo_desc_feed li a”).click(function(){ alert($(this).attr(‘href’)); return false; }) }); }(jQuery)); should work as intended. If I remember correctly the WP-supplied version of jQuery (the one you get … Read more

jQuery Datepicker displays wrong language until interection with the calendar

This must have been a conflict in my site. TBH, I wasn’t able to spot the conflict, but I was able to circumvent it by setting the necessary lang strings just before datepicker’s initiation like so: $(function() { $.datepicker.regional[‘el’] = { closeText: ‘Κλείσιμο’, prevText: ‘Προηγούμενος’, nextText: ‘Επόμενος’, currentText: ‘Σήμερα’, monthNames: [‘Ιανουάριος’, ‘Φεβρουάριος’, ‘Μάρτιος’, ‘Απρίλιος’, ‘Μάιος’, … Read more

jQuery works in console but not when in a file

I tested and works fine. but you can use the wp_footer hook and you can add your custom js. check below code. code will go to the active theme functions.php file. function add_custom_scripts(){ ?> <script type=”text/javascript”> (function($){ $(document).ready(function() { $( ‘#menu-item-927’ ).on( ‘ubermenuopen’, function(){ $(‘.site-content’).addClass(‘blur’); }); }); })(jQuery); </script> <?php } add_action( ‘wp_footer’, ‘add_custom_scripts’, 10, … Read more