Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
105 views

'global' not working when passing variable from plugin file to template

I have a custom plugin file that contains a function to generate a string upon the firing of a 3rd-party plugin hook. I want to echo this string in a custom template file — how do I give the template ...
tikis.tacos's user avatar
0 votes
2 answers
708 views

How do i set global variable in a function in wordpress functions.php

Please vet this code and help me with how to declare '.($a['link']).' variable such that i can echo its content in single.php function mp3_download_link_att($atts, $content = null) { $default = ...
John Ovye Godwin's user avatar
1 vote
1 answer
760 views

Getting List of all registered Dashboard Widgets

I am trying to get a list of all registered meta boxes in the wordpress admin, specifically the Dashboard widgets. Now this is easily achieved with the global variable $wp_meta_boxes and does exactly ...
Mark's user avatar
  • 11
1 vote
1 answer
1k views

What is the proper method of using global $post?

I am using global $post multiple times in a class. These are my doubts Is that a bad practice? Can it result in slow websites? What's the proper way to use it inside a class class Test{ public ...
user avatar
0 votes
0 answers
27 views

How do I get a reference to the HTML memory buffer while the page is being constructed?

I want to view & update the buffer with html "<head>" data section in it, after the head has been generated. Problem statement: I have created some shortcodes in a plug-in which, if ...
GaryL's user avatar
  • 101
1 vote
1 answer
2k views

Global $post not working in OOP function WordPress

I added a custom field with comment form. Below is my code.First function return post id when using var_dump function.But the last function return NULL always. class Post_Rating_Public_Helper { ...
Shoaib Saleem's user avatar
0 votes
2 answers
376 views

Translation issue with global variables

I'm creating a plugin that supports internationalization. Everything is working fine, except for global variables. Strings in global variables will not get the appropriate translation. Explanation: ...
Michele Fortunato's user avatar
0 votes
1 answer
343 views

global $post inside plugin query messes up every new post page in wp-admin

I have a very strange problem that I am trying to troubleshoot: I have a query (to build an array) that I run on a custom post type inside my plugin. It looks like this: function makePointerQuery(){ ...
Stephen's user avatar
  • 971
6 votes
1 answer
365 views

Global Objects and Public Methods

I'm developing a plugin and am just thinking over best practices. How common is it to have a global object? Currently on plugins_loaded I am creating a global object of my class: add_action( '...
Howdy_McGee's user avatar
  • 20.8k
6 votes
2 answers
2k views

Custom plugin: Trying to show saved data on frontend

I'm working on my first plugin and I have made a nice settings page which saves and works. But I have split it to few files and now I can't determine if field is checked.. I have also tried ...
Nate's user avatar
  • 186
0 votes
1 answer
2k views

how to get the post id in plugin

I have a plugin that I'm working on and I'm having trouble getting the post id so jquery can use it. I'm able to get it using the admin_head hook but I'm not sure how I can return it to jquery. I'm ...
graphical_force's user avatar
0 votes
0 answers
101 views

Sessions in plugin development?

I'm developing a plugin. At present I have two files. dotmailer.php and dotmailer-add.php. I'm creating a newsletter widget. My dotmailer.php plugin adds an admin menu, with options. It allows the ...
Francesca's user avatar
  • 305
5 votes
2 answers
1k views

What is the difference between using global $current_screen and get_current_screen()?

I have been looking at get_current_screen();. I have seen there is also a global $current_screen; that I could use. Here are two examples: // Using function function wpse_post_notice() { $...
grappler's user avatar
  • 865