0

I have added button to tinymce editor, which opens Popup using TinyMCE window manager and popup file is sbb-pop.php.

I want to show settings using get_option() on popup window. But it throws error get_option() is undefined.

Below is code in sbb-popup.php

$apikey =  get_option('sbb_api_key_value');
  $api_link = 'https://1securecart.net/Maint/CatalogItem/GetCatalogItems?APIKey='.$apikey; 
    $content=file_get_contents($api_link);
    $data=json_decode($content);

Here is JS to add button and show popup.

(function($) {
    tinymce.PluginManager.add('sbb_mce_btn', function( editor, url ) {
        editor.addButton( 'sbb_mce_btn', {
            id:'sbb-btn',
            text: 'SBB',
            icon: false,
            type: 'menubutton',
            onclick:function(){
                    editor.windowManager.open({
                            url:sbbGlobalVars.sbbPluginDir+"sbb-popup.php",
                            width:500,
                            height:250
                            },
                    {plugin_url:url,

                     });

                    }
                });

            });
})();

Is there another way to load options in popup window ? I can not include wp-load.php according to WordPress standard.

  • If your serialized array counter doesn't matched with the data inside the key value, it can behave like this. I had a similar issue. I'm not saying this is your issue, but trying make you concern about things like this. :) – Mayeenul Islam Jan 6 '16 at 6:38
  • @MayeenulIslam Actually It works if I include wp-load.php from root directory. But Its not according to WP standard. – user3288891 Jan 6 '16 at 6:42
  • It looks like you are not in wordpress contest, thats the reason you are getting error get_option() is undefined. – WPTC-Troop Jan 6 '16 at 7:02
  • How to be in wordpress context when you open open popup using TinyMCE widowmanager ? – user3288891 Jan 6 '16 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.