get_current_screen
is an Admin API, it can’t be used on the frontend, only in /wp-admin
screens.
If you want to run javascript code only on certain pages, either enqueue it on those pages, or load it on all pages and check the body classes, or many other methods. get_current_screen
is not the way to do it.
Related Posts:
- Dynamically Override Fancy Title
- WordPress after content Hook & external template part
- Call to undefined function is_home() or any conditional tags
- Difference Between Filter and Action Hooks?
- Explanation of the “posts_join” and “posts_fields” filter hooks?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How do I Make a Theme “plugin-ready”?
- function triggered by “manage_users_custom_column” filter not working
- How to modify post content before writing to database?
- Determine which theme location a wp_get_nav_menu_items is for
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Is it possible to create an action hook using do_action() within add_action()?
- Hook for post permalink update
- Define a function outside a class and call the function using action or filter hook
- Does add_filter work outside functions.php
- What function to hook for changes made in status and visibility of a post
- Synchronize Custom post type tags to WordPress default posts tags
- Woocommerce – Hide a Column in Cart Table
- Namespaced action and filter tags
- best practice for query string values – get_query_var always empty for my value supplied in query string
- Adding option to Gallery shortcode
- correct way to call javascript into hook function
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- WordPress custom taxonomy check box to dropdown
- WordPress class, using add_action to call member function does not work
- How to get all queries’s results after they have executed?
- Remove an action by extending class and replacing it
- hook filter after the_content on a specific page
- Bind a function with its own argument to show something dynamically after every content
- Hook add_attachment error
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Update variable value via add_filter
- Configure WordPress to Generate Scheme-less Relative URLs
- How to find list of all functions bind to a particular hook from my plugin?
- Adding tables to dashboard pages programmatically?
- apply_filters() and call_user_func() to define and call a function outside a class
- Override category archive page title (not the head title)
- Limit get_next_post to posts from the same author
- Any way, hook to add content right before the “read more” link?
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- Add_action not calling callback function
- Function not working on any file other than the main plugin file
- Template file structure , wordpress hook for altering the template
- WordPress permalink setting
- How do I replace title with my plugin?
- Apply function on all action hooks?
- get_term_by() returning null on plugin
- Ninja Forms: Front-End Forms, Post ID?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- add_action hook for completely new post?
- Why does WordPress add 0 (zero) to an Ajax response?
- Passing arguments to a admin menu page callback?
- Understanding WordPress functions’ naming conventions
- Using query_vars filter
- What’s the earliest point I can get the queried object ID?
- When is it appropriate to put functions on page template vs. functions.php?
- Plugin development, hooks, generate content
- Problems with removing admin bar
- Hook event for upload image in the menu
- Help with callback using do_action_ref_array
- How to allow Unfiltered HTML in a wordpress multisite install
- Is there a way to verified if an add_filter is already applied?
- multiple functions with same filter
- Plugin Uninstall and Deactivate via Options Menu
- How to delete an user including data from custom database tables
- add more custom post types and custom role to the code
- Why is my javascript not invoked in my hooks except wp_head?
- Two functions utilizing registration_errors filter
- Is there a Filter that I can use to filter the tags before they are inserted in to the database?
- Override class inside $atts shortcode_atts in WordPress
- How to use a hook to override an update_post_meta call in a plugin?
- External Authentication, session_tokens not destroyed on logout
- Why doesn’t my simple the_title filter get applied?
- How to add user details to different tables immediately after user registration
- Force HTTPS 301 redirect with hook
- use of do_action() without any functions attached
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- Plugin uninstall function is not working
- Why wp_die() doesn’t work with wp_redirect but exit() works
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- Overwriting a plugin function
- Writing editor content to a file
- How do i remove the title from a specific page
- Add hook after content without formatting
- How to enhance a self developed plugin by its own plugin architecture
- `registration_errors` filter doesn’t seem to be called
- How to grab data after wp user search is complete
- Nested Hooks with do_action for performance reasons – safe/necessary?
- WordPress plugin how to run function when button is clicked
- Change Front page displays settings conditionally when user is online
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- plugin modal/popup integration best practice
- Get user logged in status from within a plugin. $current_user not defined
- add query string to all pages after user logged in
- Insert plugin html content to a specific spot in the frontpage
- wp_head is not fired from the hook I have used in my plugin
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Do Not Back Up? Is there any accepted way to tell backup and clone plugins to skip a certain file? [closed]