<?php | |
/** | |
* Method 1 | |
* Can be used for: Any storage type | |
* | |
* page-slug - replace this with your Option Page slug | |
* option-name - replace this with your option Name/ID | |
*/ | |
$value = jet_engine()->listings->data->get_option( 'page-slug::option-name' ); | |
/** | |
* Method 2 | |
* Can be used for: Any storage type | |
* | |
* page-slug - replace this with your Option Page slug | |
* option-name - replace this with your option Name/ID | |
*/ | |
$page = jet_engine()->options_pages->registered_pages['page-slug']; | |
$value = $page->get( 'option-name' ); | |
/** | |
* Method 3 | |
* Can be used for: Default storage type | |
* | |
* page-slug - replace this with your Option Page slug | |
* option-name - replace this with your option Name/ID | |
*/ | |
$all_options = get_option( 'page-slug', array() ); | |
$value = isset( $all_options['option-name'] ) ? $all_options['option-name'] : false; | |
/** | |
* Method 4 | |
* Can be used for: Separate storage type + `Add prefix for separate options` is DISABLED | |
* | |
* option-name - replace this with your option Name/ID | |
*/ | |
$value = get_option( 'option-name' ); | |
/** | |
* Method 5 | |
* Can be used for: Separate storage type + `Add prefix for separate options` is ENABLED | |
* | |
* page-slug - replace this with your Option Page slug | |
* option-name - replace this with your option Name/ID | |
*/ | |
$value = get_option( 'page-slug_option-name' ); |
I was defining a number of modules for an overview page and then I wanted to render the modules dynamically via Ajax on click. This did not work with the jetengine object as it wasn't available during the "init" or "enqueue_scripts" action hooks.
Method 3 was the solution; I simply got the option values right out of the WordPress database.
Hope this info helps somebody else in the same situation.
This did not work with the jetengine object as it wasn't available during the "init" or "enqueue_scripts" action hooks.
it is not available until 'init' with priority of 12 or something like that, just try calling it a bit later
it is not available until 'init' with priority of 12 or something like that, just try calling it a bit later
Thank you for pointing this out. I'm sure this can come in handy at some point in the future.
Hooks are:
The only argument passed to a hook is an instance of Jet_Engine_Options_Page_Factory (\jet-engine\includes\components\options-pages\options-page.php)