Closed premiumsupport365 closed 10 years ago
Great description, what I am looking for in project am working on.
I'm not familiar with the phrase "compiler action" so having a hard time understanding the question.
To retrieve saved option values, there are different ways. You may do either of the followings.
get_option()
function. The option key is the instantiated class name by default and the options are stored as a multidimensional array.getOption()
static method. Check out the tutorial Create a Form. It has a section regarding how to retrieve the saved options.getValue()
[3.3.0+] method.Hi michael
Sorry if I am not clear. I will try to explain clearly this time. forget the word compiler at all. What I need is an action method like add_action. For example if I am saving options in a page, after that an event or action need to be performed so that I can execute my functions after the save . there is no confusion in gettting options just need to call the function.
if you are familiar with dynamik theme or any other themes. they will write the code to the file in uploads so that those files will be included to the site. It avoids repeated query to database and can be utilized in various ways.
so I needed a way that I can execute the functions after the options are saved.
I see.
The framework has the submit_{...}
action hooks but they are executed before the options are saved. Maybe submit_after_{...}
action hooks need to be added.
However, for the options of forms in generic pages added by the framework, you can use the WordPress built-in action hook, updated_option_{option key}
.
Inside the extended class, add an action like this.
add_action( "update_option_{$this->oProp->sOptionKey}", array( $this, 'replyToDoAfterSavingOptions' ) );
Then define the callback function like this.
/**
* Fires after the value of an option has been successfully updated.
*
* @param mixed $vOldOptions The old option value.
* @param mixed $vNewOptions The new option value.
*/
public function replyToDoAfterSavingOptions( $vOldOptions, $vNewOptions ) {
// Do your stuff
}
Hi michael
thanks for your guidelines. I have placed the add_action and the function.
Parse error: syntax error, unexpected 'add_action' (T_STRING), expecting function (T_FUNCTION)
sounds like I need to add the action inside the function. but If I do so I couldnt see anything happening.
can you advise mate..
here is the pastebin version http://pastebin.com/imPQ6Uz2
I have added the comment as //zebra modified in the places where i put your code.
Sorry, forgot to say that you need to add it (the line that calls add_action()
) inside the setUp()
function.
Awesome , working like a charm mate :)
Glad it helped!
That's awesome Michael. Your a genius. Hope the beer i Sent yesterday made it to your dinner table on time.
Thanks for the awesome support and being a real gentleman about it.
Haha, you are welcome and thanks for the donation!
I've added the submit_after_{...}
action hooks in 3.3.1b. Download.
This saves a line of calling add_action()
if you use it in the extended class declaration.
public function submit_after_APF_Demo( $aInput, $aOldInput, $oAdminPage ) { // submit_after_{instantited class name}
// Do your stuff here
// AdminPageFramework_Debug::log( $aInput );
}
Hello michael
Thanks for your awesome work. I Need to know whether you have compiler action in the framework. What I need is to retrieve the saved data, using get options method once the option page is saved. So that I can get the settings and perform certain functions through that.