<object data = ... > </object> changes after I save a post

I'm trying to embed an interactive graph by using the code below, and it works great:

object data="https://www.desmos.com/calculator/wr4nht4qbp" width="800" height="600"/object

When I save the post and view it it looks fine. The problem occurs when I go from the Text tab to the Visual tab. As soon as I do that it changes from the above code to the shockwave flash code below:

object width="800" height="600" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
param name="src" value="https://www.desmos.com/calculator/oobmwtyhdx" /
embed width="800" height="600" type="application/x-shockwave-flash" src="https://www.desmos.com/calculator/oobmwtyhdx" //object

Is there a way to stop this from happening? Or is there another way to embed this graph so that it stays interactive?

Topic flash embed oop Wordpress

Category Web


I would handle this with a shortcode myself. Something like this in your functions.php:

function wpa_85620_calculator_shortcode( $atts ) {
    extract( shortcode_atts( array(
        'key' => 'wr4nht4qbp',
        'width' => 800,
        'height' => 800
    ), $atts ) );

    return sprintf( '<object data="https://www.desmos.com/calculator/%s" width="%d" height="%d"></object>', $key, $width, $height );
}
add_shortcode( 'calculator', 'wpa_85620_calculator_shortcode' );

In your post/page:

[calculator] or [calculator width="400" height="200"]

As a plug-in (save as calc.php in your plugins folder):

<?php
/*
Plugin Name: Desmos Calculator
Plugin URI: http://wordpress.stackexchange.com/questions/85620/object-data-object-changes-after-i-save-a-post/85669#85669
Description: Desmos calculator shortcode
Version: 0.1
Author: Joseph Leedy
Author Email: [email protected]
License:

  Copyright 2013 Joseph Leedy ([email protected])

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License, version 2, as 
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

function wpa_85620_calculator_shortcode( $atts ) {
    extract( shortcode_atts( array(
        'key' => 'wr4nht4qbp',
        'width' => 800,
        'height' => 800
    ), $atts ) );

    return sprintf( '<object data="https://www.desmos.com/calculator/%s" width="%d" height="%d"></object>', $key, $width, $height );
}
add_shortcode( 'calculator', 'wpa_85620_calculator_shortcode' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.