Advertisement
kitchin

Kimili Flash Embed [Fix 2012/05/29 xxx]

May 27th, 2012
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 61.00 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Plugin Name: Kimili Flash Embed
  5. Plugin URI: http://www.kimili.com/plugins/kml_flashembed
  6. Description: [Fix 2012/05/29 xxx] Provides a full Wordpress interface for <a href="http://code.google.com/p/swfobject/">SWFObject</a> - the best way to embed Flash on your site.
  7. Version: 2.2.1.xxx-ver3
  8. Author: Michael Bester [aside from fixes marked xxx]
  9. Author URI: http://www.kimili.com
  10. Update: http://www.kimili.com/plugins/kml_flashembed/wp
  11. */
  12.  
  13. ///////////////////////////////////////////////////////////
  14. // XXX fixes, 2012/05
  15. ///////////////////////////////////////////////////////////
  16. // 1. Add option to use the WP version of swfobject.js, which is more up-to-date than the Google version, which is the version included in this plugin. Has security fixes.
  17. // 2. Fix enqeue/deregister notices in debug:
  18. //  Notice: wp_deregister_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.
  19. //  Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.
  20. // 3. Fix has_cap deprecated notice in debug:
  21. //  Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.
  22. ///////////////////////////////////////////////////////////
  23.  
  24. /*
  25. *
  26. *   KIMILI FLASH EMBED
  27. *
  28. *   Copyright 2010 Michael Bester (http://www.kimili.com)
  29. *   Released under the GNU General Public License (http://www.gnu.org/licenses/gpl.html)
  30. *
  31. */
  32.  
  33. /**
  34. *
  35. */
  36. class KimiliFlashEmbed
  37. {
  38.  
  39.     var $version = '2.2.1';
  40.     var $staticSwfs = array();
  41.     var $dynamicSwfs = array();
  42.  
  43. ///////////////////////////////////////////////////////////
  44. // XXX add, 2012/05
  45. ///////////////////////////////////////////////////////////
  46.     function xxx_fix_admin_enqueue_scripts_kfe($hook)
  47.     {
  48.         // see http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
  49.         // print "<!-- hook= $hook -->\n";
  50.         // 2012/05/28: could restrict this to certain hooks. Need at least:
  51.         // settings_page_kimili-flash-embed/kml_flashembed, post-new.php, post.php, ...
  52.         // But to be sure, put on all admin pages!
  53.         wp_enqueue_script( 'kimiliflashembed', plugins_url('/kimili-flash-embed/js/kfe.js'), array(), $this->version );
  54.     }
  55.  
  56.     function xxx_fix_enqueue_scripts_swfobject()
  57.     {
  58.             //////////////////////////////////////////////////////////////////////////////////////
  59.             // XXX NOTE 2012/05/27: as of WP 3.3.2, the WP version of swfobject.js (2.2-20120417)
  60.             // has SECURITY FIXES not yet in the Gooogle version (2.2), the same as the
  61.             // version included in this plugin. Development for 2.3 seems to have moved to GitHub.
  62.             ///////////////////////////////////////////////////////////////////////////////////////
  63.  
  64.             $swfobject_source= get_option('kml_flashembed_swfobject_source');
  65.             if ( $swfobject_source ) {
  66.                 // Let's override WP's bundled swfobject, cause as of WP 2.9, it's still using 2.1
  67.                 wp_deregister_script('swfobject');
  68.                 // and register our own.
  69.                 if ( $swfobject_source == '1' ) {
  70.                     wp_register_script( 'swfobject', 'http' . (is_ssl() ? 's' : '') . '://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js', array(), '2.2' );
  71.                 } else {
  72.                     wp_register_script( 'swfobject', plugins_url('/kimili-flash-embed/js/swfobject.js'), array(), '2.2' );
  73.                 }
  74.             }
  75.             // otherwise, $swfobject_source == '0', use the Wordress version
  76.  
  77.             wp_enqueue_script('swfobject');
  78.     }
  79. ///////////////////////////////////////////////////////////
  80.  
  81.     function KimiliFlashEmbed()
  82.     {
  83.         // Register Hooks
  84.         if (is_admin()) {
  85.  
  86.             // Load up the localization file if we're using WordPress in a different language
  87.             // Place it in this plugin's "langs" folder and name it "kimili-flash-embed-[value in wp-config].mo"
  88.             load_plugin_textdomain( 'kimili-flash-embed', FALSE, 'kimili-flash-embed/langs/');
  89.  
  90.             // Default Options
  91.             add_option('kml_flashembed_filename', 'untitled.swf');
  92.             add_option('kml_flashembed_target_class', 'flashmovie');
  93.             add_option('kml_flashembed_publish_method', '0');
  94.             add_option('kml_flashembed_version_major', '8');
  95.             add_option('kml_flashembed_version_minor', '0');
  96.             add_option('kml_flashembed_version_revision', '0');
  97.             add_option('kml_flashembed_alt_content', '<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>');
  98.             add_option('kml_flashembed_reference_swfobject', '1');
  99.             add_option('kml_flashembed_swfobject_source', '0');
  100.             add_option('kml_flashembed_width', '400');
  101.             add_option('kml_flashembed_height', '300');
  102.  
  103.             // Set up the options page
  104.             add_action('admin_menu', array(&$this, 'options_menu'));
  105.  
  106.             // Add Quicktag
  107.             if (current_user_can('edit_posts') || current_user_can('edit_pages') ) {
  108.                 add_action( 'edit_form_advanced', array(&$this, 'add_quicktags') );
  109.                 add_action( 'edit_page_form', array(&$this, 'add_quicktags') );
  110.             }
  111.  
  112.             // Queue Embed JS
  113.             add_action( 'admin_head', array(&$this, 'set_admin_js_vars'));
  114.  
  115. ///////////////////////////////////////////////////////////
  116. // XXX del, 2012/05
  117. ///////////////////////////////////////////////////////////
  118. //          wp_enqueue_script( 'kimiliflashembed', plugins_url('/kimili-flash-embed/js/kfe.js'), array(), $this->version );
  119. ///////////////////////////////////////////////////////////
  120. // XXX add
  121. ///////////////////////////////////////////////////////////
  122.             add_action( 'admin_enqueue_scripts', array(&$this, 'xxx_fix_admin_enqueue_scripts_kfe'));
  123. ///////////////////////////////////////////////////////////
  124.  
  125.         } else {
  126.             // Front-end
  127.             if ($this->is_feed()) {
  128.                 $this->doObStart();
  129.             } else {
  130.                 add_action('wp_head', array(&$this, 'disableAutohide'), 9);
  131.                 add_action('wp_head', array(&$this, 'doObStart'));
  132.                 add_action('wp_head', array(&$this, 'addScriptPlaceholder'));
  133.                 add_action('wp_footer', array(&$this, 'doObEnd'));
  134.             }
  135.  
  136.         }
  137.  
  138.         // Queue SWFObject
  139.         if ( get_option('kml_flashembed_reference_swfobject') == '1') {
  140.  
  141. ///////////////////////////////////////////////////////////
  142. // XXX del, 2012/05
  143. ///////////////////////////////////////////////////////////
  144. //          // Let's override WP's bundled swfobject, cause as of WP 2.9, it's still using 2.1
  145. //          wp_deregister_script('swfobject');
  146. //          // and register our own.
  147. //          if ( get_option('kml_flashembed_swfobject_source') == '0' ) {
  148. //              wp_register_script( 'swfobject', 'http' . (is_ssl() ? 's' : '') . '://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js', array(), '2.2' );
  149. //          } else {
  150. //              wp_register_script( 'swfobject', plugins_url('/kimili-flash-embed/js/swfobject.js'), array(), '2.2' );
  151. //          }
  152. //          wp_enqueue_script('swfobject');
  153. ///////////////////////////////////////////////////////////
  154. // XXX add
  155. ///////////////////////////////////////////////////////////
  156.             add_action( 'wp_enqueue_scripts', array(&$this, 'xxx_fix_enqueue_scripts_swfobject'));
  157. ///////////////////////////////////////////////////////////
  158.  
  159.         }
  160.     }
  161.  
  162.     function parseShortcodes($content)
  163.     {
  164.         $pattern = '/(<p>[\s\n\r]*)?\[(kml_(flash|swf)embed)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?([\s\n\r]*<\/p>)?/s';
  165.         $temp   = preg_replace_callback($pattern, array(&$this, 'processShortcode'), $content);
  166.         $result = preg_replace_callback('/KML_FLASHEMBED_PROCESS_SCRIPT_CALLS/s', array(&$this, 'scriptSwfs'), $temp);
  167.         return $result;
  168.     }
  169.  
  170.     // Thanks to WP shortcode API Code
  171.     function processShortcode($code)
  172.     {
  173.         $r  = "";
  174.  
  175.         $atts = $this->parseAtts($code[4]);
  176.         $altContent = isset($code[6]) ? $code[6] : '';
  177.  
  178.         $attpairs   = preg_split('/\|/', $elements, -1, PREG_SPLIT_NO_EMPTY);
  179.  
  180.         if (isset($atts['movie'])) {
  181.  
  182.             $atts['height']             = (isset($atts['height'])) ? $atts['height'] : get_option('kml_flashembed_height');
  183.             $atts['width']              = (isset($atts['width'])) ? $atts['width'] : get_option('kml_flashembed_width');
  184.             $atts['fversion']           = (isset($atts['fversion'])) ? $atts['fversion'] : get_option('kml_flashembed_version_major').'.'.get_option('kml_flashembed_version_minor').'.'.get_option('kml_flashembed_version_revision');
  185.             $atts['targetclass']        = (isset($atts['targetclass'])) ? $atts['targetclass'] : get_option('kml_flashembed_target_class');
  186.             $atts['publishmethod']      = (isset($atts['publishmethod'])) ? $atts['publishmethod'] : (get_option('kml_flashembed_publish_method') ? 'dynamic' : 'static');
  187.             $atts['useexpressinstall']  = (isset($atts['useexpressinstall'])) ? $atts['useexpressinstall'] : 'false';
  188.             $atts['xiswf']              = plugins_url('/kimili-flash-embed/lib/expressInstall.swf');
  189.  
  190.             $rand   = mt_rand();  // For making sure this instance is unique
  191.  
  192.             // Extract the filename minus the extension...
  193.             $swfname    = (strrpos($atts['movie'], "/") === false) ?
  194.                                     $atts['movie'] :
  195.                                     substr($atts['movie'], strrpos($atts['movie'], "/") + 1, strlen($atts['movie']));
  196.             $swfname    = (strrpos($swfname, ".") === false) ?
  197.                                     $swfname :
  198.                                     substr($swfname, 0, strrpos($swfname, "."));
  199.  
  200.             // set an ID for the movie if necessary
  201.             if (!isset($atts['fid'])) {
  202.                 // ... to use as a default ID if an ID is not defined.
  203.                 $atts['fid']    = "fm_" . $swfname . "_" . $rand;
  204.             }
  205.  
  206.             if (!isset($atts['target'])) {
  207.                 // ... and a target ID if need be for the dynamic publishing method
  208.                 $atts['target'] = "so_targ_" . $swfname . "_" . $rand;
  209.             }
  210.  
  211.             // Parse out the fvars
  212.             if (isset($atts['fvars'])) {
  213.                 $fvarpair_regex     = "/(?<!([$|\?]\{))\s*;\s*(?!\})/";
  214.                 // Untexturize ampersands.
  215.                 $atts['fvars']      = preg_replace('/&amp;/', '&', $atts['fvars']);
  216.                 $atts['fvars']      = preg_split($fvarpair_regex, $atts['fvars'], -1, PREG_SPLIT_NO_EMPTY);
  217.             }
  218.  
  219.             // Convert any quasi-HTML in alttext back into tags
  220.             $atts['alttext']        = (isset($atts['alttext'])) ? preg_replace("/{(.*?)}/i", "<$1>", $atts['alttext']) : $altContent;
  221.  
  222.             // Strip leading </p> and trailing <p> - detritius from the way the tags are parsed out of the RTE
  223.             $patterns = array(
  224.                 "/^[\s\n\r]*<\/p>/i",
  225.                 "/<p>[\s\n\r]*$/i"
  226.             );
  227.             $atts['alttext'] = preg_replace($patterns, "", $atts['alttext']);
  228.  
  229.             // If we're not serving up a feed, generate the script tags
  230.             if (is_feed()) {
  231.                 $r  = $this->buildObjectTag($atts);
  232.             } else {
  233.                 if ($atts['publishmethod'] == 'static') {
  234.                     $r = $this->publishStatic($atts);
  235.                 } else {
  236.                     $r = $this->publishDynamic($atts);
  237.                 }
  238.             }
  239.         }
  240.  
  241.         return $r;
  242.     }
  243.  
  244.     // Thanks to WP shortcode API Code
  245.     function parseAtts($text)
  246.     {
  247.         $atts = array();
  248.         $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
  249.         $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
  250.         if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) {
  251.             foreach ($match as $m) {
  252.                 if (!empty($m[1]))
  253.                     $atts[strtolower($m[1])] = stripcslashes($m[2]);
  254.                 elseif (!empty($m[3]))
  255.                     $atts[strtolower($m[3])] = stripcslashes($m[4]);
  256.                 elseif (!empty($m[5]))
  257.                     $atts[strtolower($m[5])] = stripcslashes($m[6]);
  258.                 elseif (isset($m[7]) and strlen($m[7]))
  259.                     $atts[] = stripcslashes($m[7]);
  260.                 elseif (isset($m[8]))
  261.                     $atts[] = stripcslashes($m[8]);
  262.             }
  263.         } else {
  264.             $atts = ltrim($text);
  265.         }
  266.         return $atts;
  267.     }
  268.  
  269.     function publishStatic($atts)
  270.     {
  271.         if (is_array($atts)) {
  272.             extract($atts);
  273.         }
  274.  
  275.         $this->staticSwfs[] = array(
  276.             'id'                    => $fid,
  277.             'version'               => $fversion,
  278.             'useexpressinstall'     => $useexpressinstall,
  279.             'xiswf'                 => $xiswf
  280.         );
  281.  
  282.         return $this->buildObjectTag($atts);
  283.     }
  284.  
  285.     function publishDynamic($atts)
  286.     {
  287.         if (is_array($atts)) {
  288.             extract($atts);
  289.         }
  290.  
  291.         $this->dynamicSwfs[] = $atts;
  292.  
  293.         $out = array();
  294.  
  295.         $out[]      = '<div id="' . $target . '" class="' . $targetclass . '">'.$alttext.'</div>';
  296.  
  297.         return join("\n", $out);
  298.     }
  299.  
  300.     function addScriptPlaceholder()
  301.     {
  302.         echo 'KML_FLASHEMBED_PROCESS_SCRIPT_CALLS';
  303.     }
  304.  
  305.     function disableAutohide()
  306.     {
  307.         // If we want to use autohide, or we don't have any swfs on the page, drop out.
  308.         if (get_option('kml_flashembed_swfobject_use_autohide')) {
  309.             return false;
  310.         }
  311.  
  312.         // Otherwise build out the script.
  313.         $out = array();
  314.  
  315.         $out[]  = '';
  316.         $out[]  = '<script type="text/javascript" charset="utf-8">';
  317.         $out[]  = '';
  318.         $out[]  = ' /**';
  319.         $out[]  = '  * Courtesy of Kimili Flash Embed - Version ' . $this->version;
  320.         $out[]  = '  * by Michael Bester - http://kimili.com';
  321.         $out[]  = '  */';
  322.         $out[]  = '';
  323.         $out[]  = ' (function(){';
  324.         $out[]  = '     try {';
  325.         $out[]  = '         // Disabling SWFObject\'s Autohide feature';
  326.         $out[]  = '         if (typeof swfobject.switchOffAutoHideShow === "function") {';
  327.         $out[]  = '             swfobject.switchOffAutoHideShow();';
  328.         $out[]  = '         }';
  329.         $out[]  = '     } catch(e) {}';
  330.         $out[]  = ' })();';
  331.         $out[]  = '</script>';
  332.         $out[]  = '';
  333.  
  334.         echo join("\n", $out);
  335.     }
  336.  
  337.     function scriptSwfs()
  338.     {
  339.         // If we don't have any swfs on the page, drop out.
  340.         if (count($this->staticSwfs) == 0 && count($this->dynamicSwfs) == 0) {
  341.             return '';
  342.         }
  343.  
  344.         // Otherwise build out the script.
  345.         $out = array();
  346.  
  347.         $out[]      = '';
  348.         $out[]      = '<script type="text/javascript" charset="utf-8">';
  349.         $out[]      = '';
  350.         $out[]      = ' /**';
  351.         $out[]      = '  * Courtesy of Kimili Flash Embed - Version ' . $this->version;
  352.         $out[]      = '  * by Michael Bester - http://kimili.com';
  353.         $out[]      = '  */';
  354.         $out[]      = '';
  355.         $out[]      = ' (function(){';
  356.         $out[]      = '     try {';
  357.         if (count($this->staticSwfs) > 0) {
  358.             $out[]  = '         // Registering Statically Published SWFs';
  359.         }
  360.  
  361.         for ($i = 0; $i < count($this->staticSwfs); $i++) {
  362.             $curr   = $this->staticSwfs[$i];
  363.             $out[]  = '         swfobject.registerObject("' . $curr['id'] . '","' . $curr['version'] . '"'.(($curr['useexpressinstall'] == 'true') ? ',"'.$curr['xiswf'].'"' : '') . ');';
  364.         }
  365.  
  366.         if (count($this->dynamicSwfs) > 0) {
  367.             $out[]      = '';
  368.             $out[]  = '         // Registering Dynamically Published SWFs';
  369.         }
  370.         for ($i = 0; $i < count($this->dynamicSwfs); $i++) {
  371.  
  372.             $curr       = $this->dynamicSwfs[$i];
  373.  
  374.             // Flashvars
  375.             $flashvars  = $this->parseFvars($curr['fvars'],'object');
  376.  
  377.             // Parameters
  378.             $params = array();
  379.             if (isset($curr['play']))               $params[] = '"play" : "' . $curr['play'] . '"';
  380.             if (isset($curr['loop']))               $params[] = '"loop" : "' . $curr['loop'] . '"';
  381.             if (isset($curr['menu']))               $params[] = '"menu" : "' . $curr['menu'] . '"';
  382.             if (isset($curr['quality']))            $params[] = '"quality" : "' . $curr['quality'] . '"';
  383.             if (isset($curr['scale']))              $params[] = '"scale" : "' . $curr['scale'] . '"';
  384.             if (isset($curr['salign']))             $params[] = '"salign" : "' . $curr['salign'] . '"';
  385.             if (isset($curr['wmode']))              $params[] = '"wmode" : "' . $curr['wmode'] . '"';
  386.             if (isset($curr['bgcolor']))            $params[] = '"bgcolor" : "' . $curr['bgcolor'] . '"';
  387.             if (isset($curr['base']))               $params[] = '"base" : "' . $curr['base'] . '"';
  388.             if (isset($curr['swliveconnect']))      $params[] = '"swliveconnect" : "' . $curr['swliveconnect'] . '"';
  389.             if (isset($curr['devicefont']))         $params[] = '"devicefont" : "' . $curr['devicefont'] . '"';
  390.             if (isset($curr['allowscriptaccess']))  $params[] = '"allowscriptaccess" : "' . $curr['allowscriptaccess'] . '"';
  391.             if (isset($curr['seamlesstabbing']))    $params[] = '"seamlesstabbing" : "' . $curr['seamlesstabbing'] . '"';
  392.             if (isset($curr['allowfullscreen']))    $params[] = '"allowfullscreen" : "' . $curr['allowfullscreen'] . '"';
  393.             if (isset($curr['allownetworking']))    $params[] = '"allownetworking" : "' . $curr['allownetworking'] . '"';
  394.  
  395.             // Attributes
  396.             $attributes = array();
  397.             if (isset($curr['align']))          $attributes[] = '"align" : "' . $curr['align'] . '"';
  398.             if (isset($curr['fid']))            $attributes[] = '"id" : "' . $curr['fid'] . '"';
  399.             if (isset($curr['fid']))            $attributes[] = '"name" : "' . $curr['fid'] . '"';
  400.             if (isset($curr['targetclass']))    $attributes[] = '"styleclass" : "' . $curr['targetclass'] . '"';
  401.  
  402.             $out[]      = '         swfobject.embedSWF("'.$curr['movie'].'","'.$curr['target'].'","'.$curr['width'].'","'.$curr['height'].'","'.$curr['fversion'].'","'.(($curr['useexpressinstall'] == 'true') ? $curr['xiswf'] : '').'",{';
  403.             for ($j = 0; $j < count($flashvars); $j++) {
  404.                 $out[]  = '             '.$flashvars[$j].(($j < count($flashvars) - 1) ? ',' : '');
  405.             }
  406.             $out[]  = '         },{';
  407.             for ($j = 0; $j < count($params); $j++) {
  408.                 $out[]  = '             '.$params[$j].(($j < count($params) - 1) ? ',' : '');
  409.             }
  410.             $out[] = '          },{';
  411.             for ($j = 0; $j < count($attributes); $j++) {
  412.                 $out[]  = '             '.$attributes[$j].(($j < count($attributes) - 1) ? ',' : '');
  413.             }
  414.             $out[] = '          });';
  415.         }
  416.  
  417.         $out[]      = '     } catch(e) {}';
  418.         $out[]      = ' })();';
  419.         $out[]      = '</script>';
  420.         $out[]      = '';
  421.  
  422.         return join("\n", $out);
  423.     }
  424.  
  425.     function buildObjectTag($atts)
  426.     {
  427.         $out    = array();
  428.         if (is_array($atts)) {
  429.             extract($atts);
  430.         }
  431.  
  432.         // Build a query string based on the $fvars attribute
  433.         $querystring = join("&amp;", $this->parseFvars($fvars));
  434.  
  435.                                         $out[] = '';
  436.                                         $out[] = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
  437.         if (isset($fid))                $out[] = '          id="'.$fid.'"';
  438.         if (isset($align))              $out[] = '          align="'.$align.'"';
  439.                                         $out[] = '          class="'.$targetclass.'"';
  440.                                         $out[] = '          width="'.$width.'"';
  441.                                         $out[] = '          height="'.$height.'">';
  442.                                         $out[] = '  <param name="movie" value="' . $movie . '" />';
  443.         if (count($fvars) > 0)          $out[] = '  <param name="flashvars" value="' . $querystring . '" />';
  444.         if (isset($play))               $out[] = '  <param name="play" value="' . $play . '" />';
  445.         if (isset($loop))               $out[] = '  <param name="loop" value="' . $loop . '" />';
  446.         if (isset($menu))               $out[] = '  <param name="menu" value="' . $menu . '" />';
  447.         if (isset($quality))            $out[] = '  <param name="quality" value="' . $quality . '" />';
  448.         if (isset($scale))              $out[] = '  <param name="scale" value="' . $scale . '" />';
  449.         if (isset($salign))             $out[] = '  <param name="salign" value="' . $salign . '" />';
  450.         if (isset($wmode))              $out[] = '  <param name="wmode" value="' . $wmode . '" />';
  451.         if (isset($bgcolor))            $out[] = '  <param name="bgcolor" value="' . $bgcolor . '" />';
  452.         if (isset($base))               $out[] = '  <param name="base" value="' . $base . '" />';
  453.         if (isset($swliveconnect))      $out[] = '  <param name="swliveconnect" value="' . $swliveconnect . '" />';
  454.         if (isset($devicefont))         $out[] = '  <param name="devicefont" value="' . $devicefont . '" />';
  455.         if (isset($allowscriptaccess))  $out[] = '  <param name="allowscriptaccess" value="' . $allowscriptaccess . '" />';
  456.         if (isset($seamlesstabbing))    $out[] = '  <param name="seamlesstabbing" value="' . $seamlesstabbing . '" />';
  457.         if (isset($allowfullscreen))    $out[] = '  <param name="allowfullscreen" value="' . $allowfullscreen . '" />';
  458.         if (isset($allownetworking))    $out[] = '  <param name="allownetworking" value="' . $allownetworking . '" />';
  459.                                         $out[] = '  <!--[if !IE]>-->';
  460.                                         $out[] = '  <object type="application/x-shockwave-flash"';
  461.                                         $out[] = '          data="'.$movie.'"';
  462.         if (isset($fid))                $out[] = '          name="'.$fid.'"';
  463.         if (isset($align))              $out[] = '          align="'.$align.'"';
  464.                                         $out[] = '          width="'.$width.'"';
  465.                                         $out[] = '          height="'.$height.'">';
  466.         if (count($fvars) > 0)          $out[] = '      <param name="flashvars" value="' . $querystring . '" />';
  467.         if (isset($play))               $out[] = '      <param name="play" value="' . $play . '" />';
  468.         if (isset($loop))               $out[] = '      <param name="loop" value="' . $loop . '" />';
  469.         if (isset($menu))               $out[] = '      <param name="menu" value="' . $menu . '" />';
  470.         if (isset($quality))            $out[] = '      <param name="quality" value="' . $quality . '" />';
  471.         if (isset($scale))              $out[] = '      <param name="scale" value="' . $scale . '" />';
  472.         if (isset($salign))             $out[] = '      <param name="salign" value="' . $salign . '" />';
  473.         if (isset($wmode))              $out[] = '      <param name="wmode" value="' . $wmode . '" />';
  474.         if (isset($bgcolor))            $out[] = '      <param name="bgcolor" value="' . $bgcolor . '" />';
  475.         if (isset($base))               $out[] = '      <param name="base" value="' . $base . '" />';
  476.         if (isset($swliveconnect))      $out[] = '      <param name="swliveconnect" value="' . $swliveconnect . '" />';
  477.         if (isset($devicefont))         $out[] = '      <param name="devicefont" value="' . $devicefont . '" />';
  478.         if (isset($allowscriptaccess))  $out[] = '      <param name="allowscriptaccess" value="' . $allowscriptaccess . '" />';
  479.         if (isset($seamlesstabbing))    $out[] = '      <param name="seamlesstabbing" value="' . $seamlesstabbing . '" />';
  480.         if (isset($allowfullscreen))    $out[] = '      <param name="allowfullscreen" value="' . $allowfullscreen . '" />';
  481.         if (isset($allownetworking))    $out[] = '      <param name="allownetworking" value="' . $allownetworking . '" />';
  482.                                         $out[] = '  <!--<![endif]-->';
  483.         if (isset($alttext))            $out[] = '      '.$alttext;
  484.                                         $out[] = '  <!--[if !IE]>-->';
  485.                                         $out[] = '  </object>';
  486.                                         $out[] = '  <!--<![endif]-->';
  487.                                         $out[] = '</object>';
  488.  
  489.         $ret .= join("\n", $out);
  490.         return $ret;
  491.     }
  492.  
  493.     function parseFvars($fvars, $format='string')
  494.     {
  495.         $ret = array();
  496.  
  497.         for ($i = 0; $i < count($fvars); $i++) {
  498.             $thispair   = trim($fvars[$i]);
  499.             $nvpair     = explode("=",$thispair);
  500.             $name       = trim($nvpair[0]);
  501.             $value      = "";
  502.             for ($j = 1; $j < count($nvpair); $j++) {           // In case someone passes in a fvars with additional "="
  503.                 $value      .= trim($nvpair[$j]);
  504.                 $value      = preg_replace('/&#038;/', '&', $value);
  505.                 if ((count($nvpair) - 1) != $j) {
  506.                     $value  .= "=";
  507.                 }
  508.             }
  509.             // Prune out JS or PHP values
  510.             if (preg_match("/^\\$\\{.*\\}/i", $value)) {        // JS
  511.                 $endtrim    = strlen($value) - 3;
  512.                 $value      = substr($value, 2, $endtrim);
  513.                 $value      = str_replace(';', '', $value);
  514.             } else if (preg_match("/^\\?\\{.*\\}/i", $value)) { // PHP
  515.                 $endtrim    = strlen($value) - 3;
  516.                 $value      = substr($value, 2, $endtrim);
  517.                 $value      = eval("return " . $value);
  518.             }
  519.  
  520.             if ($format == 'string') {
  521.                 $ret[] = $name . '=' . $value;
  522.             } else {
  523.                 $ret[] = $name . ' : "' . $value . '"';
  524.             }
  525.         }
  526.  
  527.         return $ret;
  528.  
  529.     }
  530.  
  531.     function doObStart()
  532.     {
  533.         ob_start(array(&$this, 'parseShortcodes'));
  534.     }
  535.  
  536.     function doObEnd()
  537.     {
  538.         // Check the output buffer
  539.         if (function_exists('ob_list_handlers')) {
  540.             $active_handlers = ob_list_handlers();
  541.         } else {
  542.             $active_handlers = array();
  543.         }
  544.         if (sizeof($active_handlers) > 0 &&
  545.             strtolower($active_handlers[sizeof($active_handlers) - 1]) ==
  546.             strtolower('KimiliFlashEmbed::parseShortcodes')) {
  547.             ob_end_flush();
  548.         }
  549.     }
  550.  
  551.     function is_feed()
  552.     {
  553.         return preg_match("/(\/\?feed=|\/feed)/i",$_SERVER['REQUEST_URI']);
  554.     }
  555.  
  556.     function set_admin_js_vars()
  557.     {
  558. ?>
  559. <script type="text/javascript" charset="utf-8">
  560. // <![CDATA[
  561.     if (typeof Kimili !== 'undefined' && typeof Kimili.Flash !== 'undefined') {
  562.         Kimili.Flash.configUrl = "<?php echo plugins_url('/kimili-flash-embed/admin/config.php'); ?>";
  563.     }
  564. // ]]>
  565. </script>
  566. <?php
  567.     }
  568.  
  569.     // Add a button to the quicktag view
  570.     function add_quicktags()
  571.     {
  572.         $buttonshtml = '<input type="button" class="ed_button" onclick="Kimili.Flash.embed.apply(Kimili.Flash); return false;" title="Embed a Flash Movie in your post" value="Kimili Flash Embed" />';
  573. ?>
  574. <script type="text/javascript" charset="utf-8">
  575. // <![CDATA[
  576.     (function(){
  577.  
  578.         if (typeof jQuery === 'undefined') {
  579.             return;
  580.         }
  581.  
  582.         jQuery(document).ready(function(){
  583.             // Add the buttons to the HTML view
  584.             jQuery("#ed_toolbar").append('<?php echo $buttonshtml; ?>');
  585.         });
  586.     }());
  587. // ]]>
  588. </script>
  589. <?php
  590.     }
  591.  
  592.     // Set up the Plugin Options Page
  593.     function options_menu() {
  594.  
  595. /////////////////////////////////////////////////////////////
  596. // XXX del, 2012/05
  597. /////////////////////////////////////////////////////////////
  598. //      add_options_page('Kimili Flash Embed Options', 'Kimili Flash Embed', '8', __FILE__, array(&$this, 'settings_page'));
  599. /////////////////////////////////////////////////////////////
  600. // XXX add
  601. /////////////////////////////////////////////////////////////
  602.         // fix 'has_cap' deprecated notice in debug:
  603.         add_options_page('Kimili Flash Embed Options', 'Kimili Flash Embed', 'manage_options', __FILE__, array(&$this, 'settings_page'));
  604. /////////////////////////////////////////////////////////////
  605.  
  606.     }
  607.  
  608.     // Render the settings page
  609.     function settings_page() {
  610.  
  611.         $message = null;
  612.         $message_updated = __("Kimili Flash Embed Options Updated.", 'kimili_flash_embed');
  613.  
  614.         // Create a link to the KFE JS
  615.  
  616. ///////////////////////////////////////////////////////////
  617. // XXX del, 2012/05
  618. ///////////////////////////////////////////////////////////
  619. //      wp_enqueue_script( 'kimiliflashembed', plugins_url('/kimili-flash-embed/js/kfe.js'), array(), $this->version );
  620. ///////////////////////////////////////////////////////////
  621.  
  622.         // update options
  623.         if (isset($_POST['action']) && $_POST['action'] == 'kml_flashembed_update') {
  624.  
  625.             $filename               = preg_replace("/(^|&\S+;)|(<[^>]*>)/U", '', strip_tags($_POST['filename']));
  626.             $target_class           = preg_replace("/(^|&\S+;)|(<[^>]*>)/U", '', strip_tags($_POST['target_class']));
  627.             $flash_id               = preg_replace("/(^|&\S+;)|(<[^>]*>)/U", '', strip_tags($_POST['flash_id']));
  628.  
  629.             $alt_content            = $_POST['alt_content'];
  630.             $fvars                  = $_POST['fvars'];
  631.  
  632.             $version_major          = preg_replace("/\D/s", '', $_POST['version_major']);
  633.             $version_minor          = preg_replace("/\D/s", '', $_POST['version_minor']);
  634.             $version_revision       = preg_replace("/\D/s", '', $_POST['version_revision']);
  635.  
  636.             $width                  = preg_replace("/[\D[^%]]/", '', $_POST['width']);
  637.             $height                 = preg_replace("/[\D[^%]]/", '', $_POST['height']);
  638.  
  639.             $bgcolor                = (preg_match("/^#?[0-9a-f]{6}$/i", $_POST['bgcolor'])) ? $_POST['bgcolor'] : "";
  640.             $base                   = preg_replace("/(^|&\S+;)|(<[^>]*>)/U", '', strip_tags($_POST['base']));
  641.  
  642.             if ($bgcolor != "" && !preg_match("/^#/", $bgcolor)) {
  643.                 $bgcolor = "#" . $bgcolor;
  644.             }
  645.  
  646.             if (empty($version_major)) {
  647.                 $version_major = '8';
  648.             }
  649.  
  650.             if (empty($version_minor)) {
  651.                 $version_minor = '0';
  652.             }
  653.  
  654.             if (empty($version_revision)) {
  655.                 $version_revision = '0';
  656.             }
  657.  
  658.             if (empty($width)) {
  659.                 $width = '400';
  660.             }
  661.  
  662.             if (empty($height)) {
  663.                 $height = '300';
  664.             }
  665.  
  666.             $publish_method         = ($_POST['publish_method'] == '1') ? $_POST['publish_method'] : '0';
  667.             $reference_swfobject    = ($_POST['reference_swfobject'] == '0') ? $_POST['reference_swfobject'] : '1';
  668.  
  669. /////////////////////////////
  670. // XXX del, 2012/05
  671. /////////////////////////////
  672. //          $swfobject_source       = ($_POST['swfobject_source'] == '1') ? $_POST['swfobject_source'] : '0';
  673. /////////////////////////////
  674. // XXX add
  675. /////////////////////////////
  676.             $swfobject_source       = $_POST['swfobject_source'];
  677.             $swfobject_source === '1' || $swfobject_source === '2' or $swfobject_source = '0';
  678. /////////////////////////////
  679.  
  680.             $swfobject_use_autohide = ($_POST['swfobject_use_autohide'] == '0') ? $_POST['swfobject_use_autohide'] : '1';
  681.             $use_express_install    = ($_POST['use_express_install'] == '0') ? $_POST['use_express_install'] : '1';
  682.             $dimensions_unit        = ($_POST['unit'] == 'percentage') ? $_POST['unit'] : 'pixels';
  683.  
  684.             $message = $message_updated;
  685.             update_option('kml_flashembed_filename', $filename);
  686.             update_option('kml_flashembed_target_class', $target_class);
  687.             update_option('kml_flashembed_flash_id', $flash_id);
  688.             update_option('kml_flashembed_publish_method', $publish_method);
  689.             update_option('kml_flashembed_version_major', $version_major);
  690.             update_option('kml_flashembed_version_minor', $version_minor);
  691.             update_option('kml_flashembed_version_revision', $version_revision);
  692.             update_option('kml_flashembed_alt_content', $alt_content);
  693.             update_option('kml_flashembed_reference_swfobject', $reference_swfobject);
  694.             update_option('kml_flashembed_swfobject_source', $swfobject_source);
  695.             update_option('kml_flashembed_swfobject_use_autohide', $swfobject_use_autohide);
  696.             update_option('kml_flashembed_width', $width);
  697.             update_option('kml_flashembed_height', $height);
  698.             update_option('kml_flashembed_dimensions_unit', $dimensions_unit);
  699.             update_option('kml_flashembed_use_express_install', $use_express_install);
  700.             update_option('kml_flashembed_align', $_POST['align']);
  701.             update_option('kml_flashembed_play', $_POST['play']);
  702.             update_option('kml_flashembed_loop', $_POST['loop']);
  703.             update_option('kml_flashembed_menu', $_POST['menu']);
  704.             update_option('kml_flashembed_quality', $_POST['quality']);
  705.             update_option('kml_flashembed_scale', $_POST['scale']);
  706.             update_option('kml_flashembed_salign', $_POST['salign']);
  707.             update_option('kml_flashembed_wmode', $_POST['wmode']);
  708.             update_option('kml_flashembed_bgcolor', $bgcolor);
  709.             update_option('kml_flashembed_devicefont', $_POST['devicefont']);
  710.             update_option('kml_flashembed_seamlesstabbing', $_POST['seamlesstabbing']);
  711.             update_option('kml_flashembed_swliveconnect', $_POST['swliveconnect']);
  712.             update_option('kml_flashembed_allowfullscreen', $_POST['allowfullscreen']);
  713.             update_option('kml_flashembed_allowscriptaccess', $_POST['allowscriptaccess']);
  714.             update_option('kml_flashembed_allownetworking', $_POST['allownetworking']);
  715.             update_option('kml_flashembed_base', $base);
  716.             update_option('kml_flashembed_fvars', $fvars);
  717.  
  718.             if (function_exists('wp_cache_flush')) {
  719.                 wp_cache_flush();
  720.             }
  721.  
  722.         }
  723.  
  724.     ?>
  725.  
  726. <?php if ($message) : ?>
  727. <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
  728. <?php endif; ?>
  729.  
  730. <style type="text/css" media="screen">
  731.     h3 {
  732.         background: #ddd;
  733.         padding: 8px;
  734.         margin: 2em 0 0;
  735.         border-top: 1px solid #fff;
  736.         border-bottom: 1px solid #aaa;
  737.     }
  738.     h2 + h3 {
  739.         margin-top: 1em;
  740.     }
  741.     table.form-table {
  742.         border-collapse: fixed;
  743.     }
  744.     table.form-table th[colspan] {
  745.         background: #eee;
  746.         border-top: 1px solid #fff;
  747.         border-bottom: 1px solid #ccc;
  748.         margin-top: 1em;
  749.     }
  750.     table.form-table th h4 {
  751.         margin: 3px 0;
  752.     }
  753.     table.form-table th,
  754.     table.form-table td {
  755.         padding: 5px 8px;
  756.     }
  757.     .info {
  758.         border-bottom: 1px dotted #666;
  759.         cursor: help;
  760.     }
  761.  
  762.     /* Help */
  763.  
  764.     #publishingMethodHelp, #alternativeContentHelp, #replaceIdHelp, #SWFObjectReference, #toggleReplaceId, #isIdReq, #toggleAttsParamsContainer, #autohideHelp {
  765.         display: none;
  766.     }
  767.  
  768.     .help {
  769.         margin: 0 0 10px;
  770.         padding: 10px 10px 0;
  771.         border: 1px solid #ccc;
  772.         background-color: #ffc;
  773.     }
  774.  
  775.     .help h4, .help h5, .help p, .help ul, .help li {
  776.         margin: 0 !important;
  777.         font-size: 11px;
  778.         line-height: 14px;
  779.     }
  780.  
  781.     .help h4, .help p, .help ul {
  782.         padding-bottom: 10px;
  783.     }
  784.  
  785.     .help h5 {
  786.         color: #666;
  787.     }
  788.  
  789. </style>
  790.  
  791. <script type="text/javascript" charset="utf-8">
  792.     jQuery(document).ready(function(){
  793.         try {
  794.             Kimili.Flash.Generator.initialize();
  795.         } catch(e) {}
  796.     })
  797. </script>
  798.  
  799. <form action="" method="post" accept-charset="utf-8">
  800.     <div class="wrap">
  801.         <h2><?php _e("Kimili Flash Embed Preferences", 'kimili-flash-embed'); ?></h2>
  802.  
  803.         <h3><?php _e("SWFObject Configuration Defaults", 'kimili-flash-embed'); ?></h3>
  804.  
  805.         <table class="form-table">
  806.             <tr>
  807.                 <th scope="row" style="vertical-align:top;"><?php _e("Publish Method", 'kimili-flash-embed'); ?></th>
  808.                 <td>
  809.                     <input type="radio" id="publish_method-0" name="publish_method" value="0" class="radio" <?php if (!get_option('kml_flashembed_publish_method')) echo "checked=\"checked\""; ?> /><label for="publish_method-0"><?php _e("Static Publishing", 'kimili-flash-embed'); ?></label>
  810.                     <input type="radio" id="publish_method-1" name="publish_method" value="1" class="radio" <?php if (get_option('kml_flashembed_publish_method')) echo "checked=\"checked\""; ?> /><label for="publish_method-1"><?php _e("Dynamic Publishing", 'kimili-flash-embed'); ?></label>
  811.                     <br />
  812.                     <a id="togglePublishingMethodHelp" href="#"><?php _e("what is this?",'kimili-flash-embed'); ?></a>
  813.                     <div id="publishingMethodHelp" class="help">
  814.                         <h4><?php _e("Static publishing",'kimili-flash-embed'); ?></h4>
  815.                         <h5><?php _e("Description",'kimili-flash-embed'); ?></h5>
  816.                         <p><?php _e("Embed Flash content and alternative content using standards compliant markup, and use unobtrusive JavaScript to resolve the issues that markup alone cannot solve.",'kimili-flash-embed'); ?></p>
  817.                         <h5><?php _e("Pros",'kimili-flash-embed'); ?></h5>
  818.                         <p><?php _e("The embedding of Flash content does not rely on JavaScript and the actual authoring of standards compliant markup is promoted.",'kimili-flash-embed'); ?></p>
  819.                         <h5><?php _e("Cons",'kimili-flash-embed'); ?></h5>
  820.                         <p><?php _e("Does not solve 'click-to-activate' mechanisms in Internet Explorer 6+ and Opera 9+.",'kimili-flash-embed'); ?></p>
  821.                         <h4><?php _e("Dynamic publishing",'kimili-flash-embed'); ?></h4>
  822.                         <h5><?php _e("Description",'kimili-flash-embed'); ?></h5>
  823.                         <p><?php _e("Create alternative content using standards compliant markup and embed Flash content with unobtrusive JavaScript.",'kimili-flash-embed'); ?></p>
  824.                         <h5><?php _e("Pros",'kimili-flash-embed'); ?></h5>
  825.                         <p><?php _e("Avoids 'click-to-activate' mechanisms in Internet Explorer 6+ and Opera 9+.",'kimili-flash-embed'); ?></p>
  826.                         <h5><?php _e("Cons",'kimili-flash-embed'); ?></h5>
  827.                         <p><?php _e("The embedding of Flash content relies on JavaScript, so if you have the Flash plug-in installed, but have JavaScript disabled or use a browser that doesn't support JavaScript, you will not be able to see your Flash content, however you will see alternative content instead. Flash content will also not be shown on a device like Sony PSP, which has very poor JavaScript support, and automated tools like RSS readers are not able to pick up Flash content.",'kimili-flash-embed'); ?></p>
  828.                     </div>
  829.                 </td>
  830.             </tr>
  831.             <tr>
  832.                 <th scope="row" style="vertical-align:top;">
  833.                     <label title="<?php _e("Flash version consists of major, minor and release version",'kimili-flash-embed'); ?>" class="info"><?php _e("Flash Version",'kimili-flash-embed'); ?></label>
  834.                 </th>
  835.                 <td>
  836.                     <input type="text" name="version_major" value="<?php echo get_option('kml_flashembed_version_major'); ?>" size="2" title="Major Version" />.
  837.                     <input type="text" name="version_minor" value="<?php echo get_option('kml_flashembed_version_minor'); ?>" size="2" title="Minor Version" />.
  838.                     <input type="text" name="version_revision" value="<?php echo get_option('kml_flashembed_version_revision'); ?>" size="3" title="Version Revision Number" />
  839.                 </td>
  840.             </tr>
  841.             <tr>
  842.                 <th scope="row" style="vertical-align:top;">
  843.                     <label for="expressInstall" title="<?php _e("Check checkbox to activate express install functionality on your swf.",'kimili-flash-embed'); ?>" class="info"><?php _e("Adobe Express Install",'kimili-flash-embed'); ?>:</label>
  844.                 </th>
  845.                 <td>
  846.                     <input type="radio" id="use_express_install-0" name="use_express_install" value="0" class="radio" <?php if (!get_option('kml_flashembed_use_express_install')) echo "checked=\"checked\""; ?> /><label for="use_express_install-0"><?php _e("No", 'kimili-flash-embed'); ?></label>
  847.                     <input type="radio" id="use_express_install-1" name="use_express_install" value="1" class="radio" <?php if (get_option('kml_flashembed_use_express_install')) echo "checked=\"checked\""; ?> /><label for="use_express_install-1"><?php _e("Yes", 'kimili-flash-embed'); ?></label>
  848.                 </td>
  849.             </tr>
  850.         </table>
  851.  
  852.         <h3><?php _e("SWF Definition Defaults",'kimili-flash-embed'); ?></h3>
  853.  
  854.         <table class="form-table">
  855.             <tr>
  856.                 <th scope="row" style="vertical-align:top;"><label for="swf" title="<?php _e("The relative or absolute path to your Flash content .swf file",'kimili-flash-embed'); ?>" class="info"><?php _e("Flash (.swf)",'kimili-flash-embed'); ?></label></th>
  857.                 <td><input type="text" name="filename" value="<?php echo get_option('kml_flashembed_filename'); ?>" /></td>
  858.             </tr>
  859.             <tr>
  860.                 <th scope="row" style="vertical-align:top;"><label title="<?php _e("Width &times; height (unit)",'kimili-flash-embed'); ?>" class="info"><?php _e("Dimensions",'kimili-flash-embed'); ?></label></th>
  861.                 <td>
  862.                     <input type="text" name="width" value="<?php echo get_option('kml_flashembed_width'); ?>" size="4" title="Width" />&times;
  863.                     <input type="text" name="height" value="<?php echo get_option('kml_flashembed_height'); ?>" size="4" title="Height" />
  864.                     <select id="unit" name="unit">
  865.                         <option <?php if (get_option('kml_flashembed_dimensions_unit') == "pixels") echo "selected=\"selected\""; ?>  value="pixels"><?php _e("pixels",'kimili-flash-embed'); ?></option>
  866.                         <option <?php if (get_option('kml_flashembed_dimensions_unit') == "percentage") echo "selected=\"selected\""; ?>  value="percentage"><?php _e("percentage",'kimili-flash-embed'); ?></option>
  867.                     </select>
  868.                 </td>
  869.             </tr>
  870.             <tr>
  871.                 <th colspan="2">
  872.                     <h4><?php _e("Attributes",'kimili-flash-embed'); ?></h4>
  873.                 </th>
  874.             </tr>
  875.             <tr>
  876.                 <th scope="row" style="vertical-align:top;"><label for="flash_id" class="info" title="<?php _e("Uniquely identifies the Flash movie so that it can be referenced using a scripting language or by CSS",'kimili-flash-embed'); ?>"><?php _e("Flash content ID",'kimili-flash-embed'); ?></label></th>
  877.                 <td><input type="text" id="flash_id" name="flash_id" value="<?php echo get_option('kml_flashembed_flash_id'); ?>" /></td>
  878.             </tr>
  879.             <tr>
  880.                 <th scope="row" style="vertical-align:top;"><label for="target_class" class="info" title="<?php _e("Classifies the Flash movie so that it can be referenced using a scripting language or by CSS",'kimili-flash-embed'); ?>"><?php _e("class", 'kimili-flash-embed'); ?></label></th>
  881.                 <td><input type="text" id="target_class" name="target_class" value="<?php echo get_option('kml_flashembed_target_class'); ?>" /></td>
  882.             </tr>
  883.             <tr>
  884.                 <th scope="row" style="vertical-align:top;"><label for="align" class="info" title="<?php _e("HTML alignment of the object element. If this attribute is omitted, it by default centers the movie and crops edges if the browser window is smaller than the movie. NOTE: Using this attribute is not valid in XHTML 1.0 Strict.",'kimili-flash-embed'); ?>">align</label></th>
  885.                 <td>
  886.                     <select id="align" name="align">
  887.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  888.                         <option <?php if (get_option('kml_flashembed_align') == "left") echo "selected=\"selected\""; ?> value="left" >left</option>
  889.                         <option <?php if (get_option('kml_flashembed_align') == "right") echo "selected=\"selected\""; ?> value="right">right</option>
  890.                         <option <?php if (get_option('kml_flashembed_align') == "top") echo "selected=\"selected\""; ?> value="top">top</option>
  891.                         <option <?php if (get_option('kml_flashembed_align') == "bottom") echo "selected=\"selected\""; ?> value="bottom">bottom</option>
  892.                     </select>
  893.                 </td>
  894.             </tr>
  895.  
  896.             <tr>
  897.                 <th colspan="2">
  898.                     <h4><?php _e("Parameters",'kimili-flash-embed'); ?></h4>
  899.                 </th>
  900.             </tr>
  901.  
  902.             <tr>
  903.                 <th scope="row" style="vertical-align:top;"><label for="play" class="info" title="<?php _e("Specifies whether the movie begins playing immediately on loading in the browser. The default value is true if this attribute is omitted.",'kimili-flash-embed'); ?>">play</label></th>
  904.                 <td>
  905.                     <select id="play" name="play">
  906.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  907.                         <option <?php if (get_option('kml_flashembed_play') == "true") echo "selected=\"selected\""; ?> value="true" >true</option>
  908.                         <option <?php if (get_option('kml_flashembed_play') == "false") echo "selected=\"selected\""; ?> value="false">false</option>
  909.                     </select>
  910.                 </td>
  911.             </tr>
  912.             <tr>
  913.                 <th scope="row" style="vertical-align:top;"><label for="loop" class="info" title="<?php _e("Specifies whether the movie repeats indefinitely or stops when it reaches the last frame. The default value is true if this attribute is omitted",'kimili-flash-embed'); ?>.">loop</label></th>
  914.                 <td>
  915.                     <select id="loop" name="loop">
  916.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  917.                         <option <?php if (get_option('kml_flashembed_loop') == "true") echo "selected=\"selected\""; ?> value="true" >true</option>
  918.                         <option <?php if (get_option('kml_flashembed_loop') == "false") echo "selected=\"selected\""; ?> value="false">false</option>
  919.                     </select>
  920.                 </td>
  921.             </tr>
  922.             <tr>
  923.                 <th scope="row" style="vertical-align:top;"><label for="menu" class="info" title="<?php _e("Shows a shortcut menu when users right-click (Windows) or control-click (Macintosh) the SWF file. To show only About Flash in the shortcut menu, deselect this option. By default, this option is set to true.",'kimili-flash-embed'); ?>">menu</label></th>
  924.                 <td>
  925.                     <select id="menu" name="menu">
  926.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  927.                         <option <?php if (get_option('kml_flashembed_menu') == "true") echo "selected=\"selected\""; ?> value="true" >true</option>
  928.                         <option <?php if (get_option('kml_flashembed_menu') == "false") echo "selected=\"selected\""; ?> value="false">false</option>
  929.                     </select>
  930.                 </td>
  931.             </tr>
  932.             <tr>
  933.                 <th scope="row" style="vertical-align:top;"><label for="quality" class="info" title="<?php _e("Specifies the trade-off between processing time and appearance. The default value is 'high' if this attribute is omitted.",'kimili-flash-embed'); ?>">quality</label></th>
  934.                 <td>
  935.                     <select id="quality" name="quality">
  936.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  937.                         <option <?php if (get_option('kml_flashembed_quality') == "best") echo "selected=\"selected\""; ?> value="best">best</option>
  938.                         <option <?php if (get_option('kml_flashembed_quality') == "high") echo "selected=\"selected\""; ?> value="high">high</option>
  939.                         <option <?php if (get_option('kml_flashembed_quality') == "medium") echo "selected=\"selected\""; ?> value="medium">medium</option>
  940.                         <option <?php if (get_option('kml_flashembed_quality') == "autohigh") echo "selected=\"selected\""; ?> value="autohigh">autohigh</option>
  941.                         <option <?php if (get_option('kml_flashembed_quality') == "autolow") echo "selected=\"selected\""; ?> value="autolow">autolow</option>
  942.                         <option <?php if (get_option('kml_flashembed_quality') == "low") echo "selected=\"selected\""; ?> value="low">low</option>
  943.                     </select>
  944.                 </td>
  945.             </tr>
  946.             <tr>
  947.                 <th scope="row" style="vertical-align:top;"><label for="scale" class="info"  title="<?php _e("Specifies scaling, aspect ratio, borders, distortion and cropping for if you have changed the document's original width and height.",'kimili-flash-embed'); ?>">scale</label></th>
  948.                 <td>
  949.                     <select id="scale" name="scale">
  950.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  951.                         <option <?php if (get_option('kml_flashembed_scale') == "showall") echo "selected=\"selected\""; ?> value="showall">showall</option>
  952.                         <option <?php if (get_option('kml_flashembed_scale') == "noborder") echo "selected=\"selected\""; ?> value="noborder">noborder</option>
  953.                         <option <?php if (get_option('kml_flashembed_scale') == "exactfit") echo "selected=\"selected\""; ?> value="exactfit">exactfit</option>
  954.                         <option <?php if (get_option('kml_flashembed_scale') == "noscale") echo "selected=\"selected\""; ?> value="noscale">noscale</option>
  955.                     </select>
  956.                 </td>
  957.             </tr>
  958.             <tr>
  959.                 <th scope="row" style="vertical-align:top;"><label for="salign" class="info" title="<?php _e("Specifies where the content is placed within the application window and how it is cropped.",'kimili-flash-embed'); ?>">salign</label></th>
  960.                 <td>
  961.                     <select id="salign" name="salign">
  962.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  963.                         <option <?php if (get_option('kml_flashembed_salign') == "tl") echo "selected=\"selected\""; ?> value="tl">tl</option>
  964.                         <option <?php if (get_option('kml_flashembed_salign') == "tr") echo "selected=\"selected\""; ?> value="tr">tr</option>
  965.                         <option <?php if (get_option('kml_flashembed_salign') == "bl") echo "selected=\"selected\""; ?> value="bl">bl</option>
  966.                         <option <?php if (get_option('kml_flashembed_salign') == "br") echo "selected=\"selected\""; ?> value="br">br</option>
  967.                         <option <?php if (get_option('kml_flashembed_salign') == "l") echo "selected=\"selected\""; ?> value="l">l</option>
  968.                         <option <?php if (get_option('kml_flashembed_salign') == "t") echo "selected=\"selected\""; ?> value="t">t</option>
  969.                         <option <?php if (get_option('kml_flashembed_salign') == "r") echo "selected=\"selected\""; ?> value="r">r</option>
  970.                         <option <?php if (get_option('kml_flashembed_salign') == "b") echo "selected=\"selected\""; ?> value="b">b</option>
  971.                     </select>
  972.                 </td>
  973.             </tr>
  974.             <tr>
  975.                 <th scope="row" style="vertical-align:top;"><label for="wmode" class="info" title="<?php _e("Sets the Window Mode property of the Flash movie for transparency, layering, and positioning in the browser. The default value is 'window' if this attribute is omitted.",'kimili-flash-embed'); ?>">wmode</label></th>
  976.                 <td>
  977.                     <select id="wmode" name="wmode">
  978.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  979.                         <option <?php if (get_option('kml_flashembed_wmode') == "window") echo "selected=\"selected\""; ?> value="window">window</option>
  980.                         <option <?php if (get_option('kml_flashembed_wmode') == "opaque") echo "selected=\"selected\""; ?> value="opaque">opaque</option>
  981.                         <option <?php if (get_option('kml_flashembed_wmode') == "transparent") echo "selected=\"selected\""; ?> value="transparent">transparent</option>
  982.                         <option <?php if (get_option('kml_flashembed_wmode') == "direct") echo "selected=\"selected\""; ?> value="direct">direct</option>
  983.                         <option <?php if (get_option('kml_flashembed_wmode') == "gpu") echo "selected=\"selected\""; ?> value="gpu">gpu</option>
  984.                     </select>
  985.                 </td>
  986.             </tr>
  987.             <tr>
  988.                 <th scope="row" style="vertical-align:top;"><label for="bgcolor" class="info" title="<?php _e("Hexadecimal RGB value in the format #RRGGBB, which specifies the background color of the movie, which will override the background color setting specified in the Flash file.",'kimili-flash-embed'); ?>">bgcolor</label></th>
  989.                 <td><input type="text" id="bgcolor" name="bgcolor" value="<?php echo get_option('kml_flashembed_bgcolor'); ?>" /></td>
  990.             </tr>
  991.             <tr>
  992.                 <th scope="row" style="vertical-align:top;"><label for="devicefont" class="info" title="<?php _e("Specifies whether static text objects that the Device Font option has not been selected for will be drawn using device fonts anyway, if the necessary fonts are available from the operating system.",'kimili-flash-embed'); ?>">devicefont</label></th>
  993.                 <td>
  994.                     <select id="devicefont" name="devicefont">
  995.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  996.                         <option <?php if (get_option('kml_flashembed_devicefont') == "true") echo "selected=\"selected\""; ?> value="true" >true</option>
  997.                         <option <?php if (get_option('kml_flashembed_devicefont') == "false") echo "selected=\"selected\""; ?> value="false">false</option>
  998.                     </select>
  999.                 </td>
  1000.             </tr>
  1001.             <tr>
  1002.                 <th scope="row" style="vertical-align:top;"><label for="seamlesstabbing" class="info" title="<?php _e("Specifies whether users are allowed to use the Tab key to move keyboard focus out of a Flash movie and into the surrounding HTML (or the browser, if there is nothing focusable in the HTML following the Flash movie). The default value is true if this attribute is omitted.",'kimili-flash-embed'); ?>">seamlesstabbing</label></th>
  1003.                 <td>
  1004.                     <select id="seamlesstabbing" name="seamlesstabbing">
  1005.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  1006.                         <option <?php if (get_option('kml_flashembed_seamlesstabbing') == "true") echo "selected=\"selected\""; ?> value="true" >true</option>
  1007.                         <option <?php if (get_option('kml_flashembed_seamlesstabbing') == "false") echo "selected=\"selected\""; ?> value="false">false</option>
  1008.                     </select>
  1009.                 </td>
  1010.             </tr>
  1011.             <tr>
  1012.                 <th scope="row" style="vertical-align:top;"><label for="seamlesstabbing" class="info" title="<?php _e("Specifies whether the browser should start Java when loading the Flash Player for the first time. The default value is false if this attribute is omitted. If you use JavaScript and Flash on the same page, Java must be running for the FSCommand to work.",'kimili-flash-embed'); ?>">swliveconnect</label></th>
  1013.                 <td>
  1014.                     <select id="swliveconnect" name="swliveconnect">
  1015.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  1016.                         <option <?php if (get_option('kml_flashembed_swliveconnect') == "true") echo "selected=\"selected\""; ?> value="true">true</option>
  1017.                         <option <?php if (get_option('kml_flashembed_swliveconnect') == "false") echo "selected=\"selected\""; ?> value="false">false</option>
  1018.                     </select>
  1019.                 </td>
  1020.             </tr>
  1021.             <tr>
  1022.                 <th scope="row" style="vertical-align:top;"><label for="allowfullscreen" class="info" title="<?php _e("Enables full-screen mode. The default value is false if this attribute is omitted. You must have version 9,0,28,0 or greater of Flash Player installed to use full-screen mode.",'kimili-flash-embed'); ?>">allowfullscreen</label></th>
  1023.                 <td>
  1024.                     <select id="allowfullscreen" name="allowfullscreen">
  1025.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  1026.                         <option <?php if (get_option('kml_flashembed_allowfullscreen') == "true") echo "selected=\"selected\""; ?> value="true" >true</option>
  1027.                         <option <?php if (get_option('kml_flashembed_allowfullscreen') == "false") echo "selected=\"selected\""; ?> value="false">false</option>
  1028.                     </select>
  1029.                 </td>
  1030.             </tr>
  1031.             <tr>
  1032.                 <th scope="row" style="vertical-align:top;"><label for="allowscriptaccess" class="info" title="<?php _e("Controls the ability to perform outbound scripting from within a Flash SWF. The default value is 'always' if this attribute is omitted.",'kimili-flash-embed'); ?>">allowscriptaccess</label></th>
  1033.                 <td>
  1034.                     <select id="allowscriptaccess" name="allowscriptaccess">
  1035.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  1036.                         <option <?php if (get_option('kml_flashembed_allowscriptaccess') == "always") echo "selected=\"selected\""; ?> value="always">always</option>
  1037.                         <option <?php if (get_option('kml_flashembed_allowscriptaccess') == "sameDomain") echo "selected=\"selected\""; ?> value="sameDomain">sameDomain</option>
  1038.                         <option <?php if (get_option('kml_flashembed_allowscriptaccess') == "never") echo "selected=\"selected\""; ?> value="never">never</option>
  1039.                     </select>
  1040.                 </td>
  1041.             </tr>
  1042.             <tr>
  1043.                 <th scope="row" style="vertical-align:top;"><label for="allownetworking" class="info" title="<?php _e("Controls a SWF file's access to network functionality. The default value is 'all' if this attribute is omitted.",'kimili-flash-embed'); ?>">allownetworking</label></th>
  1044.                 <td>
  1045.                     <select id="allownetworking" name="allownetworking">
  1046.                         <option value=""><?php _e("Choose",'kimili-flash-embed'); ?>...</option>
  1047.                         <option <?php if (get_option('kml_flashembed_allownetworking') == "all") echo "selected=\"selected\""; ?> value="all">all</option>
  1048.                         <option <?php if (get_option('kml_flashembed_allownetworking') == "internal") echo "selected=\"selected\""; ?> value="internal">internal</option>
  1049.                         <option <?php if (get_option('kml_flashembed_allownetworking') == "none") echo "selected=\"selected\""; ?> value="none">none</option>
  1050.                     </select>
  1051.                 </td>
  1052.             </tr>
  1053.             <tr>
  1054.                 <th scope="row" style="vertical-align:top;"><label for="base" class="info" title="<?php _e("Specifies the base directory or URL used to resolve all relative path statements in the Flash Player movie. This attribute is helpful when your Flash Player movies are kept in a different directory from your other files.",'kimili-flash-embed'); ?>">base</label></th>
  1055.                 <td><input type="text" id="base" name="base" value="<?php echo get_option('kml_flashembed_base'); ?>" /></td>
  1056.             </tr>
  1057.             <tr>
  1058.                 <th scope="row" style="vertical-align:top;"><label for="fvars" class="info" title="<?php _e("Method to pass variables to a Flash movie. You need to separate individual name/variable pairs with a semicolon (i.e. name=John Doe ; count=3).",'kimili-flash-embed'); ?>">fvars</label></th>
  1059.                 <td><textarea name="fvars" id="fvars" cols="50" rows="4"><?php echo stripcslashes(get_option('kml_flashembed_fvars')); ?></textarea></td>
  1060.             </tr>
  1061.         </table>
  1062.  
  1063.         <h3><?php _e("Alternative Content Default", 'kimili-flash-embed'); ?></h3>
  1064.  
  1065.         <table class="form-table">
  1066.             <tr>
  1067.                 <th scope="row" style="vertical-align:top;"><?php _e("Alternate Content", 'kimili-flash-embed'); ?></th>
  1068.                 <td>
  1069.                     <textarea name="alt_content" cols="50" rows="4"><?php echo stripcslashes(get_option('kml_flashembed_alt_content')); ?></textarea>
  1070.                     <br />
  1071.                     <a id="toggleAlternativeContentHelp" href="#alternativeContentHelp"><?php _e("what is this",'kimili-flash-embed'); ?>?</a>
  1072.                     <div id="alternativeContentHelp" class="help">
  1073.                         <p>
  1074.                             <?php _e("The object element allows you to nest alternative HTML content inside of it, which will be displayed if Flash is not installed or supported.
  1075.                             This content will also be picked up by search engines, making it a great tool for creating search-engine-friendly content.",'kimili-flash-embed'); ?>
  1076.                         </p>
  1077.                         <p><?php _e("Summarized, you should use alternative content for the following:",'kimili-flash-embed'); ?></p>
  1078.                         <ul>
  1079.                             <li><?php _e("When you like to create content that is accessible for people who browse the Web without plugins",'kimili-flash-embed'); ?></li>
  1080.                             <li><?php _e("When you like to create search-engine-friendly content",'kimili-flash-embed'); ?></li>
  1081.                             <li><?php _e("To tell visitors that they can have a richer user experience by downloading the Flash plugin",'kimili-flash-embed'); ?></li>
  1082.                         </ul>
  1083.                     </div>
  1084.                 </td>
  1085.             </tr>
  1086.         </table>
  1087.  
  1088.         <h3><?php _e("Javascript Options", 'kimili-flash-embed'); ?></h3>
  1089.  
  1090.         <table class="form-table">
  1091.             <tr>
  1092.                 <th scope="row" style="vertical-align:top;"><?php _e("Create a reference to SWFObject.js?", 'kimili-flash-embed'); ?></th>
  1093.                 <td>
  1094.                     <input type="radio" id="reference_swfobject-0" name="reference_swfobject" value="0" class="radio" <?php if (!get_option('kml_flashembed_reference_swfobject')) echo "checked=\"checked\""; ?> /><label for="reference_swfobject-0"><?php _e("No", 'kimili-flash-embed'); ?></label>
  1095.                     <input type="radio" id="reference_swfobject-1" name="reference_swfobject" value="1" class="radio" <?php if (get_option('kml_flashembed_reference_swfobject')) echo "checked=\"checked\""; ?> /><label for="reference_swfobject-1"><?php _e("Yes", 'kimili-flash-embed'); ?></label>
  1096.                 </td>
  1097.             </tr>
  1098.             <tr>
  1099.                 <th scope="row" style="vertical-align:top;"><?php _e("Where do you want to reference SWFObject.js from?", 'kimili-flash-embed'); ?></th>
  1100.                 <td>
  1101.  
  1102. <?php
  1103. /////////////////////////////
  1104. // XXX del, 2012/05
  1105. /////////////////////////////
  1106. //                  <input type="radio" id="swfobject_source-0" name="swfobject_source" value="0" class="radio" <xphp if (!get_option('kml_flashembed_swfobject_source')) echo "checked=\"checked\""; x> /><label for="swfobject_source-0"><xphp _e("Google Ajax Library", 'kimili-flash-embed'); x></label>
  1107. //                  <input type="radio" id="swfobject_source-1" name="swfobject_source" value="1" class="radio" <xphp if (get_option('kml_flashembed_swfobject_source')) echo "checked=\"checked\""; x> /><label for="swfobject_source-1"><xphp _e("Internal", 'kimili-flash-embed'); x></label>
  1108. //                  <br />
  1109. //                  <a id="toggleSWFObjectReference" href="#SWFObjectReference"><xphp _e("what is this",'kimili-flash-embed'); x>?</a>
  1110. /////////////////////////////
  1111. // XXX add
  1112. /////////////////////////////
  1113.                     $swfobject_source= get_option('kml_flashembed_swfobject_source');
  1114. ?>
  1115.                     <p style="margin: 2px 0 0 0;"><input type="radio" id="swfobject_source-0" name="swfobject_source" value="0" class="radio" <?php
  1116.                         if (!$swfobject_source) echo "checked=\"checked\"";
  1117.                     ?> /><label for="swfobject_source-0"><?php _e("Wordpress Internal Library", 'kimili-flash-embed'); ?></label>
  1118.                     (XXX: Recommended as of 2012/05/27)</p>
  1119.  
  1120.                     <p style="margin: 2px 0 0 0;"><input type="radio" id="swfobject_source-1" name="swfobject_source" value="1" class="radio" <?php
  1121.                         if ($swfobject_source== '1') echo "checked=\"checked\"";
  1122.                     ?> /><label for="swfobject_source-1"><?php _e("Google Ajax Library", 'kimili-flash-embed'); ?></label></p>
  1123.  
  1124.                     <p style="margin: 2px 0 0 0;"><input type="radio" id="swfobject_source-2" name="swfobject_source" value="2" class="radio" <?php
  1125.                         if ($swfobject_source == '2') echo "checked=\"checked\"";
  1126.                     ?> /><label for="swfobject_source-2"><?php _e("Kimili Internal Library", 'kimili-flash-embed'); ?></label></p>
  1127.  
  1128.                     <p style="margin: 2px 0 0 0;">
  1129.                     <a id="toggleSWFObjectReference" href="#SWFObjectReference"><?php _e("what is this",'kimili-flash-embed'); ?>?</a></p>
  1130. <?php
  1131. /////////////////////////////
  1132. ?>
  1133.  
  1134.                     <div id="SWFObjectReference" class="help">
  1135.                         <p>
  1136.                             <?php _e("If you choose to use Kimili Flash Embed to create a reference to swfobject.js (which is necessary for KFE to function properly), you have two options from where to reference the file:",'kimili-flash-embed'); ?>
  1137.                         </p>
  1138.                         <h4><?php _e("Google Ajax Library", 'kimili-flash-embed'); ?></h4>
  1139.                         <p><?php _e("The Google Ajax Library is a content distribution network the most popular open source JavaScript libraries, including SWFObject. Google hosts these libraries, correctly sets cache headers, and stays up to date with the most recent release versions.", 'kimili-flash-embed'); ?></p>
  1140.                         <p><?php _e("Choosing this option offers fast, reliable access to the SWFObject code. It also increases the chances that your users may already have SWFObject cached in their browsers if they have visited other sites that also utilize the Google hosted copy of SWFObject, making your site load even faster.", 'kimili-flash-embed'); ?></p>
  1141.                         <h4><?php _e("Internal", 'kimili-flash-embed'); ?></h4>
  1142.                         <p><?php _e("If you'd rather not rely on an external service to serve SWFObject to your users, you can choose to reference a copy of SWFObject which comes bundles with Kimili Flash Embed so it is served from the same server as the rest of your website.", 'kimili-flash-embed'); ?></p>
  1143.                     </div>
  1144.                 </td>
  1145.             </tr>
  1146.             <tr>
  1147.                 <th scope="row" style="vertical-align:top;">
  1148.                     <?php _e("Do you want to use SWFObject's autohide function?", 'kimili-flash-embed'); ?></th>
  1149.                 <td>
  1150.                     <input type="radio" id="swfobject_use_autohide-0" name="swfobject_use_autohide" value="0" class="radio" <?php if (!get_option('kml_flashembed_swfobject_use_autohide')) echo "checked=\"checked\""; ?> /><label for="swfobject_use_autohide-0"><?php _e("No", 'kimili-flash-embed'); ?></label>
  1151.                     <input type="radio" id="swfobject_use_autohide-1" name="swfobject_use_autohide" value="1" class="radio" <?php if (get_option('kml_flashembed_swfobject_use_autohide')) echo "checked=\"checked\""; ?> /><label for="swfobject_use_autohide-1"><?php _e("Yes", 'kimili-flash-embed'); ?></label>
  1152.                     <br />
  1153.                     <a id="toggleAutohideHelp" href="#autohideHelp"><?php _e("what is this",'kimili-flash-embed'); ?>?</a>
  1154.                     <div id="autohideHelp" class="help">
  1155.                         <p><?php _e("By default, SWFObject temporarily hides your SWF or alternative content until the library has decided which content to display. This option allows you to disable that behavior.", 'kimili-flash-embed'); ?></p>
  1156.                     </div>
  1157.                 </td>
  1158.             </tr>
  1159.         </table>
  1160.  
  1161.         <p class="submit">
  1162.             <input type="hidden" name="action" value="kml_flashembed_update" />
  1163.             <input type="submit" name="Submit" value="<?php _e("Update Options", 'kimili-flash-embed'); ?> &raquo;" />
  1164.         </p>
  1165.  
  1166.     </div>
  1167.  
  1168. </form>
  1169.     <?php
  1170.  
  1171.     }
  1172.  
  1173. }
  1174.  
  1175.  
  1176.  
  1177. // Start it up - on template_redirect for feeds, plugins_loaded for everything else.
  1178. add_action( (preg_match("/(\/\?feed=|\/feed)/i",$_SERVER['REQUEST_URI'])) ? 'template_redirect' : 'plugins_loaded', 'KimiliFlashEmbed' );
  1179.  
  1180. function KimiliFlashEmbed() {
  1181.     global $KimiliFlashEmbed;
  1182.     $KimiliFlashEmbed = new KimiliFlashEmbed();
  1183. }
  1184.  
  1185. /*
  1186.     Adding the KFE button to the MCE toolbar. For some reason, WP 2.6 doesn't allow me to do this from within the KimiliFlashEmbed class.
  1187. */
  1188. add_action( 'init', 'kml_flashembed_addbuttons');
  1189.  
  1190. function kml_flashembed_addbuttons() {
  1191.     if (!current_user_can('edit_posts') && !current_user_can('edit_pages') ) {
  1192.         return;
  1193.     }
  1194.     if ( get_user_option('rich_editing') == 'true') {
  1195.         add_filter( 'tiny_mce_version', 'tiny_mce_version', 0 );
  1196.         add_filter( 'mce_external_plugins', 'kml_flashembed_plugin', 0 );
  1197.         add_filter( 'mce_buttons', 'kml_flashembed_button', 0);
  1198.     }
  1199. }
  1200.  
  1201. // Break the browser cache of TinyMCE
  1202. function tiny_mce_version( $version ) {
  1203.     global $KimiliFlashEmbed;
  1204.     return $version . '-kfe' . $KimiliFlashEmbed->version;
  1205. }
  1206.  
  1207. // Load the custom TinyMCE plugin
  1208. function kml_flashembed_plugin( $plugins ) {
  1209.     $plugins['kimiliflashembed'] = plugins_url('/kimili-flash-embed/lib/tinymce3/editor_plugin.js');
  1210.     return $plugins;
  1211. }
  1212.  
  1213. function kml_flashembed_button( $buttons ) {
  1214.     array_push( $buttons, 'separator', 'kimiliFlashEmbed' );
  1215.     return $buttons;
  1216. }
  1217.  
  1218. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement