Skip to content

Instantly share code, notes, and snippets.

@shazdeh
Created February 11, 2017 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shazdeh/7ccdcb6cc9bbe29e93f659505935e009 to your computer and use it in GitHub Desktop.
Save shazdeh/7ccdcb6cc9bbe29e93f659505935e009 to your computer and use it in GitHub Desktop.
function custom_post_row_actions_https( $actions ) {
if( isset( $actions['themify-builder'] ) ) {
$actions['themify-builder'] = str_replace( 'http://', 'https://', $actions['themify-builder'] );
}
return $actions;
}
add_filter( 'post_row_actions', 'custom_post_row_actions_https', 100 );
add_filter( 'page_row_actions', 'custom_post_row_actions_https', 100 );
function custom_builder_frontend_toggle_redirect() { ?>
<script>
jQuery(function($){
$( '.toggle_tf_builder a' ).click(function(){
if( window.location.protocol == 'http:' ) {
window.location = 'https://' + window.location.hostname + window.location.pathname + '#builder_active';
return false;
}
});
});
</script>
<?php
}
add_action( 'wp_head', 'custom_builder_frontend_toggle_redirect' );
function custom_builder_switch_https_redirect() { ?>
<script>
(function($){
jQuery(window).load(function(){
jQuery( '#themify_builder_switch_frontend, #themify_builder_switch_frontend_button' ).off().on('click', function(e){
e.preventDefault();
var self = ThemifyPageBuilder,
targetLink = themifyBuilder.permalink.replace(/\&amp;/g, '&').replace( 'http', 'https' ) + '#builder_active';
$('#themify_builder_alert').addClass('busy').show();
if ($('#themify_builder_row_wrapper').is(':visible')) {
self.saveData(false, function () {
// Clear undo history
ThemifyBuilderCommon.undoManager.instance.clear();
self.createPostBuilderButton( targetLink );
});
} else {
self.createPostBuilderButton( targetLink );
} }
);
});
})(jQuery);
</script>
<?php
}
add_action( 'admin_footer', 'custom_builder_switch_https_redirect' );
function custom_preview_post_link( $link, $post ) {
if( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] ) {
$link = preg_replace( '/^http/', 'https', $link );
}
return $link;
}
add_filter( 'preview_post_link', 'custom_preview_post_link', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment