Question for those using SMOF framework

Hello,

I wonder how can I retrieve my settings in my theme’s functions.php file? Normally, I would just need to use the codes below to get my settings:

global $data
$something = $data['something'];

However, when I do that in my functions.php file, it will not work. Has anyone discovered any way to obtain the settings set by SMOF in that file so that I can use it in my post edit page?

Thanks for helping and have a great day!

PS : Here is the link to the framework https://github.com/sy4mil/Options-Framework

Not tested!

Try to create a new php file custom_functions.php (for example) and add the scripts here and include this file in functions.php

Hope this works…

Smartik said

Not tested!

Try to create a new php file custom_functions.php (for example) and add the scripts here and include this file in functions.php

Hope this works…

Thanks for the suggestion. Unfortunately, it didn't work.

Anyone has any other ideas? Thanks for helping.

The $data variable is set somewhere in the admin-interface file, so if you try to use $data before they were queued in functions.php (and therefore not defined yet) then you won’t be getting any values.

You have two ways to solve this:

1 - queue SMOF at the very top of your functions.php, or at least before where you to start be able to use $data

2 - define a new var e.g $my_data = get_options(‘my-options-name’);

The caveat for the second method is that it will always get the “old” data from the table, instead of the newer one the options were updated. Therefore I’d recommend #1 as it’s also a lot easier too.

Cheers

Hi Syamil,

Thanks for your reply. Unfortunately, the first method didn’t work for me. So, I am now using get_option to retrieve the settings from SMOF (in an array) and it seems to update correctly to the latest settings.

Thanks for helping :slight_smile:

I know this is one year old thread but none of the two methods seem to work with the new $smof_data variable.

1 - When I put the global declaration at the top of the functions.php it cannot be reached from a the function.

2 - Gives me “Call to undefined function get_options()”.

I’m trying to fire up a function useing the hook ‘wp_enqueue_scripts’. Can someone help?

the following code works for me:

// Admin panel options become usable
 global $data; 
 // Options Panel
 require_once ('admin/index.php');

they are the first lines in the functions.php (after the <? php )

Now for the enqueue I do the following:

function scripts() {
 global $data;
 $slider = $data['home_slider'];
 if ( !is_admin() && $slider=='FlexSlider') {
  wp_register_script('flex',  get_template_directory_uri() . '/js/sliders/flexslider.js', false);
  wp_enqueue_script('flex');
 }

I had to add the $data into each function or I got the same error as you do.

Hopefully that works for you :slight_smile:

Hey, thanks for replying!

I tried your code, but it didn’t worked. I did a ‘print_r’ just after the require part and it seems that the array is not full with all the keys and values. It fills itself completely just after I click on “Options Reset” - but I have to do this on every new installation of the theme :frowning:

A function like this (written in functions.php)

function my_register_googlefonts() {

global $smof_data;

    if( $smof_data['body_google_checkbox'] ) {
	    ....
    }
} 

… gives me “Undefined index: body_google_checkbox” :confused:

I’ve also declared the global variable in header.php and footer.php, because I’m using it in some functions there.

Hello Syamil, i have some question of SMOF

When i activate the SMOF on my custom wordpress theme, why i see this message :

“Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\smof\wp-content\themes\twentyfifteen\admin\functions\functions.filters.php on line 23”

And when I replace it with my own Options Panel, SMOF not work properly.

Please Reply This Message. Thanks a lot.

adiperdana said

Hello Syamil, i have some question of SMOF

When i activate the SMOF on my custom wordpress theme, why i see this message :

“Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\smof\wp-content\themes\twentyfifteen\admin\functions\functions.filters.php on line 23”

And when I replace it with my own Options Panel, SMOF not work properly.

Please Reply This Message. Thanks a lot.

Hi, you might want to switch to Redux Framework since the development on SMOF has ceased after it’s joined with Redux.

I also have tried Redux Framework, but I still can not get a good Performance, after I turn on first, background WordPress theme I changed, and I am still confused how to use it.

adiperdana said

I also have tried Redux Framework, but I still can not get a good Performance, after I turn on first, background WordPress theme I changed, and I am still confused how to use it.

Smof will be revived very soon with some extra options.

partnuz said
adiperdana said

I also have tried Redux Framework, but I still can not get a good Performance, after I turn on first, background WordPress theme I changed, and I am still confused how to use it.

Smof will be revived very soon with some extra options.

Really? It’s written on the GitHub page that SMOF has merged with Redux with no mention of having it revived.

billyf said
partnuz said
adiperdana said

I also have tried Redux Framework, but I still can not get a good Performance, after I turn on first, background WordPress theme I changed, and I am still confused how to use it.

Smof will be revived very soon with some extra options.

Really? It’s written on the GitHub page that SMOF has merged with Redux with no mention of having it revived.

All that I can say now is that new smof is up and running, has new fields like combobox, group and repeatable field. Also it’s extemely small, it has only 300 kb ( 80kb compressed ).

partnuz said

All that I can say now is that new smof is up and running, has new fields like combobox, group and repeatable field. Also it’s extemely small, it has only 300 kb ( 80kb compressed ).

I wonder whether it’s been released yet? I just asked Syamil (the developer of SMOF) and he wasn’t aware of such project at all. Would love to see how it looks when this new version is released to the public.

billyf said
partnuz said

All that I can say now is that new smof is up and running, has new fields like combobox, group and repeatable field. Also it’s extemely small, it has only 300 kb ( 80kb compressed ).

I wonder whether it’s been released yet? I just asked Syamil (the developer of SMOF) and he wasn’t aware of such project at all. Would love to see how it looks when this new version is released to the public.

It hasn’t been released yet. Options panel implementation has been finished. Currently metabox, widget and shortcode implementation is being developed.

Also there will be new version of Aqua Page Builder but it will use wordpress widgets and support grid systems like foundation and bootstrap.