PhotoDune

Wordpress widget and iframe code help

181 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 3-4 years
  • Exclusive Author
  • Mexico
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
MCStudios says

Hi I’m creating a simple plugin to add google maps but for some reason when i enter the iframe code in the widget and save it the iframe code is not complete, this is how the widget works.

function mapWidget()
{
    $settings = get_option("widget_mapwidget");
    $maptitle = $settings['title'];
    $map_id = $settings['google_map_id'];

?>
    <div class="sidebar-block">
            <h4 class="title">&lt;?php if($maptitle !== '') { echo $maptitle; } else{ echo "Find us in the map"; }?&gt;</h4>

        <div class="map-holder">
            &lt;?php echo $map_id; ?&gt;
        </div>

    </div>

&lt;?php }
function mapWidgetAdmin() {
    $settings = get_option("widget_mapwidget");
    if (isset($_POST['update_map'])) {
        $settings['title'] = strip_tags(stripslashes($_POST['map_title']));
        $settings['map_id'] = stripslashes($_POST['google_map_id']);

        update_option("widget_mapwidget",$settings);
    }
    echo '&lt;?&gt;
            <label for="map_title">Widget Title:
            <input name="map_title" class="widefat" id="map_title" value="'.$settings['title'].'" type="text" /></label>';
    echo '<p>
            <label for="google_map_id">Embed Map code:</label>

            <textarea name="google_map_id" class="widefat" id="google_map_id" value="'.$settings['map_id'].'" type="text" rows="12" cols="40"></textarea></p>';

    echo '<input name="update_map" id="update_map" value="1" type="hidden" />';

}
register_sidebar_widget('Exiria Google Map Widget', 'mapWidget');
register_widget_control('Exiria Google Map Widget', 'mapWidgetAdmin', 400, 200);
?&gt;

I think the problem is with this code $settings[‘map_id’] = stripslashes($_POST[‘google_map_id’]);

For example if i add this code to the widget:http://pastebin.com/pL9cWUt4

And then save the widget i get this code: http://pastebin.com/Uhy31P7N

And if i save again the widget i get this code:
See full size map\">">

And if i save again i get this code:

\">">

So every time i save the widget some part of the iframe code disappears.

I hope someone can help me :) thank’s.

27 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • United States
KalebAustin says

Why aren’t you using the Wordpress 2.9 Widget API , but easier that all that ‘register_sidebar_widget’, register_sidebar_control’ stuff

Developing Widgets
Developing Widgets on 2.8+
http://codex.wordpress.org/Widgets_API
About 1/2 down page

http://jessealtman.com/2009/06/08/tutorial-wordpress-28-widget-api/

181 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 3-4 years
  • Exclusive Author
  • Mexico
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
MCStudios says

I’m new to wordpress widgets but that was a great solution, thank’s.

by
by
by
by
by