Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tinyMCEPopup.onInit.add( function() {
- if ( ! tinyMCEPopup.editor.dom.getParent( tinyMCEPopup.editor.selection.getNode(), 'A' ) ) {
- selectByValue( document.forms[0], 'target_list', '_blank' );
- }
- } );
- <?php
- /*
- Plugin Name: WPSE 7785
- Plugin URI: http://wordpress.stackexchange.com/questions/7785/is-there-any-way-to-set-default-for-insertedit-link-to-open-link-in-new-window--
- Description: Is there any way to set default for "Insert/Edit Link" to "Open link in new window"?
- Version: 1.0
- Author: Jan Fabry
- */
- add_filter( 'tiny_mce_before_init', 'wpse7785_tiny_mce_before_init' );
- function wpse7785_tiny_mce_before_init( $initArray )
- {
- $initArray['external_link_list_url'] = plugins_url( 'wpse-7785.js', __FILE__ );
- return $initArray;
- }
- /*
- * Sets "Open link in a new window/tab" to checked by default
- */
- function ahu_after_wp_tiny_mce() {
- ?>
- <script type="text/javascript">
- jQuery( function() {
- jQuery( 'input#link-target-checkbox' ).prop( 'checked', true );
- } );
- </script>
- <?php
- }
- add_action( 'after_wp_tiny_mce', 'ahu_after_wp_tiny_mce' );
- <?php
- /*
- Plugin Name: Default New Window Link Opener
- Plugin URI: https://github.com/eballo
- Description: Plugin for wordpress that allow you to enable the check in the popup "Insert/Edit Linkβ to open a link in new window by default
- Version: 1.0
- Author: eballo
- This plugin is based on the solution made by Jan Fabry and lewayotte in wordpress stackexchange forum.
- http://wordpress.stackexchange.com/questions/7785/is-there-any-way-to-set-default-for-insert-edit-link-to-open-link-in-new-wind
- */
- /**
- * Sets "Open link in a new window/tab" to checked by default
- */
- function wplink_tiny_mce_init()
- {
- ?>
- <script type="text/javascript">
- jQuery(function () {
- jQuery('input#wp-link-target').prop('checked',true);
- });
- </script>
- <?php
- }
- add_action( 'before_wp_tiny_mce', 'wplink_tiny_mce_init' );
- ?>
- function edit_tag_link_new_window($content) {
- $content = preg_replace('/href/', 'target="_blank" href', $content);
- return $content;
- }
- add_filter('edit_tag_link', 'edit_tag_link_new_window');
- <input type="checkbox" id="link-target-checkbox" tabindex="30" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
- <input type="checkbox" id="link-target-checkbox" checked tabindex="30" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
Add Comment
Please, Sign In to add comment