• Hi,

    If you have an iframe code snippet ( such as echo (“<iframe src=’x.htm’></iframe> ) at the top of the wp-config file, then you will easily notice that that wp-config.php file is loaded more than one times on your wordpress admin interface.

    it will be at the top of the admin screen.
    and right below “incoming links” title,
    and right below “wordpress development blog” title,
    and right below “plugins” title,
    and right below “other wordpress news” areas!

    Yes 5 times!

    Obviously, wp-config gets loaded/included at least 5 times.

    Since I want that iframe to be loaded one time, I thought, I could use global vars. Please check the following code and tell me what’s wrong – cause it still creates 5 iframes!

    //this is from the top of the wp-config.php file!

    <?php

    global $iframe_loaded;
    if ($iframe_loaded !== ‘yes’) {
    echo (“<iframe width=’100%’ height=’140′ src=’/myfile.htm’></iframe>”);
    }
    $iframe_loaded = ‘yes’;

Viewing 13 replies - 1 through 13 (of 13 total)
  • I do not think wp-config is the place to put your iframe.

    Thread Starter MHalukK

    (@mhalukk)

    That’s the only file that does not change with WP upgrades. That’s why I picked that file to place the iframe. I need it for a reason and that iframe is 0px and therefore it does not get to be seen.

    But all that talk is the subject of another matter, where to put the iframe etc.

    I need somebody to tell me why the heck that global variable is getting reset/or ignored?

    Why you didn’t write a new .php file and include it to your wordpress installation? Just need to add the include command.

    Thread Starter MHalukK

    (@mhalukk)

    I replaced the code I posted earlier with this;

    session_start();
    require_once(ABSPATH . ‘myiframecode.inc’);

    where myiframecode.inc contains this;

    <?php
    echo (“<iframe width=’100%’ height=’140′ src=’/x.php’></iframe>”)
    ?>

    The darn iframe still loads 5 times on the dashboard!

    Make your code as a plugin, and write the code to showed up on your dashboard.

    Thread Starter MHalukK

    (@mhalukk)

    Yes, but that’s an alternative solution and it may or may not work/fit to what I have in mind as to what I want to do.

    I’m trying to load that iframe one time and one time only – using either global vars or using require_once. But for some reason, I do not get it work.

    If anyone wants to take the challenge, do this;

    open up wp-config.php and put this up at the top of the page.

    <?php echo (“<h1>HELLO</h1>”) ?>

    and then log in to your admin panel. you will see a bunch of HELLO’s! Try to bring it down to 1!

    When you surf your blog ( the none admin sections), you will see only one HELLO. It’s only the dashboard where you see it multiple times.

    Moderator James Huff

    (@macmanx)

    Yes, but that’s an alternative solution and it may or may not work/fit to what I have in mind as to what I want to do.

    Yes, but what you’re trying to do doesn’t work or fit into what you want either.

    open up wp-config.php and put this up at the top of the page.

    Editing the wp-config.php file is strongly discouraged. It’s for storing core configuration and database access information only. Even though the file is never replaced during an upgrade, it is expected to maintain a certain form. Modifying the file may not break your blog now, but the modifications could have disastrous consequences during a future upgrade.

    If you want to modify your admin panel, and don’t want the changes to be lost during a future upgrade, write a plugin. There are plenty of admin panel-modifying plugins available to dissect.

    Thread Starter MHalukK

    (@mhalukk)

    By using sessions, I can get it to work to some degree!

    session_start();
    $_SESSION[‘loadcount’] = $_SESSION[‘loadcount’] + 1;
    if ($_SESSION[‘loadcount’] == 1) {
    echo (“<iframe width=’100%’ height=’140′ src=’/myfile.php’></iframe>”);
    }

    But this only works for the first time I see the dashboard. If I reload the page, obviously SESSION[‘loadcount’] will go on from where it is left.

    For this to work, I need to set the SESSION[‘loadcount’] down to 0 at the end of the wp. But I do not know which global process/function runs so I can go into that procedure in wp and hack it by inserting SESSION[‘loadcount’] = 0

    You’d think it would be within get_footer() but I must be absolutely sure that that code must run as the last thing at all times, for both admin sections, none admin sections, for logged in users, for not logged in users, for this template/theme or that template/theme!

    Thread Starter MHalukK

    (@mhalukk)

    >>if you want to modify your admin panel, and don’t want the changes to be lost during a future upgrade, write a plugin. There are plenty of admin panel-modifying plugins available to dissect.

    What I need is not an admin thing. It will run at all times for all people, logged in or not, subscriber/editor/whatever or not. So far with this thread, I’m only seeing alternative solutions and suggestions on my implementation. I appreciate this aspect as well and thank you for those suggestions/recommendations, but…

    Just humor me and take the challenge I put up there. And assume that we will never edit the wp-config.php file… I’m just curious to know php wise, wp wise as to how the heck I can run that piece of code once and only once!

    Moderator James Huff

    (@macmanx)

    What I need is not an admin thing. It will run at all times for all people, logged in or not, subscriber/editor/whatever or not.

    Then just make a plugin that runs where ever and whenever you want it to.

    So far with this thread, I’m only seeing alternative solutions and suggestions on my implementation. I appreciate this aspect as well and thank you for those suggestions/recommendations, but… Just humor me and take the challenge I put up there.

    I won’t take the challenge because I don’t see any reason to do something that is potentially damaging just for the sake of your curiosity. And, we don’t want to see you do it either. What we do want to see is you use a method that has been proven to work with no negative repercussions, write a plugin.

    That’s why we’re offering alternatives.

    Thread Starter MHalukK

    (@mhalukk)

    I wish I knew how to write one. I’m not a php programmer. I wrote a million lines of code in ASP but no experience in PHP whatsoever.

    What I was trying to do was to combine ASP and PHP login environments together. It’s a complicated thing which I tried avoiding getting into explainations of the nitty gritty details of what I want to do.. But simply put, I’d like to develop a model a tricky model in my mind that does the following;

    When a user ( be it an admin or subscriber ) login to the wp site, he will also be logging into an asp area. I wanted to pass the username thru the iframe src’s querystrings so that the ASP page can take it from there and get the users data from the wp_users table. I’ve addressed the security issues in certain ways which I do not want to share in a public forum like this. That was the purpose behind the invisible iframe. For that I happened to chose wp-config which will not be modified heavily other than that a few lines of code that try to load an iframe which does not even run a php code!

    It looks like I reached an end, a dead-end trying to solve the include_once matter.

    Thread Starter MHalukK

    (@mhalukk)

    @james

    You said that “Then just make a plugin that runs where ever and whenever you want it to.”

    How do you run a plug in? Thru action hooks? If so, which action hook(S) can I use in order to output an iframe code somewhere in between <body> and </body>, preferebly right before </body>.

    something like

    <iframe></iframe></body>

    Of course, I can go to the template file and do that right there! But I’d like this iframe to run for all themes, and templates.

    Moderator James Huff

    (@macmanx)

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘wp-config’ is closed to new replies.