No access to wordpress functions from plugin files - wordpress

I came across this problem when I was creating a plugin. I cannot call(access ) wordpress default functions like wp_get_current_user(), $wpdb->get_results(), admin_url() etc. from my plugin files. I can access them from my main file of that plugin in which plugin description is given. But I cannot access them from other plugin files. At that time I heard that if we create a new file functions.php and put these code in that file inside a function I can access all wordpress functions. I did so. But now I cannot access that new function. How can I solve this problem? I think you guys understood what I said. Please help me.

#Jan : I got the required thing. I just put require_once('../../../wp-load.php'); in my plugin files and now can access all wp functions from there. Any ways thanks for your reply.

Related

Share wordpress template between themes

Is it possible to share a template file between WordPress themes?
If so, where should I locate it?
I didn't even manage to share a simple myfunctions.php file between theme templates.
I tried putting the file in the wp-content/themes folder, but the
include('../myfunctions.php');
fails to find the file. Am I overlooking something really simple that prevents this? Thanks.
AFAIK you can't "share files" between templates. You are looking for plugin functionality.
However, if there is a WordPress specific way for doing this I would like to know too.

drupal_get_private_key equivalent Wordpress

I'm trying to convert the theme from Drupal to Wordpress, I don't know a lot about drupal, so this function "drupal_get_private_key" confuses me a little and I can't really find a lot of documentation about it. Could someone explain me what is this function about and how could I do this in Wordpress?
Thank you for the help
Drupal uses this to generate the paths to files* (its used in other stuff too, but in themming I believe its the main reason).
*These files are the files created by users, not the files in the theme folder. The folders are configured in the admin and, when an user uploads a news picture, for example, it will be placed in the configured folder.
You problably just want to find another way to find these paths.

why we are using the ../../../wp-load.php in wordpress?

Sorry for asking this type of stupid ques.
But i don't know I need your help
I look out the coding that they are in wordpress plugin.
require_once('../../../wp-load.php');
I really don't know what the ../../.. is perform some one know ,let me give an suggestion
I am not tell about the core file and all .that extension before the php file.
Thanks.
That loads the WordPress framework for use outside of the native environment.
For example, if you wanted to have a PHP controller that handled AJAX requests, you could load the WordPress environment to validate the current WordPress user login status.
The "../../.." tells the require function to start at the current file, go up three directories, then access wp-load.php.
Based on that path, I can guess that the file is sitting in a theme folder. wp-content/themes/yourtheme

Elgg: File upload plugin hook?

I'm looking to use the File plugin to upload the files needed by the plugin I'm developing. I'd just add a specific tag to the files uploaded from my plugin, thanks to a hook.
At least that's how I wanted things to work, but I can't find any hook that would help me do that, so here comes my question:
Is there a plugin hook I could use to modify a file being uploaded using /mod/file?
If there isn't, I'd be glad to hear about any other way I could achieve what I want.
Sorry, I didnt understand your requirements correctly.
If you want to upload a file through a different plugin, use the core file upload action with in your plugin's upload action. You can then listen to an object create event and then add necessary metadata with the uploaded file.

Wordpress plugins_url function doesn't seem to be working

I have a plugin on my site that uses plugins_url to grab the correct path for an attached javascript file. However, when I load it on my site, it seems to be mixing up the path.
My wordpress installation is at http://serverip/~account/
and the plugin is trying to access the javascript file at http://serverip/~account/~account/yaddayadda (notice the duplication of the ~account dir)
Not really sure where the issue is, and how to resolve it. Any ideas where to start?
You may use WP_PLUGIN_URL to get plugin directory URL and WP_PLUGIN_DIR for directory path, BTW, what issue are you facing with plugins_url?

Resources