function wistia_wordpress_anti_mangler_render() { $wistia_wordpress_anti_mangler = get_wistia_wordpress_option('anti_mangler'); $on = empty($wistia_wordpress_anti_mangler) || $wistia_wordpress_anti_mangler == 'on'; ?> <label> <input type='radio' name='wistia_wordpress_settings[anti_mangler]' <?php echo $on ? "checked='checked'" : ''; ?> value='on'> On </label> <label> <input type='radio' name='wistia_wordpress_settings[anti_mangler]' <?php echo $on ? '' : 'checked="checked"'; ?> value='off'> Off </label> <?php }
function wistia_wordpress_update_anti_mangler_default() { // This is required for `is_plugin_active`. include_once ABSPATH . 'wp-admin/includes/plugin.php'; // If wistia_wordpress_anti_mangler isn't defined on upgrade/install, let's // define it. If you're upgrading from an older version where the option // didn't exist, default it to ON so nothing changes. New installs, however, // should default to OFF. $wistia_wordpress_anti_mangler = get_wistia_wordpress_option('anti_mangler'); $plugin_already_activated = is_plugin_active(wistia_wordpress_plugin_file()); if (empty($wistia_wordpress_anti_mangler)) { if ($plugin_already_activated) { set_wistia_wordpress_option('anti_mangler', 'on'); } else { set_wistia_wordpress_option('anti_mangler', 'off'); } } // Record version in database for future upgrade path pivoting. $current_plugin_data = get_plugin_data(wistia_wordpress_plugin_file()); $current_wistia_wordpress_version = $current_plugin_data['Version']; set_wistia_wordpress_option('version', $current_wistia_wordpress_version); }
* * @return array */ function add_valid_tiny_mce_elements($init) { $elements = 'div[*],iframe[*],script[*],object[*],embed[*],a[*],noscript[*]'; /* Add to extended_valid_elements if it already exists, else ours becomes the only allowed elements. */ if (isset($init['extended_valid_elements']) && is_string($init['extended_valid_elements'])) { $init['extended_valid_elements'] = $init['extended_valid_elements'] . ',' . $elements; } else { $init['extended_valid_elements'] = $elements; } return $init; } // Only use the mangler if it's turned on or not set. The value could be // "empty" if the plugin was updated via git/svn/ftp, without going through the // UI update path. $wistia_wordpress_anti_mangler = get_wistia_wordpress_option('anti_mangler'); if (empty($wistia_wordpress_anti_mangler) || $wistia_wordpress_anti_mangler == 'on') { add_filter('content_save_pre', 'wistia_extract_embeds', 2); add_filter('content_save_pre', 'wistia_insert_embeds', 1001); add_filter('the_content', 'wistia_extract_embeds', 2); add_filter('the_content', 'wistia_insert_embeds', 1001); add_filter('the_content', 'wistia_add_scripts_if_necessary', 1002); add_filter('the_editor_content', 'wistia_extract_embeds', 2); add_filter('the_editor_content', 'wistia_insert_embeds_for_editor', 1001); add_filter('tiny_mce_before_init', 'add_valid_tiny_mce_elements'); }