Wordpress: Call A Plugin Function With A Php Call?

May 25, 2010

I'm writing a Wordpress MU plugin, it includes a link with each post and I want to use ajax to call one of the plugin functions when the user clicks on this link, and then dynamically update the link-text with output from that function.

I'm stuck with the ajax query. I've got this complicated, clearly hack-ish, way to do it, but it is not quite working. What is the 'correct' or 'wordpress' way to include ajax functionality in a plugin?

(My current hack code is below. When I click the generate link I don't get the same output I get in the wp page as when I go directly to sample-ajax.php in my browser.)

I've got my code[1] set up as follows:

Plugin Name: Sample Plugin
if (!class_exists("SamplePlugin")) {...........

View 2 Replies


Call An Inside Plugin Function With A <a Href> Generated By Another Function Of This Plugin?

I'm making a little widget for my site using a search api I just made. Briefly, I want to retrieve last posts or top rated posts. I've got to tabs for that.By default, on loading, I'm on recent posts. If I click on Top posts, I'd like to call a function inside my plugin that modify a var that tell to my search API to retrieve data in the right order.I don't know if I'm very clear.. Please, take a look at my (simplified) code :

// here, i tell that by default, you have to load latest posts
var defaults = {


View 1 Replies

Auto Call Function For Every Other Function Call / Call Another Function Before Any Called Function Execution?

Class test{
function test1()
echo 'inside test1';
function test2()
echo 'test2';
function test3()
echo 'test3';
$obj = new test;
$obj->test2();//prints test2
$obj->test3();//prints test3

Now my question is,

How can i call another function before any called function execution? In above case, how can i auto call 'test1' function for every another function call, so that i can get the output as,


currently i am getting output as


I cannot call 'test1' function in every function definition as there may be many functions. I need a way to auto call a function before calling any function of a class.

View 6 Replies

WordPress And Call To Undefined Function Add_menu_page()?

I recently got into WordPress plugin development and I would like to add a menu page (the links in the left hand side menu). Previous SO questions and the WordPress codex say that it's as simple as calling:

add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );

However when I try this in my plugin setup file it tells me that the function is undefined:

PHP Fatal error: Call to undefined function add_menu_page()

This seems like a very simple thing to do according to the documentation but I am totally baffled.

View 1 Replies

Wordpress - Call A Function When A Comment Is Posted?

I would like to take some action in php whenever someone posts a comment. How can I set up a hook for that?I assume it would go in functions.php...EDIT - here is my udpated code:

add_action('comment_post', 'comment_posted');
function comment_posted() {
$MyClass = new MyClass(); //I do this in other functions and don't have any blank screen problems


View 1 Replies

Wordpress Sidebar Error / Call To Undefined Function?

I am new to Wordpress and I have published pages on my site. I tried to get into the code of widgets.php, but stupidly, I worked on the original desktop file instead of the one on my server and I uploaded it which replaced it. I should of downloaded widgets.php from my server. I spaced out. So, now I get this error on my page:

Fatal error: Call to undefined function: get_search_form() in /home/borrowde/public_html/iremembermovies/wp-includes/widgets.php on line 771

Here is line 771 (of widgets.php):

Code: [Select]/**
* Display search widget.
* @since 2.2.0[code]....

btw~ I was originally trying to just change the amount of "Recent Posts" my page shows by following this tutorial: here.. Which I'm sure would of worked great, but I was an idiot and I probably added a 'blank' file with no recent search widget options.

My site: http:[code]....

View 6 Replies

JavaScript Call A Function Directly - Separate Php File To Call The Function?

I am doing some basic Ajax stuff (not jquery.. just learning the basics), and I have a general structure set up where html calls a javascript function which sends data to and runs a specific php page.

But what if I just need to run a php function that's already defined in functions.php. Is that possible at all? I'm getting tired of making new php files for every task ;)

View 3 Replies

Wordpress - Error: Call To A Member Function Set_prefix() On A Non-object?

I got this error Fatal error: Call to a member functionset_prefix() on a non-object in/home/reboltutorial/reboltutorial.com/wp-settings.phpon line 254ine 254 contains:

$prefix = $wpdb->set_prefix($table_prefix); // set up global tables

This occurs if I try to call index_wordpress() instead of calling these two lines

define('WP_USE_THEMES', true);

View 1 Replies

Classes : Call A Specific Function Everytime A Method Call Is Made?

I want to call a function everytime a method call is made in PHP.

Example :
$a = new a();

View 5 Replies

Oop - Call To A Member Function / Call A Method From A Singleton Class?

I'm receiving the following error message while trying to call a method from a Singleton class, inside another class. Any ideas?

Call to a member function query() on a non-object.

View 3 Replies

Shortcodes Breaking Wordpress Website - Fatal Error: Call To Undefined Function Add_shortcode()

I am creating new shortcodes for Wordpress on my local version of a Wordpress website. In functions.php, I am adding for example:

function shortTest() {
return 'Test for shortcodes ';
add_shortcode('shortTestHTML', 'shortTest');

Adding the function only is OK, but when I add the add_shortcode() portion, I get a major issue. It breaks something somehow and I get 500 errors, meaning I can't even load my website locally anymore.

From PHP Error Log: [21-Jun-2011 19:02:37] PHP Fatal error: Call to undefined function add_shortcode() in /Users/jonas/Sites/jll/wp-includes/functions.php on line 4505

View 3 Replies

Call A Defined Value Inside Of A Function Call?

when I run it, the defined part is nottranslated in the header function call, is there a special way to do the syntax or is this exact method not possible?

define('SITE_URL', 'http://testsddf.com');
$_SESSION['user_role'] = 0;

View 2 Replies

Placing A Call To The Object Inside A Function - Call To A Member Function On A Non - Object

I've searched high and low for the solution, and have found many that don't fit the bill. The general consensus is that this happens when you've not defined your object before calling upon it's functions. That isn't the case here (I think). Placing a call to the object inside a function seems to cause this error as shown below. Anyone have a solution for this? This works!

$dbConn = new dbFunctions;
$checkID = "SELECT COUNT(id) FROM table WHERE id='j5k38'";
$dups = $dbConn->FetchRow($dbConn->Query($checkID));
if($dups[0]>0){echo "false";}else{echo "true";}

View 5 Replies

Zend Framework - Register And Call Plugin In Bootstrap File?

1- How can I register and call my plugin in bootstrap file? 2- Is it a better way to use boostrap file intead of application.ini file for registering and calling my plugins ?

Note: Iam using custom path ('Mylib/Controller/Plugin') for storing my plugins.

Actually I want to convert following 'application.ini' entries

autoloaderNamespaces[] = "Mylib_"
resources.frontController.plugins.CheckHasAccess = "Mylib_Controller_Plugin_CheckHasAccess"

into bootstrap _initPlugin function.

View 1 Replies

Call Plugin In Embed Tag (linux - Mozilla) And Can It Be Called By Python

call plugin in embed tag (linux - mozilla) and can it be called by python / someone can give me a hand?

View 1 Replies

Cannot Call SetNoRender() On ViewRenderer In PostDispatch() In A Zend Framework Controller Plugin

Calling setNoRender() or indeed any methods on the viewRenderer helper seem to have no effect in a controller plugin.

class TestPlugin extends Zend_Controller_Plugin_Abstract
public function postDispatch(Zend_Controller_Request_Abstract $request)
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');

The view script still renders. And the plugin is definitely running as I can put echoes in here and they will output.

View 3 Replies

Wordpress Can't Find Function From Plugin?

I have installed a plugin wp-fb-autoconnect I have activated it in the dasboard. Now I would to use a function from it. In my theme folder, in one of my templates I want to add FB connect button

if( function_exists(‘jfb_output_facebook_btn’) )

function_exists(‘jfb_output_facebook_btn’) returns false. The function is located in main.php in the plugin folder and i can see it. What's wrong? UPDATE The problem in general. A plugin has declared a function. I need to get access to that function from my theme folder.

View 1 Replies

Call Files In Wordpress?

I am collecting files from a directory in a wordpress blog with the PHP calling the files onto the page. Now the files come onto the page perfectly, but I was wondering is there any way to create some php that displays the files on screen in alphabetical order?

global $wpdb;

View 2 Replies

Call The Wordpress Into The Iframe?

I am working on a site.

I am trying to put a constant music player and side bar to allow for constant music while the user surfs the site...

its a blog site... wordpress to be specific...

how to call the wordpress php into the iframe?

like the nav bar and main content would change but the aidebar and header will remain constant....

View 2 Replies

Add Call Out Box In Wordpress Post?

how can i add call out box in wordpress post? And the content for that will be imported from a seperate Text file.

View 2 Replies

Wordpress - Alter A Plugin's Function From Theme's Functions?

The code below is from the "All in One SEO" pack plugin. It alters my theme's 404 page title. I understand that's how this particular plugin works, however, in this instance, its conflicting with my theme's onboard management of 404 post titles and I need to override it.My question is, from my functions.php file, how can I intercerpt and nullify the is_404() code brance in the code below?

class All_in_One_SEO_Pack {
function rewrite_title($header) {
global $aioseop_options;


View 1 Replies

Wordpress - Want To Call It From A Javascript File?

This is a file location not a script or functionality problem. I made a Wordpress theme and wanted to call a popup contact form via jQuery, if the form is validated, my js file will call a php file to send the email. Here is the file/folder structure:


I just want to know where should I place the mailer.php form, as I tried put it the same directory with the js file or in theme root or in the wordpress directory but all are not successful.

View 3 Replies

Wordpress Plugin Or Quick Function For Conditional Image Size

my index.php has a body column width of about 400px The single.php has a column width of about 550px Is there a plugin or quick way to make all images (not just the post_thumbnail) display at full size (i.e., image.jpg) on single.php but use the thumbnail size (i.e., image-350x***.jpg) on index.php?

View 1 Replies

Wordpress Plugin - Pass Variable From Admin Page To Function

I'm trying to add an admin panel to a wordpress plugin. It's my first attempt with working on a plugin and I don't use php frequently. My problem is getting values entered in the admin panel to where they need to be used in the function bp_tweet_button_activity_filter(). The values are saved and displayed fine on the admin page. I've been hacking it for a bit and may have added a little bit of superfluous code. I think the problem is in the beginning lines of that function, or maybe towards the beginning of the tweet_urls_menu_options function.

The plugin takes the link of an activity stream post and shortens it with a custom YOURLS url shortener, so the values needed are the username, password and url of the api for the shortener.

function bp_example_init() {
require( dirname( __FILE__ ) . '/bp-tweet-urls.php' );
define ( 'BP_TWEET_BUTTON_VERSION', '0.1' );
//Admin Menu
add_action('admin_menu', 'tweet_urls_menu');
function tweet_urls_menu() {

View 1 Replies

Wordpress Plugin Add_new_post($info = Array()) Type Function?

How can I add a new blog post from wordpress plugin

View 1 Replies

WordPress Plugin With TinyMCE - Use The Prepare() Function From WP And Than Store It In The Database?

I'm writing a little plugin for WordPress, which is used to create new entry's in a Notebook (also written in PHP, but not as a Plugin for WordPress). The Plugin should only create, edit and delete entry's from the Notebook (so I don't need to write a back end myself).

For the Editor, i use TinyMCE from WordPress (with the wp_tiny_mce()-function). I also use the $wpdb->prepare() function from WP to write the created entry in the Database. But the result in the Database is something like this:

Quote<p style=\"text-align: center;\">Ich bin Zentriert</p>

As you can see, escaped HTML-Code is stored in the Database and I have no idea why. I only use the prepare() Function from WP (which is used to escape code) and than store it in the Database.I first thought, Magic Quotes would maybe the Problem, but Magic Quotes isn't activated at all.The code look's like this:

global $wpdb;
Query erstellen:[code]...

View 5 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved