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.

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

Publish Confirmation Firing Twice

I have written this code to double-check users are happy to publish posts: <?php $prompt = "are you sure you're ready to publish"; function confirm_publish(){ global $prompt; print ' &...
0
votes
0answers
13 views

Change hover to onclick on menu

I've got a local website on WP using DIVI where a header menu got some "menu-item-has-children". In way to view these sub-menu, I just have to hover on it and when mouseout the sub-menu disappear. ...
0
votes
0answers
17 views

Using JS .show() and .hide() causes hidden div to not be displayed properly

So I have a drop down menu coded in HTML as follows <Select id="ContentSelector"> <option value="Courses">Courses</option> <option value="Podcourses">Podcourses</...
0
votes
0answers
11 views

event/callback on block update?

I am attempting to put together a custom block that produces an embed from a third party. The embed is generated by an external script scanning for an element with a data attribute holding a unique ...
0
votes
0answers
6 views

Pass Sku value on a single product page template using javascript

I am building a wordpress woocommerce site using elementor. Due to integrations I require a script that can pull the sku on the page then pass it through to the following coding (in the parameter data-...
2
votes
0answers
8 views

initial open/toggle PluginDocumentSettingPanel panel in document setting block editor gutenberg

i want make new panel inside document setting tab with React Script from this documentation but the problem panel not toggle onload/initial i have try open with dispatch('core/edit-post')....
0
votes
0answers
4 views

Highlight selected dates in CF7 [closed]

I have a contact form on my WordPress page and I use the datetimepicker-plugin for my clients to choose a date and a time for an appointment. I want that appointments that where already selected are ...
0
votes
0answers
9 views

Problem with phpmailer WordPress [closed]

when I buy with Woocommerce I see the error "Internal Server Error" and into debug I see this problem: 2020-05-26T15:57:51+00:00 CRITICAL Cannot declare class phpmailerException, because the name is ...
1
vote
1answer
13 views

Can't Listen to KeyDown in TInyMCE Iframe (jQuery) and Pass it to Parent HTML FORM

I am trying to build an HTML form with TinyMCE textarea such that on Clicking Ctrl+S, it submits the form, by clicking the SUBMIT buton of form. I am using jQuery, here is the KeyDown jQuery(...
-1
votes
0answers
5 views

Sticky header for wordpress changes logo position as I scroll down

My client's website have a Sticky Header with a logo. However, every time I scroll down the logo changes its position, it moves to the center and overlapped with the Menu. Anyone face the same issue ...
4
votes
1answer
90 views

Show control conditionally in Gutenberg

I have this custom post type with two meta fields that I need to show as toggle controls (RestrictControl and SubscribeControl) in the PluginDocumentSettingPanel sidebar in the Gutenberg editor. The ...
1
vote
1answer
12 views

Image upload via FormData API and AJAX is not working ($_FILES always empty)

When I try to do what's mentioned in the title, my requests all work (nonce check passes, and server response 200 receveived, and server - script also working properly). My problem is that I cannot ...
0
votes
1answer
13 views

front end editor creation for Restropress plug in - displaying information from a WP admin area, on a different URL

I dont know where to start on something I am trying to do other than by asking the question. Please forgive my newness. Thanks in advance - I have a REstropress WP plug in that shows some order ...
0
votes
1answer
19 views

Ajax search box displays nothing if taxonomy doesn't exist

Hi i have a ajax search box that pulls all my taxonomies from my post type but if I start typing and the taxonomy does not exist it just displays a small box with nothing in it. is it possible to ...
1
vote
1answer
25 views

Shrink Header Image on Scroll

I am currently using the free version of neve on a local server and I am trying to make my sticky header responsive based on the scroll. The text is responding correctly and becoming smaller, however ...
0
votes
0answers
8 views

An image gallery that shows a text overlay in the last image showing a + X being X the number of images not shown [closed]

I would like to show a simple image gallery in wordpress where I show i.e. 3 images of 10 and the system shows +6 on top of the last image thumbnail. I assume I would have to use javascript but I ...
1
vote
1answer
17 views

How to set callback to execute after all the tinyMCE editors have been initialized?

I've loaded a tinyMCE editor using wp_editor function of Wordpress. Now, I want to set value of that editor after it gets initialized. I tried to do it like this: $(function() { tinymce.get(...)....
0
votes
0answers
7 views

Convert Eventon Timezone Meta Variable to Local time

Simply put, I want to somehow extract the event start time and event end time from the events at the following link... https://rebrand.ly/yewh1tu I know the logic of what needs to happen, but don't ...
0
votes
0answers
9 views

Securely render emojis on front-end and post to backend

I am creating a wordpress plugin which allow user to select different emojis with text. I am then making a fetch request to back end to update with selected emoji. Right now I am just rendering a ...
0
votes
0answers
3 views

Woocommerce shipping options not changing checkout total

I am working with woocommerce at the moment, I have created a child theme off of storefront, and I notice that when I change the shipping option to once that has a price the total order price does not ...
0
votes
1answer
8 views

How take a widget/shortcode on top of page content with CSS o JS?

I wrote a shortcode that generate a custom HTML element using HTMLElement JavaScript class. This widget uses a lot of custom CSS. It works good but on some themes (like The7 i.e.) some page content ...
0
votes
0answers
17 views

Wordpress Guttenberg - How to get query attributes in a dynamic block?

I am trying to create a dynamic block and I am unable to determine the way to grab this information on the PHP side. Currently my index.js has: import edit from "./edit"; import { registerBlockType ...
0
votes
0answers
32 views

Required/Mandatory fields in WordPress Admin

Looking for a solution for WordPress Admin where fields such as Title, Excerpt, Category are required before being able to publish. Warning message or alert displaying what is missing because it is ...
0
votes
0answers
15 views

What is the best way to add large JSON to cart item / order?

I have a pretty large (up to 3000 key, value pairs) javascript object generated on the product page and I somehow have to add it to the cart item data (or any other way to make it accessible for every ...
0
votes
1answer
18 views

Change normal grids to masonry grids

I'm currently creating a wordpress theme and so far all my code is working fine (my theme is based on the isotope js gallery), but I would like to transform my normal grids into masonry grids, could ...
1
vote
1answer
28 views

can a buttongroup have a label?

I'm developing a Gutenberg block, and am trying to create some InspectorControls. I would like to create a buttongroup to control the alignment of a specific element within the block (I would add that ...
0
votes
2answers
18 views

How to return div with custom attributes(Coding a Gutenberg Block)

I'm making a review widget that comes as a shortcode and Gutenberg block. The shortcode part was easy as I have built many shortcodes before, but I'm stuck on building my first Gutenberg block. More ...
0
votes
0answers
14 views

Update Woocommerce shipping cost when ajax request is made

I have google autocomplete api on my address field in checkout page and embeded map with polygons as delivery zones. Each zone has it's own delivery cost which also depends on order's total cost. When ...
-1
votes
1answer
12 views

Embed Kajabi into WP

I am trying to embed kajabi into a WP page, I am using WPBakery if this is necesarry. The Kajabi is an email capture form and I need it to in a specific part of a page. Can anyone help me with this? ...
0
votes
0answers
23 views

I have an trouble in my wordpress theme. The error is “Uncaught ReferenceError: theme_scriptspf is not defined”

This is message from console of Chrome: Uncaught ReferenceError: theme_scriptspf is not defined at HTMLDivElement.<anonymous> (ajaxlist.js?ver=2.0:45) at Function.each (jquery.js?ver=1....
1
vote
0answers
17 views

Add toggle button for mobile sub-menus

Been playing with this for hours but not getting anywhere, please help! So I have a menu which works fine for the sub menu dropdown on desktop. What I want for mobile menus is for their to be an ...
2
votes
0answers
7 views

How can I filter block registration based on post-type? (Block alignment settings)

I want to disable the .alignwide and .alignfull block alignment options (remove them from the editor UI) on the 'post' post-type only. I have tried using this block registration filter to modify the '...
0
votes
0answers
12 views

WebSockets, Long Polling or Several Ajax Calls?

I'm setting up an Ajax Call which, when fired, is calling a php - script which carries out the following tasks, among others, in this sequence: upload an image to the server create a post associate ...
1
vote
1answer
19 views

I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php

I'm working on converting a code template (html, css, js) into a Wordpress Theme. This wordpress theme is not a child theme. For the home page (front-page.php file) the enqueues of stylesheets and ...
0
votes
1answer
15 views

How can I add Block Style support to the core HTML block in Gutenberg?

The HTML block in Gutenberg can be given styles like so: // JS file, enqueued using the action "enqueue_block_editor_assets" wp.blocks.registerBlockStyle( 'core/html', { name: 'full-width-video', ...
0
votes
1answer
19 views

Display one random image from Media Library

I was asking if is possible to get all images from Media Library and display one of them randomly every time I refresh the page. I think it'd be something like make an array of media library images (...
0
votes
0answers
23 views

Can I get the user name in JavaScript?

I would like to use the user name of a logged in user in JavaScript without server side implementation. Since I'm using a cache plugin (WP Super Cache), I don't want to place a user name into the ...
0
votes
1answer
60 views

Issue migrating a checkbox-type meta field to the block editor

I'm trying to add Gutenberg support to a plugin that registers a custom post type with a checkbox-type meta field called _meta_restrict, while maintaining back-compatibility with the classic editor at ...
0
votes
0answers
13 views

Delete duplicate product variations from wordpress

My Woocommerce store has thousands of products, each with 32 variations (8 color attributes and 4 sizes attributes). recently i wanted to get rid of the size attributes. I was able to update the ...
2
votes
0answers
26 views

How to save a ToggleControl value in a meta field?

I registered a boolean meta field called _meta_restrict in a custom post type: PHP: function register_meta_fields() { register_post_meta( 'custom_post_type', '_meta_restrict', array( '...
1
vote
0answers
7 views

Use AJAX to fetch Current Post Thumbnail for Wordpress when Uploaded throughMedia Uploader Frontend

i Use WordPress Media Uploader on Frontend to allow users to upload Thumbnail for there UGC site. I also show a Preview of the Image on Frontend. When a user clicks the button the Media Uploader opens ...
0
votes
0answers
14 views

Front-end post trough ajax results in infinity loop

This code creates a post successfully but then it repeat is self over and over. var visitorData = { "title": 'TEST', "status": "publish" } var createPost = new XMLHttpRequest(); createPost....
0
votes
0answers
17 views

WordPress live search and filter

I have a grid of posts on my archive page. How can I filter through them once I start typing on the search bar, or filter by category on click, please?
0
votes
2answers
24 views

Need help about understand api, wp, $ syntax in WordPress plugin script

I really new in Wordpress development and have a little bit of knowledge of jquery. I was trying to understand a WordPress plugin and also trying to understand the js code they wrote for the plugin. I ...
0
votes
0answers
8 views

Gravity form is broken after javascript defer

I want to optimise my website javascript, but i'm also using Gravity form and if I deferred js the form doesn't show up, there will be an error in the console saying jQuery is not a function. I have ...
0
votes
1answer
20 views

Wordpress site hamburger menu toggle not working

When I shrink down the browser to test for mobile responsiveness, the hamburger menu does not open, even after I clicked on it. I have tried everything from troubleshooting my plugins to searching all ...
0
votes
0answers
8 views

Display custom field under image in TinyMCE editor

I have a custom media field called "Source" with the key media_author. I would like to display it under the image in the TinyMCE editor, like the caption field is: The caption field is editable, but ...
0
votes
0answers
13 views

How to get the total number of posts (in PHP) and pass it to Javascript?

I have an AJAX call that pulls the next page of posts on my home.php template. Now I want the total number of posts as a variable in the javascript file, so that I can use it in an if-statement to ...
-2
votes
1answer
20 views

Defer parsing of JavaScript [duplicate]

When I test my page speed for the site (https://sunshineecocleaningservices.com.au/) it gives the score of 0 for defer parsing of JavaScript "3.6MiB of JavaScript is parsed during initial page load. ...
0
votes
1answer
13 views

Dynamically modify content added to table via javascript

What I want to do is quite straightforward, but I can't figure it out. Let's say you have this variable defined in your global scope of your script: var contentOfRow = "<tr><td>hello</...

1
2 3 4 5
44