Questions tagged [javascript]
A client side scripting language useful for making interactive web sites. Questions about using JavaScript outside a WordPress context are off-topic but might be asked on Stack Overflow.
971
questions with no upvoted or accepted answers
1
vote
0
answers
163
views
How to reference TinyMCE body in my script
I want to add some custom behaviour to my TinyMCE body, but I can't reference it in my script.
This is how I load my scripts inside my WordPress plugin:
$this->loader->add_filter( '...
1
vote
0
answers
24
views
Using defer or async JavaScript attributes prevents pingbacks and trackbacks from being sent
I'm using the following code to defer all JavaScript files on my site but have struggled with pingbacks and trackbacks; they don't work anymore.
It seems that WordPress is using some JavaScript to ...
1
vote
0
answers
764
views
How do I pass the id of my widget to javascript in the form function?
I would like to add a Quilljs editor to the admin area of my widget, but I am having trouble passing $this->id to javascript.
I am using the foo_example widget code, and I've appended the ...
1
vote
1
answer
809
views
TinyMCE 4 remove/add attributes for all images
i want to search for all images that have been add to TinyMCE 4 and:
Remove the height attribute from the images
Add style="max-width: 100%;" to all images
what is the best way to do this tasks?
...
1
vote
0
answers
420
views
Using React.js in WordPress
I want to add a "Widget" that is built with React.js to my WordPress site. It will not be dependent on any outside data. Besides adding npm modules and adding build processes to my Gruntfile (to ...
1
vote
2
answers
2k
views
AJAX not Working with php as supposed
I am creating a like system in PHP . My code looks like this .
<?php
class Like_System {
private $userid;
private $postid;
private $user_ko_like_count;
private $post_ko_like_count;...
1
vote
2
answers
47
views
Easy popups for wordpress?
I used a theme that had a great function for popup windows - a pop could be created by adding "#iframe" to any urllink ie
<a href="http://yahoo.com#iframe">click for popup</a>
Is there ...
1
vote
0
answers
3k
views
Google PageSpeed Enable Compression isn't working?
I am trying to improve pagespeed of my website. When I test my site it tells "Compressing https://z-1-static.xx.fbcdn.net/rsrc.php/v2/yF/r/SQ7jeOqw5xW.js could save 188.3KiB (70% reduction)." I have ...
1
vote
1
answer
841
views
Trouble with Wordpress Ajax Login System - 302
I'm trying to create a simple Ajax Login system with Wordpress.
Unfortunately, every time the "wp_signon" function is fired, my system failed and the only information I have is this one :
POST myurl/...
1
vote
0
answers
79
views
how to localized scripts of new page requested by ajax?
I'm using ajax to load pages in WP ( all links of my theme works with ajax) and when i go from a page to another, I remove old script tag ( current page ) and add scripts of requested page dynamically(...
1
vote
0
answers
2k
views
'Lazy loading' list of posts with pagination
I have reading settings set to show 30 posts per page, and what I'd like to do is show half of the list of posts and then 'lazy load' the remaining half on scroll. I've checked out some the available ...
1
vote
0
answers
3k
views
How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
I want to add a custom Mailchimp AJAX Newsletter Subscribe Form to my WP Blog. I found this tutorial and have followed it: http://neal.codes/blog/custom-mailchimp-ajax-newsletter-subscribe.
I've got ...
1
vote
0
answers
141
views
Access Customizer widget instance form
On the WordPress admin widgets page there is a known issue with the widget form not being available the first time a widget is added to a widget area. This can be seen in this trac ticket here: https:/...
1
vote
0
answers
143
views
Media Upload , file name changed automatically
I face a problem that when i upload a video that named in non-english language , for example : Arabic , it placed in uploads folder with strange name
Ùيديووو
so it can't be access through ...
1
vote
1
answer
229
views
Limit filetype and wp media
This is my input markup:
<div class="button-primary" id="fileToUpload">Upload</div>
This is js:
jQuery( '#fileToUpload' ).click( function()
{
var custom_uploader = wp.media
({
...
1
vote
0
answers
1k
views
Post repeating with infinite scroll
I'm working on this page: http://bit.ly/1ujkiFa
I'm creating an infinite scroll of books (wordpress posts).
If you see the first row of books is this one:
But if you scroll down, after it "loads ...
1
vote
0
answers
145
views
Override do_item() Function to Add Extra Attribute to Scripts
The WordPress file that do_item() is in can be found here:
class.wp-scripts.php
Line 142
Line 144
$this->print_html .= "<script type='text/javascript' src='$src'></script>\n";
...
1
vote
1
answer
505
views
Is it possible to pass js variable to template file
I have select drop down created in functions.php and in js file getting onchange value of drop down. I want to know do I pass this variable to my template file?? This is my code in functions.php file
...
1
vote
0
answers
205
views
esc_js() breaks unicode sequences by removing the slash '\' character
I've noticed that esc_js() is breaking unicode encoded characters by removing the '\' (slash) character. For example:
esc_js('\u041f')
returns:
'u041f'
I can potentially use REGEX to identify ...
1
vote
1
answer
344
views
Adding javascript actions to words in post content
I would like to have my blog run some JavaScript code when certain particular words are clicked on.
One approach would be to include "onClick" handlers in HTML elements within the posts and disable ...
1
vote
1
answer
85
views
How to get my plug-in, wrote in php, to refresh on its own every 5 minutes?
I wrote a plugin with custom widgets for the Dashboard. It retrieves information from an XML file, and display the information into the widget. The XML file will be modified a bit every few minutes or ...
1
vote
0
answers
109
views
Resetting admin post form on JS validation fail
I've got a custom plugin with a metabox and dynamic form (the user can ask for more elements of the form), with jQuery Validation plugin working great. The problem is when the validation comes back ...
1
vote
1
answer
309
views
Wordpress 3.8.3. custom theme - sliders won't load js/css files
I'm building custom WP theme and I have issues with sliders. None of those I've tried to install worked. When I looked into the developers console, and searched for their js/css files, they where not ...
1
vote
0
answers
142
views
Wordpress Scripts Being Loaded in Footer
I've bought a theme for a Wordpress site.
I noticed that the theme author has added the javascript to the footer for load time, but as I use Gravity forms, I understand that some of scripts need to ...
1
vote
1
answer
217
views
Using TinyMCE in plugin?
I've successfully integrated DataTables Editor into WordPress as its own plugin. It loads successfully and I can edit a DataTables' table. What I'm trying to figure out is how to utilize WordPress' ...
1
vote
0
answers
3k
views
Multiple Frontend Filters Using Advanced Custom Fields
I've got a series of custom post types set up, and a large amount of custom fields are linked to these post types via the Advanced Custom Fields plugin.
I want to set up a series of checkboxes on the ...
1
vote
1
answer
136
views
Proper way to enqueue a generated script that isn't in a .js file?
What's the proper way for loading a script via WordPress that isn't in a .js file?
I'm generating some javascript on the fly based on some field options in a plugin. I want to load it into the page, ...
1
vote
0
answers
389
views
Fancybox type popup window that's not an iframe
I'm a bit stuck and need some help to get me going in the right direction.
I'm trying to do something similar to the lightbox style popup on this website: http://cargocollective.com/montessori
I ...
1
vote
0
answers
255
views
videopress videos are not displayed when loading the content with ajax in a lightbox
I'm using videopress and I'm adding the videos into posts with the videopress shortcode, and when I visit the post I can see the videos and play them, but the problem is when loading the post with ...
1
vote
0
answers
172
views
Using window.onload with Ubermenu
I am using a plugin to place this code on specific pages. But it is not firing correctly.
Has anyone had experience working with Ubermenu, WP and jQuery? Do I have to call jQuery into my <script&...
1
vote
1
answer
146
views
Generate sidebar depending on height of post
I'm building a site which features sidebars next to each post/article displaying random thumbnails linking to other posts.
Each sidebar should never be longer/bigger than the post it's sitting next ...
1
vote
0
answers
222
views
Accessing theme customizer farbtastic object instances
I have multiple individual color pickers set up in the theme customizer, which results in several instances of the farbtastic color picker.
I am trying to find the jQuery/JavaScript instance variable ...
1
vote
0
answers
159
views
How does Wordpress handle HTML Tables interaction with jQuery
I have javascript that gets the width of a table and reduces the css fontsize of text within the table until the table width is less then the width of its parent div.
The code bellow shows the ...
1
vote
1
answer
3k
views
REST API: Display Category names in JSON?
Using the Wordpress REST API, I retrieve all my posts into a Angular 6 service. The category field in the JSON displays the ID of the category as an array of numbers.
"category": [ 6 ],
Is there a ...
1
vote
1
answer
3k
views
How to solve 'Eliminate render-blocking JavaScript and CSS in above-the-fold' content for multiple files?
I get this when I check my site in google insight:
Pretty ok right? But I still consider to fix Eliminate render-blocking JavaScript and CSS in above-the-fold content to get a good results on mobiles ...
1
vote
1
answer
872
views
How to load JS for specific screen size using wp_enqueue_script?
I need a option so that when I am adding some script using wp_enqueue_script it should load for specific screen size. Like when the screen size will be below 768px the script will not load.
I am ...
0
votes
0
answers
16
views
Why is my JS not working on initial load?
I'm having weird issues with one of my JS Files that I added via a child theme. I have enqueued it in the functions.php and added some vars with wp_localize_script.
wp_enqueue_script('header-astra', ...
0
votes
0
answers
13
views
Additional CSS classes not being added in Gutenberg editor
When we add additional classes to our custom block they are not being added in the editor. When we save the block and view the front-end the additional classes are showing. But in the editor they won'...
0
votes
0
answers
11
views
Sudden ERR_HTTP2_PROTOCOL_ERROR on every JS and CSS files loads
I recently went on my website which is online since more than 5 years now and realized that none of the CSS and JS files were loading. By looking into the console, I’ve seen that every load fails ...
0
votes
0
answers
15
views
allow multi carousel in same page
I have this code for slider, i need help to edit it to allow multiple slider in same page.
var all_divs = $('.px-carousel-container .px-carousel-item').length;
var i = 0,
n = 0;
let ...
0
votes
0
answers
7
views
How can i force replace a external js scripts language on the site itself?
Im using this https://www.gloriafood.com/ service and their translation is very poor. I would like to make adjustments myself. since it comes from an external source i cant really edit any spesific ...
0
votes
1
answer
23
views
Why does my JavaScript work in the browser console but does not work in my shortcode?
I am trying to create a shortcode the user can just insert which creates a button that loops through an array and displays it or hides it. On page load I want every item with an index >= 1 to have ...
0
votes
1
answer
24
views
How do I filter/modify the updated content on save using javascript?
I want to use js to filter content being saved in the Gutenberg editor for pages. So far I have this, which will get the content on save, but let's say I want to append xxxxxx to the end of the ...
0
votes
1
answer
32
views
How to detect changes in WooCommerce store (react)?
Since WooCommerce merged blocks in the plugin, the cart is now completely 'reactified'. Meaning I update the quantity on my cart, I see a network call to an endpoint, thigs update without reloading, ...
0
votes
0
answers
15
views
Passing total post count to javascript
I have a ajax post loading program, I can load more post on click of a button.
Problem im having is getting the button to hide or show less when no more post.
I can query out the post count in PHP as ...
0
votes
1
answer
14
views
get total post in category via ajx
Aim
The total to be equal to the amount of post within the selected category or sub category.
What im getting
I am getting 0 when trying to get the number of post available in a category.
My aim is to ...
0
votes
0
answers
20
views
Need help understanding Minimize main-thread work
i'm doing a pagespeed test for my site and the main error for mobile is:
Minimize main-thread work 8.4 s
Consider reducing the time spent parsing, compiling and executing JS. You may find delivering ...
0
votes
0
answers
23
views
Default post showing more than intended
I have a ajax set up where I am loading post categories via ajax request on click of a button.
I have a default query that is loaded for when the ajax filter is not set so a default state.
It should ...
0
votes
0
answers
25
views
Load more post with AJAX
I have a simple post that i am using alipine.js to help me load post using AJAX.
So far it is loading my pages and changing the category if I click a filter button, this is all expected and working.
...
0
votes
0
answers
18
views
how to assign javascript variable value to php variable in wordpress
I use following way to fetch the value of gtag if it already exists in the code:
<script>
const regex = /googletagmanager\.com\/gtag\/js\?id=([^\s'"]+)/gi;
const ...